mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-09 20:39:35 +00:00
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:
parent
6fbc658156
commit
da6fd9a9ff
3 changed files with 32 additions and 31 deletions
|
@ -53,7 +53,10 @@ class SettingsPickerCell<ItemType extends Object> extends StandardListRow {
|
||||||
displayItem?.call(selectedItem) ?? selectedItem.toString(),
|
displayItem?.call(selectedItem) ?? selectedItem.toString(),
|
||||||
textAlign: TextAlign.right,
|
textAlign: TextAlign.right,
|
||||||
style: TextStyle(
|
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,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// ignore_for_file: deprecated_member_use
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:cake_wallet/src/widgets/alert_background.dart';
|
import 'package:cake_wallet/src/widgets/alert_background.dart';
|
||||||
import 'package:cake_wallet/src/widgets/alert_close_button.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;
|
final bool Function(Item, String)? matchingCriteria;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
PickerState createState() => PickerState<Item>(items, images, onItemSelected);
|
_PickerState<Item> createState() => _PickerState<Item>(items, images, onItemSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
class PickerState<Item> extends State<Picker> {
|
class _PickerState<Item> extends State<Picker> {
|
||||||
PickerState(this.items, this.images, this.onItemSelected);
|
_PickerState(this.items, this.images, this.onItemSelected);
|
||||||
|
|
||||||
final Function(Item) onItemSelected;
|
final Function(Item) onItemSelected;
|
||||||
List<Item> items;
|
List<Item> items;
|
||||||
|
@ -94,7 +96,7 @@ class PickerState<Item> extends State<Picker> {
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.all(Radius.circular(30)),
|
borderRadius: BorderRadius.all(Radius.circular(30)),
|
||||||
child: Container(
|
child: Container(
|
||||||
color: Theme.of(context).accentTextTheme!.headline6!.color!,
|
color: Theme.of(context).accentTextTheme.headline6!.color!,
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
maxHeight: MediaQuery.of(context).size.height * 0.65,
|
maxHeight: MediaQuery.of(context).size.height * 0.65,
|
||||||
|
@ -107,12 +109,12 @@ class PickerState<Item> extends State<Picker> {
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
controller: searchController,
|
controller: searchController,
|
||||||
style: TextStyle(color: Theme.of(context).primaryTextTheme!.headline6!.color!),
|
style: TextStyle(color: Theme.of(context).primaryTextTheme.headline6!.color!),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: widget.hintText,
|
hintText: widget.hintText,
|
||||||
prefixIcon: Image.asset("assets/images/search_icon.png"),
|
prefixIcon: Image.asset("assets/images/search_icon.png"),
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Theme.of(context).accentTextTheme!.headline3!.color!,
|
fillColor: Theme.of(context).accentTextTheme.headline3!.color!,
|
||||||
alignLabelWithHint: false,
|
alignLabelWithHint: false,
|
||||||
contentPadding: const EdgeInsets.symmetric(vertical: 4, horizontal: 16),
|
contentPadding: const EdgeInsets.symmetric(vertical: 4, horizontal: 16),
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: OutlineInputBorder(
|
||||||
|
@ -129,7 +131,7 @@ class PickerState<Item> extends State<Picker> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Divider(
|
Divider(
|
||||||
color: Theme.of(context).accentTextTheme!.headline6!.backgroundColor!,
|
color: Theme.of(context).accentTextTheme.headline6!.backgroundColor!,
|
||||||
height: 1,
|
height: 1,
|
||||||
),
|
),
|
||||||
if (widget.selectedAtIndex != -1) buildSelectedItem(),
|
if (widget.selectedAtIndex != -1) buildSelectedItem(),
|
||||||
|
@ -137,7 +139,7 @@ class PickerState<Item> extends State<Picker> {
|
||||||
child: Stack(
|
child: Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
(items?.length ?? 0) > 3 ? Scrollbar(
|
items.length > 3 ? Scrollbar(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
child: itemsList(),
|
child: itemsList(),
|
||||||
) : itemsList(),
|
) : itemsList(),
|
||||||
|
@ -154,7 +156,7 @@ class PickerState<Item> extends State<Picker> {
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
fontFamily: 'Lato',
|
fontFamily: 'Lato',
|
||||||
decoration: TextDecoration.none,
|
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() {
|
Widget itemsList() {
|
||||||
return Container(
|
return Container(
|
||||||
color: Theme.of(context).accentTextTheme!.headline6!.backgroundColor!,
|
color: Theme.of(context).accentTextTheme.headline6!.backgroundColor!,
|
||||||
child: widget.isGridView
|
child: widget.isGridView
|
||||||
? GridView.builder(
|
? GridView.builder(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
controller: controller,
|
controller: controller,
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
itemCount: items == null || items.isEmpty ? 0 : items.length,
|
itemCount: items.isEmpty ? 0 : items.length,
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: 2,
|
crossAxisCount: 2,
|
||||||
crossAxisSpacing: 2,
|
crossAxisSpacing: 2,
|
||||||
|
@ -198,11 +200,11 @@ class PickerState<Item> extends State<Picker> {
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
separatorBuilder: (context, index) => widget.isSeparated
|
separatorBuilder: (context, index) => widget.isSeparated
|
||||||
? Divider(
|
? Divider(
|
||||||
color: Theme.of(context).accentTextTheme!.headline6!.backgroundColor!,
|
color: Theme.of(context).accentTextTheme.headline6!.backgroundColor!,
|
||||||
height: 1,
|
height: 1,
|
||||||
)
|
)
|
||||||
: const SizedBox(),
|
: const SizedBox(),
|
||||||
itemCount: items == null || items.isEmpty ? 0 : items.length,
|
itemCount: items.isEmpty ? 0 : items.length,
|
||||||
itemBuilder: (context, index) => buildItem(index),
|
itemBuilder: (context, index) => buildItem(index),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -215,19 +217,16 @@ class PickerState<Item> extends State<Picker> {
|
||||||
}
|
}
|
||||||
|
|
||||||
final item = items[index];
|
final item = items[index];
|
||||||
final image = images != null ? images[index] : null;
|
final image = images.isNotEmpty ? images[index] : null;
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (onItemSelected == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
onItemSelected(item);
|
onItemSelected(item);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 55,
|
height: 55,
|
||||||
color: Theme.of(context).accentTextTheme!.headline6!.color!,
|
color: Theme.of(context).accentTextTheme.headline6!.color!,
|
||||||
padding: EdgeInsets.only(left: 24, right: 24),
|
padding: EdgeInsets.only(left: 24, right: 24),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
@ -245,7 +244,7 @@ class PickerState<Item> extends State<Picker> {
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontFamily: 'Lato',
|
fontFamily: 'Lato',
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Theme.of(context).primaryTextTheme!.headline6!.color!,
|
color: Theme.of(context).primaryTextTheme.headline6!.color!,
|
||||||
decoration: TextDecoration.none,
|
decoration: TextDecoration.none,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -259,11 +258,11 @@ class PickerState<Item> extends State<Picker> {
|
||||||
|
|
||||||
Widget buildSelectedItem() {
|
Widget buildSelectedItem() {
|
||||||
final item = widget.items[widget.selectedAtIndex];
|
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(
|
return Container(
|
||||||
height: 55,
|
height: 55,
|
||||||
color: Theme.of(context).accentTextTheme!.headline6!.color!,
|
color: Theme.of(context).accentTextTheme.headline6!.color!,
|
||||||
padding: EdgeInsets.only(left: 24, right: 24),
|
padding: EdgeInsets.only(left: 24, right: 24),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
@ -280,13 +279,13 @@ class PickerState<Item> extends State<Picker> {
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontFamily: 'Lato',
|
fontFamily: 'Lato',
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
color: Theme.of(context).primaryTextTheme!.headline6!.color!,
|
color: Theme.of(context).primaryTextTheme.headline6!.color!,
|
||||||
decoration: TextDecoration.none,
|
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!),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -9,22 +9,21 @@ class BuyAmountViewModel = BuyAmountViewModelBase with _$BuyAmountViewModel;
|
||||||
|
|
||||||
abstract class BuyAmountViewModelBase with Store {
|
abstract class BuyAmountViewModelBase with Store {
|
||||||
BuyAmountViewModelBase()
|
BuyAmountViewModelBase()
|
||||||
: amount = '' {
|
: amount = '',
|
||||||
|
fiatCurrency = FiatCurrency.usd {
|
||||||
int selectedIndex = FiatCurrency.currenciesAvailableToBuyWith
|
int selectedIndex = FiatCurrency.currenciesAvailableToBuyWith
|
||||||
.indexOf(getIt.get<SettingsStore>().fiatCurrency);
|
.indexOf(getIt.get<SettingsStore>().fiatCurrency);
|
||||||
|
|
||||||
if (selectedIndex == -1) {
|
if (selectedIndex != -1) {
|
||||||
selectedIndex = FiatCurrency.currenciesAvailableToBuyWith
|
|
||||||
.indexOf(FiatCurrency.usd);
|
|
||||||
}
|
|
||||||
fiatCurrency = FiatCurrency.currenciesAvailableToBuyWith[selectedIndex];
|
fiatCurrency = FiatCurrency.currenciesAvailableToBuyWith[selectedIndex];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
String amount;
|
String amount;
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
late FiatCurrency fiatCurrency;
|
FiatCurrency fiatCurrency;
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
double get doubleAmount {
|
double get doubleAmount {
|
||||||
|
|
Loading…
Reference in a new issue