mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2026-01-18 02:17:57 +01:00
This fixes qr code scanner on iOS and also adds QR Code scanner support to macOS and web.
39 lines
1.0 KiB
Dart
39 lines
1.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
import 'package:mobile_scanner/mobile_scanner.dart';
|
|
|
|
import 'package:fluffychat/utils/url_launcher.dart';
|
|
|
|
class QrScannerModal extends StatefulWidget {
|
|
const QrScannerModal({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
_QrScannerModalState createState() => _QrScannerModalState();
|
|
}
|
|
|
|
class _QrScannerModalState extends State<QrScannerModal> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
leading: IconButton(
|
|
icon: const Icon(Icons.close_outlined),
|
|
onPressed: Navigator.of(context).pop,
|
|
tooltip: L10n.of(context)!.close,
|
|
),
|
|
title: Text(L10n.of(context)!.scanQrCode),
|
|
),
|
|
body: MobileScanner(
|
|
controller: MobileScannerController(),
|
|
onDetect: _onDetect,
|
|
),
|
|
);
|
|
}
|
|
|
|
void _onDetect(Barcode barcode, MobileScannerArguments? args) {
|
|
Navigator.of(context).pop();
|
|
UrlLauncher(context, barcode.rawValue).openMatrixToUrl();
|
|
}
|
|
}
|