Fix theme and nullability errors

This commit is contained in:
OmarHatem 2022-10-21 21:12:38 +02:00
parent 2fb05bccc1
commit b831165aca
23 changed files with 163 additions and 173 deletions

View file

@ -805,7 +805,7 @@ Future setup(
));
getIt.registerFactory(() {
final wallet = getIt.get<AppStore>().wallet;
final wallet = getIt.get<AppStore>().wallet!;
return AddBalanceViewModel(getIt.get<BuyAmountViewModel>(), wallet: wallet);
});

View file

@ -1,11 +1,11 @@
class PhoneNumberService {
const PhoneNumberService({
this.id,
this.phoneNumber,
this.planId,
this.usedUntil,
this.messageReceiveEnabled,
this.autoRenew,
required this.id,
required this.phoneNumber,
required this.planId,
required this.usedUntil,
this.messageReceiveEnabled = false,
this.autoRenew = false,
});
final String id;

View file

@ -2,10 +2,10 @@ import 'package:flutter/material.dart';
class ServicePlan {
const ServicePlan({
@required this.id,
@required this.duration,
@required this.price,
@required this.quantity,
required this.id,
required this.duration,
required this.price,
required this.quantity,
});
final String id;

View file

@ -190,7 +190,7 @@ class AddBalancePage extends BasePage {
.get<AppStore>()
.wallet
!.calculateEstimatedFee(
getIt.get<AppStore>().settingsStore!.priority[getIt.get<AppStore>().wallet!.type],
getIt.get<AppStore>().settingsStore.priority[getIt.get<AppStore>().wallet!.type]!,
addBalanceViewModel.buyAmountViewModel.doubleAmount.floor(),
)
.toDouble())),
@ -200,7 +200,7 @@ class AddBalancePage extends BasePage {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
const SizedBox(height: 16),
@ -220,8 +220,8 @@ class AddBalancePage extends BasePage {
isDividerExists: true,
rightButtonText: S.of(context).ok,
leftButtonText: S.of(context).cancel,
rightActionButtonColor: Theme.of(context).accentTextTheme.bodyText1?.color,
leftActionButtonColor: Theme.of(context).primaryTextTheme.bodyText1?.backgroundColor,
rightActionButtonColor: Theme.of(context).accentTextTheme.bodyText1!.color!,
leftActionButtonColor: Theme.of(context).primaryTextTheme.bodyText1!.backgroundColor!,
actionRightButton: () {
Navigator.of(dialogContext).pop();
showPaymentConfirmationPopup(context);
@ -244,15 +244,15 @@ class AddBalancePage extends BasePage {
// TODO: Make it reusable after finding the models related and use it here and in phone_number_product_page.dart
Widget cryptoAmount(double totalPrice) {
return FutureBuilder<BuyAmount>(
future: MoonPayBuyProvider(wallet: getIt.get<AppStore>().wallet)
future: MoonPayBuyProvider(wallet: getIt.get<AppStore>().wallet!)
.calculateAmount(totalPrice.toString(), FiatCurrency.usd.title),
builder: (context, AsyncSnapshot<BuyAmount> snapshot) {
double sourceAmount;
double destAmount;
if (snapshot.hasData) {
sourceAmount = snapshot.data.sourceAmount;
destAmount = snapshot.data.destAmount;
if (snapshot.hasData && snapshot.data != null) {
sourceAmount = snapshot.data!.sourceAmount;
destAmount = snapshot.data!.destAmount;
} else {
sourceAmount = 0.0;
destAmount = 0.0;
@ -262,11 +262,11 @@ class AddBalancePage extends BasePage {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${sourceAmount} ${getIt.get<AppStore>().wallet.currency.toString()}",
"${sourceAmount} ${getIt.get<AppStore>().wallet!.currency.toString()}",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w700,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
Text(
@ -290,7 +290,7 @@ class AddBalancePage extends BasePage {
builder: (dialogContext) {
return InfoAlertDialog(
alertTitle: S.of(context).awaiting_payment_confirmation,
alertTitleColor: Theme.of(context).primaryTextTheme.title.decorationColor,
alertTitleColor: Theme.of(context).primaryTextTheme.headline6?.decorationColor,
alertContentPadding: EdgeInsets.zero,
alertContent: Padding(
padding: const EdgeInsets.only(top: 8, bottom: 32),
@ -305,7 +305,7 @@ class AddBalancePage extends BasePage {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
),
@ -337,7 +337,7 @@ class AddBalancePage extends BasePage {
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
),
@ -357,7 +357,7 @@ class AddBalancePage extends BasePage {
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
),

View file

@ -1,7 +1,6 @@
import 'package:cake_wallet/palette.dart';
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
@ -9,7 +8,7 @@ import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
class CakePhoneAuthPage extends BasePage {
CakePhoneAuthPage({@required this.isLogin});
CakePhoneAuthPage({required this.isLogin});
final bool isLogin;
@ -24,7 +23,7 @@ class CakePhoneAuthPage extends BasePage {
fontSize: 22,
fontWeight: FontWeight.w700,
fontFamily: 'Lato',
color: Theme.of(context).primaryTextTheme.title.decorationColor),
color: Theme.of(context).primaryTextTheme.headline6?.decorationColor),
);
}
}
@ -58,9 +57,11 @@ class CakePhoneAuthBodyState extends State<CakePhoneAuthBody> {
keyboardType: TextInputType.emailAddress,
maxLines: 1,
hintText: S.of(context).email_address,
validator: (String text) {
text = text.trim();
if (text.isNotEmpty && RegExp(r"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$").hasMatch(text)) {
validator: (String? text) {
text = text?.trim();
if (text != null
&& text.isNotEmpty
&& RegExp(r"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$").hasMatch(text)) {
return null;
}
@ -130,7 +131,7 @@ class CakePhoneAuthBodyState extends State<CakePhoneAuthBody> {
void _registerCakePhone() {
// TODO: Add Registration logic
if (_formKey.currentState.validate()) {
if (_formKey.currentState!.validate()) {
Navigator.pushNamed(context, Routes.cakePhoneVerification);
} else {
setState(() {
@ -141,7 +142,7 @@ class CakePhoneAuthBodyState extends State<CakePhoneAuthBody> {
void _loginCakePhone() {
// TODO: Add Login logic
if (_formKey.currentState.validate()) {
if (_formKey.currentState!.validate()) {
Navigator.pushNamed(context, Routes.cakePhoneVerification);
} else {
setState(() {

View file

@ -1,6 +1,5 @@
import 'package:cake_wallet/routes.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
@ -18,7 +17,7 @@ class CakePhoneProductsPage extends BasePage {
fontSize: 22,
fontWeight: FontWeight.w700,
fontFamily: 'Lato',
color: Theme.of(context).primaryTextTheme.title.decorationColor),
color: Theme.of(context).primaryTextTheme.headline6?.decorationColor),
);
}
}
@ -44,7 +43,7 @@ class CakePhoneProductsBodyState extends State<CakePhoneProductsBody> {
"${S.of(context).choose_phone_products}:",
style: TextStyle(
fontSize: 16,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
fontFamily: 'Lato',
),
),

View file

@ -2,7 +2,6 @@ import 'dart:async';
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
@ -23,7 +22,7 @@ class CakePhoneVerificationPage extends BasePage {
fontSize: 22,
fontWeight: FontWeight.w700,
fontFamily: 'Lato',
color: Theme.of(context).primaryTextTheme.title.decorationColor),
color: Theme.of(context).primaryTextTheme.headline6?.decorationColor),
);
}
}
@ -77,7 +76,7 @@ class CakePhoneVerificationBodyState extends State<CakePhoneVerificationBody> {
S.of(context).fill_verification_code,
style: TextStyle(
fontSize: 16,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
fontFamily: 'Lato',
),
textAlign: TextAlign.center,
@ -100,20 +99,20 @@ class CakePhoneVerificationBodyState extends State<CakePhoneVerificationBody> {
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 12),
margin: EdgeInsets.only(bottom: 12),
decoration: BoxDecoration(
color: Theme.of(context).accentTextTheme.caption.color,
color: Theme.of(context).accentTextTheme.caption?.color,
borderRadius: BorderRadius.circular(6),
),
child: Text(
S.of(context).get_code,
style: TextStyle(
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
fontWeight: FontWeight.w900,
),
)),
),
validator: (String text) {
validator: (String? text) {
// TODO: check and apply verification constraints with backend
if (text.length < 4) {
if ((text?.length ?? 0) < 4) {
return S.of(context).invalid_verification_code;
}
return null;
@ -137,7 +136,7 @@ class CakePhoneVerificationBodyState extends State<CakePhoneVerificationBody> {
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w700,
color: Theme.of(context).textTheme.subtitle.color,
color: Theme.of(context).textTheme.subtitle2?.color,
),
),
],
@ -149,7 +148,7 @@ class CakePhoneVerificationBodyState extends State<CakePhoneVerificationBody> {
children: <Widget>[
PrimaryButton(
onPressed: () {
if (_formKey.currentState.validate()) {
if (_formKey.currentState!.validate()) {
Navigator.pushNamedAndRemoveUntil(
context,
Routes.cakePhoneProducts,

View file

@ -1,6 +1,5 @@
import 'package:cake_wallet/routes.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
@ -20,7 +19,7 @@ class CakePhoneWelcomePage extends BasePage {
fontSize: 22,
fontWeight: FontWeight.w700,
fontFamily: 'Lato',
color: Theme.of(context).primaryTextTheme.title.decorationColor),
color: Theme.of(context).primaryTextTheme.headline6?.decorationColor),
);
}
}
@ -43,7 +42,7 @@ class CakePhoneWelcomeBodyState extends State<CakePhoneWelcomeBody> {
S.of(context).cake_phone_introduction,
style: TextStyle(
fontSize: 16,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
fontFamily: 'Lato',
),
),
@ -63,7 +62,7 @@ class CakePhoneWelcomeBodyState extends State<CakePhoneWelcomeBody> {
child: Text(
S.of(context).already_have_account,
style: TextStyle(
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
fontWeight: FontWeight.w500,
),
),
@ -75,7 +74,7 @@ class CakePhoneWelcomeBodyState extends State<CakePhoneWelcomeBody> {
child: Text(
S.of(context).login,
style: TextStyle(
color: Theme.of(context).accentTextTheme.display1.color,
color: Theme.of(context).accentTextTheme.headline4?.color,
fontSize: 16,
fontWeight: FontWeight.w900,
),

View file

@ -3,7 +3,6 @@ import 'package:cake_wallet/src/screens/cake_phone/widgets/cake_phone_settings_t
import 'package:cake_wallet/src/screens/cake_phone/widgets/plan_card.dart';
import 'package:cake_wallet/view_model/cake_phone/phone_plan_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
@ -11,7 +10,7 @@ import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
class AutoRenewSettingsPage extends BasePage {
AutoRenewSettingsPage({@required this.phoneNumberService, @required this.phonePlanViewModel});
AutoRenewSettingsPage({required this.phoneNumberService, required this.phonePlanViewModel});
final PhoneNumberService phoneNumberService;
final PhonePlanViewModel phonePlanViewModel;
@ -27,7 +26,7 @@ class AutoRenewSettingsPage extends BasePage {
fontSize: 22,
fontWeight: FontWeight.w700,
fontFamily: 'Lato',
color: Theme.of(context).primaryTextTheme.title.decorationColor),
color: Theme.of(context).primaryTextTheme.headline6?.decorationColor),
);
}
}
@ -59,7 +58,7 @@ class AutoRenewSettingsBodyState extends State<AutoRenewSettingsBody> {
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
color: Theme.of(context).primaryTextTheme.title.decorationColor,
color: Theme.of(context).primaryTextTheme.headline6?.decorationColor,
fontFamily: 'Lato',
),
),
@ -113,7 +112,7 @@ class AutoRenewSettingsBodyState extends State<AutoRenewSettingsBody> {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
);
}),
@ -125,7 +124,7 @@ class AutoRenewSettingsBodyState extends State<AutoRenewSettingsBody> {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
),
@ -141,8 +140,8 @@ class AutoRenewSettingsBodyState extends State<AutoRenewSettingsBody> {
onPressed: () {
},
text: "${S.of(context).disable} ${S.of(context).auto_renew}",
color: Theme.of(context).accentTextTheme.caption.backgroundColor,
textColor: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).accentTextTheme.caption?.backgroundColor,
textColor: Theme.of(context).primaryTextTheme.headline6?.color,
),
const SizedBox(height: 8),
PrimaryButton(

View file

@ -3,14 +3,13 @@ import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/screens/cake_phone/widgets/cake_phone_settings_tile.dart';
import 'package:cake_wallet/view_model/cake_phone/phone_plan_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/standart_switch.dart';
import 'package:cake_wallet/entities/cake_phone_entities/phone_number_service.dart';
class NumberSettingsPage extends BasePage {
NumberSettingsPage({@required this.phoneNumberService, @required this.phonePlanViewModel});
NumberSettingsPage({required this.phoneNumberService, required this.phonePlanViewModel});
final PhoneNumberService phoneNumberService;
final PhonePlanViewModel phonePlanViewModel;
@ -26,7 +25,7 @@ class NumberSettingsPage extends BasePage {
fontSize: 22,
fontWeight: FontWeight.w700,
fontFamily: 'Lato',
color: Theme.of(context).primaryTextTheme.title.decorationColor),
color: Theme.of(context).primaryTextTheme.headline6?.decorationColor),
);
}
}
@ -42,7 +41,7 @@ class NumberSettingsBody extends StatefulWidget {
}
class NumberSettingsBodyState extends State<NumberSettingsBody> {
ServicePlan selectedPhoneNumberPlan;
ServicePlan? selectedPhoneNumberPlan;
bool blockIncomingSMS = true;
@override
@ -51,7 +50,7 @@ class NumberSettingsBodyState extends State<NumberSettingsBody> {
try {
selectedPhoneNumberPlan = widget.phonePlanViewModel.servicePlans
.firstWhere((element) => element.id == widget.phoneNumberService.planId);
?.firstWhere((element) => element.id == widget.phoneNumberService.planId);
} catch (err) {
// the current phone plan is no longer available so check for nullability
}
@ -72,7 +71,7 @@ class NumberSettingsBodyState extends State<NumberSettingsBody> {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
),
@ -87,13 +86,13 @@ class NumberSettingsBodyState extends State<NumberSettingsBody> {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
),
Icon(
Icons.arrow_forward_ios,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
size: 16,
),
],
@ -112,13 +111,13 @@ class NumberSettingsBodyState extends State<NumberSettingsBody> {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
),
Icon(
Icons.arrow_forward_ios,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
size: 16,
),
],
@ -134,7 +133,7 @@ class NumberSettingsBodyState extends State<NumberSettingsBody> {
child: Text(
S.of(context).block_incoming_sms,
style: TextStyle(
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
),

View file

@ -16,7 +16,6 @@ import 'package:cake_wallet/view_model/cake_phone/phone_plan_view_model.dart';
import 'package:country_pickers/country.dart';
import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:country_pickers/country_pickers.dart';
import 'package:country_pickers/countries.dart';
import 'package:cake_wallet/generated/i18n.dart';
@ -29,7 +28,7 @@ class PhoneNumberProductPage extends BasePage {
PhoneNumberProductPage(this.phonePlanViewModel, {this.phoneNumberService});
final PhonePlanViewModel phonePlanViewModel;
final PhoneNumberService phoneNumberService;
final PhoneNumberService? phoneNumberService;
@override
Widget body(BuildContext context) => PhoneNumberProductBody(phonePlanViewModel, phoneNumberService);
@ -42,7 +41,7 @@ class PhoneNumberProductPage extends BasePage {
fontSize: 22,
fontWeight: FontWeight.w700,
fontFamily: 'Lato',
color: Theme.of(context).primaryTextTheme.title.decorationColor),
color: Theme.of(context).primaryTextTheme.headline6?.decorationColor),
);
}
}
@ -51,7 +50,7 @@ class PhoneNumberProductBody extends StatefulWidget {
PhoneNumberProductBody(this.phonePlanViewModel, this.phoneNumberService);
final PhonePlanViewModel phonePlanViewModel;
final PhoneNumberService phoneNumberService;
final PhoneNumberService? phoneNumberService;
@override
PhoneNumberProductBodyState createState() => PhoneNumberProductBodyState();
@ -75,7 +74,7 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
color: Theme.of(context).primaryTextTheme.title.decorationColor,
color: Theme.of(context).primaryTextTheme.headline6?.decorationColor,
fontFamily: 'Lato',
),
),
@ -131,7 +130,7 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
);
}),
@ -140,11 +139,11 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
CakePhoneSettingsTile(
title: S.of(context).phone_number,
value: Text(
widget.phoneNumberService.phoneNumber,
widget.phoneNumberService!.phoneNumber,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
),
@ -173,7 +172,7 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
),
@ -183,7 +182,7 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
],
@ -191,7 +190,7 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
),
Icon(
Icons.arrow_forward_ios,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
size: 16,
),
],
@ -263,7 +262,7 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
);
}),
@ -294,7 +293,7 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
text: "\$${widget.phonePlanViewModel.totalPrice}",
style: TextStyle(
fontWeight: FontWeight.w700,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
],
@ -314,7 +313,7 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
builder: (dialogContext) {
return AlertWithTwoActions(
alertTitle: S.of(context).confirm_payment,
alertTitleColor: Theme.of(context).primaryTextTheme.title.decorationColor,
alertTitleColor: Theme.of(context).primaryTextTheme.headline6?.decorationColor,
alertContent: S.of(context).confirm_delete_template,
contentWidget: Column(
mainAxisSize: MainAxisSize.min,
@ -341,8 +340,8 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
});
},
text: "${S.of(context).pay_with} ${S.of(context).cake_pay_balance}",
color: Theme.of(context).accentTextTheme.caption.backgroundColor,
textColor: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).accentTextTheme.caption?.backgroundColor,
textColor: Theme.of(context).primaryTextTheme.headline6?.color,
),
const SizedBox(height: 8),
PrimaryButton(
@ -352,7 +351,7 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
builder: (dialogContext) {
return AlertWithTwoActions(
alertTitle: S.of(context).confirm_sending,
alertTitleColor: Theme.of(context).primaryTextTheme.title.decorationColor,
alertTitleColor: Theme.of(context).primaryTextTheme.headline6?.decorationColor,
alertContent: S.of(context).confirm_delete_template,
contentWidget: Column(
mainAxisSize: MainAxisSize.min,
@ -365,9 +364,9 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
title: S.of(context).send_fee,
value: cryptoAmount(getIt
.get<AppStore>()
.wallet
.wallet!
.calculateEstimatedFee(
getIt.get<AppStore>().settingsStore.priority[getIt.get<AppStore>().wallet.type],
getIt.get<AppStore>().settingsStore.priority[getIt.get<AppStore>().wallet!.type]!,
widget.phonePlanViewModel.totalPrice.floor(),
)
.toDouble()),
@ -378,7 +377,7 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
const SizedBox(height: 16),
@ -406,7 +405,7 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
actionLeftButton: () => Navigator.of(dialogContext).pop());
});
},
text: "${S.of(context).pay_with} ${getIt.get<AppStore>().wallet.currency.toString()}",
text: "${S.of(context).pay_with} ${getIt.get<AppStore>().wallet!.currency.toString()}",
color: Theme.of(context).accentTextTheme.bodyText1?.color,
textColor: Colors.white,
),
@ -433,7 +432,7 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
child: DottedBorder(
borderType: BorderType.Circle,
dashPattern: [3, 3],
color: Theme.of(context).primaryTextTheme.displayMedium?.color,
color: Theme.of(context).primaryTextTheme.headline2!.color!,
strokeWidth: 3,
child: Padding(
padding: const EdgeInsets.all(6),
@ -453,22 +452,22 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w700,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
);
}
Widget cryptoAmount(double totalPrice) {
return FutureBuilder<BuyAmount>(
future: MoonPayBuyProvider(wallet: getIt.get<AppStore>().wallet)
future: MoonPayBuyProvider(wallet: getIt.get<AppStore>().wallet!)
.calculateAmount(totalPrice.toString(), FiatCurrency.usd.title),
builder: (context, AsyncSnapshot<BuyAmount> snapshot) {
double sourceAmount;
double destAmount;
if (snapshot.hasData) {
sourceAmount = snapshot.data.sourceAmount;
destAmount = snapshot.data.destAmount;
if (snapshot.hasData && snapshot.data != null) {
sourceAmount = snapshot.data!.sourceAmount;
destAmount = snapshot.data!.destAmount;
} else {
sourceAmount = 0.0;
destAmount = 0.0;
@ -478,11 +477,11 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${sourceAmount} ${getIt.get<AppStore>().wallet.currency.toString()}",
"${sourceAmount} ${getIt.get<AppStore>().wallet!.currency.toString()}",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w700,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
Text(
@ -505,7 +504,7 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
builder: (dialogContext) {
return InfoAlertDialog(
alertTitle: S.of(context).awaiting_payment_confirmation,
alertTitleColor: Theme.of(context).primaryTextTheme.title.decorationColor,
alertTitleColor: Theme.of(context).primaryTextTheme.headline6?.decorationColor,
alertContentPadding: EdgeInsets.zero,
alertContent: Padding(
padding: const EdgeInsets.only(top: 8, bottom: 32),
@ -518,7 +517,7 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
),
@ -550,7 +549,7 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
),
@ -570,7 +569,7 @@ class PhoneNumberProductBodyState extends State<PhoneNumberProductBody> {
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
),
),

View file

@ -1,10 +1,10 @@
import 'package:flutter/material.dart';
class AddOptionsTile extends StatelessWidget {
const AddOptionsTile({Key key, @required this.leading, this.onTap}) : super(key: key);
const AddOptionsTile({Key? key, required this.leading, this.onTap}) : super(key: key);
final Widget leading;
final Function() onTap;
final Function()? onTap;
@override
Widget build(BuildContext context) {
@ -24,12 +24,12 @@ class AddOptionsTile extends StatelessWidget {
Container(
width: 2,
height: 48,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
),
const SizedBox(width: 16),
Icon(
Icons.add_circle,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
size: 24,
),
],

View file

@ -1,11 +1,11 @@
import 'package:flutter/material.dart';
class CakePhoneSettingsTile extends StatelessWidget {
const CakePhoneSettingsTile({Key key, @required this.value, this.title, this.onTap}) : super(key: key);
const CakePhoneSettingsTile({Key? key, required this.value, this.title, this.onTap}) : super(key: key);
final String title;
final String? title;
final Widget value;
final Function() onTap;
final Function()? onTap;
@override
Widget build(BuildContext context) {
@ -16,7 +16,7 @@ class CakePhoneSettingsTile extends StatelessWidget {
children: [
if (title != null)
Text(
title,
title!,
style: TextStyle(
color: Theme.of(context).accentTextTheme.subtitle1?.color,
),
@ -27,7 +27,7 @@ class CakePhoneSettingsTile extends StatelessWidget {
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Theme.of(context).accentTextTheme.title.backgroundColor,
color: Theme.of(context).accentTextTheme.headline6?.backgroundColor ?? Colors.transparent,
),
),
),

View file

@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
class InfoTextColumn extends StatelessWidget {
const InfoTextColumn({
Key key,
@required this.title,
@required this.subtitle,
Key? key,
required this.title,
required this.subtitle,
this.isReversed = false,
this.padding,
}) : super(key: key);
@ -12,7 +12,7 @@ class InfoTextColumn extends StatelessWidget {
final String title;
final String subtitle;
final bool isReversed;
final EdgeInsets padding;
final EdgeInsets? padding;
@override
Widget build(BuildContext context) {
@ -42,6 +42,6 @@ class InfoTextColumn extends StatelessWidget {
TextStyle titleTextStyle(BuildContext context) => TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Theme.of(context).primaryTextTheme.title.color,
color: Theme.of(context).primaryTextTheme.headline6?.color,
);
}

View file

@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:cake_wallet/generated/i18n.dart';
class PlanCard extends StatelessWidget {
const PlanCard({Key key, @required this.plan, @required this.onTap, this.isSelected = false}) : super(key: key);
const PlanCard({Key? key, required this.plan, required this.onTap, this.isSelected = false}) : super(key: key);
final ServicePlan plan;
final bool isSelected;
@ -36,7 +36,7 @@ class PlanCard extends StatelessWidget {
"\$${plan.price}/${S.of(context).month}",
style: TextStyle(
fontWeight: FontWeight.w500,
color: isSelected ? Colors.white : Theme.of(context).primaryTextTheme.title.color,
color: isSelected ? Colors.white : Theme.of(context).primaryTextTheme.headline6?.color,
),
),
Text(

View file

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
class ReceiptRow extends StatelessWidget {
const ReceiptRow({Key key, @required this.title, @required this.value}) : super(key: key);
const ReceiptRow({Key? key, required this.title, required this.value}) : super(key: key);
final String title;
final Widget value;

View file

@ -6,7 +6,7 @@ import 'package:cake_wallet/src/screens/cake_phone/widgets/add_options_tile.dart
import 'package:cake_wallet/src/screens/cake_phone/widgets/info_text_column.dart';
class SubscribedPhoneNumbers extends StatefulWidget {
const SubscribedPhoneNumbers({Key key}) : super(key: key);
const SubscribedPhoneNumbers({Key? key}) : super(key: key);
@override
_SubscribedPhoneNumbersState createState() => _SubscribedPhoneNumbersState();
@ -104,7 +104,7 @@ class _SubscribedPhoneNumbersState extends State<SubscribedPhoneNumbers> {
style: TextStyle(
fontSize: 16,
fontWeight: selected ? FontWeight.w700 : FontWeight.w500,
color: selected ? Colors.white : Theme.of(context).primaryTextTheme.title.color,
color: selected ? Colors.white : Theme.of(context).primaryTextTheme.headline6?.color,
),
),
),

View file

@ -1,17 +1,15 @@
import 'dart:ui';
import 'package:cake_wallet/src/widgets/base_alert_dialog.dart';
import 'package:flutter/cupertino.dart';
class AlertWithTwoActions extends BaseAlertDialog {
AlertWithTwoActions({
required this.alertTitle,
required this.alertContent,
required this.leftButtonText,
required this.rightButtonText,
required this.actionLeftButton,
required this.actionRightButton,
this.alertBarrierDismissible = true,
this.isDividerExist = false,
this.isDividerExists = false,
this.alertContent,
this.contentWidget,
this.leftActionButtonColor,
@ -21,18 +19,18 @@ class AlertWithTwoActions extends BaseAlertDialog {
final String alertTitle;
final String alertContent;
final String? alertContent;
final String leftButtonText;
final String rightButtonText;
final VoidCallback actionLeftButton;
final VoidCallback actionRightButton;
final bool alertBarrierDismissible;
final Color alertTitleColor;
final Color? alertTitleColor;
@override
String get titleText => alertTitle;
@override
String get contentText => alertContent;
String get contentText => alertContent ?? '';
@override
String get leftActionButtonText => leftButtonText;
@override
@ -44,13 +42,13 @@ class AlertWithTwoActions extends BaseAlertDialog {
@override
bool get barrierDismissible => alertBarrierDismissible;
@override
final Widget contentWidget;
final Widget? contentWidget;
@override
final bool isDividerExists;
@override
final Color leftActionButtonColor;
final Color? leftActionButtonColor;
@override
final Color rightActionButtonColor;
final Color? rightActionButtonColor;
@override
Color get titleColor => alertTitleColor;
Color? get titleColor => alertTitleColor;
}

View file

@ -11,11 +11,11 @@ class BaseAlertDialog extends StatelessWidget {
VoidCallback get actionLeft => () {};
VoidCallback get actionRight => () {};
bool get barrierDismissible => true;
Widget get contentWidget => null;
EdgeInsets get contentPadding => null;
Color get leftActionButtonColor => null;
Color get rightActionButtonColor => null;
Color get titleColor => null;
Widget? get contentWidget => null;
EdgeInsets? get contentPadding => null;
Color? get leftActionButtonColor => null;
Color? get rightActionButtonColor => null;
Color? get titleColor => null;
Widget title(BuildContext context) {
return Text(
@ -25,7 +25,7 @@ class BaseAlertDialog extends StatelessWidget {
fontSize: 20,
fontFamily: 'Lato',
fontWeight: FontWeight.w600,
color: titleColor ?? Theme.of(context).primaryTextTheme!.headline6!.color!,
color: titleColor ?? Theme.of(context).primaryTextTheme.headline6!.color!,
decoration: TextDecoration.none,
),
);
@ -39,7 +39,7 @@ class BaseAlertDialog extends StatelessWidget {
fontSize: 16,
fontWeight: FontWeight.normal,
fontFamily: 'Lato',
color: Theme.of(context).primaryTextTheme!.headline6!.color!,
color: Theme.of(context).primaryTextTheme.headline6!.color!,
decoration: TextDecoration.none,
),
);
@ -55,7 +55,7 @@ class BaseAlertDialog extends StatelessWidget {
Flexible(
child: Container(
width: double.infinity,
color: leftActionButtonColor ?? Theme.of(context).accentTextTheme!.bodyText1!.decorationColor!,
color: leftActionButtonColor ?? Theme.of(context).accentTextTheme.bodyText1!.decorationColor!,
child: TextButton(
onPressed: actionLeft,
child: Text(
@ -67,7 +67,7 @@ class BaseAlertDialog extends StatelessWidget {
fontWeight: FontWeight.w600,
color: leftActionButtonColor != null
? Colors.white
: Theme.of(context).primaryTextTheme!.bodyText1!.backgroundColor!,
: Theme.of(context).primaryTextTheme.bodyText1!.backgroundColor!,
decoration: TextDecoration.none,
),
)),
@ -81,7 +81,7 @@ class BaseAlertDialog extends StatelessWidget {
Flexible(
child: Container(
width: double.infinity,
color: rightActionButtonColor ?? Theme.of(context).accentTextTheme!.bodyText2!.backgroundColor!,
color: rightActionButtonColor ?? Theme.of(context).accentTextTheme.bodyText2!.backgroundColor!,
child: TextButton(
onPressed: actionRight,
child: Text(
@ -93,7 +93,7 @@ class BaseAlertDialog extends StatelessWidget {
fontWeight: FontWeight.w600,
color: rightActionButtonColor != null
? Colors.white
: Theme.of(context).primaryTextTheme!.bodyText2!.backgroundColor!,
: Theme.of(context).primaryTextTheme.bodyText2!.backgroundColor!,
decoration: TextDecoration.none,
),
)),
@ -120,7 +120,7 @@ class BaseAlertDialog extends StatelessWidget {
borderRadius: BorderRadius.all(Radius.circular(30)),
child: Container(
width: 300,
color: Theme.of(context).accentTextTheme!.headline6!.decorationColor!,
color: Theme.of(context).accentTextTheme.headline6!.decorationColor!,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[

View file

@ -3,17 +3,17 @@ import 'package:cake_wallet/src/widgets/base_alert_dialog.dart';
class InfoAlertDialog extends BaseAlertDialog {
InfoAlertDialog({
@required this.alertTitle,
@required this.alertContent,
required this.alertTitle,
required this.alertContent,
this.alertTitleColor,
this.alertContentPadding,
this.alertBarrierDismissible = true
});
final String alertTitle;
final Color alertTitleColor;
final Color? alertTitleColor;
final Widget alertContent;
final EdgeInsets alertContentPadding;
final EdgeInsets? alertContentPadding;
final bool alertBarrierDismissible;
@override
@ -29,10 +29,10 @@ class InfoAlertDialog extends BaseAlertDialog {
bool get isDividerExists => true;
@override
Color get titleColor => alertTitleColor;
Color? get titleColor => alertTitleColor;
@override
EdgeInsets get contentPadding => alertContentPadding;
EdgeInsets? get contentPadding => alertContentPadding;
@override
Widget actionButtons(BuildContext context) {

View file

@ -5,8 +5,8 @@ import 'package:flutter/material.dart';
class PrimaryButton extends StatelessWidget {
const PrimaryButton(
{required this.text,
required this.color,
required this.textColor,
this.textColor,
this.color,
this.onPressed,
this.isDisabled = false,
this.isDottedBorder = false,
@ -15,8 +15,8 @@ class PrimaryButton extends StatelessWidget {
final VoidCallback? onPressed;
final VoidCallback? onDisabledPressed;
final Color color;
final Color textColor;
final Color? color;
final Color? textColor;
final Color borderColor;
final String text;
final bool isDisabled;
@ -30,7 +30,7 @@ class PrimaryButton extends StatelessWidget {
child: TextButton(
onPressed: isDisabled
? (onDisabledPressed != null ? onDisabledPressed : null) : onPressed,
style: ButtonStyle(backgroundColor: MaterialStateProperty.all(isDisabled ? color.withOpacity(0.5) : color),
style: ButtonStyle(backgroundColor: MaterialStateProperty.all(isDisabled ? color?.withOpacity(0.5) : color),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(26.0),
@ -43,7 +43,7 @@ class PrimaryButton extends StatelessWidget {
fontSize: 15.0,
fontWeight: FontWeight.w600,
color: isDisabled
? textColor.withOpacity(0.5)
? textColor?.withOpacity(0.5)
: textColor)),
));
@ -63,14 +63,14 @@ class LoadingPrimaryButton extends StatelessWidget {
const LoadingPrimaryButton(
{required this.onPressed,
required this.text,
required this.color,
required this.textColor,
this.color,
this.textColor,
this.isDisabled = false,
this.isLoading = false});
final VoidCallback onPressed;
final Color color;
final Color textColor;
final Color? color;
final Color? textColor;
final bool isLoading;
final bool isDisabled;
final String text;
@ -82,7 +82,7 @@ class LoadingPrimaryButton extends StatelessWidget {
height: 52.0,
child: TextButton(
onPressed: (isLoading || isDisabled) ? null : onPressed,
style: ButtonStyle(backgroundColor: MaterialStateProperty.all(isDisabled ? color.withOpacity(0.5) : color),
style: ButtonStyle(backgroundColor: MaterialStateProperty.all(isDisabled ? color?.withOpacity(0.5) : color),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(26.0),
@ -96,7 +96,7 @@ class LoadingPrimaryButton extends StatelessWidget {
fontSize: 15.0,
fontWeight: FontWeight.w600,
color: isDisabled
? textColor.withOpacity(0.5)
? textColor?.withOpacity(0.5)
: textColor
)),
));

View file

@ -2,7 +2,6 @@ import 'package:cake_wallet/view_model/buy/buy_amount_view_model.dart';
import 'package:cw_core/crypto_currency.dart';
import 'package:cake_wallet/entities/fiat_currency.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:flutter/foundation.dart';
import 'package:mobx/mobx.dart';
import 'package:cw_core/wallet_base.dart';
@ -11,10 +10,9 @@ part 'add_balance_view_model.g.dart';
class AddBalanceViewModel = AddBalanceViewModelBase with _$AddBalanceViewModel;
abstract class AddBalanceViewModelBase with Store {
AddBalanceViewModelBase(this.buyAmountViewModel, {@required this.wallet}) {
isRunning = false;
isDisabled = true;
}
AddBalanceViewModelBase(this.buyAmountViewModel, {required this.wallet})
: this.isDisabled = true,
this.isRunning = false;
final BuyAmountViewModel buyAmountViewModel;
final WalletBase wallet;

View file

@ -8,8 +8,7 @@ part 'phone_plan_view_model.g.dart';
class PhonePlanViewModel = PhonePlanViewModelBase with _$PhonePlanViewModel;
abstract class PhonePlanViewModelBase with Store {
PhonePlanViewModelBase({this.selectedPlan}) {
additionalSms = 0;
PhonePlanViewModelBase({this.selectedPlan}) : this.additionalSms = 0 {
rateInCents = 20; // TODO: get from api
servicePlans = [
@ -21,25 +20,25 @@ abstract class PhonePlanViewModelBase with Store {
];
// TODO: servicePlans = _getServicesFromApi
selectedPlan ??= servicePlans.first;
selectedPlan ??= servicePlans!.first;
selectedCountry = countryList.firstWhere((element) => element.iso3Code == "USA");
}
@observable
ServicePlan selectedPlan;
ServicePlan? selectedPlan;
@observable
Country selectedCountry;
Country? selectedCountry;
@observable
List<ServicePlan> servicePlans;
List<ServicePlan>? servicePlans;
@observable
int additionalSms;
@observable
int rateInCents;
int? rateInCents;
@computed
double get totalPrice => (selectedPlan?.price ?? 0)