Skip to content

Commit

Permalink
feat: Add option to reset if wallet attestation is revoked #2759
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Jul 2, 2024
1 parent 3785452 commit 2126941
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/app/shared/enum/status/app_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ enum AppStatus {
success,
idle,
goBack,
//gotTokenReward,
revoked,
}
1 change: 1 addition & 0 deletions lib/dashboard/drawer/reset_wallet/reset_wallet.dart
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export 'cubit/reset_wallet_cubit.dart';
export 'helper_functions/reset_wallet.dart';
export 'view/reset_wallet_menu.dart';
4 changes: 1 addition & 3 deletions lib/enterprise/cubit/enterprise_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,7 @@ class EnterpriseCubit extends Cubit<EnterpriseState> {
// active
} else {
// revoked
throw ResponseMessage(
message: ResponseString.RESPONSE_STRING_theWalletIsSuspended,
);
emit(state.copyWith(status: AppStatus.revoked));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/enterprise/cubit/enterprise_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class EnterpriseState extends Equatable {
}

EnterpriseState copyWith({
required StateMessage? message,
StateMessage? message,
AppStatus? status,
}) {
return EnterpriseState(
Expand Down
1 change: 1 addition & 0 deletions lib/enterprise/enterprise.dart
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export 'cubit/enterprise_cubit.dart';
export 'widget/widget.dart';
63 changes: 63 additions & 0 deletions lib/enterprise/widget/wallet_revoked_dialog.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import 'package:altme/app/app.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/l10n/l10n.dart';

import 'package:flutter/material.dart';

class WalletRevokedDialog extends StatelessWidget {
const WalletRevokedDialog({super.key});

@override
Widget build(BuildContext context) {
final background = Theme.of(context).colorScheme.onSurface;
final textColor = Theme.of(context).colorScheme.surface;

final l10n = context.l10n;
return AlertDialog(
backgroundColor: background,
surfaceTintColor: Colors.transparent,
contentPadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(25)),
),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(height: 25),
Text(
l10n.theWalletIsSuspended,
style: Theme.of(context)
.textTheme
.headlineMedium!
.copyWith(color: textColor),
textAlign: TextAlign.center,
),
const SizedBox(height: 24),
MyElevatedButton(
text: l10n.deleteMyWallet,
verticalSpacing: 14,
borderRadius: Sizes.smallRadius,
elevation: 0,
onPressed: () async {
Navigator.of(context).pop();
await resetWallet(context);
},
),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text(
l10n.skip.toUpperCase(),
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(color: textColor),
textAlign: TextAlign.center,
),
),
],
),
);
}
}
1 change: 1 addition & 0 deletions lib/enterprise/widget/widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'wallet_revoked_dialog.dart';
2 changes: 1 addition & 1 deletion lib/pin_code/view/delete_my_wallet_page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:altme/app/shared/constants/image_strings.dart';
import 'package:altme/app/shared/constants/sizes.dart';
import 'package:altme/app/shared/widget/widget.dart';
import 'package:altme/dashboard/drawer/reset_wallet/helper_functions/reset_wallet.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/l10n/l10n.dart';
import 'package:flutter/material.dart';

Expand Down
7 changes: 7 additions & 0 deletions lib/splash/bloclisteners/blocklisteners.dart
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,13 @@ final enterpriseBlocListener = BlocListener<EnterpriseCubit, EnterpriseState>(
Navigator.of(context).pop();
}

if (state.status == AppStatus.revoked) {
showDialog<void>(
context: context,
builder: (_) => const WalletRevokedDialog(),
);
}

if (state.message != null) {
AlertMessage.showStateMessage(
context: context,
Expand Down

0 comments on commit 2126941

Please sign in to comment.