mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-22 09:41:32 +03:00
Improve AddToAny when NFC not available
This commit is contained in:
parent
1d69a3c669
commit
b68798d6b4
@ -36,7 +36,6 @@ import '../../exception/platform_exception_decoder.dart';
|
||||
import '../../oath/models.dart';
|
||||
import '../../oath/state.dart';
|
||||
import '../../widgets/toast.dart';
|
||||
import '../app_methods.dart';
|
||||
import '../overlay/nfc/method_channel_notifier.dart';
|
||||
import '../overlay/nfc/nfc_overlay.dart';
|
||||
|
||||
@ -192,7 +191,6 @@ final addCredentialToAnyProvider =
|
||||
Provider((ref) => (Uri credentialUri, {bool requireTouch = false}) async {
|
||||
final oath = ref.watch(_oathMethodsProvider.notifier);
|
||||
try {
|
||||
await preserveConnectedDeviceWhenPaused();
|
||||
var result = jsonDecode(await oath.invoke('addAccountToAny', {
|
||||
'uri': credentialUri.toString(),
|
||||
'requireTouch': requireTouch
|
||||
@ -208,7 +206,6 @@ final addCredentialsToAnyProvider = Provider(
|
||||
(ref) => (List<String> credentialUris, List<bool> touchRequired) async {
|
||||
final oath = ref.read(_oathMethodsProvider.notifier);
|
||||
try {
|
||||
await preserveConnectedDeviceWhenPaused();
|
||||
_log.debug(
|
||||
'Calling android with ${credentialUris.length} credentials to be added');
|
||||
var result = jsonDecode(await oath.invoke('addAccountsToAny',
|
||||
|
@ -37,6 +37,7 @@ final nfcOverlay =
|
||||
class _NfcOverlayNotifier extends Notifier<int> {
|
||||
Timer? processingViewTimeout;
|
||||
late final l10n = ref.read(l10nProvider);
|
||||
late final eventNotifier = ref.read(nfcEventNotifier.notifier);
|
||||
|
||||
@override
|
||||
int build() {
|
||||
@ -76,10 +77,9 @@ class _NfcOverlayNotifier extends Notifier<int> {
|
||||
});
|
||||
|
||||
_channel.setMethodCallHandler((call) async {
|
||||
final notifier = ref.read(nfcEventNotifier.notifier);
|
||||
switch (call.method) {
|
||||
case 'show':
|
||||
notifier.send(showTapYourYubiKey());
|
||||
eventNotifier.send(showTapYourYubiKey());
|
||||
break;
|
||||
|
||||
case 'close':
|
||||
@ -97,12 +97,13 @@ class _NfcOverlayNotifier extends Notifier<int> {
|
||||
}
|
||||
|
||||
NfcEvent showTapYourYubiKey() {
|
||||
final nfcAvailable = ref.watch(androidNfcAdapterState);
|
||||
ref.read(nfcOverlayWidgetProperties.notifier).update(hasCloseButton: true);
|
||||
return NfcSetViewEvent(
|
||||
child: NfcContentWidget(
|
||||
title: l10n.s_nfc_ready_to_scan,
|
||||
subtitle: l10n.s_nfc_tap_your_yubikey,
|
||||
icon: const NfcIconProgressBar(false),
|
||||
subtitle: nfcAvailable ? l10n.s_nfc_tap_your_yubikey : l10n.l_insert_yk,
|
||||
icon: nfcAvailable ? const NfcIconProgressBar(false) : const UsbIcon(),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,17 @@ class NfcIconProgressBar extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
class UsbIcon extends StatelessWidget {
|
||||
const UsbIcon({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Icon(
|
||||
Symbols.usb,
|
||||
size: 64,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
);
|
||||
}
|
||||
|
||||
class NfcIconSuccess extends StatelessWidget {
|
||||
const NfcIconSuccess({super.key});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user