Files
kooltab/lib/views/dialogs/close_tab_dialog.dart
T

47 lines
1.3 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:kooltab2/viewmodels/bar_screen_view_model.dart';
import 'package:kooltab2/views/widgets/slide_confirm.dart';
import 'package:provider/provider.dart';
import 'package:flutter/material.dart';
Future<void> confirmCloseTab(BuildContext context) async {
final viewModel = context.read<BarScreenViewModel>();
final tab = viewModel.selectedTab;
if (tab == null) return;
final confirmed = await showDialog<bool>(
context: context,
builder: (dialogContext) {
return AlertDialog(
title: Text('Close ${tab.customerName}ʼs tab?'),
content: SizedBox(
width: 360,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text('Current total: ${tab.formattedTotal}'),
const SizedBox(height: 20),
SlideConfirm(
onConfirmed: () {
Navigator.of(dialogContext).pop(true);
},
),
],
),
),
actionsPadding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
actions: [
TextButton(
onPressed: () => Navigator.of(dialogContext).pop(false),
child: const Text('Cancel'),
),
],
);
},
);
if (confirmed != true) return;
await viewModel.closeSelectedTab();
}