-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add account & select assets (#467)
* feat: select asset * feat: add account flow * fix: analyze * fix: code review --------- Co-authored-by: Egor Komarov <[email protected]>
- Loading branch information
Showing
37 changed files
with
1,311 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export 'add_account_confirm/add_new_account_confirm_sheet.dart'; | ||
export 'add_account_page.dart'; | ||
export 'add_account_result/add_account_result_sheet.dart'; | ||
export 'add_account_type/add_account_type_widget.dart'; | ||
export 'add_new_account_sheet.dart'; |
73 changes: 73 additions & 0 deletions
73
lib/feature/wallet/add_account/add_account_confirm/add_account_confirm_model.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import 'package:app/app/service/service.dart'; | ||
import 'package:app/generated/generated.dart'; | ||
import 'package:elementary/elementary.dart'; | ||
import 'package:local_auth/local_auth.dart'; | ||
import 'package:nekoton_repository/nekoton_repository.dart' hide Message; | ||
|
||
class AddAccountConfirmModel extends ElementaryModel { | ||
AddAccountConfirmModel( | ||
ErrorHandler errorHandler, | ||
this._biometryService, | ||
this._messengerService, | ||
this._nekotonRepository, | ||
) : super(errorHandler: errorHandler); | ||
|
||
final BiometryService _biometryService; | ||
final MessengerService _messengerService; | ||
final NekotonRepository _nekotonRepository; | ||
|
||
Future<List<BiometricType>> getAvailableBiometry(PublicKey publicKey) async { | ||
final isBiometryEnabled = _biometryService.enabled; | ||
final hasKeyPassword = await _biometryService.hasKeyPassword(publicKey); | ||
|
||
if (isBiometryEnabled && hasKeyPassword) { | ||
return _biometryService.getAvailableBiometry(); | ||
} | ||
|
||
return []; | ||
} | ||
|
||
Future<String?> requestBiometry(PublicKey publicKey) async { | ||
try { | ||
final password = await _biometryService.getKeyPassword( | ||
publicKey: publicKey, | ||
localizedReason: LocaleKeys.biometryAuthReason.tr(), | ||
); | ||
|
||
return password; | ||
} catch (_) { | ||
return null; | ||
} | ||
} | ||
|
||
Future<bool> checkPassword({ | ||
required String password, | ||
required PublicKey publicKey, | ||
}) async { | ||
if (password.isEmpty) return false; | ||
|
||
final list = _nekotonRepository.seedList; | ||
|
||
final correct = await list.checkKeyPassword( | ||
publicKey: publicKey, | ||
password: password, | ||
signatureId: | ||
await _nekotonRepository.currentTransport.transport.getSignatureId(), | ||
); | ||
|
||
if (_biometryService.enabled && correct) { | ||
await _biometryService.setKeyPassword( | ||
publicKey: publicKey, | ||
password: password, | ||
); | ||
} | ||
|
||
return correct; | ||
} | ||
|
||
void showWrongPassword() { | ||
_messengerService.show( | ||
Message.error(message: LocaleKeys.passwordIsWrong.tr()), | ||
); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
lib/feature/wallet/add_account/add_account_confirm/add_account_confirm_widget.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import 'package:app/feature/wallet/add_account/add_account_confirm/add_account_confirm_wm.dart'; | ||
import 'package:app/generated/generated.dart'; | ||
import 'package:elementary/elementary.dart'; | ||
import 'package:elementary_helper/elementary_helper.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:local_auth/local_auth.dart'; | ||
import 'package:lucide_icons_flutter/lucide_icons.dart'; | ||
import 'package:nekoton_repository/nekoton_repository.dart'; | ||
import 'package:ui_components_lib/ui_components_lib.dart'; | ||
import 'package:ui_components_lib/v2/ui_components_lib_v2.dart'; | ||
|
||
class AddAccountConfirmWidget | ||
extends ElementaryWidget<AddAccountConfirmWidgetModel> { | ||
const AddAccountConfirmWidget({ | ||
required this.publicKey, | ||
Key? key, | ||
WidgetModelFactory wmFactory = defaultAddAccountConfirmWidgetModelFactory, | ||
}) : super(wmFactory, key: key); | ||
|
||
final PublicKey publicKey; | ||
|
||
@override | ||
Widget build(AddAccountConfirmWidgetModel wm) { | ||
return SeparatedColumn( | ||
separatorSize: DimensSizeV2.d28, | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
SecureTextField( | ||
textEditingController: wm.controller, | ||
hintText: LocaleKeys.enterYourPassword.tr(), | ||
isAutofocus: true, | ||
onSubmit: (_) => wm.onPasswordSubmit(), | ||
), | ||
Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
AccentButton( | ||
buttonShape: ButtonShape.pill, | ||
title: LocaleKeys.confirm.tr(), | ||
onPressed: wm.onPasswordSubmit, | ||
), | ||
StateNotifierBuilder( | ||
listenableState: wm.availableBiometry, | ||
builder: (_, value) { | ||
if (value?.contains(BiometricType.face) ?? false) { | ||
return Padding( | ||
padding: const EdgeInsets.only(top: DimensSizeV2.d8), | ||
child: PrimaryButton( | ||
buttonShape: ButtonShape.pill, | ||
title: LocaleKeys.useFaceID.tr(), | ||
icon: LucideIcons.scanFace, | ||
onPressed: wm.onUseBiometry, | ||
), | ||
); | ||
} | ||
|
||
if (value?.contains(BiometricType.fingerprint) ?? false) { | ||
return Padding( | ||
padding: const EdgeInsets.only(top: DimensSizeV2.d8), | ||
child: PrimaryButton( | ||
buttonShape: ButtonShape.pill, | ||
title: LocaleKeys.useFingerprint.tr(), | ||
icon: LucideIcons.fingerprint, | ||
onPressed: wm.onUseBiometry, | ||
), | ||
); | ||
} | ||
|
||
return const SizedBox.shrink(); | ||
}, | ||
), | ||
], | ||
), | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.