feat: add localisation
This commit is contained in:
@@ -6,9 +6,11 @@ import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
import '../../models/payment_method.dart';
|
||||
import '../../viewmodels/bar_screen_view_model.dart';
|
||||
import '../widgets/slide_confirm.dart';
|
||||
import '../../l10n/app_localizations.dart';
|
||||
|
||||
Future<void> confirmCloseTab(BuildContext context) async {
|
||||
final viewModel = context.read<BarScreenViewModel>();
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final tab = viewModel.selectedTab;
|
||||
|
||||
if (tab == null) return;
|
||||
@@ -21,16 +23,16 @@ Future<void> confirmCloseTab(BuildContext context) async {
|
||||
return StatefulBuilder(
|
||||
builder: (context, setDialogState) {
|
||||
return AlertDialog(
|
||||
title: Text('Close ${tab.customerName}ʼs tab?'),
|
||||
title: Text(l10n.closeTabForCustomer(tab.customerName)),
|
||||
content: SizedBox(
|
||||
width: 360,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text('Current total: ${tab.formattedTotal}'),
|
||||
Text(l10n.currentTotal(tab.formattedTotal)),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
'Payment method',
|
||||
l10n.paymentMethod,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
@@ -53,7 +55,7 @@ Future<void> confirmCloseTab(BuildContext context) async {
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(false),
|
||||
child: const Text('Cancel'),
|
||||
child: Text(l10n.cancel),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -69,9 +71,9 @@ Future<void> confirmCloseTab(BuildContext context) async {
|
||||
} catch (e, stack) {
|
||||
Sentry.captureException(e, stackTrace: stack);
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Could not close tab: $e')),
|
||||
);
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(l10n.couldNotCloseTab)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,22 +81,19 @@ class _PaymentPicker extends StatelessWidget {
|
||||
final PaymentMethod selected;
|
||||
final ValueChanged<PaymentMethod> onChanged;
|
||||
|
||||
const _PaymentPicker({
|
||||
required this.selected,
|
||||
required this.onChanged,
|
||||
});
|
||||
const _PaymentPicker({required this.selected, required this.onChanged});
|
||||
|
||||
static const _options = [
|
||||
(PaymentMethod.cash, 'Cash'),
|
||||
(PaymentMethod.payconiq, 'Payconiq'),
|
||||
];
|
||||
static const _options = [PaymentMethod.cash, PaymentMethod.payconiq];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: _options.map((option) {
|
||||
final (value, label) = option;
|
||||
final value = option;
|
||||
final label = value == PaymentMethod.cash ? l10n.cash : l10n.payconiq;
|
||||
final isSelected = selected == value;
|
||||
|
||||
return Padding(
|
||||
@@ -117,7 +116,10 @@ class _PaymentPicker extends StatelessWidget {
|
||||
'assets/icons/payconic.svg',
|
||||
width: 16,
|
||||
height: 16,
|
||||
colorFilter: ColorFilter.mode(Colors.pinkAccent, BlendMode.srcIn),
|
||||
colorFilter: ColorFilter.mode(
|
||||
Colors.pinkAccent,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(label),
|
||||
@@ -128,4 +130,4 @@ class _PaymentPicker extends StatelessWidget {
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user