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