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
This commit is contained in:
Omar Hatem 2022-10-17 23:01:50 +02:00 committed by GitHub
parent 6fbc658156
commit da6fd9a9ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 31 deletions

View file

@ -53,7 +53,10 @@ class SettingsPickerCell<ItemType extends Object> 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,
),
);
}
}

View file

@ -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<Item extends Object> extends StatefulWidget {
final bool Function(Item, String)? matchingCriteria;
@override
PickerState createState() => PickerState<Item>(items, images, onItemSelected);
_PickerState<Item> createState() => _PickerState<Item>(items, images, onItemSelected);
}
class PickerState<Item> extends State<Picker> {
PickerState(this.items, this.images, this.onItemSelected);
class _PickerState<Item> extends State<Picker> {
_PickerState(this.items, this.images, this.onItemSelected);
final Function(Item) onItemSelected;
List<Item> items;
@ -94,7 +96,7 @@ class PickerState<Item> extends State<Picker> {
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<Item> extends State<Picker> {
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<Item> extends State<Picker> {
),
),
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<Item> extends State<Picker> {
child: Stack(
alignment: Alignment.center,
children: <Widget>[
(items?.length ?? 0) > 3 ? Scrollbar(
items.length > 3 ? Scrollbar(
controller: controller,
child: itemsList(),
) : itemsList(),
@ -154,7 +156,7 @@ class PickerState<Item> extends State<Picker> {
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<Item> extends State<Picker> {
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<Item> extends State<Picker> {
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<Item> extends State<Picker> {
}
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<Item> extends State<Picker> {
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<Item> extends State<Picker> {
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<Item> extends State<Picker> {
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!),
],
),
);

View file

@ -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<SettingsStore>().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 {