You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cake_wallet/lib/view_model/unspent_coins/unspent_coins_details_view_...

63 lines
2.2 KiB

import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart';
import 'package:cake_wallet/src/screens/transaction_details/textfield_list_item.dart';
import 'package:cake_wallet/src/screens/transaction_details/transaction_details_list_item.dart';
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_item.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_list_view_model.dart';
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_switch_item.dart';
import 'package:mobx/mobx.dart';
part 'unspent_coins_details_view_model.g.dart';
class UnspentCoinsDetailsViewModel = UnspentCoinsDetailsViewModelBase
with _$UnspentCoinsDetailsViewModel;
abstract class UnspentCoinsDetailsViewModelBase with Store {
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
),
TextFieldListItem(
title: S.current.note_tap_to_change,
value: note,
onSubmitted: (value) {
unspentCoinsItem.note = value;
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);
}
)
];
}
@observable
bool isFrozen;
@observable
String note;
final UnspentCoinsItem unspentCoinsItem;
final UnspentCoinsListViewModel unspentCoinsListViewModel;
List<TransactionDetailsListItem> items;
}