more updates to handling of system navigation bar

This commit is contained in:
Adam Velebil 2022-09-09 10:45:34 +02:00
parent cec222ef84
commit a09692b9ff
No known key found for this signature in database
GPG Key ID: AC6D6B9D715FC084
5 changed files with 51 additions and 40 deletions

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:yubico_authenticator/app/state.dart';
import 'package:yubico_authenticator/cancellation_exception.dart';
import 'qr_scanner_view.dart';
@ -17,7 +18,8 @@ class AndroidQrScanner implements QrScanner {
reverseTransitionDuration: const Duration(seconds: 0),
)));
if (scannedCode == null) {
throw Exception('Null value from QR scanner');
// user has cancelled the scan
throw CancellationException();
}
return scannedCode;
}

View File

@ -82,12 +82,12 @@ class _QrScannerViewState extends State<QrScannerView> {
void initState() {
super.initState();
_status = ScanStatus.scanning;
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
}
@override
void dispose() {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge,
overlays: SystemUiOverlay.values);
super.dispose();
}
@ -95,8 +95,7 @@ class _QrScannerViewState extends State<QrScannerView> {
@override
Widget build(BuildContext context) {
final screenSize = MediaQuery.of(context).size;
return SafeArea(
child: Scaffold(
return Scaffold(
resizeToAvoidBottomInset: false,
extendBodyBehindAppBar: true,
extendBody: true,
@ -130,7 +129,7 @@ class _QrScannerViewState extends State<QrScannerView> {
maintainSize: true,
visible: _permissionsGranted,
child: QRScannerZxingView(
key: _zxingViewKey,
key: _zxingViewKey,
marginPct: 50,
onDetect: (scannedData) => handleResult(scannedData),
onViewInitialized: (bool permissionsGranted) {
@ -164,6 +163,6 @@ class _QrScannerViewState extends State<QrScannerView> {
)),
],
),
));
);
}
}

View File

@ -109,8 +109,10 @@ class LogWarningOverlay extends StatelessWidget {
return const SizedBox();
}
var deviceBottomViewPadding = MediaQueryData.fromWindow(WidgetsBinding.instance.window).viewPadding.bottom;
return Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 20),
padding:
EdgeInsets.fromLTRB(5, 0, 5, deviceBottomViewPadding + 15),
child: Align(
alignment: Alignment.bottomCenter,
child: IgnorePointer(
@ -119,9 +121,10 @@ class LogWarningOverlay extends StatelessWidget {
textDirection: TextDirection.ltr,
textAlign: TextAlign.center,
style: const TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
),
color: Colors.red,
fontWeight: FontWeight.bold,
height: 1.5,
fontSize: 16),
),
),
),

View File

@ -47,35 +47,39 @@ class AppPage extends ConsumerWidget {
},
);
Widget _buildScrollView() => SafeArea(
bottom: false,
child: SingleChildScrollView(
child: Center(
child: SizedBox(
width: 700,
child: Column(
children: [
child,
if (actions.isNotEmpty)
Align(
alignment:
centered ? Alignment.center : Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 16.0, horizontal: 18.0),
child: Wrap(
spacing: 4,
runSpacing: 4,
children: actions,
),
Widget _buildScrollView() {
var bottomPadding = MediaQueryData.fromWindow(WidgetsBinding.instance.window).viewPadding.bottom;
return SafeArea(
bottom: bottomPadding > 24,
maintainBottomViewPadding: false,
child: SingleChildScrollView(
child: Center(
child: SizedBox(
width: 700,
child: Column(
children: [
child,
if (actions.isNotEmpty)
Align(
alignment:
centered ? Alignment.center : Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 16.0, horizontal: 18.0),
child: Wrap(
spacing: 4,
runSpacing: 4,
children: actions,
),
),
],
),
),
],
),
),
),
);
),
);
}
Scaffold _buildScaffold(BuildContext context, WidgetRef ref, bool hasDrawer) {
return Scaffold(

View File

@ -104,11 +104,14 @@ class _OathAddAccountPageState extends ConsumerState<OathAddAccountPage> {
} else {
errorMessage = e.toString();
}
showMessage(
context,
'${AppLocalizations.of(context)!.oath_failed_reading_qr}: $errorMessage',
duration: const Duration(seconds: 4),
);
if (e is! CancellationException) {
showMessage(
context,
'${AppLocalizations.of(context)!.oath_failed_reading_qr}: $errorMessage',
duration: const Duration(seconds: 4),
);
}
setState(() {
_qrState = _QrScanState.failed;
});