Flutter upgrade

This commit is contained in:
M
2022-10-12 13:09:57 -04:00
parent c921ad890a
commit 1beb18b045
505 changed files with 6657 additions and 5875 deletions
+24 -22
View File
@@ -49,16 +49,18 @@ class WalletNameForm extends StatefulWidget {
}
class _WalletNameFormState extends State<WalletNameForm> {
_WalletNameFormState(this._walletNewVM);
_WalletNameFormState(this._walletNewVM)
: _formKey = GlobalKey<FormState>(),
_languageSelectorKey = GlobalKey<SeedLanguageSelectorState>(),
_controller = TextEditingController();
static const aspectRatioImage = 1.22;
final _formKey = GlobalKey<FormState>();
final _languageSelectorKey = GlobalKey<SeedLanguageSelectorState>();
ReactionDisposer _stateReaction;
final GlobalKey<FormState> _formKey;
final GlobalKey<SeedLanguageSelectorState> _languageSelectorKey;
final WalletNewVM _walletNewVM;
final TextEditingController _controller = TextEditingController();
final TextEditingController _controller;
ReactionDisposer? _stateReaction;
@override
void initState() {
@@ -116,29 +118,29 @@ class _WalletNameFormState extends State<WalletNameForm> {
fontSize: 20.0,
fontWeight: FontWeight.w600,
color:
Theme.of(context).primaryTextTheme.title.color),
Theme.of(context).primaryTextTheme!.headline6!.color!),
decoration: InputDecoration(
hintStyle: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w500,
color: Theme.of(context)
.accentTextTheme
.display3
.color),
.accentTextTheme!
.headline2!
.color!),
hintText: S.of(context).wallet_name,
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context)
.accentTextTheme
.display3
.decorationColor,
.accentTextTheme!
.headline2!
.decorationColor!,
width: 1.0)),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context)
.accentTextTheme
.display3
.decorationColor,
.accentTextTheme!
.headline2!
.decorationColor!,
width: 1.0),
),
suffixIcon: IconButton(
@@ -164,9 +166,9 @@ class _WalletNameFormState extends State<WalletNameForm> {
child: Image.asset(
'assets/images/refresh_icon.png',
color: Theme.of(context)
.primaryTextTheme
.display1
.decorationColor,
.primaryTextTheme!
.headline4!
.decorationColor!,
),
),
),
@@ -186,7 +188,7 @@ class _WalletNameFormState extends State<WalletNameForm> {
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w500,
color: Theme.of(context).primaryTextTheme.title.color),
color: Theme.of(context).primaryTextTheme!.headline6!.color!),
),
),
Padding(
@@ -215,7 +217,7 @@ class _WalletNameFormState extends State<WalletNameForm> {
}
void _confirmForm() {
if (!_formKey.currentState.validate()) {
if (_formKey.currentState != null && !_formKey.currentState!.validate()) {
return;
}
if (_walletNewVM.nameExists(_walletNewVM.name)) {
@@ -231,7 +233,7 @@ class _WalletNameFormState extends State<WalletNameForm> {
} else {
_walletNewVM.create(
options: _walletNewVM.hasLanguageSelector
? _languageSelectorKey.currentState.selected
? _languageSelectorKey.currentState!.selected
: null);
}
}
@@ -5,7 +5,7 @@ import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/view_model/wallet_new_vm.dart';
import 'package:flushbar/flushbar.dart';
// import 'package:flushbar/flushbar.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:cake_wallet/themes/theme_base.dart';
import 'package:flutter/material.dart';
@@ -18,35 +18,29 @@ import 'package:cake_wallet/src/screens/new_wallet/widgets/select_button.dart';
import 'package:cake_wallet/wallet_types.g.dart';
class NewWalletTypePage extends BasePage {
NewWalletTypePage(this.walletNewVM, {this.onTypeSelected, this.isNewWallet});
NewWalletTypePage({required this.onTypeSelected});
final void Function(BuildContext, WalletType) onTypeSelected;
final bool isNewWallet;
final WalletNewVM walletNewVM;
final walletTypeImage = Image.asset('assets/images/wallet_type.png');
final walletTypeLightImage =
Image.asset('assets/images/wallet_type_light.png');
@override
String get title =>
isNewWallet ? S.current.new_wallet : S.current.wallet_list_restore_wallet;
String get title => S.current.wallet_list_restore_wallet;
@override
Widget body(BuildContext context) => WalletTypeForm(walletNewVM, isNewWallet,
onTypeSelected: onTypeSelected,
walletImage: currentTheme.type == ThemeType.dark
? walletTypeImage
: walletTypeLightImage);
Widget body(BuildContext context) => WalletTypeForm(
onTypeSelected: onTypeSelected,
walletImage: currentTheme.type == ThemeType.dark
? walletTypeImage
: walletTypeLightImage);
}
class WalletTypeForm extends StatefulWidget {
WalletTypeForm(this.walletNewVM, this.isNewWallet,
{this.onTypeSelected, this.walletImage});
WalletTypeForm({required this.onTypeSelected,
required this.walletImage});
final void Function(BuildContext, WalletType) onTypeSelected;
final WalletNewVM walletNewVM;
final bool isNewWallet;
final Image walletImage;
@override
@@ -54,6 +48,9 @@ class WalletTypeForm extends StatefulWidget {
}
class WalletTypeFormState extends State<WalletTypeForm> {
WalletTypeFormState()
: types = availableWalletTypes;
static const aspectRatioImage = 1.22;
final moneroIcon =
@@ -68,9 +65,10 @@ class WalletTypeFormState extends State<WalletTypeForm> {
final havenIcon =
Image.asset('assets/images/haven_logo.png', height: 24, width: 24);
WalletType selected;
WalletType? selected;
List<WalletType> types;
Flushbar<void> _progressBar;
// FIX-ME: Replace Flushbar
// Flushbar<void>? _progressBar;
@override
void initState() {
@@ -99,7 +97,7 @@ class WalletTypeFormState extends State<WalletTypeForm> {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Theme.of(context).primaryTextTheme.title.color),
color: Theme.of(context).primaryTextTheme!.headline6!.color!),
),
),
...types.map((type) => Padding(
@@ -116,7 +114,7 @@ class WalletTypeFormState extends State<WalletTypeForm> {
bottomSection: PrimaryButton(
onPressed: () => onTypeSelected(),
text: S.of(context).seed_language_next,
color: Theme.of(context).accentTextTheme.body2.color,
color: Theme.of(context).accentTextTheme!.bodyText1!.color!,
textColor: Colors.white,
isDisabled: selected == null,
),
@@ -134,38 +132,15 @@ class WalletTypeFormState extends State<WalletTypeForm> {
case WalletType.haven:
return havenIcon;
default:
return null;
throw Exception('_iconFor: Incorrect Wallet Type. Cannot find icon for Wallet Type: ${type.toString()}');
}
}
Future<void> onTypeSelected() async {
if (!widget.isNewWallet) {
widget.onTypeSelected(context, selected);
return;
if (selected == null) {
throw Exception('Wallet Type is not selected yet.');
}
try {
_changeProcessText(S.of(context).creating_new_wallet);
widget.walletNewVM.type = selected;
await widget.walletNewVM
.create(options: 'English'); // FIXME: Unnamed constant
await _progressBar?.dismiss();
final state = widget.walletNewVM.state;
if (state is ExecutedSuccessfullyState) {
widget.onTypeSelected(context, selected);
}
if (state is FailureState) {
_changeProcessText(
S.of(context).creating_new_wallet_error(state.error));
}
} catch (e) {
_changeProcessText(S.of(context).creating_new_wallet_error(e.toString()));
}
}
void _changeProcessText(String text) {
_progressBar = createBar<void>(text, duration: null)..show(context);
widget.onTypeSelected(context, selected!);
}
}
@@ -2,13 +2,13 @@ import 'package:flutter/material.dart';
class SelectButton extends StatelessWidget {
SelectButton({
@required this.image,
@required this.text,
@required this.onTap,
required this.text,
required this.onTap,
this.image,
this.isSelected = false,
});
final Image image;
final Image? image;
final String text;
final bool isSelected;
final VoidCallback onTap;
@@ -17,13 +17,13 @@ class SelectButton extends StatelessWidget {
Widget build(BuildContext context) {
final color = isSelected
? Colors.green
: Theme.of(context).accentTextTheme.caption.color;
: Theme.of(context).accentTextTheme!.caption!.color!;
final textColor = isSelected
? Theme.of(context).accentTextTheme.headline.decorationColor
: Theme.of(context).primaryTextTheme.title.color;
? Theme.of(context).accentTextTheme!.headline5!.decorationColor!
: Theme.of(context).primaryTextTheme!.headline6!.color!;
final arrowColor = isSelected
? Theme.of(context).accentTextTheme.headline.decorationColor
: Theme.of(context).accentTextTheme.subhead.color;
? Theme.of(context).accentTextTheme!.headline5!.decorationColor!
: Theme.of(context).accentTextTheme!.subtitle1!.color!;
final selectArrowImage = Image.asset('assets/images/select_arrow.png',
color: arrowColor);