-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #426 from privacyidea:Enhance-QRScannerWidget-with…
…-flashlight-and-gallery-options Enhance QRScannerWidget with flashlight and gallery options
- Loading branch information
Showing
20 changed files
with
251 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
Authors: Timo Sturm <[email protected]> | ||
Frank Merkel <[email protected]> | ||
Copyright (c) 2017-2023 NetKnights GmbH | ||
Copyright (c) 2017-2024 NetKnights GmbH | ||
Licensed under the Apache License, Version 2.0 (the 'License'); | ||
you may not use this file except in compliance with the License. | ||
|
@@ -58,58 +58,49 @@ class _QRScannerViewState extends State<QRScannerView> { | |
PermissionStatus? _cameraPermission; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return FutureBuilder<PermissionStatus>( | ||
future: Future<PermissionStatus>(() async => _cameraPermission ?? await _requestCameraPermission()), | ||
builder: (context, isGranted) { | ||
if (isGranted.connectionState != ConnectionState.done) return const Center(child: CircularProgressIndicator()); | ||
if (isGranted.data == PermissionStatus.permanentlyDenied) { | ||
return DefaultDialog( | ||
title: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogTitle), | ||
content: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogPermanentlyDenied), | ||
); | ||
} | ||
if (isGranted.data != PermissionStatus.granted) { | ||
return DefaultDialog( | ||
title: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogTitle), | ||
content: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogContent), | ||
actions: [ | ||
DefaultDialogButton( | ||
child: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogButton), | ||
onPressed: () async { | ||
//Trigger the permission to request it | ||
final cameraPermission = await _requestCameraPermission(); | ||
setState(() => _cameraPermission = cameraPermission); | ||
}, | ||
Widget build(BuildContext context) => FutureBuilder<PermissionStatus>( | ||
future: Future<PermissionStatus>(() async => _cameraPermission ?? await _requestCameraPermission()), | ||
builder: (context, isGranted) { | ||
if (isGranted.connectionState != ConnectionState.done) return const Center(child: CircularProgressIndicator()); | ||
return switch (isGranted.data) { | ||
PermissionStatus.permanentlyDenied => DefaultDialog( | ||
title: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogTitle), | ||
content: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogPermanentlyDenied), | ||
), | ||
DefaultDialogButton( | ||
child: Text(AppLocalizations.of(context)!.cancel), | ||
onPressed: () { | ||
Navigator.pop(context, null); | ||
}, | ||
), | ||
], | ||
); | ||
} | ||
return SafeArea( | ||
child: Stack( | ||
children: [ | ||
const QRScannerWidget(), | ||
Scaffold( | ||
resizeToAvoidBottomInset: false, | ||
backgroundColor: Colors.transparent, | ||
appBar: AppBar( | ||
PermissionStatus.granted => SafeArea( | ||
child: Scaffold( | ||
resizeToAvoidBottomInset: false, | ||
backgroundColor: Colors.transparent, | ||
foregroundColor: Colors.white, | ||
elevation: 0, | ||
appBar: AppBar( | ||
backgroundColor: Colors.transparent, | ||
foregroundColor: Colors.white, | ||
elevation: 0, | ||
), | ||
extendBodyBehindAppBar: true, | ||
body: const QRScannerWidget(), | ||
), | ||
extendBodyBehindAppBar: true, | ||
body: const SizedBox(), | ||
), | ||
], | ||
), | ||
); | ||
}, | ||
); | ||
} | ||
_ => DefaultDialog( | ||
title: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogTitle), | ||
content: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogContent), | ||
actions: [ | ||
DefaultDialogButton( | ||
child: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogButton), | ||
onPressed: () async { | ||
//Trigger the permission to request it | ||
final cameraPermission = await _requestCameraPermission(); | ||
setState(() => _cameraPermission = cameraPermission); | ||
}, | ||
), | ||
DefaultDialogButton( | ||
child: Text(AppLocalizations.of(context)!.cancel), | ||
onPressed: () { | ||
Navigator.pop(context, null); | ||
}, | ||
), | ||
], | ||
), | ||
}; | ||
}, | ||
); | ||
} |
Oops, something went wrong.