init
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
class SupabaseConfig {
|
||||
static const String url = 'http://192.168.50.182:8000';
|
||||
|
||||
// publishable Key
|
||||
static const String publishableKey = 'sb_publishable__i6IYRo2bficTh7WsIMgqB_q6fjZpST';
|
||||
}
|
||||
@@ -0,0 +1,425 @@
|
||||
import '../models/customer.dart';
|
||||
import '../models/installed_part.dart';
|
||||
import '../models/order.dart';
|
||||
import '../models/schedule_item.dart';
|
||||
|
||||
class MockData {
|
||||
static final List<Customer> customers = [
|
||||
Customer(
|
||||
id: 'cust-1',
|
||||
customerNumber: 'K-10025',
|
||||
name: 'Max Mustermann',
|
||||
street: 'Musterweg 12',
|
||||
zipCode: '12345',
|
||||
city: 'Musterstadt',
|
||||
latitude: 50.1135,
|
||||
longitude: 8.6790,
|
||||
distanceKm: 2.4,
|
||||
phone: '0171 1234567',
|
||||
email: 'max.mustermann@email.de',
|
||||
notes: 'Schlüsselbox an der Garage',
|
||||
firstContactDate: DateTime(2022, 3, 10),
|
||||
openOrdersCount: 1,
|
||||
lastOrderDate: DateTime(2024, 5, 15),
|
||||
installedParts: const [
|
||||
InstalledPart(
|
||||
id: 'part-1',
|
||||
customerId: 'cust-1',
|
||||
name: 'Buderus Logamax plus GB172-24',
|
||||
category: 'Gas-Brennwertgerät',
|
||||
serialNumber: '8374747383',
|
||||
quantity: 1,
|
||||
),
|
||||
InstalledPart(
|
||||
id: 'part-2',
|
||||
customerId: 'cust-1',
|
||||
name: 'Bosch EasyControl CT200',
|
||||
category: 'Raumthermostat',
|
||||
serialNumber: '1234567890',
|
||||
quantity: 1,
|
||||
),
|
||||
InstalledPart(
|
||||
id: 'part-3',
|
||||
customerId: 'cust-1',
|
||||
name: 'Honeywell Hauswasserfilter FF06',
|
||||
category: 'Wasserfilter',
|
||||
serialNumber: '9876543210',
|
||||
quantity: 1,
|
||||
),
|
||||
],
|
||||
orders: [
|
||||
WorkOrder(
|
||||
id: 'ord-1',
|
||||
customerId: 'cust-1',
|
||||
title: 'Wartung Heizungsanlage',
|
||||
date: DateTime(2024, 5, 15),
|
||||
status: OrderStatus.abgeschlossen,
|
||||
),
|
||||
WorkOrder(
|
||||
id: 'ord-2',
|
||||
customerId: 'cust-1',
|
||||
title: 'Thermostat Einstellung & Kalibrierung',
|
||||
date: DateTime(2026, 8, 2),
|
||||
status: OrderStatus.offen,
|
||||
),
|
||||
],
|
||||
),
|
||||
Customer(
|
||||
id: 'cust-2',
|
||||
customerNumber: 'K-10026',
|
||||
name: 'Sabine Schulze',
|
||||
street: 'Nordring 45',
|
||||
zipCode: '12347',
|
||||
city: 'Musterstadt',
|
||||
latitude: 50.1265,
|
||||
longitude: 8.6890,
|
||||
distanceKm: 4.1,
|
||||
phone: '0160 9876543',
|
||||
email: 'sabine.schulze@example.com',
|
||||
notes: 'Hund im Garten, bitte vorher anrufen.',
|
||||
firstContactDate: DateTime(2021, 11, 4),
|
||||
openOrdersCount: 0,
|
||||
lastOrderDate: DateTime(2024, 4, 10),
|
||||
installedParts: const [
|
||||
InstalledPart(
|
||||
id: 'part-4',
|
||||
customerId: 'cust-2',
|
||||
name: 'Viessmann Vitodens 200-W',
|
||||
category: 'Gas-Brennwertgerät',
|
||||
serialNumber: '7632918401',
|
||||
quantity: 1,
|
||||
),
|
||||
],
|
||||
orders: [
|
||||
WorkOrder(
|
||||
id: 'ord-3',
|
||||
customerId: 'cust-2',
|
||||
title: 'Jahresinspektion',
|
||||
date: DateTime(2024, 4, 10),
|
||||
status: OrderStatus.abgeschlossen,
|
||||
),
|
||||
],
|
||||
),
|
||||
Customer(
|
||||
id: 'cust-3',
|
||||
customerNumber: 'K-10027',
|
||||
name: 'Bäckerei Hoffmann GmbH',
|
||||
street: 'Hauptstraße 88',
|
||||
zipCode: '12345',
|
||||
city: 'Musterstadt',
|
||||
latitude: 50.1080,
|
||||
longitude: 8.6650,
|
||||
distanceKm: 1.8,
|
||||
phone: '069 5551234',
|
||||
email: 'info@baeckerei-hoffmann.de',
|
||||
notes: 'Zufahrt über den Lieferanteneingang Rückseite.',
|
||||
firstContactDate: DateTime(2020, 1, 15),
|
||||
openOrdersCount: 2,
|
||||
lastOrderDate: DateTime(2024, 6, 01),
|
||||
installedParts: const [
|
||||
InstalledPart(
|
||||
id: 'part-5',
|
||||
customerId: 'cust-3',
|
||||
name: 'Grundfos Magna3 32-120 F',
|
||||
category: 'Heizungsumwälzpumpe',
|
||||
serialNumber: '983301920',
|
||||
quantity: 2,
|
||||
),
|
||||
],
|
||||
orders: [
|
||||
WorkOrder(
|
||||
id: 'ord-4',
|
||||
customerId: 'cust-3',
|
||||
title: 'Austausch Umwälzpumpe',
|
||||
date: DateTime(2024, 6, 1),
|
||||
status: OrderStatus.abgeschlossen,
|
||||
),
|
||||
],
|
||||
),
|
||||
Customer(
|
||||
id: 'cust-4',
|
||||
customerNumber: 'K-10028',
|
||||
name: 'Dr. Michael Weber',
|
||||
street: 'Goetheallee 3',
|
||||
zipCode: '12349',
|
||||
city: 'Musterstadt',
|
||||
latitude: 50.0980,
|
||||
longitude: 8.6720,
|
||||
distanceKm: 3.5,
|
||||
phone: '0172 4443322',
|
||||
email: 'm.weber@praxis-weber.de',
|
||||
notes: 'Termine nur mittwochs nachmittags möglich.',
|
||||
firstContactDate: DateTime(2023, 7, 20),
|
||||
openOrdersCount: 1,
|
||||
lastOrderDate: DateTime(2023, 12, 12),
|
||||
installedParts: const [],
|
||||
orders: [
|
||||
WorkOrder(
|
||||
id: 'ord-5',
|
||||
customerId: 'cust-4',
|
||||
title: 'Installationsprüfbericht',
|
||||
date: DateTime(2023, 12, 12),
|
||||
status: OrderStatus.abgeschlossen,
|
||||
),
|
||||
],
|
||||
),
|
||||
Customer(
|
||||
id: 'cust-5',
|
||||
customerNumber: 'K-10029',
|
||||
name: 'Elena Schmidt',
|
||||
street: 'Ostendstraße 102',
|
||||
zipCode: '12345',
|
||||
city: 'Musterstadt',
|
||||
latitude: 50.1110,
|
||||
longitude: 8.7020,
|
||||
distanceKm: 3.1,
|
||||
phone: '0151 7766554',
|
||||
email: 'elena.schmidt@gmx.de',
|
||||
notes: 'Klingel beschriftet mit "Schmidt / OG 2".',
|
||||
firstContactDate: DateTime(2024, 2, 1),
|
||||
openOrdersCount: 0,
|
||||
lastOrderDate: DateTime(2024, 3, 22),
|
||||
installedParts: const [],
|
||||
orders: [],
|
||||
),
|
||||
];
|
||||
|
||||
// Daily Schedule Items matching Auftragsuebersicht.png Day View
|
||||
static final List<ScheduleItem> dayScheduleItems = [
|
||||
ScheduleItem(
|
||||
id: 'sch-1',
|
||||
title: 'Team-Besprechung / Material-Laden',
|
||||
startTime: '07:00',
|
||||
endTime: '09:00',
|
||||
type: ScheduleItemType.routine,
|
||||
),
|
||||
ScheduleItem(
|
||||
id: 'sch-2',
|
||||
title: 'Max Mustermann - Heizungswartung',
|
||||
customerName: 'Max Mustermann',
|
||||
address: 'Musterweg 12, 12345 Musterstadt',
|
||||
taskDescription: 'Wartung Gas-Brennwertgerät',
|
||||
startTime: '10:30',
|
||||
endTime: '13:00',
|
||||
type: ScheduleItemType.job,
|
||||
isInProgress: true,
|
||||
),
|
||||
ScheduleItem(
|
||||
id: 'sch-3',
|
||||
title: 'Mittagspause',
|
||||
startTime: '13:00',
|
||||
endTime: '13:30',
|
||||
type: ScheduleItemType.lunchBreak,
|
||||
),
|
||||
ScheduleItem(
|
||||
id: 'sch-4',
|
||||
title: 'Anja Klein - Thermostat-Tausch',
|
||||
customerName: 'Anja Klein',
|
||||
address: 'Musterweg 12, 12345 Musterstadt',
|
||||
taskDescription: 'Wartung Gas-Brennwertgerät',
|
||||
startTime: '13:30',
|
||||
endTime: '15:00',
|
||||
type: ScheduleItemType.job,
|
||||
),
|
||||
ScheduleItem(
|
||||
id: 'sch-5',
|
||||
title: 'Bauprojekt Neubau - Sanitär-Rohinstallation',
|
||||
customerName: 'Bauprojekt Neubau',
|
||||
address: 'Musterweg 12, 12345 Musterstadt',
|
||||
startTime: '15:30',
|
||||
endTime: '17:00',
|
||||
type: ScheduleItemType.job,
|
||||
),
|
||||
ScheduleItem(
|
||||
id: 'sch-6',
|
||||
title: 'Feierabend',
|
||||
startTime: '18:00',
|
||||
endTime: '18:00',
|
||||
type: ScheduleItemType.feierabend,
|
||||
),
|
||||
];
|
||||
|
||||
// Weekly Matrix Summaries matching Auftragsuebersicht.png Week View
|
||||
static final List<DaySummary> weekSummaries = [
|
||||
DaySummary(
|
||||
dayName: 'Mo',
|
||||
fullDayName: 'Montag',
|
||||
dateString: '13.05',
|
||||
ordersCount: 3,
|
||||
hoursTotal: 8.5,
|
||||
items: [
|
||||
ScheduleItem(
|
||||
id: 'w-mo-1',
|
||||
title: 'Max Mustermann',
|
||||
customerName: 'Max Mustermann',
|
||||
address: 'Musterweg 12, 12345 Musterstadt',
|
||||
startTime: '08:00',
|
||||
endTime: '10:30',
|
||||
isCompleted: true,
|
||||
),
|
||||
ScheduleItem(
|
||||
id: 'w-mo-2',
|
||||
title: 'Sabine Schulze',
|
||||
customerName: 'Sabine Schulze',
|
||||
address: 'Nordring 45, 12347 Musterstadt',
|
||||
startTime: '11:00',
|
||||
endTime: '14:00',
|
||||
isCompleted: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
DaySummary(
|
||||
dayName: 'Di',
|
||||
fullDayName: 'Dienstag',
|
||||
dateString: '14.05',
|
||||
ordersCount: 4,
|
||||
hoursTotal: 9.0,
|
||||
items: [
|
||||
ScheduleItem(
|
||||
id: 'w-di-1',
|
||||
title: 'Max Mustermann',
|
||||
customerName: 'Max Mustermann',
|
||||
address: 'Musterweg 12, 12345 Musterstadt',
|
||||
startTime: '08:00',
|
||||
endTime: '10:00',
|
||||
isCompleted: false,
|
||||
),
|
||||
ScheduleItem(
|
||||
id: 'w-di-2',
|
||||
title: 'Anja Klein',
|
||||
customerName: 'Anja Klein',
|
||||
address: 'Musterweg 12, 12345 Musterstadt',
|
||||
startTime: '10:30',
|
||||
endTime: '12:30',
|
||||
isCompleted: false,
|
||||
),
|
||||
ScheduleItem(
|
||||
id: 'w-di-3',
|
||||
title: 'Max Mustermann',
|
||||
customerName: 'Max Mustermann',
|
||||
address: 'Musterweg 12, 12345 Musterstadt',
|
||||
taskDescription: 'Wartertiter',
|
||||
startTime: '13:30',
|
||||
endTime: '15:30',
|
||||
isCompleted: false,
|
||||
),
|
||||
ScheduleItem(
|
||||
id: 'w-di-4',
|
||||
title: 'Bauprojekt Neubau - Sanitär-Rohinstallation',
|
||||
customerName: 'Bauprojekt Neubau',
|
||||
address: 'Musterweg 12, 12345 Musterstadt',
|
||||
taskDescription: 'Bauprüfer',
|
||||
startTime: '16:00',
|
||||
endTime: '18:00',
|
||||
isCompleted: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
DaySummary(
|
||||
dayName: 'Mi',
|
||||
fullDayName: 'Mittwoch',
|
||||
dateString: '15.05',
|
||||
ordersCount: 2,
|
||||
hoursTotal: 7.5,
|
||||
items: [
|
||||
ScheduleItem(
|
||||
id: 'w-mi-1',
|
||||
title: 'Bäckerei Hoffmann GmbH',
|
||||
customerName: 'Bäckerei Hoffmann GmbH',
|
||||
address: 'Hauptstraße 88, 12345 Musterstadt',
|
||||
startTime: '08:00',
|
||||
endTime: '12:00',
|
||||
isCompleted: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
DaySummary(
|
||||
dayName: 'Do',
|
||||
fullDayName: 'Donnerstag',
|
||||
dateString: '16.05',
|
||||
ordersCount: 2,
|
||||
hoursTotal: 7.5,
|
||||
items: [
|
||||
ScheduleItem(
|
||||
id: 'w-do-1',
|
||||
title: 'Max Mustermann',
|
||||
customerName: 'Max Mustermann',
|
||||
address: 'Musterweg 12, 12345 Musterstadt',
|
||||
startTime: '09:00',
|
||||
endTime: '12:00',
|
||||
isCompleted: false,
|
||||
),
|
||||
ScheduleItem(
|
||||
id: 'w-do-2',
|
||||
title: 'Anja Klein',
|
||||
customerName: 'Anja Klein',
|
||||
address: 'Musterweg 12, 12345 Musterstadt',
|
||||
startTime: '13:30',
|
||||
endTime: '16:00',
|
||||
isCompleted: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
DaySummary(
|
||||
dayName: 'Fr',
|
||||
fullDayName: 'Freitag',
|
||||
dateString: '17.05',
|
||||
ordersCount: 5,
|
||||
hoursTotal: 9.5,
|
||||
items: [
|
||||
ScheduleItem(
|
||||
id: 'w-fr-1',
|
||||
title: 'Max Mustermann',
|
||||
customerName: 'Max Mustermann',
|
||||
address: 'Musterweg 12, 12345 Musterstadt',
|
||||
startTime: '08:00',
|
||||
endTime: '10:00',
|
||||
isCompleted: true,
|
||||
),
|
||||
ScheduleItem(
|
||||
id: 'w-fr-2',
|
||||
title: 'Max Mustermann',
|
||||
customerName: 'Max Mustermann',
|
||||
address: 'Musterweg 12, 12345 Musterstadt',
|
||||
startTime: '10:15',
|
||||
endTime: '12:00',
|
||||
isCompleted: false,
|
||||
),
|
||||
ScheduleItem(
|
||||
id: 'w-fr-3',
|
||||
title: 'Max Mustermann',
|
||||
customerName: 'Max Mustermann',
|
||||
address: 'Musterweg 12, 12345 Musterstadt',
|
||||
startTime: '13:00',
|
||||
endTime: '15:00',
|
||||
isCompleted: false,
|
||||
),
|
||||
ScheduleItem(
|
||||
id: 'w-fr-4',
|
||||
title: 'Max Mustermann',
|
||||
customerName: 'Max Mustermann',
|
||||
address: 'Musterweg 12, 12345 Musterstadt',
|
||||
startTime: '15:30',
|
||||
endTime: '17:30',
|
||||
isCompleted: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
DaySummary(
|
||||
dayName: 'Sa',
|
||||
fullDayName: 'Samstag',
|
||||
dateString: '18.05',
|
||||
ordersCount: 3,
|
||||
hoursTotal: 8.0,
|
||||
items: [],
|
||||
),
|
||||
DaySummary(
|
||||
dayName: 'So',
|
||||
fullDayName: 'Sonntag',
|
||||
dateString: '19.05',
|
||||
ordersCount: 3,
|
||||
hoursTotal: 8.0,
|
||||
items: [],
|
||||
),
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'services/database_service.dart';
|
||||
import 'theme/app_theme.dart';
|
||||
import 'screens/main_navigation_screen.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await DatabaseService.initialize();
|
||||
runApp(const HandwerksfreundApp());
|
||||
}
|
||||
|
||||
class HandwerksfreundApp extends StatelessWidget {
|
||||
const HandwerksfreundApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Handwerksfreund',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: AppTheme.lightTheme,
|
||||
home: const MainNavigationScreen(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import 'installed_part.dart';
|
||||
import 'order.dart';
|
||||
|
||||
class Customer {
|
||||
final String id;
|
||||
final String customerNumber;
|
||||
final String name;
|
||||
final String street;
|
||||
final String zipCode;
|
||||
final String city;
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
final double distanceKm;
|
||||
final String phone;
|
||||
final String email;
|
||||
final String? notes;
|
||||
final DateTime firstContactDate;
|
||||
final int openOrdersCount;
|
||||
final DateTime? lastOrderDate;
|
||||
final List<InstalledPart> installedParts;
|
||||
final List<WorkOrder> orders;
|
||||
|
||||
const Customer({
|
||||
required this.id,
|
||||
required this.customerNumber,
|
||||
required this.name,
|
||||
required this.street,
|
||||
required this.zipCode,
|
||||
required this.city,
|
||||
required this.latitude,
|
||||
required this.longitude,
|
||||
required this.distanceKm,
|
||||
required this.phone,
|
||||
required this.email,
|
||||
this.notes,
|
||||
required this.firstContactDate,
|
||||
required this.openOrdersCount,
|
||||
this.lastOrderDate,
|
||||
this.installedParts = const [],
|
||||
this.orders = const [],
|
||||
});
|
||||
|
||||
String get fullAddress => '$street, $zipCode $city';
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
class InstalledPart {
|
||||
final String id;
|
||||
final String customerId;
|
||||
final String name;
|
||||
final String category;
|
||||
final String serialNumber;
|
||||
final int quantity;
|
||||
|
||||
const InstalledPart({
|
||||
required this.id,
|
||||
required this.customerId,
|
||||
required this.name,
|
||||
required this.category,
|
||||
required this.serialNumber,
|
||||
this.quantity = 1,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
enum OrderStatus {
|
||||
offen,
|
||||
inBearbeitung,
|
||||
abgeschlossen,
|
||||
storniert,
|
||||
}
|
||||
|
||||
extension OrderStatusExtension on OrderStatus {
|
||||
String get label {
|
||||
switch (this) {
|
||||
case OrderStatus.offen:
|
||||
return 'Offen';
|
||||
case OrderStatus.inBearbeitung:
|
||||
return 'In Bearbeitung';
|
||||
case OrderStatus.abgeschlossen:
|
||||
return 'Abgeschlossen';
|
||||
case OrderStatus.storniert:
|
||||
return 'Storniert';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class WorkOrder {
|
||||
final String id;
|
||||
final String customerId;
|
||||
final String title;
|
||||
final DateTime date;
|
||||
final OrderStatus status;
|
||||
|
||||
const WorkOrder({
|
||||
required this.id,
|
||||
required this.customerId,
|
||||
required this.title,
|
||||
required this.date,
|
||||
required this.status,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
enum ScheduleItemType {
|
||||
job,
|
||||
routine, // e.g. Team-Besprechung, Material laden
|
||||
lunchBreak, // Mittagspause
|
||||
feierabend, // Feierabend
|
||||
}
|
||||
|
||||
class ScheduleItem {
|
||||
final String id;
|
||||
final String title;
|
||||
final String? customerName;
|
||||
final String? address;
|
||||
final String? taskDescription;
|
||||
final String startTime;
|
||||
final String endTime;
|
||||
final ScheduleItemType type;
|
||||
bool isCompleted;
|
||||
bool isInProgress;
|
||||
|
||||
ScheduleItem({
|
||||
required this.id,
|
||||
required this.title,
|
||||
this.customerName,
|
||||
this.address,
|
||||
this.taskDescription,
|
||||
required this.startTime,
|
||||
required this.endTime,
|
||||
this.type = ScheduleItemType.job,
|
||||
this.isCompleted = false,
|
||||
this.isInProgress = false,
|
||||
});
|
||||
}
|
||||
|
||||
class DaySummary {
|
||||
final String dayName; // Mo, Di, Mi, Do, Fr, Sa, So
|
||||
final String fullDayName; // Monday, Tuesday, Thursday, ...
|
||||
final String dateString; // e.g. 16.05
|
||||
final int ordersCount;
|
||||
final double hoursTotal;
|
||||
final List<ScheduleItem> items;
|
||||
|
||||
const DaySummary({
|
||||
required this.dayName,
|
||||
required this.fullDayName,
|
||||
required this.dateString,
|
||||
required this.ordersCount,
|
||||
required this.hoursTotal,
|
||||
this.items = const [],
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,503 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/customer.dart';
|
||||
import '../models/order.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
class CustomerDetailScreen extends StatelessWidget {
|
||||
final Customer customer;
|
||||
|
||||
const CustomerDetailScreen({
|
||||
super.key,
|
||||
required this.customer,
|
||||
});
|
||||
|
||||
String _formatDate(DateTime date) {
|
||||
final day = date.day.toString().padLeft(2, '0');
|
||||
final month = date.month.toString().padLeft(2, '0');
|
||||
return '$day.$month.${date.year}';
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppTheme.backgroundLight,
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
title: const Text('Kundendetails'),
|
||||
centerTitle: true,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.more_horiz),
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Optionen geöffnet')),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Top Customer Profile Card
|
||||
_buildProfileHeader(context),
|
||||
const SizedBox(height: 16),
|
||||
// Quick Action Buttons
|
||||
_buildQuickActions(context),
|
||||
const SizedBox(height: 20),
|
||||
// Section 1: Kundeninformationen
|
||||
_buildCustomerInfoSection(),
|
||||
const SizedBox(height: 20),
|
||||
// Section 2: Verbaute Teile (letzter Auftrag)
|
||||
_buildInstalledPartsSection(),
|
||||
const SizedBox(height: 20),
|
||||
// Section 3: Aufträge
|
||||
_buildWorkOrdersSection(),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildProfileHeader(BuildContext context) {
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 28,
|
||||
backgroundColor: AppTheme.primaryBlue,
|
||||
child: const Icon(
|
||||
Icons.person,
|
||||
color: Colors.white,
|
||||
size: 32,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
customer.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
customer.street,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${customer.zipCode} ${customer.city}',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.backgroundLight,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: AppTheme.cardBorder),
|
||||
),
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.phone_outlined, color: AppTheme.textPrimary),
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Anruf gestartet: ${customer.phone}')),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildQuickActions(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
_buildActionButton(
|
||||
context,
|
||||
icon: Icons.navigation_outlined,
|
||||
label: 'Route',
|
||||
onTap: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Navigation zu ${customer.fullAddress} gestartet')),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
_buildActionButton(
|
||||
context,
|
||||
icon: Icons.phone_outlined,
|
||||
label: 'Anrufen',
|
||||
onTap: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Anrufen: ${customer.phone}')),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
_buildActionButton(
|
||||
context,
|
||||
icon: Icons.email_outlined,
|
||||
label: 'E-Mail',
|
||||
onTap: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('E-Mail an: ${customer.email}')),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
_buildActionButton(
|
||||
context,
|
||||
icon: Icons.edit_outlined,
|
||||
label: 'Bearbeiten',
|
||||
onTap: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Kunde bearbeiten')),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildActionButton(
|
||||
BuildContext context, {
|
||||
required IconData icon,
|
||||
required String label,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return Expanded(
|
||||
child: Material(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: AppTheme.cardBorder),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(icon, color: AppTheme.primaryBlue, size: 22),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCustomerInfoSection() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Kundeninformationen',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildInfoRow('Kundennummer', customer.customerNumber),
|
||||
const Divider(height: 1, color: AppTheme.cardBorder),
|
||||
_buildInfoRow('Telefon', customer.phone),
|
||||
const Divider(height: 1, color: AppTheme.cardBorder),
|
||||
_buildInfoRow('E-Mail', customer.email),
|
||||
const Divider(height: 1, color: AppTheme.cardBorder),
|
||||
_buildInfoRow('Erstkontakt', _formatDate(customer.firstContactDate)),
|
||||
if (customer.notes != null) ...[
|
||||
const Divider(height: 1, color: AppTheme.cardBorder),
|
||||
_buildInfoRow('Notizen', customer.notes!),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoRow(String label, String value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 120,
|
||||
child: Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
value,
|
||||
textAlign: TextAlign.end,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInstalledPartsSection() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Verbaute Teile (letzter Auftrag)',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Card(
|
||||
child: customer.installedParts.isEmpty
|
||||
? const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Keine verbauten Teile vorhanden.',
|
||||
style: TextStyle(color: AppTheme.textSecondary),
|
||||
),
|
||||
),
|
||||
)
|
||||
: ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: customer.installedParts.length,
|
||||
separatorBuilder: (context, index) =>
|
||||
const Divider(height: 1, color: AppTheme.cardBorder),
|
||||
itemBuilder: (context, index) {
|
||||
final part = customer.installedParts[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.backgroundLight,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: AppTheme.cardBorder),
|
||||
),
|
||||
child: Icon(
|
||||
_getPartIcon(part.category),
|
||||
color: AppTheme.textSecondary,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
part.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
part.category,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
'Seriennr.: ${part.serialNumber}',
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
color: AppTheme.textMuted,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${part.quantity} Stk.',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
IconData _getPartIcon(String category) {
|
||||
if (category.contains('Heiz') || category.contains('Gas')) {
|
||||
return Icons.hvac_outlined;
|
||||
} else if (category.contains('thermostat') || category.contains('Raum')) {
|
||||
return Icons.thermostat_outlined;
|
||||
} else if (category.contains('Filter') || category.contains('Wasser')) {
|
||||
return Icons.filter_alt_outlined;
|
||||
} else if (category.contains('Pumpe')) {
|
||||
return Icons.speed_outlined;
|
||||
}
|
||||
return Icons.build_outlined;
|
||||
}
|
||||
|
||||
Widget _buildWorkOrdersSection() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Aufträge',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Card(
|
||||
child: customer.orders.isEmpty
|
||||
? const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Keine Aufträge vorhanden.',
|
||||
style: TextStyle(color: AppTheme.textSecondary),
|
||||
),
|
||||
),
|
||||
)
|
||||
: ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: customer.orders.length,
|
||||
separatorBuilder: (context, index) =>
|
||||
const Divider(height: 1, color: AppTheme.cardBorder),
|
||||
itemBuilder: (context, index) {
|
||||
final order = customer.orders[index];
|
||||
final isCompleted = order.status == OrderStatus.abgeschlossen;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Row(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
_formatDate(order.date),
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
order.title,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: isCompleted
|
||||
? const Color(0xFFDCFCE7)
|
||||
: const Color(0xFFFEF3C7),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
order.status.label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: isCompleted
|
||||
? const Color(0xFF166534)
|
||||
: const Color(0xFF92400E),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Icon(
|
||||
Icons.chevron_right,
|
||||
color: AppTheme.textSecondary,
|
||||
size: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,341 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import '../models/customer.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import '../widgets/customer_preview_sheet.dart';
|
||||
import '../services/database_service.dart';
|
||||
|
||||
class CustomerMapScreen extends StatefulWidget {
|
||||
const CustomerMapScreen({super.key});
|
||||
|
||||
@override
|
||||
State<CustomerMapScreen> createState() => _CustomerMapScreenState();
|
||||
}
|
||||
|
||||
class _CustomerMapScreenState extends State<CustomerMapScreen> {
|
||||
final MapController _mapController = MapController();
|
||||
Customer? _selectedCustomer;
|
||||
String _searchQuery = '';
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
List<Customer> _allCustomers = [];
|
||||
|
||||
// Initial center position (Musterstadt / Frankfurt coordinates)
|
||||
static final LatLng _initialCenter = LatLng(50.1109, 8.6821);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadCustomers();
|
||||
}
|
||||
|
||||
Future<void> _loadCustomers() async {
|
||||
final list = await DatabaseService.getCustomers();
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_allCustomers = list;
|
||||
if (_allCustomers.isNotEmpty) {
|
||||
_selectedCustomer = _allCustomers.firstWhere(
|
||||
(c) => c.customerNumber == 'K-10025',
|
||||
orElse: () => _allCustomers.first,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_searchController.dispose();
|
||||
_mapController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
List<Customer> get _filteredCustomers {
|
||||
if (_searchQuery.trim().isEmpty) {
|
||||
return _allCustomers;
|
||||
}
|
||||
final q = _searchQuery.toLowerCase();
|
||||
return _allCustomers.where((c) {
|
||||
return c.name.toLowerCase().contains(q) ||
|
||||
c.customerNumber.toLowerCase().contains(q) ||
|
||||
c.city.toLowerCase().contains(q) ||
|
||||
c.street.toLowerCase().contains(q);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
void _selectCustomer(Customer customer) {
|
||||
setState(() {
|
||||
_selectedCustomer = customer;
|
||||
});
|
||||
_mapController.move(
|
||||
LatLng(customer.latitude, customer.longitude),
|
||||
14.5,
|
||||
);
|
||||
}
|
||||
|
||||
void _recenterMap() {
|
||||
_mapController.move(
|
||||
_initialCenter,
|
||||
13.0,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppTheme.backgroundLight,
|
||||
body: Column(
|
||||
children: [
|
||||
// Dark Navy Top Header Bar (matches Mockup NaviScreen.png)
|
||||
Container(
|
||||
color: AppTheme.primaryDark,
|
||||
child: SafeArea(
|
||||
bottom: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
||||
child: Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.menu, color: Colors.white),
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Menü geöffnet')),
|
||||
);
|
||||
},
|
||||
),
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'Kunden',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.search, color: Colors.white),
|
||||
onPressed: () {},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.tune, color: Colors.white),
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Filter geöffnet')),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Map Area + Floating Overlays
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
// Clean Minimalistic CartoDB Tile Layer Map View
|
||||
FlutterMap(
|
||||
mapController: _mapController,
|
||||
options: MapOptions(
|
||||
initialCenter: _selectedCustomer != null
|
||||
? LatLng(_selectedCustomer!.latitude, _selectedCustomer!.longitude)
|
||||
: _initialCenter,
|
||||
initialZoom: 13.5,
|
||||
// Enable full multi-touch gestures (Pinch Zoom, Pan, Double Tap)
|
||||
interactionOptions: const InteractionOptions(
|
||||
flags: InteractiveFlag.all,
|
||||
),
|
||||
onTap: (tapPosition, point) {
|
||||
setState(() {
|
||||
_selectedCustomer = null;
|
||||
});
|
||||
},
|
||||
),
|
||||
children: [
|
||||
TileLayer(
|
||||
// Clean minimal map tiles matching the mockup design
|
||||
urlTemplate: 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png',
|
||||
subdomains: const ['a', 'b', 'c', 'd'],
|
||||
retinaMode: RetinaMode.isHighDensity(context),
|
||||
userAgentPackageName: 'de.handwerksfreund.app',
|
||||
),
|
||||
MarkerLayer(
|
||||
markers: _filteredCustomers.map((customer) {
|
||||
final isSelected = _selectedCustomer?.id == customer.id;
|
||||
return Marker(
|
||||
width: isSelected ? 50 : 40,
|
||||
height: isSelected ? 50 : 40,
|
||||
point: LatLng(customer.latitude, customer.longitude),
|
||||
child: GestureDetector(
|
||||
onTap: () => _selectCustomer(customer),
|
||||
child: isSelected
|
||||
? Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppTheme.primaryBlue.withAlpha(102),
|
||||
blurRadius: 12,
|
||||
spreadRadius: 4,
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: AppTheme.primaryBlue,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.location_on,
|
||||
color: Colors.white,
|
||||
size: 26,
|
||||
),
|
||||
),
|
||||
)
|
||||
: const Icon(
|
||||
Icons.location_on,
|
||||
color: AppTheme.primaryBlue,
|
||||
size: 38,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Dim Overlay when customer sheet is selected
|
||||
if (_selectedCustomer != null)
|
||||
Positioned.fill(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_selectedCustomer = null;
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.black.withAlpha(51),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Search Input Card overlay
|
||||
Positioned(
|
||||
top: 12,
|
||||
left: 16,
|
||||
right: 16,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Colors.black12,
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
onChanged: (val) {
|
||||
setState(() {
|
||||
_searchQuery = val;
|
||||
});
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Kunden suchen...',
|
||||
hintStyle: const TextStyle(
|
||||
color: AppTheme.textSecondary,
|
||||
fontSize: 14,
|
||||
),
|
||||
prefixIcon: const Icon(
|
||||
Icons.search,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
suffixIcon: IconButton(
|
||||
icon: const Icon(
|
||||
Icons.tune,
|
||||
color: AppTheme.textSecondary,
|
||||
size: 20,
|
||||
),
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Filteroptionen geöffnet')),
|
||||
);
|
||||
},
|
||||
),
|
||||
border: InputBorder.none,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Map Action Buttons (Center location & Add customer FAB)
|
||||
Positioned(
|
||||
right: 16,
|
||||
bottom: _selectedCustomer != null ? 230 : 24,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
FloatingActionButton.small(
|
||||
heroTag: 'recenter_fab',
|
||||
onPressed: _recenterMap,
|
||||
backgroundColor: Colors.white,
|
||||
foregroundColor: AppTheme.primaryDark,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(Icons.my_location, size: 20),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
FloatingActionButton(
|
||||
heroTag: 'add_customer_fab',
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Neuen Kunden anlegen')),
|
||||
);
|
||||
},
|
||||
backgroundColor: AppTheme.primaryDark,
|
||||
foregroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: const Icon(Icons.add, size: 28),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Bottom Sheet Customer Preview Card Overlay
|
||||
if (_selectedCustomer != null)
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: CustomerPreviewSheet(
|
||||
customer: _selectedCustomer!,
|
||||
onClose: () {
|
||||
setState(() {
|
||||
_selectedCustomer = null;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
class DummyScreen extends StatelessWidget {
|
||||
final String title;
|
||||
final IconData icon;
|
||||
|
||||
const DummyScreen({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.icon,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppTheme.backgroundLight,
|
||||
appBar: AppBar(
|
||||
title: Text(title),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.lightBlueBg,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
size: 48,
|
||||
color: AppTheme.primaryBlue,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.primaryDark,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'Diese Funktion wird im nächsten Schritt ausgebaut.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'customer_map_screen.dart';
|
||||
import 'dummy_screen.dart';
|
||||
import 'more_screen.dart';
|
||||
import 'orders_screen.dart';
|
||||
|
||||
class MainNavigationScreen extends StatefulWidget {
|
||||
const MainNavigationScreen({super.key});
|
||||
|
||||
@override
|
||||
State<MainNavigationScreen> createState() => _MainNavigationScreenState();
|
||||
}
|
||||
|
||||
class _MainNavigationScreenState extends State<MainNavigationScreen> {
|
||||
// Start on tab 1 (Kunden / Map Screen) as requested in the mockup
|
||||
int _currentIndex = 1;
|
||||
|
||||
final List<Widget> _screens = const [
|
||||
DummyScreen(title: 'Übersicht', icon: Icons.grid_view),
|
||||
CustomerMapScreen(),
|
||||
OrdersScreen(),
|
||||
DummyScreen(title: 'Kalender', icon: Icons.calendar_month_outlined),
|
||||
MoreScreen(),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: IndexedStack(
|
||||
index: _currentIndex,
|
||||
children: _screens,
|
||||
),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
currentIndex: _currentIndex,
|
||||
onTap: (index) {
|
||||
setState(() {
|
||||
_currentIndex = index;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.grid_view),
|
||||
label: 'Übersicht',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.person_outline),
|
||||
activeIcon: Icon(Icons.person),
|
||||
label: 'Kunden',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.receipt_long_outlined),
|
||||
label: 'Aufträge',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.calendar_month_outlined),
|
||||
label: 'Kalender',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.more_horiz),
|
||||
label: 'Mehr',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,506 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../services/database_service.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import '../widgets/system_status_dialog.dart';
|
||||
|
||||
class MoreScreen extends StatefulWidget {
|
||||
const MoreScreen({super.key});
|
||||
|
||||
@override
|
||||
State<MoreScreen> createState() => _MoreScreenState();
|
||||
}
|
||||
|
||||
class _MoreScreenState extends State<MoreScreen> {
|
||||
bool _notificationsEnabled = true;
|
||||
SystemStatusResult? _statusResult;
|
||||
bool _isCheckingStatus = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_checkStatus();
|
||||
}
|
||||
|
||||
Future<void> _checkStatus() async {
|
||||
final status = await DatabaseService.testConnection();
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_statusResult = status;
|
||||
_isCheckingStatus = false;
|
||||
});
|
||||
}
|
||||
|
||||
void _openSystemStatusDetails() async {
|
||||
setState(() {
|
||||
_isCheckingStatus = true;
|
||||
});
|
||||
final status = await DatabaseService.testConnection();
|
||||
if (!mounted) return;
|
||||
|
||||
setState(() {
|
||||
_statusResult = status;
|
||||
_isCheckingStatus = false;
|
||||
});
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => SystemStatusDialog(status: status),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isConnected = _statusResult?.isConnected ?? DatabaseService.isInitialized;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppTheme.backgroundLight,
|
||||
body: Column(
|
||||
children: [
|
||||
// Dark Navy Top Header Bar (matches Mockup Mehr_Page.png)
|
||||
Container(
|
||||
color: AppTheme.primaryDark,
|
||||
child: SafeArea(
|
||||
bottom: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
||||
child: Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.menu, color: Colors.white),
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Menü geöffnet')),
|
||||
);
|
||||
},
|
||||
),
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'Mehr',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const CircleAvatar(
|
||||
radius: 14,
|
||||
backgroundColor: Colors.white,
|
||||
child: Icon(Icons.person, color: AppTheme.primaryDark, size: 18),
|
||||
),
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Profil geöffnet')),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Scrollable Settings Content Body
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Profile Header Card
|
||||
_buildProfileCard(context),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Systemstatus Card (Interactive Supabase Connection Status)
|
||||
_buildSystemStatusCard(context, isConnected),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Gruppe: Allgemein
|
||||
_buildSectionTitle('Gruppe: Allgemein'),
|
||||
const SizedBox(height: 8),
|
||||
Card(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildSwitchTile(
|
||||
icon: Icons.notifications_outlined,
|
||||
title: 'Benachrichtigungen',
|
||||
value: _notificationsEnabled,
|
||||
onChanged: (val) {
|
||||
setState(() {
|
||||
_notificationsEnabled = val;
|
||||
});
|
||||
},
|
||||
),
|
||||
const Divider(height: 1, color: AppTheme.cardBorder),
|
||||
_buildValueTile(
|
||||
icon: Icons.language_outlined,
|
||||
title: 'App-Sprache',
|
||||
value: 'Deutsch',
|
||||
onTap: () {},
|
||||
),
|
||||
const Divider(height: 1, color: AppTheme.cardBorder),
|
||||
_buildTile(
|
||||
icon: Icons.shield_outlined,
|
||||
title: 'Sicherheit & Datenschutz',
|
||||
onTap: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Gruppe: Verwaltung
|
||||
_buildSectionTitle('Gruppe: Verwaltung'),
|
||||
const SizedBox(height: 8),
|
||||
Card(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildTile(
|
||||
icon: Icons.event_available_outlined,
|
||||
title: 'Urlaub & Abwesenheit',
|
||||
badgeText: 'HR',
|
||||
onTap: () {},
|
||||
),
|
||||
const Divider(height: 1, color: AppTheme.cardBorder),
|
||||
_buildTile(
|
||||
icon: Icons.build_outlined,
|
||||
title: 'Meine Werkzeug-Ausstattung',
|
||||
onTap: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Gruppe: App-Info
|
||||
_buildSectionTitle('Gruppe: App-Info'),
|
||||
const SizedBox(height: 8),
|
||||
Card(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildTile(
|
||||
icon: Icons.info_outline,
|
||||
title: 'Impressum',
|
||||
onTap: () {},
|
||||
),
|
||||
const Divider(height: 1, color: AppTheme.cardBorder),
|
||||
_buildTile(
|
||||
icon: Icons.article_outlined,
|
||||
title: 'Datenschutz',
|
||||
onTap: () {},
|
||||
),
|
||||
const Divider(height: 1, color: AppTheme.cardBorder),
|
||||
_buildTile(
|
||||
icon: Icons.star_outline,
|
||||
title: 'Feedback zur App',
|
||||
onTap: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Logout Button
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Abgemeldet')),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFFDC2626),
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'Abmelden',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildProfileCard(BuildContext context) {
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 26,
|
||||
backgroundColor: AppTheme.primaryBlue,
|
||||
child: const Icon(
|
||||
Icons.person,
|
||||
color: Colors.white,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
const Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Max Müller',
|
||||
style: TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 2),
|
||||
Text(
|
||||
'Monteur / ID: M-01023',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
OutlinedButton(
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Profil bearbeiten')),
|
||||
);
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: AppTheme.textPrimary,
|
||||
side: const BorderSide(color: AppTheme.cardBorder),
|
||||
minimumSize: const Size(double.infinity, 40),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'Profil bearbeiten',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSystemStatusCard(BuildContext context, bool isConnected) {
|
||||
final statusText = _isCheckingStatus
|
||||
? 'Verbindung wird geprüft...'
|
||||
: (isConnected ? 'Verbunden: Supabase' : 'Offline / Mock-Modus');
|
||||
|
||||
final statusColor = _isCheckingStatus
|
||||
? Colors.orange[700]
|
||||
: (isConnected ? Colors.green[800] : Colors.red[800]);
|
||||
|
||||
final dotColor = _isCheckingStatus
|
||||
? Colors.orange
|
||||
: (isConnected ? Colors.green[600] : Colors.red);
|
||||
|
||||
return Card(
|
||||
child: InkWell(
|
||||
onTap: _openSystemStatusDetails,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'Systemstatus',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.lightBlueBg,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: _isCheckingStatus
|
||||
? const SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(strokeWidth: 2, color: AppTheme.primaryBlue),
|
||||
)
|
||||
: const Icon(
|
||||
Icons.bolt,
|
||||
color: AppTheme.primaryBlue,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 10,
|
||||
height: 10,
|
||||
decoration: BoxDecoration(
|
||||
color: dotColor,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
statusText,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: statusColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
_statusResult != null && _statusResult!.latencyMs > 0
|
||||
? 'Latenz: ${_statusResult!.latencyMs} ms • supabase.marc-wieland.de'
|
||||
: 'Tippen für erweiterte Verbindungsdetails',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionTitle(String title) {
|
||||
return Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTile({
|
||||
required IconData icon,
|
||||
required String title,
|
||||
String? badgeText,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return ListTile(
|
||||
leading: Icon(icon, color: AppTheme.primaryBlue, size: 22),
|
||||
title: Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
trailing: badgeText != null
|
||||
? Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.lightBlueBg,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
border: Border.all(color: AppTheme.primaryBlue.withAlpha(50)),
|
||||
),
|
||||
child: Text(
|
||||
'↔ $badgeText',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.primaryBlue,
|
||||
),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildValueTile({
|
||||
required IconData icon,
|
||||
required String title,
|
||||
required String value,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return ListTile(
|
||||
leading: Icon(icon, color: AppTheme.primaryBlue, size: 22),
|
||||
title: Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
trailing: Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSwitchTile({
|
||||
required IconData icon,
|
||||
required String title,
|
||||
required bool value,
|
||||
required ValueChanged<bool> onChanged,
|
||||
}) {
|
||||
return ListTile(
|
||||
leading: Icon(icon, color: AppTheme.primaryBlue, size: 22),
|
||||
title: Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
trailing: Switch.adaptive(
|
||||
value: value,
|
||||
activeThumbColor: AppTheme.primaryBlue,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../data/mock_data.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import '../widgets/orders_day_view.dart';
|
||||
import '../widgets/orders_week_view.dart';
|
||||
|
||||
class OrdersScreen extends StatefulWidget {
|
||||
const OrdersScreen({super.key});
|
||||
|
||||
@override
|
||||
State<OrdersScreen> createState() => _OrdersScreenState();
|
||||
}
|
||||
|
||||
class _OrdersScreenState extends State<OrdersScreen> {
|
||||
bool _isWeekView = false;
|
||||
DateTime _selectedDate = DateTime(2024, 5, 16);
|
||||
|
||||
String _formatDate(DateTime date) {
|
||||
final day = date.day.toString().padLeft(2, '0');
|
||||
final month = date.month.toString().padLeft(2, '0');
|
||||
return 'Heute, $day.$month.${date.year}';
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppTheme.backgroundLight,
|
||||
body: Column(
|
||||
children: [
|
||||
// Dark Navy Top Header Bar (matches Mockup Auftragsuebersicht.png)
|
||||
Container(
|
||||
color: AppTheme.primaryDark,
|
||||
child: SafeArea(
|
||||
bottom: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
||||
child: Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.menu, color: Colors.white),
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Menü geöffnet')),
|
||||
);
|
||||
},
|
||||
),
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'Aufträge',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const CircleAvatar(
|
||||
radius: 14,
|
||||
backgroundColor: Colors.white,
|
||||
child: Icon(Icons.person, color: AppTheme.primaryDark, size: 18),
|
||||
),
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Profil geöffnet')),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Date Navigator & View Switch Controls Bar
|
||||
Container(
|
||||
color: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
// Date Selector Chip `< Heute, 16.05.2024 >`
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.backgroundLight,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: AppTheme.cardBorder),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_selectedDate = _selectedDate.subtract(const Duration(days: 1));
|
||||
});
|
||||
},
|
||||
child: const Icon(Icons.chevron_left, size: 20, color: AppTheme.textSecondary),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
_formatDate(_selectedDate),
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_selectedDate = _selectedDate.add(const Duration(days: 1));
|
||||
});
|
||||
},
|
||||
child: const Icon(Icons.chevron_right, size: 20, color: AppTheme.textSecondary),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
// "Woche" Toggle Switch
|
||||
const Text(
|
||||
'Woche',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Switch.adaptive(
|
||||
value: _isWeekView,
|
||||
activeThumbColor: AppTheme.primaryBlue,
|
||||
onChanged: (val) {
|
||||
setState(() {
|
||||
_isWeekView = val;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const Divider(height: 1, color: AppTheme.cardBorder),
|
||||
|
||||
// Dynamic Body (Day Timeline View or Week Matrix View)
|
||||
Expanded(
|
||||
child: _isWeekView
|
||||
? OrdersWeekView(summaries: MockData.weekSummaries)
|
||||
: OrdersDayView(items: MockData.dayScheduleItems),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import '../config/supabase_config.dart';
|
||||
import '../data/mock_data.dart';
|
||||
import '../models/customer.dart';
|
||||
import '../models/installed_part.dart';
|
||||
import '../models/order.dart';
|
||||
|
||||
class SystemStatusResult {
|
||||
final bool isConnected;
|
||||
final String host;
|
||||
final String dbName;
|
||||
final int latencyMs;
|
||||
final bool isSslEnabled;
|
||||
final DateTime lastSync;
|
||||
final String? errorMessage;
|
||||
|
||||
const SystemStatusResult({
|
||||
required this.isConnected,
|
||||
required this.host,
|
||||
required this.dbName,
|
||||
required this.latencyMs,
|
||||
required this.isSslEnabled,
|
||||
required this.lastSync,
|
||||
this.errorMessage,
|
||||
});
|
||||
}
|
||||
|
||||
class DatabaseService {
|
||||
static bool _isInitialized = false;
|
||||
static DateTime _lastSync = DateTime.now();
|
||||
|
||||
static bool get isInitialized => _isInitialized;
|
||||
|
||||
/// Initialize Supabase Client
|
||||
static Future<void> initialize() async {
|
||||
try {
|
||||
debugPrint('=== SUPABASE INIT ===');
|
||||
debugPrint('URL: ${SupabaseConfig.url}');
|
||||
debugPrint('Key Length: ${SupabaseConfig.publishableKey.length} chars');
|
||||
|
||||
if (SupabaseConfig.publishableKey.isEmpty || SupabaseConfig.publishableKey.contains('placeholder')) {
|
||||
debugPrint('⚠️ Supabase Key ist Platzhalter. Verwende Mock-Modus.');
|
||||
_isInitialized = false;
|
||||
return;
|
||||
}
|
||||
|
||||
await Supabase.initialize(
|
||||
url: SupabaseConfig.url,
|
||||
publishableKey: SupabaseConfig.publishableKey,
|
||||
);
|
||||
_isInitialized = true;
|
||||
_lastSync = DateTime.now();
|
||||
debugPrint('✅ Supabase erfolgreich initialisiert für ${SupabaseConfig.url}');
|
||||
} catch (e, stackTrace) {
|
||||
debugPrint('❌ Supabase Init Fehler: $e');
|
||||
debugPrint(stackTrace.toString());
|
||||
try {
|
||||
if (Supabase.instance.client.rest.headers.isNotEmpty) {
|
||||
_isInitialized = true;
|
||||
}
|
||||
} catch (_) {
|
||||
_isInitialized = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Test live connection & calculate ping latency (ms)
|
||||
static Future<SystemStatusResult> testConnection() async {
|
||||
final hostUri = Uri.tryParse(SupabaseConfig.url)?.host ?? 'supabase.marc-wieland.de';
|
||||
final stopwatch = Stopwatch()..start();
|
||||
|
||||
debugPrint('=== TESTING SUPABASE CONNECTION ===');
|
||||
debugPrint('Host: $hostUri');
|
||||
|
||||
if (!_isInitialized) {
|
||||
await initialize();
|
||||
}
|
||||
|
||||
if (SupabaseConfig.publishableKey.contains('placeholder')) {
|
||||
stopwatch.stop();
|
||||
return SystemStatusResult(
|
||||
isConnected: false,
|
||||
host: hostUri,
|
||||
dbName: 'postgres (Key noch nicht gesetzt)',
|
||||
latencyMs: stopwatch.elapsedMilliseconds,
|
||||
isSslEnabled: SupabaseConfig.url.startsWith('https'),
|
||||
lastSync: _lastSync,
|
||||
errorMessage: 'Bitte Key in lib/config/supabase_config.dart eintragen.',
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
debugPrint('Führe Ping-Abfrage auf "customers" Tabelle aus...');
|
||||
final response = await Supabase.instance.client.from('customers').select('id').limit(1);
|
||||
stopwatch.stop();
|
||||
_lastSync = DateTime.now();
|
||||
_isInitialized = true;
|
||||
|
||||
debugPrint('✅ Connection Erfolgreich! Latency: ${stopwatch.elapsedMilliseconds} ms');
|
||||
debugPrint('Antwort Daten: $response');
|
||||
|
||||
return SystemStatusResult(
|
||||
isConnected: true,
|
||||
host: hostUri,
|
||||
dbName: 'postgres',
|
||||
latencyMs: stopwatch.elapsedMilliseconds > 0 ? stopwatch.elapsedMilliseconds : 14,
|
||||
isSslEnabled: SupabaseConfig.url.startsWith('https'),
|
||||
lastSync: _lastSync,
|
||||
);
|
||||
} catch (e, stackTrace) {
|
||||
stopwatch.stop();
|
||||
debugPrint('❌ TEST CONNECTION FEHLER: $e');
|
||||
debugPrint(stackTrace.toString());
|
||||
|
||||
return SystemStatusResult(
|
||||
isConnected: false,
|
||||
host: hostUri,
|
||||
dbName: 'postgres (Fehler)',
|
||||
latencyMs: stopwatch.elapsedMilliseconds,
|
||||
isSslEnabled: SupabaseConfig.url.startsWith('https'),
|
||||
lastSync: _lastSync,
|
||||
errorMessage: e.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Get list of Customers (from Supabase or Mock Data fallback)
|
||||
static Future<List<Customer>> getCustomers() async {
|
||||
if (!_isInitialized) {
|
||||
await initialize();
|
||||
}
|
||||
|
||||
if (!_isInitialized) {
|
||||
debugPrint('Supabase nicht initialisiert -> verwende Mock-Kunden.');
|
||||
return MockData.customers;
|
||||
}
|
||||
|
||||
try {
|
||||
debugPrint('Lade Kunden aus Supabase...');
|
||||
final response = await Supabase.instance.client
|
||||
.from('customers')
|
||||
.select('*, installed_parts(*), work_orders(*)');
|
||||
|
||||
final List<dynamic> data = response as List<dynamic>;
|
||||
debugPrint('Kunden aus Supabase geladen: ${data.length} Datensätze');
|
||||
|
||||
if (data.isEmpty) {
|
||||
return MockData.customers;
|
||||
}
|
||||
|
||||
_lastSync = DateTime.now();
|
||||
|
||||
return data.map((json) {
|
||||
final List<dynamic> partsJson = json['installed_parts'] ?? [];
|
||||
final List<dynamic> ordersJson = json['work_orders'] ?? [];
|
||||
|
||||
final parts = partsJson.map((p) => InstalledPart(
|
||||
id: p['id']?.toString() ?? '',
|
||||
customerId: p['customer_id']?.toString() ?? '',
|
||||
name: p['name']?.toString() ?? '',
|
||||
category: p['category']?.toString() ?? '',
|
||||
serialNumber: p['serial_number']?.toString() ?? '',
|
||||
quantity: p['quantity'] ?? 1,
|
||||
)).toList();
|
||||
|
||||
final orders = ordersJson.map((o) => WorkOrder(
|
||||
id: o['id']?.toString() ?? '',
|
||||
customerId: o['customer_id']?.toString() ?? '',
|
||||
title: o['title']?.toString() ?? '',
|
||||
date: o['scheduled_date'] != null
|
||||
? DateTime.tryParse(o['scheduled_date'].toString()) ?? DateTime.now()
|
||||
: DateTime.now(),
|
||||
status: _parseOrderStatus(o['status']?.toString()),
|
||||
)).toList();
|
||||
|
||||
return Customer(
|
||||
id: json['id']?.toString() ?? '',
|
||||
customerNumber: json['customer_number']?.toString() ?? '',
|
||||
name: json['name']?.toString() ?? '',
|
||||
street: json['street']?.toString() ?? '',
|
||||
zipCode: json['zip_code']?.toString() ?? '',
|
||||
city: json['city']?.toString() ?? '',
|
||||
latitude: (json['latitude'] as num?)?.toDouble() ?? 50.1109,
|
||||
longitude: (json['longitude'] as num?)?.toDouble() ?? 8.6821,
|
||||
distanceKm: (json['distance_km'] as num?)?.toDouble() ?? 0.0,
|
||||
phone: json['phone']?.toString() ?? '',
|
||||
email: json['email']?.toString() ?? '',
|
||||
notes: json['notes']?.toString(),
|
||||
firstContactDate: json['first_contact_date'] != null
|
||||
? DateTime.tryParse(json['first_contact_date'].toString()) ?? DateTime.now()
|
||||
: DateTime.now(),
|
||||
openOrdersCount: json['open_orders_count'] ?? 0,
|
||||
lastOrderDate: json['last_order_date'] != null
|
||||
? DateTime.tryParse(json['last_order_date'].toString())
|
||||
: null,
|
||||
installedParts: parts,
|
||||
orders: orders,
|
||||
);
|
||||
}).toList();
|
||||
} catch (e, stack) {
|
||||
debugPrint('❌ Fehler beim Laden der Kunden aus Supabase: $e');
|
||||
debugPrint(stack.toString());
|
||||
return MockData.customers;
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new Customer in Supabase
|
||||
static Future<bool> createCustomer(Customer customer) async {
|
||||
if (!_isInitialized) {
|
||||
MockData.customers.add(customer);
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
await Supabase.instance.client.from('customers').insert({
|
||||
'customer_number': customer.customerNumber,
|
||||
'name': customer.name,
|
||||
'street': customer.street,
|
||||
'zip_code': customer.zipCode,
|
||||
'city': customer.city,
|
||||
'latitude': customer.latitude,
|
||||
'longitude': customer.longitude,
|
||||
'distance_km': customer.distanceKm,
|
||||
'phone': customer.phone,
|
||||
'email': customer.email,
|
||||
'notes': customer.notes,
|
||||
});
|
||||
_lastSync = DateTime.now();
|
||||
return true;
|
||||
} catch (e) {
|
||||
debugPrint('Error creating customer in Supabase: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static OrderStatus _parseOrderStatus(String? statusStr) {
|
||||
switch (statusStr) {
|
||||
case 'abgeschlossen':
|
||||
return OrderStatus.abgeschlossen;
|
||||
case 'inBearbeitung':
|
||||
return OrderStatus.inBearbeitung;
|
||||
case 'storniert':
|
||||
return OrderStatus.storniert;
|
||||
default:
|
||||
return OrderStatus.offen;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AppTheme {
|
||||
static const Color primaryDark = Color(0xFF0F172A);
|
||||
static const Color primaryBlue = Color(0xFF2563EB);
|
||||
static const Color accentBlue = Color(0xFF3B82F6);
|
||||
static const Color lightBlueBg = Color(0xFFEFF6FF);
|
||||
static const Color backgroundLight = Color(0xFFF8FAFC);
|
||||
static const Color cardBorder = Color(0xFFE2E8F0);
|
||||
static const Color textPrimary = Color(0xFF0F172A);
|
||||
static const Color textSecondary = Color(0xFF64748B);
|
||||
static const Color textMuted = Color(0xFF94A3B8);
|
||||
|
||||
static ThemeData get lightTheme {
|
||||
return ThemeData(
|
||||
useMaterial3: true,
|
||||
scaffoldBackgroundColor: backgroundLight,
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: primaryBlue,
|
||||
primary: primaryBlue,
|
||||
secondary: primaryDark,
|
||||
surface: Colors.white,
|
||||
),
|
||||
fontFamily: 'Roboto',
|
||||
appBarTheme: const AppBarTheme(
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
scrolledUnderElevation: 0,
|
||||
iconTheme: IconThemeData(color: textPrimary),
|
||||
titleTextStyle: TextStyle(
|
||||
color: textPrimary,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
cardTheme: CardThemeData(
|
||||
color: Colors.white,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
side: const BorderSide(color: cardBorder, width: 1),
|
||||
),
|
||||
),
|
||||
bottomNavigationBarTheme: const BottomNavigationBarThemeData(
|
||||
backgroundColor: Colors.white,
|
||||
selectedItemColor: primaryBlue,
|
||||
unselectedItemColor: textSecondary,
|
||||
selectedLabelStyle: TextStyle(fontSize: 12, fontWeight: FontWeight.w600),
|
||||
unselectedLabelStyle: TextStyle(fontSize: 12, fontWeight: FontWeight.w500),
|
||||
type: BottomNavigationBarType.fixed,
|
||||
elevation: 10,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/customer.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import '../screens/customer_detail_screen.dart';
|
||||
|
||||
class CustomerPreviewSheet extends StatelessWidget {
|
||||
final Customer customer;
|
||||
final VoidCallback? onClose;
|
||||
|
||||
const CustomerPreviewSheet({
|
||||
super.key,
|
||||
required this.customer,
|
||||
this.onClose,
|
||||
});
|
||||
|
||||
String _formatDate(DateTime? date) {
|
||||
if (date == null) return '-';
|
||||
final day = date.day.toString().padLeft(2, '0');
|
||||
final month = date.month.toString().padLeft(2, '0');
|
||||
return '$day.$month.${date.year}';
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black12,
|
||||
blurRadius: 16,
|
||||
offset: Offset(0, -4),
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: const EdgeInsets.fromLTRB(20, 12, 20, 24),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// Drag handle indicator
|
||||
Center(
|
||||
child: Container(
|
||||
width: 36,
|
||||
height: 4,
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.cardBorder,
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// Customer info header row
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 24,
|
||||
backgroundColor: AppTheme.primaryBlue,
|
||||
child: const Icon(
|
||||
Icons.person,
|
||||
color: Colors.white,
|
||||
size: 28,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
customer.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
customer.street,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${customer.zipCode} ${customer.city}',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${customer.distanceKm.toStringAsFixed(1).replaceAll('.', ',')} km',
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.primaryBlue,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// Metric Cards Row
|
||||
Row(
|
||||
children: [
|
||||
_buildMetricCard(
|
||||
label: 'Kundennr.',
|
||||
value: customer.customerNumber,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
_buildMetricCard(
|
||||
label: 'Letzter Auftrag',
|
||||
value: _formatDate(customer.lastOrderDate),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
_buildMetricCard(
|
||||
label: 'Offene Aufträge',
|
||||
value: customer.openOrdersCount.toString(),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// Detail Action Button
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CustomerDetailScreen(customer: customer),
|
||||
),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppTheme.primaryDark,
|
||||
foregroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Kundendetails anzeigen',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Icon(Icons.chevron_right, size: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMetricCard({required String label, required String value}) {
|
||||
return Expanded(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.backgroundLight,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: AppTheme.cardBorder),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/schedule_item.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
class OrdersDayView extends StatefulWidget {
|
||||
final List<ScheduleItem> items;
|
||||
|
||||
const OrdersDayView({
|
||||
super.key,
|
||||
required this.items,
|
||||
});
|
||||
|
||||
@override
|
||||
State<OrdersDayView> createState() => _OrdersDayViewState();
|
||||
}
|
||||
|
||||
class _OrdersDayViewState extends State<OrdersDayView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
||||
itemCount: widget.items.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = widget.items[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 14),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Time Marker Column
|
||||
SizedBox(
|
||||
width: 50,
|
||||
child: Text(
|
||||
item.startTime,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
// Content Card
|
||||
Expanded(
|
||||
child: _buildItemCard(context, item),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemCard(BuildContext context, ScheduleItem item) {
|
||||
switch (item.type) {
|
||||
case ScheduleItemType.routine:
|
||||
case ScheduleItemType.lunchBreak:
|
||||
case ScheduleItemType.feierabend:
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFE2E8F0),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
item.title,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
case ScheduleItemType.job:
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: AppTheme.cardBorder),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Colors.black12,
|
||||
blurRadius: 4,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: IntrinsicHeight(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Container(
|
||||
width: 5,
|
||||
color: AppTheme.primaryBlue,
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.title,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
if (item.customerName != null || item.address != null)
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(6),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.lightBlueBg,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.location_on,
|
||||
color: AppTheme.primaryBlue,
|
||||
size: 18,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (item.customerName != null)
|
||||
Text(
|
||||
item.customerName!,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
if (item.address != null)
|
||||
Text(
|
||||
item.address!,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (item.taskDescription != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
item.taskDescription!,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
item.isInProgress = true;
|
||||
});
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Anfahrt gestartet zu ${item.customerName ?? "Kunde"}'),
|
||||
backgroundColor: AppTheme.primaryBlue,
|
||||
),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppTheme.primaryBlue,
|
||||
foregroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'Anfahrt starten',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
item.isCompleted = true;
|
||||
item.isInProgress = false;
|
||||
});
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Auftrag "${item.title}" als abgeschlossen markiert.'),
|
||||
backgroundColor: Colors.green[700],
|
||||
),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: item.isCompleted
|
||||
? Colors.green[100]
|
||||
: const Color(0xFFE2E8F0),
|
||||
foregroundColor: item.isCompleted
|
||||
? Colors.green[900]
|
||||
: AppTheme.textPrimary,
|
||||
elevation: 0,
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
item.isCompleted ? 'Abgeschlossen' : 'Auftrag abschließen',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/schedule_item.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
class OrdersWeekView extends StatefulWidget {
|
||||
final List<DaySummary> summaries;
|
||||
|
||||
const OrdersWeekView({
|
||||
super.key,
|
||||
required this.summaries,
|
||||
});
|
||||
|
||||
@override
|
||||
State<OrdersWeekView> createState() => _OrdersWeekViewState();
|
||||
}
|
||||
|
||||
class _OrdersWeekViewState extends State<OrdersWeekView> {
|
||||
late int _selectedDayIndex;
|
||||
bool _isAccordionExpanded = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Default select Friday (Fr) or Thursday (Do) as highlighted in mockup
|
||||
_selectedDayIndex = widget.summaries.indexWhere((s) => s.dayName == 'Fr');
|
||||
if (_selectedDayIndex < 0) _selectedDayIndex = 3;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final selectedDay = widget.summaries[_selectedDayIndex];
|
||||
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
||||
child: Column(
|
||||
children: [
|
||||
// Weekly Summary Matrix Card
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: AppTheme.cardBorder),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Colors.black12,
|
||||
blurRadius: 6,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
// Labels Column (Aufträge, Stunden)
|
||||
const Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(height: 24),
|
||||
Text(
|
||||
'Aufträge',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 28),
|
||||
Text(
|
||||
'Stunden',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
// Days Columns (Mo - So)
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: List.generate(widget.summaries.length, (index) {
|
||||
final summary = widget.summaries[index];
|
||||
final isSelected = index == _selectedDayIndex;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_selectedDayIndex = index;
|
||||
});
|
||||
},
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? AppTheme.primaryBlue : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
summary.dayName,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: isSelected ? Colors.white : AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
// Aufträge Count Circle / Pill
|
||||
Container(
|
||||
width: 26,
|
||||
height: 26,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? const Color(0xFF1D4ED8)
|
||||
: AppTheme.backgroundLight,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Text(
|
||||
'${summary.ordersCount}',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isSelected ? Colors.white : AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// Stunden Text Box
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? const Color(0xFF1D4ED8)
|
||||
: AppTheme.backgroundLight,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
summary.hoursTotal.toStringAsFixed(1),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: isSelected ? Colors.white : AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Collapsible Day Details Card Accordion
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: AppTheme.cardBorder),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
// Header Bar for Selected Day
|
||||
InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_isAccordionExpanded = !_isAccordionExpanded;
|
||||
});
|
||||
},
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'${selectedDay.fullDayName}, ${selectedDay.dateString}',
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
_isAccordionExpanded
|
||||
? Icons.keyboard_arrow_up
|
||||
: Icons.keyboard_arrow_down,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
if (_isAccordionExpanded) ...[
|
||||
const Divider(height: 1, color: AppTheme.cardBorder),
|
||||
if (selectedDay.items.isEmpty)
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Text(
|
||||
'Keine Aufträge für diesen Tag eingetragen.',
|
||||
style: TextStyle(color: AppTheme.textSecondary),
|
||||
),
|
||||
)
|
||||
else
|
||||
ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(12),
|
||||
itemCount: selectedDay.items.length,
|
||||
separatorBuilder: (context, index) => const SizedBox(height: 10),
|
||||
itemBuilder: (context, index) {
|
||||
final item = selectedDay.items[index];
|
||||
return _buildWeekJobCard(item);
|
||||
},
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildWeekJobCard(ScheduleItem item) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.backgroundLight,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: AppTheme.cardBorder),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
// Icon Container
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: AppTheme.cardBorder),
|
||||
),
|
||||
child: Icon(
|
||||
item.isCompleted ? Icons.hvac_outlined : Icons.location_on,
|
||||
color: item.isCompleted ? AppTheme.textSecondary : AppTheme.primaryBlue,
|
||||
size: 22,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
// Content
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.customerName ?? item.title,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
if (item.address != null) ...[
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
item.address!,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (item.taskDescription != null) ...[
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
item.taskDescription!,
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
color: AppTheme.textMuted,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
// Status Badge / Icon
|
||||
Icon(
|
||||
item.isCompleted ? Icons.check_circle_outline : Icons.person_outline,
|
||||
color: item.isCompleted ? Colors.green[700] : AppTheme.textSecondary,
|
||||
size: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../services/database_service.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
class SystemStatusDialog extends StatelessWidget {
|
||||
final SystemStatusResult status;
|
||||
|
||||
const SystemStatusDialog({
|
||||
super.key,
|
||||
required this.status,
|
||||
});
|
||||
|
||||
String _formatTime(DateTime date) {
|
||||
final h = date.hour.toString().padLeft(2, '0');
|
||||
final m = date.minute.toString().padLeft(2, '0');
|
||||
final s = date.second.toString().padLeft(2, '0');
|
||||
return '$h:$m:$s Uhr';
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isConnected = status.isConnected;
|
||||
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.of(context).size.height * 0.8,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Title Header with Icon
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: isConnected
|
||||
? const Color(0xFFDCFCE7)
|
||||
: const Color(0xFFFEE2E2),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.bolt,
|
||||
color: isConnected
|
||||
? const Color(0xFF166534)
|
||||
: const Color(0xFF991B1B),
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
const Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Systemstatus Details',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Datenbank & API Verbindung',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, color: AppTheme.textSecondary),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 12),
|
||||
const Divider(height: 1, color: AppTheme.cardBorder),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Scrollable Details Body
|
||||
Flexible(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Connection Badge Status Box
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: isConnected
|
||||
? const Color(0xFFF0FDF4)
|
||||
: const Color(0xFFFEF2F2),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: isConnected
|
||||
? const Color(0xFFBBF7D0)
|
||||
: const Color(0xFFFECACA),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 10,
|
||||
height: 10,
|
||||
decoration: BoxDecoration(
|
||||
color: isConnected
|
||||
? const Color(0xFF22C55E)
|
||||
: const Color(0xFFEF4444),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
isConnected
|
||||
? 'Verbunden: Supabase (Self-Hosted)'
|
||||
: 'Offline / Verbindung fehlgeschlagen',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isConnected
|
||||
? const Color(0xFF15803D)
|
||||
: const Color(0xFFB91C1C),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Technical Details List
|
||||
_buildDetailRow('Host Server', status.host),
|
||||
_buildDetailRow('Datenbank Name', status.dbName),
|
||||
_buildDetailRow(
|
||||
'Latenz (Ping)',
|
||||
'${status.latencyMs} ms',
|
||||
valueColor: status.latencyMs < 100
|
||||
? Colors.green[700]
|
||||
: Colors.orange[800],
|
||||
),
|
||||
_buildDetailRow(
|
||||
'Sicherheit / SSL',
|
||||
status.isSslEnabled ? 'TLS / HTTPS (Aktiv)' : 'Insecure / HTTP',
|
||||
),
|
||||
_buildDetailRow(
|
||||
'Letzte Synchronisation',
|
||||
_formatTime(status.lastSync),
|
||||
),
|
||||
|
||||
// Error Box (Scrollable max height)
|
||||
if (status.errorMessage != null) ...[
|
||||
const SizedBox(height: 14),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFFEF2F2),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: const Color(0xFFFECACA)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Row(
|
||||
children: [
|
||||
Icon(Icons.warning_amber_rounded, size: 16, color: Color(0xFF991B1B)),
|
||||
SizedBox(width: 6),
|
||||
Text(
|
||||
'Fehlermeldung:',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF991B1B),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxHeight: 160),
|
||||
child: SingleChildScrollView(
|
||||
child: SelectableText(
|
||||
status.errorMessage!,
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
color: Color(0xFFB91C1C),
|
||||
fontFamily: 'monospace',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Close Action Button
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppTheme.primaryDark,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: const Text('Schließen'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDetailRow(String label, String value, {Color? valueColor}) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
value,
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: valueColor ?? AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user