i18n: fit the long Tamil strings on the new UI (#3878)
What changed, and why it matters
This commit fixes visual layout bugs in the Cake Wallet mobile app where long Tamil translations were being drawn off-screen or clipped. It also fixes a broken unit test by adding a missing mock object. There is no security vulnerability here; it is a routine user-interface polish and test-maintenance change.
No security action required. Treat as a normal UI/UX and test-fix merge.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch addresses Flutter RenderFlex overflow and unbounded-width layout issues for Tamil (ta) and other Indic-script locales on the welcome, dashboard, and receive screens. Changes include bounding Positioned widgets, replacing Text with AutoSizeText, adding ConstrainedBox/FittedBox/Expanded constraints, reducing horizontal padding, and adding TextOverflow.ellipsis. A unit test for the settings page is updated to stub dashboardViewModel.settingsStore and its displayAmountsInSatoshi property so the test suite passes.
Changed components
lib/new-ui/widgets/coins_page/action_row/coin_action_button.dartlib/new-ui/widgets/coins_page/action_row/coin_action_row.dartlib/new-ui/widgets/modern_button.dartlib/new-ui/widgets/receive_page/receive_bottom_buttons.dartlib/src/screens/welcome/create_pin_welcome_page.darttest/new-ui/pages/settings_page_test.dartInspect captured patch +232 / −144
### lib/new-ui/widgets/coins_page/action_row/coin_action_button.dart
@@ -1,5 +1,7 @@
import "dart:math";
+import "package:auto_size_text/auto_size_text.dart";
+
import "package:cake_wallet/themes/core/theme_extension.dart";
import "package:flutter/material.dart";
import "package:flutter/services.dart";
@@ -66,11 +68,25 @@ class CoinActionButton extends StatelessWidget {
Padding(
padding: const EdgeInsets.only(top: 8),
child: ExcludeSemantics(
- child: Text(
- style: Theme.of(context).textTheme.bodySmall?.copyWith(
- color: Theme.of(context).colorScheme.onSurfaceVariant,
- ),
- label,
+ // Long translations (Tamil "பரிமாற்றம்", "ஸ்கேன் செய்யவும்")
+ // were wider than the circle and pushed the row past the
+ // screen edge; keep the caption inside the button's width.
+ child: ConstrainedBox(
+ constraints: BoxConstraints(maxWidth: effectiveSize + 12),
+ child: AutoSizeText(
+ textAlign: TextAlign.center,
+ maxLines: 2,
+ // The "copied" confirmation is one long word in Tamil
+ // ("நகலெடுக்கப்பட்டது") and cannot wrap, so allow a deep
+ // shrink and never clip silently.
+ minFontSize: 6,
+ overflow: TextOverflow.ellipsis,
+ wrapWords: false,
+ style: Theme.of(context).textTheme.bodySmall?.copyWith(
+ color: Theme.of(context).colorScheme.onSurfaceVariant,
+ ),
+ label,
+ ),
),
),
),
### lib/new-ui/widgets/coins_page/action_row/coin_action_row.dart
@@ -43,96 +43,104 @@ class CoinActionRow extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
spacing: MediaQuery.sizeOf(context).width * 0.05,
children: [
- CoinActionButton(
- key: ValueKey("home_page_send_button_key"),
- icon: CakeImageWidget(
- imageUrl: "assets/new-ui/send.svg",
- colorFilter: ColorFilter.mode(
- Theme.of(context).colorScheme.primary,
- BlendMode.srcIn,
+ Expanded(
+ child: CoinActionButton(
+ key: ValueKey("home_page_send_button_key"),
+ icon: CakeImageWidget(
+ imageUrl: "assets/new-ui/send.svg",
+ colorFilter: ColorFilter.mode(
+ Theme.of(context).colorScheme.primary,
+ BlendMode.srcIn,
+ ),
),
- ),
- label: S.of(context).send,
- action: () {
- final sendPage = getIt.get<NewSendPage>(
- param1: SendPageParams(
- unspentCoinType:
- lightningMode ? UnspentCoinType.lightning : UnspentCoinType.nonMweb,
- ),
- );
+ label: S.of(context).send,
+ action: () {
+ final sendPage = getIt.get<NewSendPage>(
+ param1: SendPageParams(
+ unspentCoinType:
+ lightningMode ? UnspentCoinType.lightning : UnspentCoinType.nonMweb,
+ ),
+ );
- CupertinoScaffold.showCupertinoModalBottomSheet(
- context: context,
- isDismissible: true,
- barrierColor: Colors.black.withAlpha(60),
- builder: (context) {
- return Material(
- child: ModalNavigator(
- rootPage: sendPage,
- parentContext: context,
- ),
- );
- },
- );
- },
- ),
- CoinActionButton(
- key: ValueKey("home_page_receive_button_key"),
- icon: CakeImageWidget(
- imageUrl: "assets/new-ui/receive.svg",
- colorFilter: ColorFilter.mode(
- Theme.of(context).colorScheme.primary,
- BlendMode.srcIn,
- ),
+ CupertinoScaffold.showCupertinoModalBottomSheet(
+ context: context,
+ isDismissible: true,
+ barrierColor: Colors.black.withAlpha(60),
+ builder: (context) {
+ return Material(
+ child: ModalNavigator(
+ rootPage: sendPage,
+ parentContext: context,
+ ),
+ );
+ },
+ );
+ },
),
- label: S.of(context).receive,
- action: () async {
- final page = getIt.get<NewReceivePage>(param1: lightningMode);
- CupertinoScaffold.showCupertinoModalBottomSheet(
- context: context,
- barrierColor: Colors.black.withAlpha(60),
- builder: (context) {
- return Material(child: ModalNavigator(parentContext: context, rootPage: page));
- },
- );
- },
),
- if (showSwap)
- CoinActionButton(
- key: ValueKey("home_page_swap_button_key"),
+ Expanded(
+ child: CoinActionButton(
+ key: ValueKey("home_page_receive_button_key"),
icon: CakeImageWidget(
- imageUrl: "assets/new-ui/exchange.svg",
+ imageUrl: "assets/new-ui/receive.svg",
colorFilter: ColorFilter.mode(
Theme.of(context).colorScheme.primary,
BlendMode.srcIn,
),
),
- label: S.of(context).swap,
- action: () {
- final page =
- getIt.get<NewSwapPage>(param2: lightningMode ? CryptoCurrency.btcln : null);
+ label: S.of(context).receive,
+ action: () async {
+ final page = getIt.get<NewReceivePage>(param1: lightningMode);
CupertinoScaffold.showCupertinoModalBottomSheet(
context: context,
- barrierColor: Colors.black.withAlpha(85),
- builder: (context) => Material(
- child: ModalNavigator(
- rootPage: page,
- parentContext: context,
- )),
+ barrierColor: Colors.black.withAlpha(60),
+ builder: (context) {
+ return Material(child: ModalNavigator(parentContext: context, rootPage: page));
+ },
);
},
),
- CoinActionButton(
- key: ValueKey("home_page_scan_button_key"),
- icon: CakeImageWidget(
- imageUrl: "assets/new-ui/scan.svg",
- colorFilter: ColorFilter.mode(
- Theme.of(context).colorScheme.primary,
- BlendMode.srcIn,
+ ),
+ if (showSwap)
+ Expanded(
+ child: CoinActionButton(
+ key: ValueKey("home_page_swap_button_key"),
+ icon: CakeImageWidget(
+ imageUrl: "assets/new-ui/exchange.svg",
+ colorFilter: ColorFilter.mode(
+ Theme.of(context).colorScheme.primary,
+ BlendMode.srcIn,
+ ),
+ ),
+ label: S.of(context).swap,
+ action: () {
+ final page =
+ getIt.get<NewSwapPage>(param2: lightningMode ? CryptoCurrency.btcln : null);
+ CupertinoScaffold.showCupertinoModalBottomSheet(
+ context: context,
+ barrierColor: Colors.black.withAlpha(85),
+ builder: (context) => Material(
+ child: ModalNavigator(
+ rootPage: page,
+ parentContext: context,
+ )),
+ );
+ },
+ ),
+ ),
+ Expanded(
+ child: CoinActionButton(
+ key: ValueKey("home_page_scan_button_key"),
+ icon: CakeImageWidget(
+ imageUrl: "assets/new-ui/scan.svg",
+ colorFilter: ColorFilter.mode(
+ Theme.of(context).colorScheme.primary,
+ BlendMode.srcIn,
+ ),
),
+ label: S.of(context).scan,
+ action: () => _onPressedScan(context),
),
- label: S.of(context).scan,
- action: () => _onPressedScan(context),
),
],
),
### lib/new-ui/widgets/modern_button.dart
@@ -1,3 +1,4 @@
+import 'package:auto_size_text/auto_size_text.dart';
import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
@@ -88,12 +89,28 @@ class ModernButton extends StatelessWidget {
),
if (label != null && label!.isNotEmpty)
ExcludeSemantics(
- child: Text(
- label!,
- style: TextStyle(
- fontSize: 12,
- fontWeight: FontWeight.w400,
- color: Theme.of(context).colorScheme.onSurface),
+ // The caption can be longer than the circle (Tamil
+ // "தொகையை அமைக்கவும்"); bound it to the button width so rows of
+ // buttons cannot overflow the screen.
+ child: ConstrainedBox(
+ constraints: BoxConstraints(maxWidth: size + 16),
+ // Tamil "தொகையை அமைக்கவும்" needs more room than the
+ // circle gives; shrink to fit rather than break mid-word.
+ child: AutoSizeText(
+ label!,
+ textAlign: TextAlign.center,
+ maxLines: 2,
+ // The "copied" confirmation is one long word in Tamil
+ // ("நகலெடுக்கப்பட்டது") and cannot wrap, so allow a deep
+ // shrink and never clip silently.
+ minFontSize: 6,
+ overflow: TextOverflow.ellipsis,
+ wrapWords: false,
+ style: TextStyle(
+ fontSize: 12,
+ fontWeight: FontWeight.w400,
+ color: Theme.of(context).colorScheme.onSurface),
+ ),
),
)
],
### lib/new-ui/widgets/receive_page/receive_bottom_buttons.dart
@@ -46,56 +46,67 @@ class _ReceiveBottomButtonsState extends State<ReceiveBottomButtons> {
opacity: targetOpacity,
curve: Curves.easeOut,
child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 32),
+ padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
- spacing: 16,
+ spacing: 12,
children: [
// The button itself is the only control: it copies when there
// is data to copy, otherwise it opens the payjoin copy modal.
- CopyWrapper(
- data: widget.copyData,
- controlBuilder: (context, copied, onCopy) => AnimatedSwitcher(
- duration: const Duration(milliseconds: 200),
- child: ModernButton.svg(
- key: ValueKey(copied),
- size: 60,
- iconSize: 32,
- svgPath: "assets/new-ui/copy.svg",
- onPressed: onCopy ?? widget.onCopyButtonPressed,
- label: copied ? S.of(context).copied : S.of(context).copy,
- iconColor: copied
- ? Theme.of(context).colorScheme.primary
- : Theme.of(context).colorScheme.surfaceContainer,
- backgroundColor: copied
- ? Theme.of(context).colorScheme.surfaceContainerHighest
- : Theme.of(context).colorScheme.primary,
+ // Each control gets an equal share of the row so localized
+ // captions ("தொகையை அமைக்கவும்") wrap inside their button
+ // instead of pushing the row past the screen edge.
+ Expanded(
+ child: CopyWrapper(
+ data: widget.copyData,
+ controlBuilder: (context, copied, onCopy) => AnimatedSwitcher(
+ duration: const Duration(milliseconds: 200),
+ child: ModernButton.svg(
+ key: ValueKey(copied),
+ size: 60,
+ iconSize: 32,
+ svgPath: "assets/new-ui/copy.svg",
+ onPressed: onCopy ?? widget.onCopyButtonPressed,
+ label: copied ? S.of(context).copied : S.of(context).copy,
+ iconColor: copied
+ ? Theme.of(context).colorScheme.primary
+ : Theme.of(context).colorScheme.surfaceContainer,
+ backgroundColor: copied
+ ? Theme.of(context).colorScheme.surfaceContainerHighest
+ : Theme.of(context).colorScheme.primary,
+ ),
),
),
),
- ModernButton.svg(
- size: 60,
- iconSize: 32,
- svgPath: "assets/new-ui/set-amount.svg",
- onPressed: widget.onAmountButtonPressed,
- label: S.of(context).set_amount,
- ),
- if (widget.showLabelButton)
- ModernButton.svg(
+ Expanded(
+ child: ModernButton.svg(
size: 60,
iconSize: 32,
- svgPath: "assets/new-ui/add-label.svg",
- onPressed: widget.onLabelButtonPressed,
- label: S.of(context).label,
+ svgPath: "assets/new-ui/set-amount.svg",
+ onPressed: widget.onAmountButtonPressed,
+ label: S.of(context).set_amount,
+ ),
+ ),
+ if (widget.showLabelButton)
+ Expanded(
+ child: ModernButton.svg(
+ size: 60,
+ iconSize: 32,
+ svgPath: "assets/new-ui/add-label.svg",
+ onPressed: widget.onLabelButtonPressed,
+ label: S.of(context).label,
+ ),
),
if (widget.showAccountsButton)
- ModernButton.svg(
- size: 60,
- iconSize: 32,
- svgPath: "assets/new-ui/addr-book.svg",
- onPressed: widget.onAccountsButtonPressed,
- label: S.of(context).addresses,
+ Expanded(
+ child: ModernButton.svg(
+ size: 60,
+ iconSize: 32,
+ svgPath: "assets/new-ui/addr-book.svg",
+ onPressed: widget.onAccountsButtonPressed,
+ label: S.of(context).addresses,
+ ),
),
],
),
### lib/src/screens/welcome/create_pin_welcome_page.dart
@@ -1,5 +1,6 @@
import 'dart:io';
+import 'package:auto_size_text/auto_size_text.dart';
import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
import 'package:cake_wallet/src/widgets/scrollable_with_bottom_section.dart';
import 'package:flutter/gestures.dart';
@@ -86,6 +87,13 @@ class CreatePinWelcomePage extends BasePage {
cakeLogoThemed = cakeLogoLight;
}
+ // The headline lives in a Positioned with only `top` set, which Flutter
+ // lays out with unbounded width: text there can neither wrap nor shrink,
+ // so a long word (Tamil "வரவேற்கிறோம்") is painted past both screen edges
+ // with no overflow report. Bound it to the visible width.
+ final headlineWidth =
+ MediaQuery.sizeOf(context).width.clamp(0.0, imageMaxWidth) - 32;
+
return PopScope(
canPop: false,
child: SafeArea(
@@ -113,10 +121,20 @@ class CreatePinWelcomePage extends BasePage {
),
Positioned(
top: (imageMaxWidth / imageAspectRatio) * 0.57,
+ // Positioned with only `top` gets unbounded width; `width`
+ // keeps the headline inside the screen.
+ width: headlineWidth,
child: Column(
children: <Widget>[
- Text(
+ // A single long word (Tamil "வரவேற்கிறோம்") cannot wrap:
+ // the Text keeps the box width and paints the glyphs
+ // past it, so the word is cut off at both screen
+ // edges without any overflow report. Shrink instead.
+ AutoSizeText(
S.current.welcome,
+ maxLines: 1,
+ minFontSize: 24,
+ wrapWords: false,
style: Theme.of(context).textTheme.displayLarge?.copyWith(
fontWeight: FontWeight.w700,
fontSize: 60,
@@ -127,6 +145,7 @@ class CreatePinWelcomePage extends BasePage {
),
SizedBox(height: 16),
Row(
+ mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
@@ -163,29 +182,34 @@ class CreatePinWelcomePage extends BasePage {
?.copyWith(fontWeight: FontWeight.w500),
textAlign: TextAlign.center,
),
+ // The headline above is width-bounded; keep this
+ // row inside the same box (Tamil "பெறுநர்").
if (!isMoneroOnly)
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: [
- AnimatedTypingText(
- words: [S.current.payments, S.current.privacy, S.current.security],
- style: Theme.of(context).textTheme.titleLarge?.copyWith(
- fontWeight: FontWeight.w600,
- color: Theme.of(context).colorScheme.primary,
- ),
- cursorColor: Theme.of(context).colorScheme.primary,
- cursorHeight: 28,
- cursorWidth: 4,
- ),
- SizedBox(width: 4),
- Text(
- S.current.made_easy,
- style: Theme.of(context).textTheme.titleLarge?.copyWith(
- fontWeight: FontWeight.w600,
- ),
- ),
- ],
+ FittedBox(
+ fit: BoxFit.scaleDown,
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ AnimatedTypingText(
+ words: [S.current.payments, S.current.privacy, S.current.security],
+ style: Theme.of(context).textTheme.titleLarge?.copyWith(
+ fontWeight: FontWeight.w600,
+ color: Theme.of(context).colorScheme.primary,
+ ),
+ cursorColor: Theme.of(context).colorScheme.primary,
+ cursorHeight: 28,
+ cursorWidth: 4,
+ ),
+ SizedBox(width: 4),
+ Text(
+ S.current.made_easy,
+ style: Theme.of(context).textTheme.titleLarge?.copyWith(
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ],
+ ),
),
],
),
### test/new-ui/pages/settings_page_test.dart
@@ -10,6 +10,8 @@ import "package:cake_wallet/routes.dart";
import "package:cake_wallet/view_model/dashboard/balance_view_model.dart";
import "package:cake_wallet/view_model/dashboard/dashboard_view_model.dart";
import "package:cake_wallet/view_model/wallet_account_list/monero_account_list/monero_account_list_view_model.dart";
+import "package:cake_wallet/entities/bitcoin_amount_display_mode.dart";
+import "package:cake_wallet/store/settings_store.dart";
import "package:cake_wallet/wallet_types.g.dart";
import "package:cw_core/balance.dart";
import "package:cw_core/crypto_currency.dart";
@@ -35,6 +37,8 @@ class _MockAccountListViewModel extends Mock implements MoneroAccountListViewMod
class _MockAuthService extends Mock implements AuthService {}
+class _MockSettingsStore extends Mock implements SettingsStore {}
+
class _MockDatabase extends Mock implements Database {}
class _MockWallet extends Mock
@@ -50,6 +54,7 @@ void main() {
late MockDashboardViewModel dashboardViewModel;
late _MockWallet wallet;
late _MockAuthService authService;
+ late _MockSettingsStore settingsStore;
setUpAll(() async {
english = await S.delegate.load(const Locale("en"));
@@ -63,6 +68,13 @@ void main() {
dashboardViewModel = MockDashboardViewModel();
wallet = _MockWallet();
authService = _MockAuthService();
+ settingsStore = _MockSettingsStore();
+
+ // Bitcoin settings read the amount display mode, so the store cannot be a
+ // bare mock.
+ when(() => dashboardViewModel.settingsStore).thenReturn(settingsStore);
+ when(() => settingsStore.displayAmountsInSatoshi)
+ .thenReturn(BitcoinAmountDisplayMode.bitcoin);
when(() => dashboardViewModel.balanceViewModel).thenReturn(balanceViewModel);
when(() => dashboardViewModel.isMultiAccountsEnabled).thenReturn(true);Why this scored 22/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.