feat: Beautify qr code scanner

This commit is contained in:
Christian Pauly 2021-08-24 14:07:49 +02:00
parent 8029a366f7
commit 0728a30565
2 changed files with 20 additions and 5 deletions

View File

@ -79,9 +79,10 @@ class NewPrivateChatController extends State<NewPrivateChat> {
void openScannerAction() async {
final status = await Permission.camera.request();
if (!status.isGranted) return;
await showDialog(
await showModalBottomSheet(
context: context,
useRootNavigator: false,
//useSafeArea: false,
builder: (_) => QrScannerModal(),
);
}

View File

@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:io';
import 'package:fluffychat/utils/url_launcher.dart';
@ -33,19 +34,32 @@ class _QrScannerModalState extends State<QrScannerModal> {
leading: IconButton(
icon: Icon(Icons.close_outlined),
onPressed: Navigator.of(context).pop,
tooltip: L10n.of(context).close,
),
title: Text(L10n.of(context).scanQrCode),
),
body: QRView(
key: qrKey,
onQRViewCreated: _onQRViewCreated,
body: Stack(
children: [
QRView(
key: qrKey,
onQRViewCreated: _onQRViewCreated,
overlay: QrScannerOverlayShape(
borderColor: Theme.of(context).primaryColor,
borderRadius: 10,
borderLength: 30,
borderWidth: 8,
),
),
],
),
);
}
void _onQRViewCreated(QRViewController controller) {
this.controller = controller;
controller.scannedDataStream.listen((scanData) {
StreamSubscription sub;
sub = controller.scannedDataStream.listen((scanData) {
sub.cancel();
Navigator.of(context).pop();
UrlLauncher(context, scanData.code).openMatrixToUrl();
});