This repository has been archived by the owner on Sep 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from MXCzkEVM/account_management_feat
Account management feature
- Loading branch information
Showing
23 changed files
with
670 additions
and
110 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
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
67 changes: 67 additions & 0 deletions
67
...features/security/presentation/passcode_authenticate/passcode_authenticate_user_page.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,67 @@ | ||
import 'package:datadashwallet/features/security/security.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_i18n/flutter_i18n.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
import 'package:mxc_ui/mxc_ui.dart'; | ||
|
||
import 'passcode_authenticate_user_presenter.dart'; | ||
import 'passcode_authenticate_user_state.dart'; | ||
|
||
class PasscodeAuthenticateUserPage extends PasscodeBasePage { | ||
const PasscodeAuthenticateUserPage( | ||
{Key? key, this.change = false, this.dismissedDest}) | ||
: super(key: key); | ||
|
||
final bool change; | ||
final String? dismissedDest; | ||
|
||
@override | ||
String title(BuildContext context, WidgetRef ref) => | ||
FlutterI18n.translate(context, 'view_private_key'); | ||
|
||
@override | ||
String hint(BuildContext context, WidgetRef ref) => | ||
FlutterI18n.translate(context, 'enter_your_passcode'); | ||
|
||
@override | ||
String secondHint(BuildContext context, WidgetRef ref) => | ||
FlutterI18n.translate(context, 'view_private_key_notice'); | ||
|
||
@override | ||
String? dismissedPage() => dismissedDest; | ||
|
||
@override | ||
ProviderBase<PasscodeBasePagePresenter> get presenter => | ||
passcodeAuthenticateUserContainer.actions; | ||
|
||
@override | ||
ProviderBase<PasscodeAuthenticateUserState> get state => | ||
passcodeAuthenticateUserContainer.state; | ||
|
||
@override | ||
Widget buildErrorMessage(BuildContext context, WidgetRef ref) => SizedBox( | ||
height: 90, | ||
width: 280, | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
crossAxisAlignment: CrossAxisAlignment.stretch, | ||
children: [ | ||
if (ref.watch(state).errorText != null) ...[ | ||
Text( | ||
ref.watch(state).errorText!, | ||
textAlign: TextAlign.center, | ||
style: FontTheme.of(context).subtitle2.error(), | ||
), | ||
if (ref.watch(state).wrongInputCounter == 2) ...[ | ||
const SizedBox(height: 6), | ||
Text( | ||
FlutterI18n.translate(context, 'app_will_be_locked_alert'), | ||
textAlign: TextAlign.center, | ||
style: FontTheme.of(context).subtitle1.error(), | ||
), | ||
], | ||
] | ||
], | ||
), | ||
); | ||
} |
41 changes: 41 additions & 0 deletions
41
...res/security/presentation/passcode_authenticate/passcode_authenticate_user_presenter.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,41 @@ | ||
import 'package:datadashwallet/core/core.dart'; | ||
import 'package:datadashwallet/features/security/security.dart'; | ||
import 'passcode_authenticate_user_state.dart'; | ||
|
||
final passcodeAuthenticateUserContainer = PresenterContainer< | ||
PasscodeAuthenticateUserPresenter, | ||
PasscodeAuthenticateUserState>( | ||
() => PasscodeAuthenticateUserPresenter()); | ||
|
||
class PasscodeAuthenticateUserPresenter | ||
extends PasscodeBasePagePresenter<PasscodeAuthenticateUserState> { | ||
PasscodeAuthenticateUserPresenter() | ||
: super(PasscodeAuthenticateUserState()); | ||
|
||
late final PasscodeUseCase _passcodeUseCase = | ||
ref.read(passcodeUseCaseProvider); | ||
|
||
@override | ||
void onAllNumbersEntered(String? dismissedPage) async { | ||
if (state.enteredNumbers.join('') != _passcodeUseCase.passcode.value) { | ||
if (state.wrongInputCounter < 2) { | ||
state.errorText = translate('incorrect_passcode')!; | ||
state.wrongInputCounter++; | ||
} else { | ||
state.errorText = null; | ||
state.wrongInputCounter = 0; | ||
ref.read(passcodeUseCaseProvider).penaltyLock(); | ||
} | ||
state.enteredNumbers = []; | ||
notify(); | ||
return; | ||
} | ||
|
||
Future.delayed( | ||
passcodeTransitionDuration, | ||
() => notify(() => state.enteredNumbers = []), | ||
); | ||
|
||
navigator?.pop(true); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...eatures/security/presentation/passcode_authenticate/passcode_authenticate_user_state.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,11 @@ | ||
import 'package:datadashwallet/features/security/security.dart'; | ||
|
||
class PasscodeAuthenticateUserState extends PasscodeBasePageState { | ||
int wrongInputCounter = 0; | ||
|
||
@override | ||
List<Object?> get props => [ | ||
...super.props, | ||
wrongInputCounter, | ||
]; | ||
} |
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
Oops, something went wrong.