From 8557b8f583a1ad226691f5e186c9527e1bc6bae5 Mon Sep 17 00:00:00 2001 From: Ethan Lee <125412902+ethan-tbd@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:04:30 -0700 Subject: [PATCH] fix: update did copy (#251) --- lib/features/account/account_page.dart | 6 +++--- lib/features/did/did_qr_code_page.dart | 10 +++------- lib/features/did/did_storage_service.dart | 4 ---- lib/l10n/app_en.arb | 3 ++- lib/l10n/app_localizations.dart | 6 ++++++ lib/l10n/app_localizations_en.dart | 3 +++ .../{modal_remove_item.dart => modal_manage_item.dart} | 4 ++-- 7 files changed, 19 insertions(+), 17 deletions(-) rename lib/shared/modal/{modal_remove_item.dart => modal_manage_item.dart} (97%) diff --git a/lib/features/account/account_page.dart b/lib/features/account/account_page.dart index b1a2022b..a6784183 100644 --- a/lib/features/account/account_page.dart +++ b/lib/features/account/account_page.dart @@ -7,7 +7,7 @@ import 'package:didpay/features/pfis/pfis_add_page.dart'; import 'package:didpay/features/pfis/pfis_notifier.dart'; import 'package:didpay/features/vcs/vcs_notifier.dart'; import 'package:didpay/l10n/app_localizations.dart'; -import 'package:didpay/shared/modal/modal_remove_item.dart'; +import 'package:didpay/shared/modal/modal_manage_item.dart'; import 'package:didpay/shared/theme/grid.dart'; import 'package:didpay/shared/tile_container.dart'; import 'package:flutter/material.dart'; @@ -146,7 +146,7 @@ class AccountPage extends HookConsumerWidget { ), child: const Center(child: Icon(Icons.account_balance)), ), - onTap: () => ModalRemoveItem.show( + onTap: () => ModalManageItem.show( context, pfi.did, Loc.of(context).removePfi, @@ -229,7 +229,7 @@ class AccountPage extends HookConsumerWidget { ), child: const Center(child: Icon(Icons.gpp_good)), ), - onTap: () => ModalRemoveItem.show( + onTap: () => ModalManageItem.show( context, _getCredentialTitle(credential), Loc.of(context).removeCredential, diff --git a/lib/features/did/did_qr_code_page.dart b/lib/features/did/did_qr_code_page.dart index 27ff5776..ea5b2f4b 100644 --- a/lib/features/did/did_qr_code_page.dart +++ b/lib/features/did/did_qr_code_page.dart @@ -66,19 +66,15 @@ class DidQrCodePage extends HookConsumerWidget { trailing: IconButton( icon: const Icon(Icons.copy), onPressed: () async { - final didJson = await ref - .read(didServiceProvider) - .getPortableDidJson(); + final did = ref.read(didProvider); await Clipboard.setData( - ClipboardData( - text: didJson ?? 'Error: portable did not found', - ), + ClipboardData(text: did.uri), ); if (context.mounted) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - 'Copied portable did', + Loc.of(context).copiedToClipboard, style: Theme.of(context) .textTheme .titleSmall diff --git a/lib/features/did/did_storage_service.dart b/lib/features/did/did_storage_service.dart index d4e8cf64..cd658363 100644 --- a/lib/features/did/did_storage_service.dart +++ b/lib/features/did/did_storage_service.dart @@ -34,10 +34,6 @@ class DidStorageService { return did; } - // TODO(ethan-tbd): remove portable did method - Future getPortableDidJson() async => - storage.read(key: Constants.portableDidKey); - Future regenerateDid() async { await storage.delete(key: Constants.portableDidKey); diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 582422fd..86773849 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -171,5 +171,6 @@ "areYouSure": "Are you sure?", "allOfYourCredentialsWillAlsoBeDeleted": "All of your credentials will also be deleted", "regenerate": "Regenerate", - "goBack": "Go back" + "goBack": "Go back", + "copiedToClipboard": "Copied to clipboard" } \ No newline at end of file diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index c37ee0bc..63d5eb6c 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -894,6 +894,12 @@ abstract class Loc { /// In en, this message translates to: /// **'Go back'** String get goBack; + + /// No description provided for @copiedToClipboard. + /// + /// In en, this message translates to: + /// **'Copied to clipboard'** + String get copiedToClipboard; } class _LocDelegate extends LocalizationsDelegate { diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 09b0de42..44fd46da 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -415,4 +415,7 @@ class LocEn extends Loc { @override String get goBack => 'Go back'; + + @override + String get copiedToClipboard => 'Copied to clipboard'; } diff --git a/lib/shared/modal/modal_remove_item.dart b/lib/shared/modal/modal_manage_item.dart similarity index 97% rename from lib/shared/modal/modal_remove_item.dart rename to lib/shared/modal/modal_manage_item.dart index 954a1185..6e90c84b 100644 --- a/lib/shared/modal/modal_remove_item.dart +++ b/lib/shared/modal/modal_manage_item.dart @@ -3,7 +3,7 @@ import 'package:didpay/shared/theme/grid.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -class ModalRemoveItem { +class ModalManageItem { static Future show( BuildContext context, String title, @@ -29,7 +29,7 @@ class ModalRemoveItem { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - 'Copied to clipboard', + Loc.of(context).copiedToClipboard, style: Theme.of(context) .textTheme .titleSmall