This commit is contained in:
Adam Velebil 2022-04-29 10:44:29 +02:00
commit 35668a1e18
No known key found for this signature in database
GPG Key ID: AC6D6B9D715FC084
2 changed files with 22 additions and 2 deletions

View File

@ -24,7 +24,10 @@ enum _QrScanState { none, scanning, success, failed }
class OathAddAccountPage extends ConsumerStatefulWidget {
final DevicePath devicePath;
const OathAddAccountPage(this.devicePath, {Key? key}) : super(key: key);
final bool openQrScanner;
const OathAddAccountPage(this.devicePath,
{Key? key, required this.openQrScanner})
: super(key: key);
@override
ConsumerState<ConsumerStatefulWidget> createState() =>
@ -98,6 +101,18 @@ class _OathAddAccountPageState extends ConsumerState<OathAddAccountPage> {
}
}
@override
void initState() {
super.initState();
final qrScanner = ref.read(qrScannerProvider);
if (qrScanner != null && widget.openQrScanner) {
WidgetsBinding.instance.addPostFrameCallback((_) {
_scanQrCode(qrScanner);
});
}
}
@override
Widget build(BuildContext context) {
// If current device changes, we need to pop back to the main Page.

View File

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@ -127,7 +129,10 @@ class _UnlockedView extends ConsumerWidget {
action: (context) {
showDialog(
context: context,
builder: (context) => OathAddAccountPage(devicePath),
builder: (context) => OathAddAccountPage(
devicePath,
openQrScanner: Platform.isAndroid,
),
);
},
),