From 9fdf817269c0966cad29a3848e5310e4bd158926 Mon Sep 17 00:00:00 2001 From: Catrya <140891948+Catrya@users.noreply.github.com> Date: Fri, 15 Aug 2025 17:46:12 -0600 Subject: [PATCH 1/4] feat: enhance walkthrough highlighting and localize payment methods - Add green highlighting for "create your own offer" text in walkthrough across all languages - Fix Spanish walkthrough highlighting: "Facturas Retenidas" now displays correctly - Localize payment method selection to display and send user's language to Mostro - Add Spanish/Italian translations for "Cash in person" ("Efectivo"/"Contanti di persona") and "Other" ("Otro"/"Altro") - Payment methods now sent to Mostro in user's selected language instead of English --- .../order/screens/add_order_screen.dart | 7 +++- .../widgets/payment_methods_section.dart | 34 ++++++++++++++----- .../screens/walkthrough_screen.dart | 8 +++-- .../walkthrough/utils/highlight_config.dart | 6 +++- lib/l10n/intl_en.arb | 2 ++ lib/l10n/intl_es.arb | 2 ++ lib/l10n/intl_it.arb | 2 ++ 7 files changed, 49 insertions(+), 12 deletions(-) diff --git a/lib/features/order/screens/add_order_screen.dart b/lib/features/order/screens/add_order_screen.dart index ed3cf9db5..2e0b1673a 100644 --- a/lib/features/order/screens/add_order_screen.dart +++ b/lib/features/order/screens/add_order_screen.dart @@ -296,7 +296,12 @@ class _AddOrderScreenState extends ConsumerState { if (_showCustomPaymentMethod && _customPaymentMethodController.text.isNotEmpty) { - paymentMethods.remove("Other"); + // Remove translated "Other" text from the list + paymentMethods.removeWhere((method) => + method == S.of(context)!.other || + method == "Other" || + method == "Otro" || + method == "Altro"); String sanitizedPaymentMethod = _customPaymentMethodController.text; diff --git a/lib/features/order/widgets/payment_methods_section.dart b/lib/features/order/widgets/payment_methods_section.dart index 377d90209..957147f5a 100644 --- a/lib/features/order/widgets/payment_methods_section.dart +++ b/lib/features/order/widgets/payment_methods_section.dart @@ -12,6 +12,20 @@ class PaymentMethodsSection extends ConsumerWidget { final TextEditingController customController; final Function(List, bool) onMethodsChanged; + /// Helper function to translate payment method names + String _translatePaymentMethod(String method, BuildContext context) { + switch (method) { + case 'Bank Transfer': + return S.of(context)!.bankTransfer; + case 'Cash in person': + return S.of(context)!.cashInPerson; + case 'Other': + return S.of(context)!.other; + default: + return method; + } + } + const PaymentMethodsSection({ super.key, required this.selectedMethods, @@ -63,10 +77,13 @@ class PaymentMethodsSection extends ConsumerWidget { List availableMethods = []; if (data.containsKey(selectedFiatCode)) { - availableMethods = List.from(data[selectedFiatCode]); + availableMethods = List.from(data[selectedFiatCode]) + .map((method) => _translatePaymentMethod(method, context)) + .toList(); } else { - availableMethods = List.from(data['default'] ?? - ['Bank Transfer', 'Cash in person', 'Other']); + availableMethods = List.from(data['default'] ?? ['Bank Transfer', 'Cash in person', 'Other']) + .map((method) => _translatePaymentMethod(method, context)) + .toList(); } return InkWell( @@ -110,12 +127,13 @@ class PaymentMethodsSection extends ConsumerWidget { Function(List, bool) onMethodsChanged, TextEditingController customController, ) { - if (!availableMethods.contains('Other')) { - availableMethods = [...availableMethods, 'Other']; + final translatedOther = _translatePaymentMethod('Other', context); + if (!availableMethods.contains(translatedOther)) { + availableMethods = [...availableMethods, translatedOther]; } List dialogSelectedMethods = List.from(selectedMethods); - bool dialogShowOtherField = dialogSelectedMethods.contains('Other'); + bool dialogShowOtherField = dialogSelectedMethods.contains(translatedOther); showDialog( context: context, @@ -145,12 +163,12 @@ class PaymentMethodsSection extends ConsumerWidget { setDialogState(() { if (selected == true) { dialogSelectedMethods.add(method); - if (method == 'Other') { + if (method == translatedOther) { dialogShowOtherField = true; } } else { dialogSelectedMethods.remove(method); - if (method == 'Other') { + if (method == translatedOther) { dialogShowOtherField = false; } } diff --git a/lib/features/walkthrough/screens/walkthrough_screen.dart b/lib/features/walkthrough/screens/walkthrough_screen.dart index 90b60392c..8a628bcf4 100644 --- a/lib/features/walkthrough/screens/walkthrough_screen.dart +++ b/lib/features/walkthrough/screens/walkthrough_screen.dart @@ -20,6 +20,7 @@ class _WalkthroughScreenState extends ConsumerState { bool isSecurityStep = false, bool isChatStep = false, bool isOrderBookStep = false, + bool isCreateOfferStep = false, }) { const defaultStyle = TextStyle(fontSize: 16, color: Color(0xFF9aa1b6)); const highlightStyle = TextStyle( @@ -39,7 +40,9 @@ class _WalkthroughScreenState extends ConsumerState { ? HighlightConfig.chat : isOrderBookStep ? HighlightConfig.orderBook - : HighlightConfig.firstStep; + : isCreateOfferStep + ? HighlightConfig.createOffer + : HighlightConfig.firstStep; final RegExp highlightRegex = RegExp(config.pattern, caseSensitive: true); @@ -149,7 +152,8 @@ class _WalkthroughScreenState extends ConsumerState { ), PageViewModel( title: S.of(context)!.cantFindWhatYouNeed, - bodyWidget: _buildHighlightedText(S.of(context)!.createYourOwnOffer), + bodyWidget: _buildHighlightedText(S.of(context)!.createYourOwnOffer, + isCreateOfferStep: true), image: buildPageImage("assets/images/wt-6.png"), decoration: pageDecoration, ), diff --git a/lib/features/walkthrough/utils/highlight_config.dart b/lib/features/walkthrough/utils/highlight_config.dart index e50cc7748..a2e0a3bfc 100644 --- a/lib/features/walkthrough/utils/highlight_config.dart +++ b/lib/features/walkthrough/utils/highlight_config.dart @@ -13,7 +13,7 @@ class HighlightConfig { ); static const security = HighlightConfig( - pattern: r'\b(Hold Invoices|Facturas de Retención|Fatture di Blocco)\b', + pattern: r'\b(Hold Invoices|Facturas Retenidas|Fatture di Blocco)\b', ); static const chat = HighlightConfig( @@ -24,4 +24,8 @@ class HighlightConfig { static const orderBook = HighlightConfig( pattern: r'\b(order book|libro de órdenes|libro ordini)\b', ); + + static const createOffer = HighlightConfig( + pattern: r'\b(create your own offer|crear tu propia oferta|creare la tua offerta)\b', + ); } diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index c43f77c24..0b8be7b0f 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -275,6 +275,8 @@ "buyingBitcoin": "Buying Bitcoin", "sellingBitcoin": "Selling Bitcoin", "bankTransfer": "Bank Transfer", + "cashInPerson": "Cash in person", + "other": "Other", "createdByYou": "Created by you", "takenByYou": "Taken by you", "active": "Active", diff --git a/lib/l10n/intl_es.arb b/lib/l10n/intl_es.arb index f42d88e0f..f69dd0bcd 100644 --- a/lib/l10n/intl_es.arb +++ b/lib/l10n/intl_es.arb @@ -227,6 +227,8 @@ "buyingBitcoin": "Comprando Bitcoin", "sellingBitcoin": "Vendiendo Bitcoin", "bankTransfer": "Transferencia Bancaria", + "cashInPerson": "Efectivo", + "other": "Otro", "createdByYou": "Creado por ti", "takenByYou": "Tomado por ti", "active": "Activo", diff --git a/lib/l10n/intl_it.arb b/lib/l10n/intl_it.arb index c5a5b5482..57a3bc211 100644 --- a/lib/l10n/intl_it.arb +++ b/lib/l10n/intl_it.arb @@ -236,6 +236,8 @@ "buyingBitcoin": "Comprando Bitcoin", "sellingBitcoin": "Vendendo Bitcoin", "bankTransfer": "Bonifico Bancario", + "cashInPerson": "Contanti di persona", + "other": "Altro", "createdByYou": "Creato da te", "takenByYou": "Preso da te", "active": "Attivo", From bbd358dbb3a3cc223543f9f42f30cc1bd4e9e4dc Mon Sep 17 00:00:00 2001 From: Catrya <140891948+Catrya@users.noreply.github.com> Date: Fri, 15 Aug 2025 18:01:48 -0600 Subject: [PATCH 2/4] refactor: normalize payment method comparison using localized strings --- lib/features/order/screens/add_order_screen.dart | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/features/order/screens/add_order_screen.dart b/lib/features/order/screens/add_order_screen.dart index 2e0b1673a..4c8756530 100644 --- a/lib/features/order/screens/add_order_screen.dart +++ b/lib/features/order/screens/add_order_screen.dart @@ -296,12 +296,11 @@ class _AddOrderScreenState extends ConsumerState { if (_showCustomPaymentMethod && _customPaymentMethodController.text.isNotEmpty) { - // Remove translated "Other" text from the list - paymentMethods.removeWhere((method) => - method == S.of(context)!.other || - method == "Other" || - method == "Otro" || - method == "Altro"); + // Remove localized "Other" (case-insensitive, trimmed) from the list + final localizedOther = S.of(context)!.other.trim().toLowerCase(); + paymentMethods.removeWhere( + (method) => method.trim().toLowerCase() == localizedOther, + ); String sanitizedPaymentMethod = _customPaymentMethodController.text; From 107170e85467379133d42550b940b6c6c3d75274 Mon Sep 17 00:00:00 2001 From: Catrya <140891948+Catrya@users.noreply.github.com> Date: Fri, 15 Aug 2025 18:11:14 -0600 Subject: [PATCH 3/4] fix: normalize payment method selection for proper checkbox pre-selection --- lib/features/order/widgets/payment_methods_section.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/features/order/widgets/payment_methods_section.dart b/lib/features/order/widgets/payment_methods_section.dart index 957147f5a..712a70f2a 100644 --- a/lib/features/order/widgets/payment_methods_section.dart +++ b/lib/features/order/widgets/payment_methods_section.dart @@ -132,7 +132,11 @@ class PaymentMethodsSection extends ConsumerWidget { availableMethods = [...availableMethods, translatedOther]; } - List dialogSelectedMethods = List.from(selectedMethods); + // Normalize to current locale so checkbox states align with localized labels + final localizedSelected = selectedMethods + .map((m) => _translatePaymentMethod(m, context)) + .toList(); + List dialogSelectedMethods = List.from(localizedSelected); bool dialogShowOtherField = dialogSelectedMethods.contains(translatedOther); showDialog( From 23ad2aa3d70b35d0a682c0fc47e5798567fd530a Mon Sep 17 00:00:00 2001 From: Catrya <140891948+Catrya@users.noreply.github.com> Date: Fri, 15 Aug 2025 18:19:00 -0600 Subject: [PATCH 4/4] fix: make walkthrough text highlighting case-insensitive and unicode-aware --- lib/features/walkthrough/screens/walkthrough_screen.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/features/walkthrough/screens/walkthrough_screen.dart b/lib/features/walkthrough/screens/walkthrough_screen.dart index 8a628bcf4..41360219b 100644 --- a/lib/features/walkthrough/screens/walkthrough_screen.dart +++ b/lib/features/walkthrough/screens/walkthrough_screen.dart @@ -44,7 +44,11 @@ class _WalkthroughScreenState extends ConsumerState { ? HighlightConfig.createOffer : HighlightConfig.firstStep; - final RegExp highlightRegex = RegExp(config.pattern, caseSensitive: true); + final RegExp highlightRegex = RegExp( + config.pattern, + caseSensitive: false, + unicode: true, + ); int start = 0; for (final match in highlightRegex.allMatches(text)) {