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

OleksandrSobol committed May 26, 2021 at 19:10 UTC b71e85b11259738b70ef5970cc605c8d9a3b7f17
2 files changed +20 -19
lib/src/screens/unspent_coins/unspent_coins_list_page.dart
+12 -12
@@ -4,6 +4,7 @@ import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_list_view_mod
4 import 'package:flutter/material.dart';
5 import 'package:flutter/cupertino.dart';
6 import 'package:cake_wallet/src/screens/base_page.dart';
7 +import 'package:flutter_mobx/flutter_mobx.dart';
8
9 class UnspentCoinsListPage extends BasePage {
10 UnspentCoinsListPage({this.unspentCoinsListViewModel});
@@ -15,24 +16,23 @@ class UnspentCoinsListPage extends BasePage {
16
17 @override
18 Widget body(BuildContext context) {
18 - return SectionStandardList(
19 + return Observer(builder: (_) => SectionStandardList(
20 sectionCount: 1,
21 itemCounter: (int _) => unspentCoinsListViewModel.items.length,
22 itemBuilder: (_, __, index) {
23 final item = unspentCoinsListViewModel.items[index];
24
25 return GestureDetector(
25 - onTap: () {print('Item taped');},
26 - child: UnspentCoinsListItem(
27 - address: item.address,
28 - amount: item.amount,
29 - isFrozen: item.isFrozen,
30 - note: item.note,
31 - isSending: item.isSending,
32 - onCheckBoxTap: (value) {print('CheckBox taped');},
33 - )
34 - );
35 - });
26 + onTap: () {print('Item taped');},
27 + child: UnspentCoinsListItem(
28 + address: item.address,
29 + amount: item.amount,
30 + isFrozen: item.isFrozen,
31 + note: item.note,
32 + isSending: item.isSending,
33 + onCheckBoxTap: (value) {print('CheckBox taped');},
34 + ));
35 + }));
36 }
37
38 }
\ No newline at end of file
lib/view_model/unspent_coins/unspent_coins_list_view_model.dart
+8 -7
@@ -37,11 +37,12 @@ class UnspentCoinsListViewModel = UnspentCoinsListViewModelBase with _$UnspentCo
37
38 abstract class UnspentCoinsListViewModelBase with Store {
39 @computed
40 - List<UnspentCoinsItem> get items => unspentCoinsMap.map((elem) =>
41 - UnspentCoinsItem(
42 - address: elem["address"] as String,
43 - amount: elem["amount"] as String,
44 - isFrozen: elem["isFrozen"] as bool,
45 - note: elem["note"] as String
46 - )).toList();
40 + ObservableList<UnspentCoinsItem> get items =>
41 + ObservableList.of(unspentCoinsMap.map((elem) =>
42 + UnspentCoinsItem(
43 + address: elem["address"] as String,
44 + amount: elem["amount"] as String,
45 + isFrozen: elem["isFrozen"] as bool,
46 + note: elem["note"] as String
47 + )));
48 }
\ No newline at end of file