@@ -19,30 +19,45 @@ class ScanPage extends ConsumerWidget {
1919 });
2020
2121 @override
22- Widget build (BuildContext context, WidgetRef ref) => CodeScanner (
23- once: true ,
24- formats: const [BarcodeFormat .qrCode],
25- loading: const CenteredCircularProgressIndicator (),
26- onScan: (code, details, listener) async {
27- if (code == null || ! context.mounted) {
28- return ;
29- }
30- Uri ? uri = Uri .tryParse (code);
31- if (uri == null ) {
32- Navigator .pop (context);
33- SnackBarIcon .showErrorSnackBar (context, text: translations.error.scan.noUri);
34- return ;
35- }
36- await showWaitingOverlay (
37- context,
38- future: TotpPage .openFromUri (context, ref, uri),
39- );
40- },
41- onAccessDenied: (exception, listener) => ConfirmationDialog .ask (
42- context,
43- title: translations.error.scan.accessDeniedDialog.title,
44- message: translations.error.scan.accessDeniedDialog.message (exception: exception),
22+ Widget build (BuildContext context, WidgetRef ref) => Scaffold (
23+ body: CodeScanner (
24+ once: true ,
25+ formats: const [BarcodeFormat .qrCode],
26+ loading: const CenteredCircularProgressIndicator (),
27+ onScan: (code, details, listener) async {
28+ if (code == null || ! context.mounted) {
29+ return ;
30+ }
31+ Uri ? uri = Uri .tryParse (code);
32+ if (uri == null ) {
33+ Navigator .pop (context);
34+ SnackBarIcon .showErrorSnackBar (context, text: translations.error.scan.noUri);
35+ return ;
36+ }
37+ await showWaitingOverlay (
38+ context,
39+ future: TotpPage .openFromUri (context, ref, uri),
40+ );
41+ },
42+ onAccessDenied: (exception, listener) async {
43+ bool result = await ConfirmationDialog .ask (
44+ context,
45+ title: translations.error.scan.accessDeniedDialog.title,
46+ message: translations.error.scan.accessDeniedDialog.message (exception: exception),
47+ );
48+ if (result) {
49+ return true ;
50+ }
51+ if (context.mounted) {
52+ Navigator .pop (context);
53+ }
54+ return false ;
55+ },
56+ onError: (exception, listener) => SnackBarIcon .showErrorSnackBar (context, text: translations.error.generic.withException (exception: exception)),
57+ ),
58+ floatingActionButton: FloatingActionButton (
59+ child: const BackButtonIcon (),
60+ onPressed: () => Navigator .pop (context),
4561 ),
46- onError: (exception, listener) => SnackBarIcon .showErrorSnackBar (context, text: translations.error.generic.withException (exception: exception)),
4762 );
4863}
0 commit comments