From 44dbfc36d97bdd454e26f15ff50bb5330733acfe Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 4 Oct 2025 20:38:42 +0800 Subject: [PATCH] :lipstick: Optimized wallet screen --- assets/i18n/en-US.json | 1 + lib/screens/wallet.dart | 62 +++++++++++------------- lib/widgets/payment/README.md | 2 +- lib/widgets/payment/payment_overlay.dart | 2 +- 4 files changed, 31 insertions(+), 36 deletions(-) diff --git a/assets/i18n/en-US.json b/assets/i18n/en-US.json index 02a21a2c..68f611bf 100644 --- a/assets/i18n/en-US.json +++ b/assets/i18n/en-US.json @@ -481,6 +481,7 @@ "pinCode": "PIN Code", "biometric": "Biometric", "enterPinToConfirm": "Enter your 6-digit PIN to confirm payment", + "enterPin": "Enter your PIN code", "clearPin": "Clear PIN", "useBiometricToConfirm": "Use biometric authentication to confirm payment", "touchSensorToAuthenticate": "Touch the sensor to authenticate", diff --git a/lib/screens/wallet.dart b/lib/screens/wallet.dart index 898cd7f3..f2800a6d 100644 --- a/lib/screens/wallet.dart +++ b/lib/screens/wallet.dart @@ -285,37 +285,6 @@ class _CreateFundSheetState extends State { ), ); }), - if (selectedRecipients.length < 10) - OutlinedButton.icon( - onPressed: () async { - final recipient = - await showModalBottomSheet( - context: context, - useRootNavigator: true, - isScrollControlled: true, - builder: - (context) => - const AccountPickerSheet(), - ); - if (recipient != null && - !selectedRecipients.contains( - recipient, - )) { - setState( - () => - selectedRecipients.add(recipient), - ); - } - }, - icon: const Icon(Icons.person_add), - label: Text('addRecipient'.tr()), - style: OutlinedButton.styleFrom( - minimumSize: const Size( - double.infinity, - 48, - ), - ), - ).padding(all: 16), ], ) : Column( @@ -470,7 +439,7 @@ class _CreateFundSheetState extends State { bottom: MediaQuery.of(context).viewInsets.bottom, ), child: SheetScaffold( - titleText: 'enterPinToConfirm'.tr(), + titleText: 'enterPin'.tr(), heightFactor: 0.5, child: Padding( padding: const EdgeInsets.all(20), @@ -481,7 +450,7 @@ class _CreateFundSheetState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - 'enterPinToConfirm'.tr(), + 'enterPinToConfirmPayment'.tr(), style: Theme.of(context).textTheme.titleMedium ?.copyWith(fontWeight: FontWeight.w500), textAlign: TextAlign.center, @@ -862,6 +831,29 @@ class WalletScreen extends HookConsumerWidget { return 'walletCurrency${isShort ? 'Short' : ''}${currency[0].toUpperCase()}${currency.substring(1).toLowerCase()}'; } + List _getAllCurrencies(List pockets) { + final allCurrencies = {}; + allCurrencies.addAll(kCurrencyIconData.keys); + allCurrencies.addAll(pockets.map((p) => p.currency)); + + return allCurrencies.map((currency) { + final existingPocket = pockets.firstWhere( + (p) => p.currency == currency, + orElse: + () => SnWalletPocket( + id: '', + currency: currency, + amount: 0.0, + walletId: '', + createdAt: DateTime.now(), + updatedAt: DateTime.now(), + deletedAt: null, + ), + ); + return existingPocket; + }).toList(); + } + return AppScaffold( appBar: AppBar( title: Text('wallet').tr(), @@ -908,7 +900,7 @@ class WalletScreen extends HookConsumerWidget { margin: EdgeInsets.zero, child: Column( children: [ - ...data.pockets.map( + ..._getAllCurrencies(data.pockets).map( (pocket) => ListTile( leading: Icon( kCurrencyIconData[pocket.currency] ?? @@ -932,6 +924,8 @@ class WalletScreen extends HookConsumerWidget { ).padding(horizontal: 12, top: 12), ), + SliverGap(8), + // Tab Bar SliverToBoxAdapter( child: TabBar( diff --git a/lib/widgets/payment/README.md b/lib/widgets/payment/README.md index 645502d6..a472d512 100644 --- a/lib/widgets/payment/README.md +++ b/lib/widgets/payment/README.md @@ -188,7 +188,7 @@ Add these keys to your localization files: "description": "Description", "pinCode": "PIN Code", "biometric": "Biometric", - "enterPinToConfirm": "Enter your 6-digit PIN to confirm payment", + "enterPinToConfirmPayment": "Enter your 6-digit PIN to confirm payment", "clearPin": "Clear PIN", "useBiometricToConfirm": "Use biometric authentication to confirm payment", "touchSensorToAuthenticate": "Touch the sensor to authenticate", diff --git a/lib/widgets/payment/payment_overlay.dart b/lib/widgets/payment/payment_overlay.dart index 1589a774..580d6ba4 100644 --- a/lib/widgets/payment/payment_overlay.dart +++ b/lib/widgets/payment/payment_overlay.dart @@ -385,7 +385,7 @@ class _PaymentContentState extends ConsumerState<_PaymentContent> { return Column( children: [ Text( - 'enterPinToConfirm'.tr(), + 'enterPinToConfirmPayment'.tr(), style: Theme.of( context, ).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w500),