Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
steel97 committed Dec 2, 2023
2 parents 1efb37f + 4e5192b commit 1bb9a9d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
16 changes: 16 additions & 0 deletions lib/src/core/func_checker.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'dart:io';
import 'package:local_auth/local_auth.dart';

var auth = LocalAuthentication();

Future<bool> checkBiometricsSupport() async{
if(Platform.isLinux || Platform.isFuchsia) {
return false;
}

final bool canAuthenticateWithBiometrics =
await auth.canCheckBiometrics;
final bool canAuthenticate = canAuthenticateWithBiometrics ||
await auth.isDeviceSupported();
return canAuthenticate;
}
7 changes: 4 additions & 3 deletions lib/src/core/wallet_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,13 @@ class WalletHelper {
continue;
}

reconstructedWallets.add(rndWalletId.toString());
await storageService.writeSecureData(
StorageItem(prefsWalletsStorage, reconstructedWallets.join(',')));
break;
}

reconstructedWallets.add(rndWalletId.toString());
await storageService.writeSecureData(
StorageItem(prefsWalletsStorage, reconstructedWallets.join(',')));

// 2. save wallet name
await storageService.writeSecureData(
StorageItem(prefsWalletNames + rndWalletId.toString(), walletName));
Expand Down
12 changes: 3 additions & 9 deletions lib/src/views/import_seed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:local_auth/local_auth.dart';
import 'package:veil_light_plugin/veil_light.dart';
import 'package:veil_wallet/src/core/constants.dart';
import 'package:veil_wallet/src/core/func_checker.dart';
import 'package:veil_wallet/src/core/screen.dart';
import 'package:veil_wallet/src/core/wallet_helper.dart';
import 'package:veil_wallet/src/helpers/responsive.dart';
Expand Down Expand Up @@ -48,7 +48,7 @@ class _ImportSeedState extends State<ImportSeed> {
canPop: false,
child: BackLayout(
title: AppLocalizations.of(context)?.importSeedTitle,
back: () {
back: _importLoading ? null : () {
_backAction();
},
child: Form(
Expand Down Expand Up @@ -174,13 +174,7 @@ class _ImportSeedState extends State<ImportSeed> {
.add(element.text.toLowerCase().trim());
}

var auth = LocalAuthentication();
final bool canAuthenticateWithBiometrics =
await auth.canCheckBiometrics;
final bool canAuthenticate =
canAuthenticateWithBiometrics ||
await auth.isDeviceSupported();

final bool canAuthenticate = await checkBiometricsSupport();
if (BaseStaticState.prevScreen ==
Screen.settings ||
!canAuthenticate) {
Expand Down
12 changes: 3 additions & 9 deletions lib/src/views/new_wallet_verify_seed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:local_auth/local_auth.dart';
import 'package:veil_light_plugin/veil_light.dart';
import 'package:veil_wallet/src/core/constants.dart';
import 'package:veil_wallet/src/core/func_checker.dart';
import 'package:veil_wallet/src/core/screen.dart';
import 'package:veil_wallet/src/core/wallet_helper.dart';
import 'package:veil_wallet/src/helpers/responsive.dart';
Expand All @@ -30,7 +30,7 @@ class _NewWalletVerifySeedState extends State<NewWalletVerifySeed> {
return PopScope(
child: BackLayout(
title: AppLocalizations.of(context)?.verifySeedPhraseTitle,
back: () {
back: _createLoading ? null : () {
Navigator.of(context).push(_createBackRoute());
},
child: Form(
Expand Down Expand Up @@ -120,13 +120,7 @@ class _NewWalletVerifySeedState extends State<NewWalletVerifySeed> {
}

// move to biometrics if not opened from settings
var auth = LocalAuthentication();
final bool canAuthenticateWithBiometrics =
await auth.canCheckBiometrics;
final bool canAuthenticate =
canAuthenticateWithBiometrics ||
await auth.isDeviceSupported();

final bool canAuthenticate = await checkBiometricsSupport();
if (BaseStaticState.prevScreen ==
Screen.settings ||
!canAuthenticate) {
Expand Down
9 changes: 2 additions & 7 deletions lib/src/views/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:local_auth/local_auth.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:veil_wallet/src/core/constants.dart';
import 'package:veil_wallet/src/core/func_checker.dart';
import 'package:veil_wallet/src/core/locale_entry.dart';
import 'package:veil_wallet/src/core/node_entry.dart';
import 'package:veil_wallet/src/core/screen.dart';
Expand Down Expand Up @@ -45,12 +46,6 @@ class _SettingsState extends State<Settings> {
String _localeTmp = '';
String _selectedNode = defaultNodeAddress;

Future<bool> checkBiometricsPossible() async {
var auth = LocalAuthentication();
final bool canAuthenticateWithBiometrics = await auth.canCheckBiometrics;
return canAuthenticateWithBiometrics || await auth.isDeviceSupported();
}

@override
void initState() {
super.initState();
Expand Down Expand Up @@ -78,7 +73,7 @@ class _SettingsState extends State<Settings> {

_darkMode = context.read<WalletState>().darkMode;

var biometricsPossibleFeature = checkBiometricsPossible();
var biometricsPossibleFeature = checkBiometricsSupport();

List<Widget> authActions = [];

Expand Down

0 comments on commit 1bb9a9d

Please sign in to comment.