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/cupertino.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
class UnspentCoinsListPage extends BasePage {
UnspentCoinsListPage({this.unspentCoinsListViewModel});
@ -15,7 +16,7 @@ class UnspentCoinsListPage extends BasePage {
@override
Widget body(BuildContext context) {
return SectionStandardList(
return Observer(builder: (_) => SectionStandardList(
sectionCount: 1,
itemCounter: (int _) => unspentCoinsListViewModel.items.length,
itemBuilder: (_, __, index) {
@ -30,9 +31,8 @@ class UnspentCoinsListPage extends BasePage {
note: item.note,
isSending: item.isSending,
onCheckBoxTap: (value) {print('CheckBox taped');},
)
);
});
));
}));
}
}

View file

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