1- import 'package:flutter/material.dart' ;
21import 'package:flutter_riverpod/flutter_riverpod.dart' ;
32import 'package:local_auth/local_auth.dart' hide LocalAuthentication;
43import 'package:open_authenticator/i18n/localizable_exception.dart' ;
54import 'package:open_authenticator/i18n/translations.g.dart' ;
5+ import 'package:open_authenticator/model/app_unlock/interaction.dart' ;
66import 'package:open_authenticator/model/app_unlock/reason.dart' ;
77import 'package:open_authenticator/model/crypto/derived_key.dart' ;
88import 'package:open_authenticator/model/crypto/salt.dart' ;
@@ -13,7 +13,6 @@ import 'package:open_authenticator/model/totp/repository.dart';
1313import 'package:open_authenticator/model/totp/totp.dart' ;
1414import 'package:open_authenticator/utils/local_authentication/local_authentication.dart' ;
1515import 'package:open_authenticator/utils/result/result.dart' ;
16- import 'package:open_authenticator/widgets/dialog/text_input_dialog.dart' ;
1716
1817part 'local_auth.dart' ;
1918part 'master_password.dart' ;
@@ -44,17 +43,16 @@ sealed class AppUnlockMethod<T> {
4443 }) : _ref = ref;
4544
4645 /// Unlock the app, handling errors.
47- /// [context] is required so that we can interact with the user.
48- Future <Result <T >> unlock (BuildContext context, UnlockReason reason) async {
46+ Future <Result <T >> unlock (AppUnlockInteraction interaction, UnlockReason reason) async {
4947 try {
5048 CannotUnlockException ? cannotUnlockException = await canUnlock (reason);
5149 if (cannotUnlockException != null ) {
5250 throw cannotUnlockException;
5351 }
54- if (! context.mounted ) {
52+ if (! interaction.canInteract ) {
5553 return const ResultCancelled ();
5654 }
57- return await _tryUnlock (context , reason);
55+ return await _tryUnlock (interaction , reason);
5856 } catch (ex, stackTrace) {
5957 if (ex is LocalAuthException ) {
6058 if (ex.code == LocalAuthExceptionCode .userCanceled || ex.code == LocalAuthExceptionCode .systemCanceled) {
@@ -69,8 +67,7 @@ sealed class AppUnlockMethod<T> {
6967 }
7068
7169 /// Tries to unlock the app.
72- /// [context] is required so that we can interact with the user.
73- Future <Result <T >> _tryUnlock (BuildContext context, UnlockReason reason);
70+ Future <Result <T >> _tryUnlock (AppUnlockInteraction interaction, UnlockReason reason);
7471
7572 /// The default app lock state.
7673 AppLockState get defaultAppLockState => AppLockState .locked;
0 commit comments