mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-01 12:04:21 +01:00
CW-143 cake pay custom tip amount (#492)
* Add custom tip logic * Fix euro currency
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import 'package:cake_wallet/ionia/ionia_merchant.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_tip.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'ionia_custom_tip_view_model.g.dart';
|
||||
|
||||
class IoniaCustomTipViewModel = IoniaCustomTipViewModelBase with _$IoniaCustomTipViewModel;
|
||||
|
||||
abstract class IoniaCustomTipViewModelBase with Store {
|
||||
IoniaCustomTipViewModelBase({this.amount, this.tip, this.ioniaMerchant}){
|
||||
customTip = tip;
|
||||
percentage = 0;
|
||||
}
|
||||
final IoniaMerchant ioniaMerchant;
|
||||
final double amount;
|
||||
final IoniaTip tip;
|
||||
|
||||
@observable
|
||||
IoniaTip customTip;
|
||||
|
||||
@observable
|
||||
double percentage;
|
||||
|
||||
@action
|
||||
void onTipChanged(String value){
|
||||
|
||||
final _amount = value.isEmpty ? 0 : double.parse(value.replaceAll(',', '.'));
|
||||
percentage = _amount/amount * 100;
|
||||
customTip = IoniaTip(percentage: percentage, originalAmount: amount);
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ abstract class IoniaMerchPurchaseViewModelBase with Store {
|
||||
IoniaTip(percentage: 15, originalAmount: amount),
|
||||
IoniaTip(percentage: 18, originalAmount: amount),
|
||||
IoniaTip(percentage: 20, originalAmount: amount),
|
||||
IoniaTip(percentage: 0, originalAmount: amount, isCustom: true),
|
||||
];
|
||||
selectedTip = tips.first;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user