feat: add remote products and qr code for payconic
This commit is contained in:
@@ -64,7 +64,12 @@ Future<void> confirmCloseTab(BuildContext context) async {
|
||||
},
|
||||
);
|
||||
|
||||
if (confirmed != true) return;
|
||||
if (confirmed != true || !context.mounted) return;
|
||||
|
||||
if (paymentMethod == PaymentMethod.payconiq) {
|
||||
final paid = await _showPayconiqQr(context, tab.totalInCents.asEuro);
|
||||
if (paid != true || !context.mounted) return;
|
||||
}
|
||||
|
||||
try {
|
||||
await viewModel.closeSelectedTab(paymentMethod: paymentMethod);
|
||||
@@ -76,17 +81,62 @@ Future<void> confirmCloseTab(BuildContext context) async {
|
||||
}
|
||||
}
|
||||
|
||||
const _payconiqQrAsset = 'assets/payconiq/qr.png';
|
||||
|
||||
/// Shows the Payconiq QR code for the customer to scan. Resolves to true
|
||||
/// once the bartender taps Done; dismissing it leaves the tab open.
|
||||
Future<bool?> _showPayconiqQr(BuildContext context, String amount) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
|
||||
return showDialog<bool>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
return AlertDialog(
|
||||
title: Text(l10n.payconiq),
|
||||
content: SizedBox(
|
||||
width: 360,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(l10n.scanToPay(amount), textAlign: TextAlign.center),
|
||||
const SizedBox(height: 20),
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Image.asset(
|
||||
_payconiqQrAsset,
|
||||
width: 280,
|
||||
height: 280,
|
||||
fit: BoxFit.contain,
|
||||
errorBuilder: (context, _, _) => const SizedBox(
|
||||
width: 280,
|
||||
height: 280,
|
||||
child: Icon(Icons.qr_code_2, size: 160),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: FilledButton(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(true),
|
||||
child: Text(l10n.done),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class _PaymentPicker extends StatelessWidget {
|
||||
final PaymentMethod selected;
|
||||
final ValueChanged<PaymentMethod> onChanged;
|
||||
|
||||
const _PaymentPicker({required this.selected, required this.onChanged});
|
||||
|
||||
static const _options = [
|
||||
PaymentMethod.cash,
|
||||
PaymentMethod.payconiq,
|
||||
PaymentMethod.paymentPending,
|
||||
];
|
||||
static const _options = [PaymentMethod.cash, PaymentMethod.payconiq];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
Reference in New Issue
Block a user