mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-01 18:07:44 +00:00
42 lines
1.4 KiB
Dart
42 lines
1.4 KiB
Dart
import 'package:cake_wallet/entities/balance.dart';
|
|
import 'package:cake_wallet/entities/balance_display_mode.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:cake_wallet/monero/monero_amount_format.dart';
|
|
|
|
class MoneroBalance extends Balance {
|
|
MoneroBalance({@required this.fullBalance, @required this.unlockedBalance})
|
|
: formattedFullBalance = moneroAmountToString(amount: fullBalance),
|
|
formattedUnlockedBalance =
|
|
moneroAmountToString(amount: unlockedBalance),
|
|
super(const [
|
|
BalanceDisplayMode.availableBalance,
|
|
BalanceDisplayMode.fullBalance
|
|
]);
|
|
|
|
MoneroBalance.fromString(
|
|
{@required this.formattedFullBalance,
|
|
@required this.formattedUnlockedBalance})
|
|
: fullBalance = moneroParseAmount(amount: formattedFullBalance),
|
|
unlockedBalance = moneroParseAmount(amount: formattedUnlockedBalance),
|
|
super(const [
|
|
BalanceDisplayMode.availableBalance,
|
|
BalanceDisplayMode.fullBalance
|
|
]);
|
|
|
|
final int fullBalance;
|
|
final int unlockedBalance;
|
|
final String formattedFullBalance;
|
|
final String formattedUnlockedBalance;
|
|
|
|
@override
|
|
String formattedBalance(BalanceDisplayMode mode) {
|
|
switch (mode) {
|
|
case BalanceDisplayMode.fullBalance:
|
|
return formattedFullBalance;
|
|
case BalanceDisplayMode.availableBalance:
|
|
return formattedUnlockedBalance;
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
}
|