Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/features/order/screens/add_order_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,11 @@ class _AddOrderScreenState extends ConsumerState<AddOrderScreen> {
if (_showCustomPaymentMethod &&
_customPaymentMethodController.text.isNotEmpty) {

paymentMethods.remove("Other");
// Remove localized "Other" (case-insensitive, trimmed) from the list
final localizedOther = S.of(context)!.other.trim().toLowerCase();
paymentMethods.removeWhere(
(method) => method.trim().toLowerCase() == localizedOther,
);
Comment thread
Catrya marked this conversation as resolved.

String sanitizedPaymentMethod = _customPaymentMethodController.text;

Expand Down
40 changes: 31 additions & 9 deletions lib/features/order/widgets/payment_methods_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ class PaymentMethodsSection extends ConsumerWidget {
final TextEditingController customController;
final Function(List<String>, 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,
Expand Down Expand Up @@ -63,10 +77,13 @@ class PaymentMethodsSection extends ConsumerWidget {

List<String> availableMethods = [];
if (data.containsKey(selectedFiatCode)) {
availableMethods = List<String>.from(data[selectedFiatCode]);
availableMethods = List<String>.from(data[selectedFiatCode])
.map((method) => _translatePaymentMethod(method, context))
.toList();
} else {
availableMethods = List<String>.from(data['default'] ??
['Bank Transfer', 'Cash in person', 'Other']);
availableMethods = List<String>.from(data['default'] ?? ['Bank Transfer', 'Cash in person', 'Other'])
.map((method) => _translatePaymentMethod(method, context))
.toList();
}

return InkWell(
Expand Down Expand Up @@ -110,12 +127,17 @@ class PaymentMethodsSection extends ConsumerWidget {
Function(List<String>, bool) onMethodsChanged,
TextEditingController customController,
) {
if (!availableMethods.contains('Other')) {
availableMethods = [...availableMethods, 'Other'];
final translatedOther = _translatePaymentMethod('Other', context);
if (!availableMethods.contains(translatedOther)) {
availableMethods = [...availableMethods, translatedOther];
}

List<String> dialogSelectedMethods = List<String>.from(selectedMethods);
bool dialogShowOtherField = dialogSelectedMethods.contains('Other');
// Normalize to current locale so checkbox states align with localized labels
final localizedSelected = selectedMethods
.map((m) => _translatePaymentMethod(m, context))
.toList();
List<String> dialogSelectedMethods = List<String>.from(localizedSelected);
bool dialogShowOtherField = dialogSelectedMethods.contains(translatedOther);

showDialog(
context: context,
Expand Down Expand Up @@ -145,12 +167,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;
}
}
Expand Down
16 changes: 12 additions & 4 deletions lib/features/walkthrough/screens/walkthrough_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class _WalkthroughScreenState extends ConsumerState<WalkthroughScreen> {
bool isSecurityStep = false,
bool isChatStep = false,
bool isOrderBookStep = false,
bool isCreateOfferStep = false,
}) {
const defaultStyle = TextStyle(fontSize: 16, color: Color(0xFF9aa1b6));
const highlightStyle = TextStyle(
Expand All @@ -39,9 +40,15 @@ class _WalkthroughScreenState extends ConsumerState<WalkthroughScreen> {
? HighlightConfig.chat
: isOrderBookStep
? HighlightConfig.orderBook
: HighlightConfig.firstStep;

final RegExp highlightRegex = RegExp(config.pattern, caseSensitive: true);
: isCreateOfferStep
? HighlightConfig.createOffer
: HighlightConfig.firstStep;

final RegExp highlightRegex = RegExp(
config.pattern,
caseSensitive: false,
unicode: true,
);

int start = 0;
for (final match in highlightRegex.allMatches(text)) {
Expand Down Expand Up @@ -149,7 +156,8 @@ class _WalkthroughScreenState extends ConsumerState<WalkthroughScreen> {
),
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,
),
Expand Down
6 changes: 5 additions & 1 deletion lib/features/walkthrough/utils/highlight_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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',
);
}
2 changes: 2 additions & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/intl_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/intl_it.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down