Skip to content

Commit

Permalink
Merge PR #1692
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamVe committed Sep 17, 2024
2 parents 1d69a3c + b68798d commit 2e94f0a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
3 changes: 0 additions & 3 deletions lib/android/oath/state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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
Expand All @@ -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',
Expand Down
9 changes: 5 additions & 4 deletions lib/android/overlay/nfc/nfc_overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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':
Expand All @@ -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(),
));
}

Expand Down
11 changes: 11 additions & 0 deletions lib/android/overlay/nfc/views/nfc_overlay_icons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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});

Expand Down

0 comments on commit 2e94f0a

Please sign in to comment.