From c8c2ec0921449cd1c54afb3e0c246c9f8ab77c0e Mon Sep 17 00:00:00 2001 From: Mathias Beaulieu-Duncan Date: Tue, 20 Jan 2026 11:40:20 -0500 Subject: [PATCH] auto-claude: subtask-4-1 - Update deliveries_page.dart to import and use extracted components - Import LoadingDialog and PhotoCaptureDialog components - Replace inline photo confirmation dialog with PhotoCaptureDialog.show() - Replace inline loading dialog with LoadingDialog.show() and LoadingDialog.hide() - Use localized uploadingPhoto string for loading message Co-Authored-By: Claude --- lib/pages/deliveries_page.dart | 65 ++++++---------------------------- 1 file changed, 10 insertions(+), 55 deletions(-) diff --git a/lib/pages/deliveries_page.dart b/lib/pages/deliveries_page.dart index 1ee0ef0..748fdda 100644 --- a/lib/pages/deliveries_page.dart +++ b/lib/pages/deliveries_page.dart @@ -13,6 +13,8 @@ import '../models/delivery_commands.dart'; import '../components/map_sidebar_layout.dart'; import '../components/dark_mode_map.dart'; import '../components/unified_delivery_list.dart'; +import '../components/loading_dialog.dart'; +import '../components/photo_capture_dialog.dart'; import '../utils/toast_helper.dart'; class DeliveriesPage extends ConsumerStatefulWidget { @@ -410,38 +412,10 @@ class _DeliveriesPageState extends ConsumerState { if (!context.mounted) return; - final bool? confirmed = await showDialog( - context: context, - builder: (BuildContext dialogContext) { - return AlertDialog( - title: const Text('Confirm Photo'), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Image.file( - File(pickedFile!.path), - height: 300, - fit: BoxFit.contain, - ), - const SizedBox(height: 16), - Text( - 'Upload this photo for ${delivery.name}?', - textAlign: TextAlign.center, - ), - ], - ), - actions: [ - TextButton( - onPressed: () => Navigator.of(dialogContext).pop(false), - child: Text(AppLocalizations.of(context)!.cancel), - ), - ElevatedButton( - onPressed: () => Navigator.of(dialogContext).pop(true), - child: Text(AppLocalizations.of(context)!.upload), - ), - ], - ); - }, + final bool? confirmed = await PhotoCaptureDialog.show( + context, + imageFile: File(pickedFile.path), + deliveryName: delivery.name, ); if (confirmed != true) { @@ -450,27 +424,8 @@ class _DeliveriesPageState extends ConsumerState { if (!context.mounted) return; - showDialog( - context: context, - barrierDismissible: false, - builder: (BuildContext dialogContext) { - return const Center( - child: Card( - child: Padding( - padding: EdgeInsets.all(24.0), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - CircularProgressIndicator(), - SizedBox(height: 16), - Text('Uploading photo...'), - ], - ), - ), - ), - ); - }, - ); + final localizations = AppLocalizations.of(context); + LoadingDialog.show(context, message: localizations.uploadingPhoto); try { final Uri uploadUrl = Uri.parse( @@ -485,7 +440,7 @@ class _DeliveriesPageState extends ConsumerState { final http.Response response = await http.Response.fromStream(streamedResponse); if (context.mounted) { - Navigator.of(context).pop(); + LoadingDialog.hide(context); } if (response.statusCode >= 200 && response.statusCode < 300) { @@ -501,7 +456,7 @@ class _DeliveriesPageState extends ConsumerState { } } catch (e) { if (context.mounted) { - Navigator.of(context).pop(); + LoadingDialog.hide(context); ToastHelper.showError(context, 'Upload error: $e'); } }