From c921ad890a00bd700f96716eb01f39a09d20b266 Mon Sep 17 00:00:00 2001 From: Godwin Asuquo <41484542+godilite@users.noreply.github.com> Date: Mon, 19 Sep 2022 18:09:23 +0300 Subject: [PATCH] Truncate to double (#511) * Truncate to double * fix format remaining amount --- lib/src/screens/ionia/cards/ionia_custom_redeem_page.dart | 2 +- lib/view_model/ionia/ionia_custom_redeem_view_model.dart | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/src/screens/ionia/cards/ionia_custom_redeem_page.dart b/lib/src/screens/ionia/cards/ionia_custom_redeem_page.dart index 4bb76848f..88d8f4e97 100644 --- a/lib/src/screens/ionia/cards/ionia_custom_redeem_page.dart +++ b/lib/src/screens/ionia/cards/ionia_custom_redeem_page.dart @@ -117,7 +117,7 @@ class IoniaCustomRedeemPage extends BasePage { Observer(builder: (_)=> !ioniaCustomRedeemViewModel.disableRedeem ? Center( - child: Text('\$${giftCard.remainingAmount} - \$${ioniaCustomRedeemViewModel.amount} = \$${ioniaCustomRedeemViewModel.remaining} ${S.of(context).remaining}', + child: Text('\$${giftCard.remainingAmount} - \$${ioniaCustomRedeemViewModel.amount} = \$${ioniaCustomRedeemViewModel.formattedRemaining} ${S.of(context).remaining}', style: TextStyle( color: Theme.of(context).primaryTextTheme.headline.color, ),), diff --git a/lib/view_model/ionia/ionia_custom_redeem_view_model.dart b/lib/view_model/ionia/ionia_custom_redeem_view_model.dart index 88cc08e83..6bd8e15fa 100644 --- a/lib/view_model/ionia/ionia_custom_redeem_view_model.dart +++ b/lib/view_model/ionia/ionia_custom_redeem_view_model.dart @@ -16,6 +16,9 @@ abstract class IoniaCustomRedeemViewModelBase with Store { @computed double get remaining => amount <= giftCard.remainingAmount ? giftCard.remainingAmount - amount : 0; + @computed + String get formattedRemaining => remaining.toStringAsFixed(2); + @computed bool get disableRedeem => amount > giftCard.remainingAmount;