From 6fbc658156f255fd2a488830e2674da3e16648ba Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Mon, 17 Oct 2022 22:57:04 +0200 Subject: [PATCH 1/2] Cw 187 fix separator color (#538) * Revert commented color attribute for list separator * Handle theme nullability --- lib/src/widgets/standard_list.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/widgets/standard_list.dart b/lib/src/widgets/standard_list.dart index 53039a1ab..ae8978eb4 100644 --- a/lib/src/widgets/standard_list.dart +++ b/lib/src/widgets/standard_list.dart @@ -88,7 +88,7 @@ class StandardListSeparator extends StatelessWidget { color: Theme.of(context).backgroundColor, child: Container( height: height, - // color: Theme.of(context).primaryTextTheme!.headline6!.backgroundColor! + color: Theme.of(context).primaryTextTheme.headline6?.backgroundColor )); } } From da6fd9a9ffbac61a8c4074391e10109bed2f9085 Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Mon, 17 Oct 2022 23:01:50 +0200 Subject: [PATCH 2/2] Cw 188 fix grey screen (#537) * Fix late initialization exception when using late with Mobx Fix index out of range exception in picker * Add haven account list class to configure file to be generated in haven.dart --- .../widgets/settings_picker_cell.dart | 5 +- lib/src/widgets/picker.dart | 47 +++++++++---------- lib/view_model/buy/buy_amount_view_model.dart | 11 ++--- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/lib/src/screens/settings/widgets/settings_picker_cell.dart b/lib/src/screens/settings/widgets/settings_picker_cell.dart index 6785de4d5..1da2d6fc1 100644 --- a/lib/src/screens/settings/widgets/settings_picker_cell.dart +++ b/lib/src/screens/settings/widgets/settings_picker_cell.dart @@ -53,7 +53,10 @@ class SettingsPickerCell extends StandardListRow { displayItem?.call(selectedItem) ?? selectedItem.toString(), textAlign: TextAlign.right, style: TextStyle( - fontSize: 14.0, fontWeight: FontWeight.w500, color: Theme.of(context).primaryTextTheme!.overline!.color!), + fontSize: 14.0, + fontWeight: FontWeight.w500, + color: Theme.of(context).primaryTextTheme.overline?.color, + ), ); } } diff --git a/lib/src/widgets/picker.dart b/lib/src/widgets/picker.dart index 12f98be85..36aafe5aa 100644 --- a/lib/src/widgets/picker.dart +++ b/lib/src/widgets/picker.dart @@ -1,3 +1,5 @@ +// ignore_for_file: deprecated_member_use + import 'package:flutter/material.dart'; import 'package:cake_wallet/src/widgets/alert_background.dart'; import 'package:cake_wallet/src/widgets/alert_close_button.dart'; @@ -34,11 +36,11 @@ class Picker extends StatefulWidget { final bool Function(Item, String)? matchingCriteria; @override - PickerState createState() => PickerState(items, images, onItemSelected); + _PickerState createState() => _PickerState(items, images, onItemSelected); } -class PickerState extends State { - PickerState(this.items, this.images, this.onItemSelected); +class _PickerState extends State { + _PickerState(this.items, this.images, this.onItemSelected); final Function(Item) onItemSelected; List items; @@ -94,7 +96,7 @@ class PickerState extends State { child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(30)), child: Container( - color: Theme.of(context).accentTextTheme!.headline6!.color!, + color: Theme.of(context).accentTextTheme.headline6!.color!, child: ConstrainedBox( constraints: BoxConstraints( maxHeight: MediaQuery.of(context).size.height * 0.65, @@ -107,12 +109,12 @@ class PickerState extends State { padding: const EdgeInsets.all(16), child: TextFormField( controller: searchController, - style: TextStyle(color: Theme.of(context).primaryTextTheme!.headline6!.color!), + style: TextStyle(color: Theme.of(context).primaryTextTheme.headline6!.color!), decoration: InputDecoration( hintText: widget.hintText, prefixIcon: Image.asset("assets/images/search_icon.png"), filled: true, - fillColor: Theme.of(context).accentTextTheme!.headline3!.color!, + fillColor: Theme.of(context).accentTextTheme.headline3!.color!, alignLabelWithHint: false, contentPadding: const EdgeInsets.symmetric(vertical: 4, horizontal: 16), enabledBorder: OutlineInputBorder( @@ -129,7 +131,7 @@ class PickerState extends State { ), ), Divider( - color: Theme.of(context).accentTextTheme!.headline6!.backgroundColor!, + color: Theme.of(context).accentTextTheme.headline6!.backgroundColor!, height: 1, ), if (widget.selectedAtIndex != -1) buildSelectedItem(), @@ -137,7 +139,7 @@ class PickerState extends State { child: Stack( alignment: Alignment.center, children: [ - (items?.length ?? 0) > 3 ? Scrollbar( + items.length > 3 ? Scrollbar( controller: controller, child: itemsList(), ) : itemsList(), @@ -154,7 +156,7 @@ class PickerState extends State { fontWeight: FontWeight.w500, fontFamily: 'Lato', decoration: TextDecoration.none, - color: Theme.of(context).primaryTextTheme!.headline6!.color!, + color: Theme.of(context).primaryTextTheme.headline6!.color!, ), ), ) @@ -178,13 +180,13 @@ class PickerState extends State { Widget itemsList() { return Container( - color: Theme.of(context).accentTextTheme!.headline6!.backgroundColor!, + color: Theme.of(context).accentTextTheme.headline6!.backgroundColor!, child: widget.isGridView ? GridView.builder( padding: EdgeInsets.zero, controller: controller, shrinkWrap: true, - itemCount: items == null || items.isEmpty ? 0 : items.length, + itemCount: items.isEmpty ? 0 : items.length, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 2, @@ -198,11 +200,11 @@ class PickerState extends State { shrinkWrap: true, separatorBuilder: (context, index) => widget.isSeparated ? Divider( - color: Theme.of(context).accentTextTheme!.headline6!.backgroundColor!, + color: Theme.of(context).accentTextTheme.headline6!.backgroundColor!, height: 1, ) : const SizedBox(), - itemCount: items == null || items.isEmpty ? 0 : items.length, + itemCount: items.isEmpty ? 0 : items.length, itemBuilder: (context, index) => buildItem(index), ), ); @@ -215,19 +217,16 @@ class PickerState extends State { } final item = items[index]; - final image = images != null ? images[index] : null; + final image = images.isNotEmpty ? images[index] : null; return GestureDetector( onTap: () { - if (onItemSelected == null) { - return; - } Navigator.of(context).pop(); onItemSelected(item); }, child: Container( height: 55, - color: Theme.of(context).accentTextTheme!.headline6!.color!, + color: Theme.of(context).accentTextTheme.headline6!.color!, padding: EdgeInsets.only(left: 24, right: 24), child: Row( mainAxisSize: MainAxisSize.max, @@ -239,13 +238,13 @@ class PickerState extends State { child: Padding( padding: EdgeInsets.only(left: image != null ? 12 : 0), child: Text( - // What a hack (item as) ? + // What a hack (item as) ? widget.displayItem?.call(item as Object) ?? item.toString(), style: TextStyle( fontSize: 14, fontFamily: 'Lato', fontWeight: FontWeight.w600, - color: Theme.of(context).primaryTextTheme!.headline6!.color!, + color: Theme.of(context).primaryTextTheme.headline6!.color!, decoration: TextDecoration.none, ), ), @@ -259,11 +258,11 @@ class PickerState extends State { Widget buildSelectedItem() { final item = widget.items[widget.selectedAtIndex]; - final image = images != null ? widget.images[widget.selectedAtIndex] : null; + final image = images.isNotEmpty ? widget.images[widget.selectedAtIndex] : null; return Container( height: 55, - color: Theme.of(context).accentTextTheme!.headline6!.color!, + color: Theme.of(context).accentTextTheme.headline6!.color!, padding: EdgeInsets.only(left: 24, right: 24), child: Row( mainAxisSize: MainAxisSize.max, @@ -280,13 +279,13 @@ class PickerState extends State { fontSize: 16, fontFamily: 'Lato', fontWeight: FontWeight.w700, - color: Theme.of(context).primaryTextTheme!.headline6!.color!, + color: Theme.of(context).primaryTextTheme.headline6!.color!, decoration: TextDecoration.none, ), ), ), ), - Icon(Icons.check_circle, color: Theme.of(context).accentTextTheme!.bodyText1!.color!), + Icon(Icons.check_circle, color: Theme.of(context).accentTextTheme.bodyText1!.color!), ], ), ); diff --git a/lib/view_model/buy/buy_amount_view_model.dart b/lib/view_model/buy/buy_amount_view_model.dart index e6af75c24..8f23d9ef4 100644 --- a/lib/view_model/buy/buy_amount_view_model.dart +++ b/lib/view_model/buy/buy_amount_view_model.dart @@ -9,22 +9,21 @@ class BuyAmountViewModel = BuyAmountViewModelBase with _$BuyAmountViewModel; abstract class BuyAmountViewModelBase with Store { BuyAmountViewModelBase() - : amount = '' { + : amount = '', + fiatCurrency = FiatCurrency.usd { int selectedIndex = FiatCurrency.currenciesAvailableToBuyWith .indexOf(getIt.get().fiatCurrency); - if (selectedIndex == -1) { - selectedIndex = FiatCurrency.currenciesAvailableToBuyWith - .indexOf(FiatCurrency.usd); + if (selectedIndex != -1) { + fiatCurrency = FiatCurrency.currenciesAvailableToBuyWith[selectedIndex]; } - fiatCurrency = FiatCurrency.currenciesAvailableToBuyWith[selectedIndex]; } @observable String amount; @observable - late FiatCurrency fiatCurrency; + FiatCurrency fiatCurrency; @computed double get doubleAmount {