From ff12b4915e513f7754ad86acac80698732c76eba Mon Sep 17 00:00:00 2001 From: Chris Daley Date: Wed, 20 Nov 2024 01:15:49 -0800 Subject: [PATCH] Fixes to Code Rabbit's fixes... --- lib/data/models/mostro_message.dart | 2 +- lib/data/models/nostr_event.dart | 2 +- .../widgets/currency_dropdown.dart | 22 ++++++++----------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/lib/data/models/mostro_message.dart b/lib/data/models/mostro_message.dart index 5ccf9c12..c60781f3 100644 --- a/lib/data/models/mostro_message.dart +++ b/lib/data/models/mostro_message.dart @@ -39,7 +39,7 @@ class MostroMessage { ? order['id'] as String? : throw FormatException('Missing id field'); - final content = order['content'] ?? Content.fromJson(event['order']['content']) as T; + final content = order['content'] != null ? Content.fromJson(event['order']['content']) as T : null; return MostroMessage( action: action, diff --git a/lib/data/models/nostr_event.dart b/lib/data/models/nostr_event.dart index 5ca0d78f..33d7c758 100644 --- a/lib/data/models/nostr_event.dart +++ b/lib/data/models/nostr_event.dart @@ -9,7 +9,7 @@ extension NostrEventExtensions on NostrEvent { // Getters para acceder fácilmente a los tags específicos String? get recipient => _getTagValue('p'); String? get orderId => _getTagValue('d'); - OrderType? get orderType => OrderType.fromString(_getTagValue('k')!); + OrderType? get orderType => _getTagValue('k') != null ? OrderType.fromString(_getTagValue('k')!) : null; String? get currency => _getTagValue('f'); String? get status => _getTagValue('s'); String? get amount => _getTagValue('amt'); diff --git a/lib/presentation/widgets/currency_dropdown.dart b/lib/presentation/widgets/currency_dropdown.dart index 2e33b830..c0129464 100644 --- a/lib/presentation/widgets/currency_dropdown.dart +++ b/lib/presentation/widgets/currency_dropdown.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:mostro_mobile/core/theme/app_theme.dart'; import 'package:mostro_mobile/providers/exchange_service_provider.dart'; class CurrencyDropdown extends ConsumerWidget { @@ -13,18 +14,19 @@ class CurrencyDropdown extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final currencyCodesAsync = ref.watch(currencyCodesProvider); - final selectedFiatCode = ref.watch(selectedFiatCodeProvider) ?? ''; + final selectedFiatCode = ref.watch(selectedFiatCodeProvider); return Container( padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), decoration: BoxDecoration( - color: const Color(0xFF1D212C), + color: AppTheme.dark1, borderRadius: BorderRadius.circular(8), ), child: currencyCodesAsync.when( loading: () => const Center( child: SizedBox( - height: double.infinity, + height: 24, + width: 24, child: CircularProgressIndicator(), ), ), @@ -43,7 +45,7 @@ class CurrencyDropdown extends ConsumerWidget { value: code, child: Text( '$code - ${currencyCodes[code]}', - style: const TextStyle(color: Colors.white), + style: const TextStyle(color: AppTheme.cream1), ), ); }).toList(); @@ -52,18 +54,12 @@ class CurrencyDropdown extends ConsumerWidget { decoration: InputDecoration( border: InputBorder.none, labelText: label, - labelStyle: Theme.of(context).inputDecorationTheme.labelStyle, + labelStyle: const TextStyle(color: AppTheme.grey2), ), - dropdownColor: Theme.of(context).colorScheme.surface, - style: Theme.of(context).textTheme.bodyMedium, + dropdownColor: AppTheme.dark1, + style: TextStyle(color: AppTheme.cream1), items: items, value: selectedFiatCode, - validator: (value) { - if (value == null || value.isEmpty) { - return 'Please select a currency'; - } - return null; - }, onChanged: (value) => ref.read(selectedFiatCodeProvider.notifier).state = value, );