38 lines
1.3 KiB
Dart
38 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../domain/entities/shopping_list_item.dart';
|
|
import '../../domain/value_objects/measurement_units.dart';
|
|
|
|
/// Prompts "Add to Pantry Inventory?" when a checklist item is ticked.
|
|
///
|
|
/// Resolves to `true` (check off AND merge into pantry stock), `false`
|
|
/// (check off only), or `null` (cancel — the item stays unchecked).
|
|
Future<bool?> showAddToPantryPrompt(
|
|
BuildContext context,
|
|
ShoppingListItem item,
|
|
) =>
|
|
showDialog<bool>(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: const Text('Add to Pantry Inventory?'),
|
|
content: Text(
|
|
'Check off "${item.name}" '
|
|
'(${formatQuantityForDisplay(item.requiredQuantity)} ${item.unit}) '
|
|
'and add it to your pantry stock?',
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
child: const Text('Cancel'),
|
|
),
|
|
TextButton(
|
|
onPressed: () => Navigator.of(context).pop(false),
|
|
child: const Text('Check Off Only'),
|
|
),
|
|
FilledButton(
|
|
onPressed: () => Navigator.of(context).pop(true),
|
|
child: const Text('Add to Pantry'),
|
|
),
|
|
],
|
|
),
|
|
); |