code formatting

This commit is contained in:
Serhii 2023-03-27 10:27:54 +03:00
parent 5a95fd4ab5
commit 05e7cb3a10
4 changed files with 53 additions and 71 deletions

View file

@ -25,12 +25,10 @@ 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);
@ -38,8 +36,7 @@ class ElectrumBalance extends Balance {
}
@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});

View file

@ -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(
return Observer(
builder: (_) => UnspentCoinsSwitchRow(
title: item.title,
switchValue: item.switchValue(),
onSwitchValueChange: item.onSwitchValueChange
));
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),
);
}

View file

@ -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,
@ -49,17 +42,15 @@ abstract class UnspentCoinsDetailsViewModelBase with Store {
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);
}
)
})
];
}

View file

@ -13,9 +13,8 @@ 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})
UnspentCoinsListViewModelBase(
{required this.wallet, required Box<UnspentCoinsInfo> unspentCoinsInfo})
: _unspentCoinsInfo = unspentCoinsInfo {
bitcoin!.updateUnspents(wallet);
}
@ -24,7 +23,8 @@ abstract class UnspentCoinsListViewModelBase with Store {
final Box<UnspentCoinsInfo> _unspentCoinsInfo;
@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) +
' ${wallet.currency.title}';
@ -37,15 +37,13 @@ abstract class UnspentCoinsListViewModelBase with Store {
hash: elem.hash,
isFrozen: info.isFrozen,
note: info.note,
isSending: info.isSending
);
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;