mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 10:11:52 +03:00
Merge PR #107.
This commit is contained in:
commit
35668a1e18
@ -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.
|
||||
|
@ -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,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user