locale fix

Robert Malikowski committed Jun 26, 2026 at 13:25 UTC eff46638d9ba26b9bf3b4decb6da71bf143332c4
3 files changed +48 -69
lib/new-ui/widgets/coins_page/assets_history/assets_history_section.dart
+26 -9
@@ -4,6 +4,7 @@ import 'package:cake_wallet/new-ui/widgets/coins_page/assets_history/assets_top_
4 import 'package:cake_wallet/new-ui/widgets/coins_page/assets_history/history_modal.dart';
5 import 'package:cake_wallet/new-ui/widgets/coins_page/assets_history/history_top_bar.dart';
6 import 'package:cake_wallet/reactions/wallet_connect.dart';
7 +import 'package:cake_wallet/routes.dart';
8 import 'package:cake_wallet/src/screens/dashboard/pages/nft_listing_page.dart';
9 import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
10 import 'package:cake_wallet/view_model/dashboard/nft_view_model.dart';
@@ -13,11 +14,20 @@ import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
14 import 'assets_section.dart';
15 import 'history_section.dart';
16
17 +class AssetsHistorySectionActionButton {
18 + final String title;
19 + final String iconPath;
20 + final VoidCallback onPressed;
21 +
22 + const AssetsHistorySectionActionButton(this.title, this.iconPath, this.onPressed);
23 +}
24 +
25 class AssetsHistorySectionTab {
26 final String title;
27 final Widget content;
28 + final AssetsHistorySectionActionButton? actionButton;
29
20 - AssetsHistorySectionTab(this.title, this.content);
30 + const AssetsHistorySectionTab(this.title, this.content, this.actionButton);
31 }
32
33 class AssetsHistorySection extends StatefulWidget {
@@ -36,24 +46,31 @@ class _AssetsHistorySectionState extends State<AssetsHistorySection> {
46
47 void reloadTabs() {
48 final oldTabLength = tabs.length;
49 + final hasAssetsTab = widget.dashboardViewModel.balanceViewModel.isHomeScreenSettingsEnabled || (widget.dashboardViewModel.hasMweb && widget.dashboardViewModel.mwebEnabled);
50 + final hasNftTab = isNFTACtivatedChain(widget.dashboardViewModel.wallet.type,
51 + chainId: widget.dashboardViewModel.wallet.chainId);
52 tabs = [
40 - if (widget.dashboardViewModel.balanceViewModel.isHomeScreenSettingsEnabled || (widget.dashboardViewModel.hasMweb && widget.dashboardViewModel.mwebEnabled))
53 + if (hasAssetsTab)
54 AssetsHistorySectionTab(
55 S.current.assets,
56 AssetsSection(
57 dashboardViewModel: widget.dashboardViewModel,
45 - )),
58 + ), AssetsHistorySectionActionButton(S.current.tokens, "assets/new-ui/options_slider.svg", (){
59 + Navigator.of(context).pushNamed(
60 + Routes.homeSettings,
61 + arguments: widget.dashboardViewModel.balanceViewModel,
62 + );
63 + })),
64 AssetsHistorySectionTab(
65 S.current.history,
66 HistorySection(
67 detailsAsPage: false,
50 - roundedTopSection: tabs.length > 1,
68 + roundedTopSection: hasAssetsTab || hasNftTab,
69 dashboardViewModel: widget.dashboardViewModel,
70 short: true,
53 - )),
54 - if (isNFTACtivatedChain(widget.dashboardViewModel.wallet.type,
55 - chainId: widget.dashboardViewModel.wallet.chainId))
56 - AssetsHistorySectionTab(S.current.nfts, NFTListingPage(nftViewModel: widget.nftViewModel))
71 + ), AssetsHistorySectionActionButton(S.current.all_pascal_case, "assets/new-ui/arrow_right.svg", (){openHistoryModal(context);})),
72 + if (hasNftTab)
73 + AssetsHistorySectionTab(S.current.nfts, NFTListingPage(nftViewModel: widget.nftViewModel), null)
74 ];
75 if (oldTabLength != tabs.length) {
76 setState(() {
@@ -81,7 +98,7 @@ class _AssetsHistorySectionState extends State<AssetsHistorySection> {
98 AssetsTopBar(
99 onTransactionHistoryOpened: () => openHistoryModal(context),
100 dashboardViewModel: widget.dashboardViewModel,
84 - tabs: tabs.map((item) => item.title).toList(),
101 + tabs: tabs,
102 onTabChange: (index) {
103 setState(() {
104 _selectedTab = index;
lib/new-ui/widgets/coins_page/assets_history/assets_top_bar.dart
+11 -47
@@ -1,9 +1,5 @@
1 -import 'package:cake_wallet/core/csv_export_service.dart';
2 -import 'package:cake_wallet/generated/i18n.dart';
1 +import 'package:cake_wallet/new-ui/widgets/coins_page/assets_history/assets_history_section.dart';
2 import 'package:cake_wallet/new-ui/widgets/line_tab_switcher.dart';
4 -import 'package:cake_wallet/routes.dart';
5 -import 'package:cake_wallet/src/screens/dashboard/widgets/filter_widget.dart';
6 -import 'package:cake_wallet/utils/show_pop_up.dart';
3 import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
4 import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
5 import 'package:flutter/material.dart';
@@ -20,13 +16,11 @@ class AssetsTopBar extends StatelessWidget {
16 final void Function(int) onTabChange;
17 final VoidCallback onTransactionHistoryOpened;
18 final int selectedTab;
23 - final List<String> tabs;
19 + final List<AssetsHistorySectionTab> tabs;
20 final DashboardViewModel dashboardViewModel;
21
22 @override
23 Widget build(BuildContext context) {
28 - final settingsButtonText = _getSettingsButtonText();
29 - final hasTokenSettingsButton = settingsButtonText != null;
24
25 return SliverToBoxAdapter(
26 child: Padding(
@@ -36,7 +30,7 @@ class AssetsTopBar extends StatelessWidget {
30 mainAxisAlignment: MainAxisAlignment.spaceBetween,
31 children: [
32 LineTabSwitcher(
39 - tabs: tabs,
33 + tabs: tabs.map((item)=>item.title).toList(),
34 onTabChange: onTabChange,
35 selectedTab: selectedTab,
36 ),
@@ -57,19 +51,13 @@ class AssetsTopBar extends StatelessWidget {
51 children: [
52
53 Opacity(
60 - opacity: hasTokenSettingsButton ? 1 : 0,
54 + opacity: tabs[selectedTab].actionButton != null ? 1 : 0,
55 child: GestureDetector(
56 onTap: () {
63 - if (tabs[selectedTab] == S.of(context).assets) {
64 - Navigator.of(context).pushNamed(
65 - Routes.homeSettings,
66 - arguments: dashboardViewModel.balanceViewModel,
67 - );
68 - } else if (tabs[selectedTab] == S.of(context).history) {
69 -
70 - onTransactionHistoryOpened();
71 - }
72 - },
57 + if(tabs[selectedTab].actionButton != null) {
58 + tabs[selectedTab].actionButton?.onPressed();
59 + }
60 + },
61 child: Container(
62 height: 40,
63 decoration: BoxDecoration(
@@ -82,13 +70,13 @@ class AssetsTopBar extends StatelessWidget {
70 spacing: 6,
71 children: [
72
85 - if ((settingsButtonText ?? "").isNotEmpty)
73 + if ((tabs[selectedTab].actionButton?.title ?? "").isNotEmpty)
74 Text(
87 - settingsButtonText ?? "",
75 + tabs[selectedTab].actionButton?.title ?? "",
76 style: TextStyle(color: Theme.of(context).colorScheme.primary),
77 ),
78 CakeImageWidget(
91 - imageUrl: _getSettingsButtonIconPath(),
79 + imageUrl: tabs[selectedTab].actionButton?.iconPath,
80 colorFilter: ColorFilter.mode(
81 Theme.of(context).colorScheme.primary, BlendMode.srcIn)),
82 ],
@@ -106,28 +94,4 @@ class AssetsTopBar extends StatelessWidget {
94 );
95 }
96
109 - String? _getSettingsButtonIconPath() {
110 - if (tabs[selectedTab] == S.current.history) {
111 - return "assets/new-ui/arrow_right.svg";
112 - }
113 -
114 - if (tabs[selectedTab] == S.current.assets &&
115 - dashboardViewModel.balanceViewModel.isHomeScreenSettingsEnabled) {
116 - return "assets/new-ui/options_slider.svg";
117 - }
118 -
119 - return null;
120 - }
121 -
122 - String? _getSettingsButtonText() {
123 - if (tabs[selectedTab] == S.current.assets &&
124 - dashboardViewModel.balanceViewModel.isHomeScreenSettingsEnabled) {
125 - return S.current.tokens;
126 - }
127 -
128 - if (tabs[selectedTab] == S.current.history) {
129 - return S.current.all_pascal_case;
130 - }
131 - return null;
132 - }
97 }
lib/new-ui/widgets/coins_page/assets_history/history_section.dart
+11 -13
@@ -1,5 +1,3 @@
1 -import 'dart:math';
2 -
1 import 'package:cake_wallet/di.dart';
2 import 'package:cake_wallet/generated/i18n.dart';
3 import 'package:cake_wallet/new-ui/widgets/coins_page/assets_history/anonpay_history_tile.dart';
@@ -9,7 +7,6 @@ import 'package:cake_wallet/new-ui/widgets/coins_page/assets_history/history_tra
7 import 'package:cake_wallet/new-ui/widgets/coins_page/assets_history/payjoin_history_tile.dart';
8 import 'package:cake_wallet/new-ui/widgets/coins_page/assets_history/transaction_details_modal.dart';
9 import 'package:cake_wallet/routes.dart';
12 -import 'package:cake_wallet/utils/date_formatter.dart';
10 import 'package:cake_wallet/view_model/dashboard/anonpay_transaction_list_item.dart';
11 import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
12 import 'package:cake_wallet/view_model/dashboard/date_section_item.dart';
@@ -39,6 +36,7 @@ class HistorySection extends StatelessWidget {
36 padding: EdgeInsets.only(left: 16.0, right: 16, top: short && roundedTopSection ? 18 : 0),
37 sliver: Observer(
38 builder: (_) {
39 + final localeName = Localizations.localeOf(context).toString();
40 final items = short ? dashboardViewModel.itemsShort : dashboardViewModel.items;
41
42 return (items.isEmpty)
@@ -100,7 +98,7 @@ class HistorySection extends StatelessWidget {
98 },
99 child: HistoryTile(
100 title: item.formattedTitle + transactionType,
103 - date: _formatTransactionDate(item.date),
101 + date: _formatTransactionDate(item.date, localeName),
102 amount: item.formattedCryptoAmount,
103 amountFiat: item.formattedFiatAmount,
104 hasTokens: item.hasTokens,
@@ -128,7 +126,7 @@ class HistorySection extends StatelessWidget {
126 from: tradeFrom,
127 to: tradeTo,
128 provider: trade.provider,
131 - date: _formatTransactionDate(item.trade.createdAt ?? DateTime.now()),
129 + date: _formatTransactionDate(item.trade.createdAt ?? DateTime.now(), localeName),
130 amount: trade.amountFormatted(),
131 receiveAmount: trade.receiveAmountFormatted(),
132 roundedBottom: roundedBottom,
@@ -154,7 +152,7 @@ class HistorySection extends StatelessWidget {
152 onTap: () => Navigator.of(context)
153 .pushNamed(Routes.orderDetails, arguments: item.order),
154 child: HistoryOrderTile(
157 - date: _formatTransactionDate(item.order.createdAt),
155 + date: _formatTransactionDate(item.order.createdAt, localeName),
156 amount: item.orderFormattedAmount,
157 amountFiat: "USD 0.00",
158 roundedBottom: roundedBottom,
@@ -171,7 +169,7 @@ class HistorySection extends StatelessWidget {
169 arguments: [item.sessionId, item.transaction],
170 ),
171 child: PayjoinHistoryTile(
174 - createdAt: _formatTransactionDate(session.inProgressSince!),
172 + createdAt: _formatTransactionDate(session.inProgressSince!, localeName),
173 amount: dashboardViewModel.appStore.amountParsingProxy
174 .getDisplayCryptoString(
175 session.amount.toInt(), CryptoCurrency.btc),
@@ -190,7 +188,7 @@ class HistorySection extends StatelessWidget {
188 .pushNamed(Routes.anonPayDetailsPage, arguments: transactionInfo),
189 child: AnonpayHistoryTile(
190 provider: transactionInfo.provider,
193 - createdAt: _formatTransactionDate(transactionInfo.createdAt),
191 + createdAt: _formatTransactionDate(transactionInfo.createdAt, localeName),
192 amount: transactionInfo.fiatAmount?.toString() ??
193 (transactionInfo.amountTo?.toString() ?? ''),
194 currency: transactionInfo.fiatAmount != null
@@ -220,8 +218,8 @@ class HistorySection extends StatelessWidget {
218 }
219 }
220
223 - String _formatTransactionDate(DateTime date) {
224 - final time = DateFormat.Hm();
221 + String _formatTransactionDate(DateTime date, String localeName) {
222 + final time = DateFormat.Hm(localeName);
223
224 final now = DateTime.now();
225 final today = DateTime(now.year, now.month, now.day);
@@ -239,16 +237,16 @@ class HistorySection extends StatelessWidget {
237 }
238
239 if (daysAgo < 7) {
242 - final weekday = DateFormat.EEEE().format(date);
240 + final weekday = DateFormat.EEEE(localeName).format(date);
241 return "$weekday, $timeStr";
242 }
243
244 if (date.year == now.year) {
247 - final dayMonth = DateFormat("d MMMM").format(date);
245 + final dayMonth = DateFormat("d MMMM", localeName).format(date);
246 return "$dayMonth, $timeStr";
247 }
248
251 - final full = DateFormat("d MMM yyyy").format(date);
249 + final full = DateFormat("d MMM yyyy", localeName).format(date);
250 return "$full, $timeStr";
251 }
252 }