From 48dc741ceece693e4b18ea3753446c3845aba901 Mon Sep 17 00:00:00 2001 From: Godwin Asuquo Date: Wed, 20 Jul 2022 18:56:52 +0300 Subject: [PATCH] checkout screen fixes for ionia --- lib/ionia/ionia_tip.dart | 6 -- .../cards/ionia_buy_card_detail_page.dart | 87 +++---------------- .../ionia/cards/ionia_buy_gift_card.dart | 7 +- .../ionia/widgets/ionia_alert_modal.dart | 87 +++++++++++++++++++ .../ionia_purchase_merch_view_model.dart | 3 +- 5 files changed, 107 insertions(+), 83 deletions(-) create mode 100644 lib/src/screens/ionia/widgets/ionia_alert_modal.dart diff --git a/lib/ionia/ionia_tip.dart b/lib/ionia/ionia_tip.dart index 340c6226f..9e6487413 100644 --- a/lib/ionia/ionia_tip.dart +++ b/lib/ionia/ionia_tip.dart @@ -3,10 +3,4 @@ class IoniaTip { final double originalAmount; final double percentage; double get additionalAmount => double.parse((originalAmount * percentage / 100).toStringAsFixed(2)); - - static const tipList = [ - IoniaTip(originalAmount: 0, percentage: 0), - IoniaTip(originalAmount: 10, percentage: 10), - IoniaTip(originalAmount: 20, percentage: 20) - ]; } diff --git a/lib/src/screens/ionia/cards/ionia_buy_card_detail_page.dart b/lib/src/screens/ionia/cards/ionia_buy_card_detail_page.dart index abf9b3032..7f2325a5f 100644 --- a/lib/src/screens/ionia/cards/ionia_buy_card_detail_page.dart +++ b/lib/src/screens/ionia/cards/ionia_buy_card_detail_page.dart @@ -7,8 +7,8 @@ import 'package:cake_wallet/ionia/ionia_tip.dart'; import 'package:cake_wallet/palette.dart'; import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/src/screens/ionia/widgets/confirm_modal.dart'; +import 'package:cake_wallet/src/screens/ionia/widgets/ionia_alert_modal.dart'; import 'package:cake_wallet/src/screens/ionia/widgets/text_icon_button.dart'; -import 'package:cake_wallet/src/widgets/alert_background.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/src/widgets/discount_badge.dart'; import 'package:cake_wallet/src/widgets/primary_button.dart'; @@ -110,11 +110,8 @@ class IoniaBuyGiftCardDetailPage extends StatelessWidget { if (state is ExecutedSuccessfullyState) { WidgetsBinding.instance.addPostFrameCallback((_) { - Navigator.of(context).pushReplacementNamed( - Routes.ioniaPaymentStatusPage, - arguments: [ - ioniaPurchaseViewModel.paymentInfo, - ioniaPurchaseViewModel.committedInfo]); + Navigator.of(context).pushReplacementNamed(Routes.ioniaPaymentStatusPage, + arguments: [ioniaPurchaseViewModel.paymentInfo, ioniaPurchaseViewModel.committedInfo]); }); } }); @@ -161,7 +158,7 @@ class IoniaBuyGiftCardDetailPage extends StatelessWidget { ), SizedBox(height: 4), Text( - '\$${ioniaPurchaseViewModel.giftCardAmount}', + '\$${ioniaPurchaseViewModel.giftCardAmount.toStringAsFixed(2)}', style: textXLargeSemiBold(), ), SizedBox(height: 24), @@ -179,7 +176,7 @@ class IoniaBuyGiftCardDetailPage extends StatelessWidget { ), SizedBox(height: 4), Text( - '\$${ioniaPurchaseViewModel.amount}', + '\$${ioniaPurchaseViewModel.amount.toStringAsFixed(2)}', style: textLargeSemiBold(), ), ], @@ -193,7 +190,7 @@ class IoniaBuyGiftCardDetailPage extends StatelessWidget { ), SizedBox(height: 4), Text( - '\$$tipAmount', + '\$${tipAmount.toStringAsFixed(2)}', style: textLargeSemiBold(), ), ], @@ -273,11 +270,10 @@ class IoniaBuyGiftCardDetailPage extends StatelessWidget { showPopUp( context: context, builder: (BuildContext context) { - return AlertWithOneAction( - alertTitle: '', - alertContent: ioniaPurchaseViewModel.ioniaMerchant.termsAndConditions, - buttonText: S.of(context).agree, - buttonAction: () => Navigator.of(context).pop(), + return IoniaAlertModal( + title: '', + content: ioniaPurchaseViewModel.ioniaMerchant.termsAndConditions, + actionTitle: S.of(context).agree, ); }, ); @@ -298,65 +294,10 @@ class IoniaBuyGiftCardDetailPage extends StatelessWidget { showPopUp( context: context, builder: (BuildContext context) { - return AlertBackground( - child: Material( - color: Colors.transparent, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - SizedBox(height: 10), - Container( - padding: EdgeInsets.only(top: 24, left: 24, right: 24), - margin: EdgeInsets.all(24), - decoration: BoxDecoration( - color: Theme.of(context).backgroundColor, - borderRadius: BorderRadius.circular(30), - ), - child: Column( - children: [ - Text( - S.of(context).how_to_use_card, - style: textLargeSemiBold( - color: Theme.of(context).textTheme.body1.color, - ), - ), - SizedBox(height: 24), - Align( - alignment: Alignment.bottomLeft, - child: Text( - merchant.usageInstructionsBak, - style: textMedium( - color: Theme.of(context).textTheme.display2.color, - ), - ), - ), - SizedBox(height: 35), - PrimaryButton( - onPressed: () => Navigator.pop(context), - text: S.of(context).send_got_it, - color: Color.fromRGBO(233, 242, 252, 1), - textColor: Theme.of(context).textTheme.display2.color, - ), - SizedBox(height: 21), - ], - ), - ), - InkWell( - onTap: () => Navigator.pop(context), - child: Container( - margin: EdgeInsets.only(bottom: 40), - child: CircleAvatar( - child: Icon( - Icons.close, - color: Colors.black, - ), - backgroundColor: Colors.white, - ), - ), - ) - ], - ), - ), + return IoniaAlertModal( + title: S.of(context).how_to_use_card, + content: merchant.usageInstructionsBak, + actionTitle: S.current.send_got_it, ); }); } diff --git a/lib/src/screens/ionia/cards/ionia_buy_gift_card.dart b/lib/src/screens/ionia/cards/ionia_buy_gift_card.dart index 882dfdc88..d92253583 100644 --- a/lib/src/screens/ionia/cards/ionia_buy_gift_card.dart +++ b/lib/src/screens/ionia/cards/ionia_buy_gift_card.dart @@ -87,7 +87,8 @@ class IoniaBuyGiftCardPage extends BasePage { keyboardType: TextInputType.numberWithOptions(signed: false, decimal: true), inputFormatters: [ FilteringTextInputFormatter.deny(RegExp('[\-|\ ]')), - WhitelistingTextInputFormatter(RegExp(r'^\d+(\.|\,)?\d{0,2}'))], + WhitelistingTextInputFormatter(RegExp(r'^\d+(\.|\,)?\d{0,2}')) + ], hintText: '1000', placeholderTextStyle: TextStyle( color: Theme.of(context).primaryTextTheme.headline.color, @@ -124,13 +125,13 @@ class IoniaBuyGiftCardPage extends BasePage { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - S.of(context).min_amount(merchant.minimumCardPurchase.toString()), + S.of(context).min_amount(merchant.minimumCardPurchase.toStringAsFixed(2)), style: TextStyle( color: Theme.of(context).primaryTextTheme.headline.color, ), ), Text( - S.of(context).max_amount(merchant.maximumCardPurchase.toString()), + S.of(context).max_amount(merchant.maximumCardPurchase.toStringAsFixed(2)), style: TextStyle( color: Theme.of(context).primaryTextTheme.headline.color, ), diff --git a/lib/src/screens/ionia/widgets/ionia_alert_modal.dart b/lib/src/screens/ionia/widgets/ionia_alert_modal.dart new file mode 100644 index 000000000..3f31887ca --- /dev/null +++ b/lib/src/screens/ionia/widgets/ionia_alert_modal.dart @@ -0,0 +1,87 @@ +import 'package:cake_wallet/src/widgets/alert_background.dart'; +import 'package:cake_wallet/src/widgets/primary_button.dart'; +import 'package:cake_wallet/typography.dart'; +import 'package:flutter/material.dart'; + +class IoniaAlertModal extends StatelessWidget { + const IoniaAlertModal({ + Key key, + @required this.title, + @required this.content, + @required this.actionTitle, + }) : super(key: key); + + final String title; + final String content; + final String actionTitle; + @override + Widget build(BuildContext context) { + return AlertBackground( + child: Material( + color: Colors.transparent, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + SizedBox(height: 10), + Container( + padding: EdgeInsets.only(top: 24, left: 24, right: 24), + margin: EdgeInsets.all(24), + decoration: BoxDecoration( + color: Theme.of(context).backgroundColor, + borderRadius: BorderRadius.circular(30), + ), + child: Column( + children: [ + if (title.isNotEmpty) + Text( + title, + style: textLargeSemiBold( + color: Theme.of(context).textTheme.body1.color, + ), + ), + Container( + constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height * 0.4), + child: ListView( + children: [ + Align( + alignment: Alignment.bottomLeft, + child: Text( + content, + style: textMedium( + color: Theme.of(context).textTheme.display2.color, + ), + ), + ), + SizedBox(height: 35), + ], + ), + ), + PrimaryButton( + onPressed: () => Navigator.pop(context), + text: actionTitle, + color: Color.fromRGBO(233, 242, 252, 1), + textColor: Theme.of(context).textTheme.display2.color, + ), + SizedBox(height: 21), + ], + ), + ), + InkWell( + onTap: () => Navigator.pop(context), + child: Container( + margin: EdgeInsets.only(bottom: 40), + child: CircleAvatar( + child: Icon( + Icons.close, + color: Colors.black, + ), + backgroundColor: Colors.white, + ), + ), + ) + ], + ), + ), + ); + } +} diff --git a/lib/view_model/ionia/ionia_purchase_merch_view_model.dart b/lib/view_model/ionia/ionia_purchase_merch_view_model.dart index 10e7c1f5e..7fc66bc37 100644 --- a/lib/view_model/ionia/ionia_purchase_merch_view_model.dart +++ b/lib/view_model/ionia/ionia_purchase_merch_view_model.dart @@ -22,7 +22,8 @@ abstract class IoniaMerchPurchaseViewModelBase with Store { percentage = 0.0; tips = [ IoniaTip(percentage: 0, originalAmount: amount), - IoniaTip(percentage: 10, originalAmount: amount), + IoniaTip(percentage: 15, originalAmount: amount), + IoniaTip(percentage: 18, originalAmount: amount), IoniaTip(percentage: 20, originalAmount: amount), ]; selectedTip = tips.first;