mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-03 17:40:43 +00:00
code formatting
This commit is contained in:
parent
5a95fd4ab5
commit
05e7cb3a10
4 changed files with 53 additions and 71 deletions
|
@ -25,21 +25,18 @@ class ElectrumBalance extends Balance {
|
|||
final int frozen;
|
||||
|
||||
@override
|
||||
String get formattedAvailableBalance =>
|
||||
bitcoinAmountToString(amount: confirmed);
|
||||
String get formattedAvailableBalance => bitcoinAmountToString(amount: confirmed);
|
||||
|
||||
@override
|
||||
String get formattedAdditionalBalance =>
|
||||
bitcoinAmountToString(amount: unconfirmed);
|
||||
String get formattedAdditionalBalance => bitcoinAmountToString(amount: unconfirmed);
|
||||
|
||||
String get formattedFrozenBalance {
|
||||
final frozenFormatted = bitcoinAmountToString(amount: frozen);
|
||||
return frozenFormatted == '0.0' ? '' : frozenFormatted;
|
||||
return frozenFormatted == '0.0' ? '' : frozenFormatted;
|
||||
}
|
||||
|
||||
@override
|
||||
String get formattedTotalAvailableBalance =>
|
||||
bitcoinAmountToString(amount: confirmed - frozen);
|
||||
String get formattedTotalAvailableBalance => bitcoinAmountToString(amount: confirmed - frozen);
|
||||
|
||||
String toJSON() =>
|
||||
json.encode({'confirmed': confirmed, 'unconfirmed': unconfirmed, 'frozen': frozen});
|
||||
|
|
|
@ -33,15 +33,12 @@ class UnspentCoinsDetailsPage extends BasePage {
|
|||
final item = unspentCoinsDetailsViewModel.items[index];
|
||||
|
||||
if (item is StandartListItem) {
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(text: item.value));
|
||||
showBar<void>(context,
|
||||
S.of(context).transaction_details_copied(item.title));
|
||||
showBar<void>(context, S.of(context).transaction_details_copied(item.title));
|
||||
},
|
||||
child:
|
||||
ListRow(title: '${item.title}:', value: item.value),
|
||||
child: ListRow(title: '${item.title}:', value: item.value),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -54,18 +51,17 @@ class UnspentCoinsDetailsPage extends BasePage {
|
|||
}
|
||||
|
||||
if (item is UnspentCoinsSwitchItem) {
|
||||
return Observer(builder: (_) => UnspentCoinsSwitchRow(
|
||||
title: item.title,
|
||||
switchValue: item.switchValue(),
|
||||
onSwitchValueChange: item.onSwitchValueChange
|
||||
));
|
||||
return Observer(
|
||||
builder: (_) => UnspentCoinsSwitchRow(
|
||||
title: item.title,
|
||||
switchValue: item.switchValue(),
|
||||
onSwitchValueChange: item.onSwitchValueChange));
|
||||
}
|
||||
|
||||
if (item is BlockExplorerListItem) {
|
||||
return GestureDetector(
|
||||
onTap: item.onTap,
|
||||
child:
|
||||
ListRow(title: '${item.title}:', value: item.value),
|
||||
child: ListRow(title: '${item.title}:', value: item.value),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,21 +16,14 @@ class UnspentCoinsDetailsViewModel = UnspentCoinsDetailsViewModelBase
|
|||
with _$UnspentCoinsDetailsViewModel;
|
||||
|
||||
abstract class UnspentCoinsDetailsViewModelBase with Store {
|
||||
UnspentCoinsDetailsViewModelBase({
|
||||
required this.unspentCoinsItem,
|
||||
required this.unspentCoinsListViewModel})
|
||||
UnspentCoinsDetailsViewModelBase(
|
||||
{required this.unspentCoinsItem, required this.unspentCoinsListViewModel})
|
||||
: items = <TransactionDetailsListItem>[],
|
||||
isFrozen = unspentCoinsItem.isFrozen,
|
||||
note = unspentCoinsItem.note {
|
||||
items = [
|
||||
StandartListItem(
|
||||
title: S.current.transaction_details_amount,
|
||||
value: unspentCoinsItem.amount
|
||||
),
|
||||
StandartListItem(
|
||||
title: S.current.widgets_address,
|
||||
value: unspentCoinsItem.address
|
||||
),
|
||||
StandartListItem(title: S.current.transaction_details_amount, value: unspentCoinsItem.amount),
|
||||
StandartListItem(title: S.current.widgets_address, value: unspentCoinsItem.address),
|
||||
TextFieldListItem(
|
||||
title: S.current.note_tap_to_change,
|
||||
value: note,
|
||||
|
@ -39,27 +32,25 @@ abstract class UnspentCoinsDetailsViewModelBase with Store {
|
|||
unspentCoinsListViewModel.saveUnspentCoinInfo(unspentCoinsItem);
|
||||
}),
|
||||
UnspentCoinsSwitchItem(
|
||||
title: S.current.freeze,
|
||||
value: '',
|
||||
switchValue: () => isFrozen,
|
||||
onSwitchValueChange: (value) async {
|
||||
isFrozen = value;
|
||||
unspentCoinsItem.isFrozen = value;
|
||||
if (value) {
|
||||
unspentCoinsItem.isSending = !value;
|
||||
}
|
||||
await unspentCoinsListViewModel.saveUnspentCoinInfo(unspentCoinsItem);
|
||||
}
|
||||
),
|
||||
title: S.current.freeze,
|
||||
value: '',
|
||||
switchValue: () => isFrozen,
|
||||
onSwitchValueChange: (value) async {
|
||||
isFrozen = value;
|
||||
unspentCoinsItem.isFrozen = value;
|
||||
if (value) {
|
||||
unspentCoinsItem.isSending = !value;
|
||||
}
|
||||
await unspentCoinsListViewModel.saveUnspentCoinInfo(unspentCoinsItem);
|
||||
}),
|
||||
BlockExplorerListItem(
|
||||
title: S.current.view_in_block_explorer,
|
||||
value: _explorerDescription(unspentCoinsListViewModel.wallet.type),
|
||||
onTap: () {
|
||||
final url = Uri.parse(_explorerUrl(unspentCoinsListViewModel.wallet.type,
|
||||
unspentCoinsItem.hash));
|
||||
final url = Uri.parse(
|
||||
_explorerUrl(unspentCoinsListViewModel.wallet.type, unspentCoinsItem.hash));
|
||||
return launchUrl(url);
|
||||
}
|
||||
)
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -13,10 +13,9 @@ part 'unspent_coins_list_view_model.g.dart';
|
|||
class UnspentCoinsListViewModel = UnspentCoinsListViewModelBase with _$UnspentCoinsListViewModel;
|
||||
|
||||
abstract class UnspentCoinsListViewModelBase with Store {
|
||||
UnspentCoinsListViewModelBase({
|
||||
required this.wallet,
|
||||
required Box<UnspentCoinsInfo> unspentCoinsInfo})
|
||||
: _unspentCoinsInfo = unspentCoinsInfo {
|
||||
UnspentCoinsListViewModelBase(
|
||||
{required this.wallet, required Box<UnspentCoinsInfo> unspentCoinsInfo})
|
||||
: _unspentCoinsInfo = unspentCoinsInfo {
|
||||
bitcoin!.updateUnspents(wallet);
|
||||
}
|
||||
|
||||
|
@ -24,28 +23,27 @@ abstract class UnspentCoinsListViewModelBase with Store {
|
|||
final Box<UnspentCoinsInfo> _unspentCoinsInfo;
|
||||
|
||||
@computed
|
||||
ObservableList<UnspentCoinsItem> get items => ObservableList.of(bitcoin!.getUnspents(wallet).map((elem) {
|
||||
final amount = bitcoin!.formatterBitcoinAmountToString(amount: elem.value) +
|
||||
' ${wallet.currency.title}';
|
||||
ObservableList<UnspentCoinsItem> get items =>
|
||||
ObservableList.of(bitcoin!.getUnspents(wallet).map((elem) {
|
||||
final amount = bitcoin!.formatterBitcoinAmountToString(amount: elem.value) +
|
||||
' ${wallet.currency.title}';
|
||||
|
||||
final info = _unspentCoinsInfo.values
|
||||
.firstWhere((element) => element.walletId == wallet.id && element.hash == elem.hash);
|
||||
final info = _unspentCoinsInfo.values
|
||||
.firstWhere((element) => element.walletId == wallet.id && element.hash == elem.hash);
|
||||
|
||||
return UnspentCoinsItem(
|
||||
address: elem.address,
|
||||
amount: amount,
|
||||
hash: elem.hash,
|
||||
isFrozen: info.isFrozen,
|
||||
note: info.note,
|
||||
isSending: info.isSending
|
||||
);
|
||||
}));
|
||||
return UnspentCoinsItem(
|
||||
address: elem.address,
|
||||
amount: amount,
|
||||
hash: elem.hash,
|
||||
isFrozen: info.isFrozen,
|
||||
note: info.note,
|
||||
isSending: info.isSending);
|
||||
}));
|
||||
|
||||
Future<void> saveUnspentCoinInfo(UnspentCoinsItem item) async {
|
||||
try {
|
||||
final info = _unspentCoinsInfo.values
|
||||
.firstWhere((element) => element.walletId.contains(wallet.id) &&
|
||||
element.hash.contains(item.hash));
|
||||
final info = _unspentCoinsInfo.values.firstWhere(
|
||||
(element) => element.walletId.contains(wallet.id) && element.hash.contains(item.hash));
|
||||
|
||||
info.isFrozen = item.isFrozen;
|
||||
info.isSending = item.isSending;
|
||||
|
|
Loading…
Reference in a new issue