mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-24 04:59:26 +01:00
feat: Beautify qr code scanner
This commit is contained in:
parent
8029a366f7
commit
0728a30565
@ -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(),
|
||||
);
|
||||
}
|
||||
|
@ -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(
|
||||
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();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user