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 <noreply@anthropic.com>
This commit is contained in:
parent
5cb220f68c
commit
c8c2ec0921
@ -13,6 +13,8 @@ import '../models/delivery_commands.dart';
|
|||||||
import '../components/map_sidebar_layout.dart';
|
import '../components/map_sidebar_layout.dart';
|
||||||
import '../components/dark_mode_map.dart';
|
import '../components/dark_mode_map.dart';
|
||||||
import '../components/unified_delivery_list.dart';
|
import '../components/unified_delivery_list.dart';
|
||||||
|
import '../components/loading_dialog.dart';
|
||||||
|
import '../components/photo_capture_dialog.dart';
|
||||||
import '../utils/toast_helper.dart';
|
import '../utils/toast_helper.dart';
|
||||||
|
|
||||||
class DeliveriesPage extends ConsumerStatefulWidget {
|
class DeliveriesPage extends ConsumerStatefulWidget {
|
||||||
@ -410,38 +412,10 @@ class _DeliveriesPageState extends ConsumerState<DeliveriesPage> {
|
|||||||
|
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
|
|
||||||
final bool? confirmed = await showDialog<bool>(
|
final bool? confirmed = await PhotoCaptureDialog.show(
|
||||||
context: context,
|
context,
|
||||||
builder: (BuildContext dialogContext) {
|
imageFile: File(pickedFile.path),
|
||||||
return AlertDialog(
|
deliveryName: delivery.name,
|
||||||
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),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (confirmed != true) {
|
if (confirmed != true) {
|
||||||
@ -450,27 +424,8 @@ class _DeliveriesPageState extends ConsumerState<DeliveriesPage> {
|
|||||||
|
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
|
|
||||||
showDialog(
|
final localizations = AppLocalizations.of(context);
|
||||||
context: context,
|
LoadingDialog.show(context, message: localizations.uploadingPhoto);
|
||||||
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...'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Uri uploadUrl = Uri.parse(
|
final Uri uploadUrl = Uri.parse(
|
||||||
@ -485,7 +440,7 @@ class _DeliveriesPageState extends ConsumerState<DeliveriesPage> {
|
|||||||
final http.Response response = await http.Response.fromStream(streamedResponse);
|
final http.Response response = await http.Response.fromStream(streamedResponse);
|
||||||
|
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
Navigator.of(context).pop();
|
LoadingDialog.hide(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||||
@ -501,7 +456,7 @@ class _DeliveriesPageState extends ConsumerState<DeliveriesPage> {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
Navigator.of(context).pop();
|
LoadingDialog.hide(context);
|
||||||
ToastHelper.showError(context, 'Upload error: $e');
|
ToastHelper.showError(context, 'Upload error: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user