CAKE-329 | applied observable list to items in the unspent_coins_list_view_model.dart

This commit is contained in:
OleksandrSobol 2021-05-26 19:10:46 +03:00
parent aca8e8a292
commit b71e85b112
2 changed files with 20 additions and 19 deletions

View file

@ -4,6 +4,7 @@ import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_list_view_mod
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
class UnspentCoinsListPage extends BasePage { class UnspentCoinsListPage extends BasePage {
UnspentCoinsListPage({this.unspentCoinsListViewModel}); UnspentCoinsListPage({this.unspentCoinsListViewModel});
@ -15,24 +16,23 @@ class UnspentCoinsListPage extends BasePage {
@override @override
Widget body(BuildContext context) { Widget body(BuildContext context) {
return SectionStandardList( return Observer(builder: (_) => SectionStandardList(
sectionCount: 1, sectionCount: 1,
itemCounter: (int _) => unspentCoinsListViewModel.items.length, itemCounter: (int _) => unspentCoinsListViewModel.items.length,
itemBuilder: (_, __, index) { itemBuilder: (_, __, index) {
final item = unspentCoinsListViewModel.items[index]; final item = unspentCoinsListViewModel.items[index];
return GestureDetector( return GestureDetector(
onTap: () {print('Item taped');}, onTap: () {print('Item taped');},
child: UnspentCoinsListItem( child: UnspentCoinsListItem(
address: item.address, address: item.address,
amount: item.amount, amount: item.amount,
isFrozen: item.isFrozen, isFrozen: item.isFrozen,
note: item.note, note: item.note,
isSending: item.isSending, isSending: item.isSending,
onCheckBoxTap: (value) {print('CheckBox taped');}, onCheckBoxTap: (value) {print('CheckBox taped');},
) ));
); }));
});
} }
} }

View file

@ -37,11 +37,12 @@ class UnspentCoinsListViewModel = UnspentCoinsListViewModelBase with _$UnspentCo
abstract class UnspentCoinsListViewModelBase with Store { abstract class UnspentCoinsListViewModelBase with Store {
@computed @computed
List<UnspentCoinsItem> get items => unspentCoinsMap.map((elem) => ObservableList<UnspentCoinsItem> get items =>
UnspentCoinsItem( ObservableList.of(unspentCoinsMap.map((elem) =>
address: elem["address"] as String, UnspentCoinsItem(
amount: elem["amount"] as String, address: elem["address"] as String,
isFrozen: elem["isFrozen"] as bool, amount: elem["amount"] as String,
note: elem["note"] as String isFrozen: elem["isFrozen"] as bool,
)).toList(); note: elem["note"] as String
)));
} }