Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add remove wallet feature in lock screen #1152

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/domain/usecases/authentication/authentication.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mixin AuthenticationWithLock {
static int get maxFailedAttempts => 5;

Duration lockDuration(int attempts) {
if (attempts == 20) {
if (attempts >= 20) {
return const Duration(hours: 24);
}

Expand Down
1 change: 1 addition & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"biometricsMethod": "Biometrics",
"language": "Language",
"removeWallet": "Remove Wallet from this device",
"removeWalletBtn": "Remove Wallet",
"removeWalletDescription": "You can find it at any time with your secret phrase",
"resyncWallet": "Resynchronize Wallet",
"resyncWalletAreYouSure": "Are you sure you want to clear your cache and reload the information from the blockchain?\n\nThis action takes a few seconds and is safe because it only reloads your recent transactions.",
Expand Down
1 change: 1 addition & 0 deletions lib/l10n/intl_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"biometricsMethod": "Biométrie",
"language": "Langue",
"removeWallet": "Supprimer le wallet de cet appareil",
"removeWalletBtn": "Supprimer le wallet",
"resyncWallet": "Resynchroniser le wallet",
"resyncWalletAreYouSure": "Êtes-vous sûr(e) de vouloir vider votre cache et recharger les informations à partir de la blockchain ?\n\nCette action requiert quelques secondes et est sans risque car elle recharge uniquement vos transactions récentes.",
"resyncWalletDescription": "Vider le cache et recharger les informations de la blockchain",
Expand Down
7 changes: 2 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:logging/logging.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:oktoast/oktoast.dart';
import 'package:window_manager/window_manager.dart';

Expand Down Expand Up @@ -439,15 +438,13 @@ class SplashState extends ConsumerState<Splash> {
.textStyleSize16W400MainButtonLabel.color,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Symbols.delete),
const Spacer(),
Text(
'Remove wallet',
AppLocalizations.of(context)!.removeWalletBtn,
style: ArchethicThemeStyles
.textStyleSize16W400MainButtonLabel,
),
const Spacer(),
],
),
),
Expand Down
6 changes: 6 additions & 0 deletions lib/ui/views/authenticate/auto_lock_guard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ import 'package:aewallet/application/authentication/authentication.dart';
import 'package:aewallet/ui/themes/archethic_theme.dart';
import 'package:aewallet/ui/themes/styles.dart';
import 'package:aewallet/ui/util/dimens.dart';
import 'package:aewallet/ui/views/authenticate/auth_factory.dart';
import 'package:aewallet/ui/views/authenticate/components/lock_overlay.mixin.dart';
import 'package:aewallet/ui/views/authenticate/logging_out.dart';
import 'package:aewallet/ui/views/main/components/sheet_appbar.dart';
import 'package:aewallet/ui/widgets/components/app_button.dart';
import 'package:aewallet/ui/widgets/components/app_button_tiny.dart';
import 'package:aewallet/ui/widgets/components/sheet_skeleton.dart';
import 'package:aewallet/ui/widgets/components/sheet_skeleton_interface.dart';
import 'package:archethic_dapp_framework_flutter/archethic_dapp_framework_flutter.dart'
as aedappfm;
import 'package:async/async.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/localizations.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:logging/logging.dart';

part 'components/lock_mask_screen.dart';
Expand Down
207 changes: 194 additions & 13 deletions lib/ui/views/authenticate/countdown_lock_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,51 @@ class _CountdownLockScreen extends ConsumerWidget
)
.valueOrNull ??
'';
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
AppButtonTiny(
AppButtonTinyType.primary,
isLocked ? countDownString : localizations.unlock,
Dimens.buttonBottomDimens,
key: const Key('unlock'),
onPressed: () {
if (isLocked) return;
CountdownLockOverlay.instance().hide();
},
disabled: isLocked,
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
AppButtonTiny(
AppButtonTinyType.primary,
isLocked ? countDownString : localizations.unlock,
Dimens.buttonTopDimens,
key: const Key('unlock'),
onPressed: () {
if (isLocked) return;
CountdownLockOverlay.instance().hide();
},
disabled: isLocked,
),
],
),
Container(
height: 50,
margin: Dimens.buttonBottomDimens.edgeInsetsDirectional,
child: FilledButton(
onPressed: () {
RemoveWalletDialogOverlay.showOverlay(
context,
ref,
);
},
style: FilledButton.styleFrom(
backgroundColor: Colors.red,
foregroundColor:
ArchethicThemeStyles.textStyleSize16W400MainButtonLabel.color,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
AppLocalizations.of(context)!.removeWalletBtn,
style:
ArchethicThemeStyles.textStyleSize16W400MainButtonLabel,
),
],
),
),
),
],
);
Expand Down Expand Up @@ -123,3 +155,152 @@ class _CountdownLockScreen extends ConsumerWidget
);
}
}

class RemoveWalletDialogOverlay {
static void showOverlay(
BuildContext context,
WidgetRef ref,
) {
final localizations = AppLocalizations.of(context)!;

OverlayEntry? overlayEntry;

overlayEntry = OverlayEntry(
builder: (BuildContext overlayContext) {
return Positioned(
top: 0,
bottom: 0,
left: 0,
right: 0,
child: Material(
color: Colors.black.withOpacity(0.8),
child: SizedBox(
width: MediaQuery.of(context).size.width,
child: Center(
child: aedappfm.PopupTemplate(
displayCloseButton: false,
popupTitle: localizations.warning,
popupContent: Column(
children: [
Text(
localizations.removeWalletDetail,
style: ArchethicThemeStyles.textStyleSize12W100Primary,
),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AppButton(
key: const Key('cancelButton'),
labelBtn: AppLocalizations.of(
context,
)!
.no,
onPressed: () {
overlayEntry?.remove();
},
),
AppButton(
key: const Key('yesButton'),
labelBtn: localizations.yes,
onPressed: () async {
overlayEntry?.remove();
Overlay.of(context).insert(
_createConfirmOverlay(
context,
ref,
),
);
},
),
],
),
],
),
),
),
),
),
);
},
);

Overlay.of(context).insert(overlayEntry);
}

static OverlayEntry _createConfirmOverlay(
BuildContext context,
WidgetRef ref,
) {
final localizations = AppLocalizations.of(context)!;

OverlayEntry? overlayEntry;

// ignore: join_return_with_assignment
overlayEntry = OverlayEntry(
builder: (BuildContext overlayContext) {
return Positioned(
top: 0,
bottom: 0,
left: 0,
right: 0,
child: Material(
color: Colors.black.withOpacity(0.8),
child: SizedBox(
width: MediaQuery.of(context).size.width,
child: Center(
child: aedappfm.PopupTemplate(
displayCloseButton: false,
popupTitle: localizations.areYouSure,
popupContent: Column(
children: [
Text(
localizations.removeWalletReassurance,
style: ArchethicThemeStyles.textStyleSize12W100Primary,
),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AppButton(
key: const Key('cancelButton'),
labelBtn: AppLocalizations.of(
context,
)!
.no,
onPressed: () {
overlayEntry?.remove();
},
),
AppButton(
key: const Key('yesButton'),
labelBtn: AppLocalizations.of(
context,
)!
.yes,
onPressed: () async {
overlayEntry?.remove();

CountdownLockOverlay.instance().hide();
context.go(LoggingOutScreen.routerPage);
},
),
],
),
],
),
),
),
),
),
);
},
);

return overlayEntry;
}
}