Remove USD as the default fiat currency#250
Conversation
Changes Made: 1. Modified selectedFiatCodeProvider in lib/shared/providers/exchange_service_provider.dart to return String? instead of String and removed the ?? 'USD' fallback 2. Added localization keys in all ARB files (en/es/it): - "selectCurrency" - "Select Currency" / "Seleccionar Moneda" / "Seleziona Valuta" - "noCurrencySelected" - "No currency selected" / "Ninguna moneda seleccionada" / "Nessuna valuta selezionata" 3. Updated UI components to handle null currency selection: - currency_section.dart - Shows "Select Currency" when no currency is selected - settings_screen.dart - Shows "No currency selected" in settings when none chosen - add_order_screen.dart - Properly validates non-null currency before order submission - payment_methods_section.dart - Handles null currency code gracefully 4. Fixed all Flutter analyzer issues - Zero warnings or errors remain Now when the app is first installed, users will see "Select Currency" instead of USD, and they must explicitly choose a fiat currency before they can create orders. The selected currency persists in settings once chosen.
|
Caution Review failedThe pull request is closed. WalkthroughThis update refactors fiat currency selection and state management in the order and settings flows. It makes the fiat code provider nullable, resets it to the default on order screen initialization, improves null handling in UI and validation, and adds new localization strings for currency selection prompts in English, Spanish, and Italian. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant AddOrderScreen
participant SettingsProvider
participant selectedFiatCodeProvider
User->>AddOrderScreen: Navigates to Add Order
AddOrderScreen->>SettingsProvider: Fetch defaultFiatCode
AddOrderScreen->>selectedFiatCodeProvider: Reset to defaultFiatCode
User->>AddOrderScreen: Fills order form, submits
AddOrderScreen->>selectedFiatCodeProvider: Read selectedFiatCode
AddOrderScreen->>AddOrderScreen: Validate selectedFiatCode (null/empty)
AddOrderScreen->>Order: Create order with fiatCode
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Possibly related PRs
Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
lib/features/order/screens/add_order_screen.dart(5 hunks)lib/features/order/widgets/currency_section.dart(2 hunks)lib/features/order/widgets/payment_methods_section.dart(1 hunks)lib/features/settings/settings_screen.dart(2 hunks)lib/l10n/intl_en.arb(1 hunks)lib/l10n/intl_es.arb(1 hunks)lib/l10n/intl_it.arb(1 hunks)lib/shared/providers/exchange_service_provider.dart(1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
lib/l10n/*.arb
📄 CodeRabbit Inference Engine (CLAUDE.md)
lib/l10n/*.arb: Internationalization must useflutter_intlwith ARB files inlib/l10n/
Use proper ARB metadata for parameterized strings
Files:
lib/l10n/intl_es.arblib/l10n/intl_en.arblib/l10n/intl_it.arb
lib/l10n/intl_{en,es,it}.arb
📄 CodeRabbit Inference Engine (CLAUDE.md)
Add new localization keys to all three ARB files (en, es, it)
Files:
lib/l10n/intl_es.arblib/l10n/intl_en.arblib/l10n/intl_it.arb
lib/features/*/{screens,providers,notifiers,widgets}/**/*.dart
📄 CodeRabbit Inference Engine (CLAUDE.md)
Feature-based organization:
features/{feature}/{screens|providers|notifiers|widgets}/
Files:
lib/features/order/widgets/payment_methods_section.dartlib/features/order/widgets/currency_section.dartlib/features/order/screens/add_order_screen.dart
lib/**/*.dart
📄 CodeRabbit Inference Engine (CLAUDE.md)
lib/**/*.dart: UseS.of(context).yourKeyfor all user-facing strings
Always use localized strings instead of hardcoded text
Pass BuildContext to methods that need localization
Always use latest APIs (e.g.,withValues()instead ofwithOpacity())
Always checkmountedbefore using context after async operations
Files:
lib/features/order/widgets/payment_methods_section.dartlib/shared/providers/exchange_service_provider.dartlib/features/settings/settings_screen.dartlib/features/order/widgets/currency_section.dartlib/features/order/screens/add_order_screen.dart
**/*.dart
📄 CodeRabbit Inference Engine (CLAUDE.md)
**/*.dart: Remove unused imports and dependencies
Useconstconstructors where possible
Files:
lib/features/order/widgets/payment_methods_section.dartlib/shared/providers/exchange_service_provider.dartlib/features/settings/settings_screen.dartlib/features/order/widgets/currency_section.dartlib/features/order/screens/add_order_screen.dart
lib/shared/**/*.dart
📄 CodeRabbit Inference Engine (CLAUDE.md)
Shared utilities and widgets must be placed in
shared/
Files:
lib/shared/providers/exchange_service_provider.dart
🧠 Learnings (19)
📚 Learning: applies to lib/l10n/intl_{en,es,it}.arb : add new localization keys to all three arb files (en, es, ...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/l10n/intl_{en,es,it}.arb : Add new localization keys to all three ARB files (en, es, it)
Applied to files:
lib/l10n/intl_es.arblib/l10n/intl_en.arblib/l10n/intl_it.arb
📚 Learning: applies to lib/l10n/*.arb : use proper arb metadata for parameterized strings...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/l10n/*.arb : Use proper ARB metadata for parameterized strings
Applied to files:
lib/l10n/intl_es.arblib/l10n/intl_en.arblib/l10n/intl_it.arb
📚 Learning: applies to lib/l10n/*.arb : internationalization must use `flutter_intl` with arb files in `lib/l10n...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/l10n/*.arb : Internationalization must use `flutter_intl` with ARB files in `lib/l10n/`
Applied to files:
lib/l10n/intl_es.arblib/l10n/intl_en.arblib/l10n/intl_it.arb
📚 Learning: applies to lib/**/*.dart : pass buildcontext to methods that need localization...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/**/*.dart : Pass BuildContext to methods that need localization
Applied to files:
lib/features/order/widgets/payment_methods_section.dartlib/features/settings/settings_screen.dartlib/features/order/widgets/currency_section.dartlib/features/order/screens/add_order_screen.dart
📚 Learning: applies to lib/**/*.dart : always use localized strings instead of hardcoded text...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/**/*.dart : Always use localized strings instead of hardcoded text
Applied to files:
lib/features/order/widgets/payment_methods_section.dartlib/features/settings/settings_screen.dartlib/features/order/widgets/currency_section.dartlib/features/order/screens/add_order_screen.dart
📚 Learning: applies to lib/features/*/providers/**/*.dart : providers are organized by feature in `features/{fea...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/features/*/providers/**/*.dart : Providers are organized by feature in `features/{feature}/providers/`
Applied to files:
lib/shared/providers/exchange_service_provider.dartlib/features/order/widgets/currency_section.dartlib/features/order/screens/add_order_screen.dart
📚 Learning: in the mostro mobile codebase, `eventstorageprovider` is exported from `package:mostro_mobile/shared...
Learnt from: chebizarro
PR: MostroP2P/mobile#74
File: lib/services/mostro_service.dart:70-76
Timestamp: 2025-05-06T15:49:26.443Z
Learning: In the Mostro Mobile codebase, `eventStorageProvider` is exported from `package:mostro_mobile/shared/providers/mostro_service_provider.dart` and not from a separate `event_storage_provider.dart` file.
Applied to files:
lib/shared/providers/exchange_service_provider.dartlib/features/order/screens/add_order_screen.dart
📚 Learning: applies to lib/shared/providers/mostro_database_provider.dart : database initialization must occur i...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/shared/providers/mostro_database_provider.dart : Database initialization must occur in `shared/providers/mostro_database_provider.dart`
Applied to files:
lib/shared/providers/exchange_service_provider.dartlib/features/order/widgets/currency_section.dartlib/features/order/screens/add_order_screen.dart
📚 Learning: in the mostro mobile codebase, riverpod code generation is used with `@riverpod` annotations. provid...
Learnt from: chebizarro
PR: MostroP2P/mobile#74
File: lib/services/mostro_service.dart:70-76
Timestamp: 2025-05-06T15:49:26.443Z
Learning: In the Mostro Mobile codebase, Riverpod code generation is used with `@Riverpod` annotations. Providers like `eventStorageProvider` are generated in `.g.dart` files from annotated functions in the main provider files. These providers are accessible by importing the main provider file (e.g., `mostro_service_provider.dart`), not by importing a separate provider file.
Applied to files:
lib/shared/providers/exchange_service_provider.dart
📚 Learning: applies to lib/data/models.dart : models must be exported through `data/models.dart`...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/data/models.dart : Models must be exported through `data/models.dart`
Applied to files:
lib/shared/providers/exchange_service_provider.dartlib/features/order/screens/add_order_screen.dart
📚 Learning: applies to lib/features/*/{screens,providers,notifiers,widgets}/**/*.dart : feature-based organizati...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/features/*/{screens,providers,notifiers,widgets}/**/*.dart : Feature-based organization: `features/{feature}/{screens|providers|notifiers|widgets}/`
Applied to files:
lib/features/settings/settings_screen.dartlib/features/order/widgets/currency_section.dartlib/features/order/screens/add_order_screen.dart
📚 Learning: applies to **/*.dart : remove unused imports and dependencies...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to **/*.dart : Remove unused imports and dependencies
Applied to files:
lib/features/order/widgets/currency_section.dart
📚 Learning: applies to lib/**/*.dart : use `s.of(context).yourkey` for all user-facing strings...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/**/*.dart : Use `S.of(context).yourKey` for all user-facing strings
Applied to files:
lib/features/order/widgets/currency_section.dartlib/features/order/screens/add_order_screen.dart
📚 Learning: applies to lib/main.dart : locales for the timeago package must be configured in `main.dart` with `t...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/main.dart : Locales for the timeago package must be configured in `main.dart` with `timeago.setLocaleMessages()`
Applied to files:
lib/features/order/widgets/currency_section.dartlib/features/order/screens/add_order_screen.dart
📚 Learning: applies to test/mocks.mocks.dart : never manually edit `test/mocks.mocks.dart` - it's auto-generated...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to test/mocks.mocks.dart : Never manually edit `test/mocks.mocks.dart` - it's auto-generated by Mockito
Applied to files:
lib/features/order/widgets/currency_section.dart
📚 Learning: all changes should pass `flutter analyze` before commit...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: All changes should pass `flutter analyze` before commit
Applied to files:
lib/features/order/screens/add_order_screen.dart
📚 Learning: applies to lib/shared/**/*.dart : shared utilities and widgets must be placed in `shared/`...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/shared/**/*.dart : Shared utilities and widgets must be placed in `shared/`
Applied to files:
lib/features/order/screens/add_order_screen.dart
📚 Learning: applies to lib/services/nostr_service.dart : all nostr protocol interactions must go through `servic...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/services/nostr_service.dart : All Nostr protocol interactions must go through `services/nostr_service.dart`
Applied to files:
lib/features/order/screens/add_order_screen.dart
📚 Learning: mostroservice methods like takebuyorder() and takesellorder() return future and trigger side e...
Learnt from: chebizarro
PR: MostroP2P/mobile#110
File: test/notifiers/take_order_notifier_test.dart:72-74
Timestamp: 2025-06-04T19:35:20.209Z
Learning: MostroService methods like takeBuyOrder() and takeSellOrder() return Future<void> and trigger side effects through other mechanisms rather than direct return values. When testing these methods, focus on verifying method calls and testing state changes through the provider system rather than mocking return values.
Applied to files:
lib/features/order/screens/add_order_screen.dart
🪛 RuboCop (1.76.1)
lib/l10n/intl_es.arb
[warning] 735-735: Duplicated key in hash literal.
(Lint/DuplicateHashKey)
lib/l10n/intl_en.arb
[warning] 705-705: Duplicated key in hash literal.
(Lint/DuplicateHashKey)
lib/l10n/intl_it.arb
[warning] 743-743: Duplicated key in hash literal.
(Lint/DuplicateHashKey)
🔇 Additional comments (12)
lib/l10n/intl_es.arb (1)
735-736: LGTM: Proper Spanish localization added.The new localization keys
selectCurrencyandnoCurrencySelectedwith appropriate Spanish translations support the PR objective to handle null currency states properly.lib/l10n/intl_en.arb (1)
705-706: LGTM: Appropriate English localization added.The new localization keys
selectCurrencyandnoCurrencySelectedprovide clear English text for handling null currency selection states, aligning with the PR objectives.lib/features/order/widgets/payment_methods_section.dart (1)
30-30: LGTM: Proper null-safety handling.The null-coalescing operator ensures the localization method
paymentMethodsForCurrencyalways receives a non-null string, preventing runtime errors whenselectedFiatCodeis null. This aligns well with the PR changes to make currency selection nullable.lib/shared/providers/exchange_service_provider.dart (1)
30-33: LGTM! Correctly implements nullable fiat code selection.The change from
StringtoString?with null initialization successfully removes the automatic USD default and allows explicit currency selection. The removal of the settings import is also appropriate since it's no longer used.lib/features/order/screens/add_order_screen.dart (4)
18-18: LGTM! Proper import added for settings provider.The settings provider import is correctly added to support the new initialization logic.
65-67: LGTM! Explicit currency initialization from settings.The initialization logic properly sets the selected fiat code from the user's default settings when the screen loads. This ensures each new order starts with the appropriate currency selected while maintaining the nullable provider pattern.
259-270: LGTM! Improved null safety in validation logic.The validation now properly handles both null and empty string cases, and the introduction of the
fiatCodevariable after validation provides type safety for downstream usage. This is a clean approach to null handling.
327-327: LGTM! Using the validated non-null fiatCode variable.Correctly using the
fiatCodevariable instead of the potentially nullselectedFiatCodeensures type safety in the Order creation.lib/features/settings/settings_screen.dart (1)
386-421: LGTM! Correctly updated currency display logic.The changes properly shift from reading
selectedFiatCodeProvidertosettingsProvider.defaultFiatCode, which makes sense for the settings screen. The null handling with localized fallback text (noCurrencySelected) is well implemented and follows the localization guidelines.lib/features/order/widgets/currency_section.dart (3)
35-45: LGTM! Proper nullable currency handling implemented.The initialization of
namewith the localizedselectCurrencystring and the conditional currency lookup only whenselectedFiatCodeis not null demonstrates good null safety practices. The logic correctly handles both the selected and unselected states.
64-64: LGTM! Key generation handles null case appropriately.The key now properly handles the null case by using
'none'as a fallback, ensuring consistent widget identity management.
69-69: LGTM! Improved display text logic.The conditional display logic elegantly shows either the full "CODE - Name" format when a currency is selected or just the localized "Select Currency" text when none is selected.
Changes Made:
Now when the app is first installed, users will see "Select Currency" instead of USD, and they must explicitly choose a fiat currency before they can create orders. The selected currency persists in settings once chosen.
Summary by CodeRabbit
New Features
Bug Fixes
Style