Intégration fonctionnalites V1

This commit is contained in:
bastien
2026-07-04 22:46:14 +02:00
parent bf191d6396
commit 9f352b91d2
25 changed files with 779 additions and 184 deletions
@@ -1,11 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:intl/intl.dart';
import '../../../core/router/app_router.dart';
import '../../../core/theme/app_colors.dart';
import '../../../core/theme/machine_status_theme.dart';
import '../../../core/time/server_time.dart';
import '../../booking/data/booking_repository.dart';
import '../data/machine_repository.dart';
import '../domain/machine_detail.dart';
@@ -21,7 +21,7 @@ class MachineBookingScreen extends ConsumerStatefulWidget {
}
class _MachineBookingScreenState extends ConsumerState<MachineBookingScreen> {
DateTime _selectedDate = DateTime.now();
DateTime _selectedDate = ServerTime.startOfToday();
TimeSlot? _selectedSlot;
bool _isBooking = false;
@@ -112,14 +112,14 @@ class _MachineBookingScreenState extends ConsumerState<MachineBookingScreen> {
itemCount: 6,
separatorBuilder: (_, __) => const SizedBox(width: 8),
itemBuilder: (context, index) {
final date = DateTime.now().add(Duration(days: index));
final date = ServerTime.startOfToday().add(Duration(days: index));
final normalized = DateTime(date.year, date.month, date.day);
final isSelected = normalized.year == _selectedDate.year &&
normalized.month == _selectedDate.month &&
normalized.day == _selectedDate.day;
return ChoiceChip(
label: Text(DateFormat('EEE dd/MM', 'fr_FR').format(normalized)),
label: Text(ServerTime.format(normalized, pattern: 'EEE dd/MM')),
selected: isSelected,
onSelected: (_) => setState(() {
_selectedDate = normalized;
@@ -159,7 +159,7 @@ class _MachineBookingScreenState extends ConsumerState<MachineBookingScreen> {
runSpacing: 8,
children: slots.map((slot) {
final label =
'${DateFormat('HH:mm').format(slot.start)} ${DateFormat('HH:mm').format(slot.end)}';
'${ServerTime.format(slot.start, pattern: 'HH:mm')} ${ServerTime.format(slot.end, pattern: 'HH:mm')}';
final isSelected = _selectedSlot?.start == slot.start;
return FilterChip(
@@ -183,14 +183,9 @@ class _MachineBookingScreenState extends ConsumerState<MachineBookingScreen> {
width: double.infinity,
height: 56,
child: ElevatedButton.icon(
onPressed: _isBooking ? null : () => _confirmBooking(detail),
style: ElevatedButton.styleFrom(
backgroundColor: AppColors.primary,
foregroundColor: Colors.white,
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
textStyle: const TextStyle(fontSize: 17, fontWeight: FontWeight.w600),
),
onPressed: (_isBooking || _selectedSlot == null)
? null
: () => _confirmBooking(detail),
icon: _isBooking
? const SizedBox(
width: 22,