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 createState() => _OrdersScreenState(); } class _OrdersScreenState extends State { 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), ), ], ), ); } }