From b71e85b11259738b70ef5970cc605c8d9a3b7f17 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Wed, 26 May 2021 19:10:46 +0300 Subject: [PATCH] CAKE-329 | applied observable list to items in the unspent_coins_list_view_model.dart --- .../unspent_coins_list_page.dart | 24 +++++++++---------- .../unspent_coins_list_view_model.dart | 15 ++++++------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/src/screens/unspent_coins/unspent_coins_list_page.dart b/lib/src/screens/unspent_coins/unspent_coins_list_page.dart index 44a6a34b8..cc175eb01 100644 --- a/lib/src/screens/unspent_coins/unspent_coins_list_page.dart +++ b/lib/src/screens/unspent_coins/unspent_coins_list_page.dart @@ -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,24 +16,23 @@ class UnspentCoinsListPage extends BasePage { @override Widget body(BuildContext context) { - return SectionStandardList( + return Observer(builder: (_) => SectionStandardList( sectionCount: 1, itemCounter: (int _) => unspentCoinsListViewModel.items.length, itemBuilder: (_, __, index) { final item = unspentCoinsListViewModel.items[index]; return GestureDetector( - onTap: () {print('Item taped');}, - child: UnspentCoinsListItem( - address: item.address, - amount: item.amount, - isFrozen: item.isFrozen, - note: item.note, - isSending: item.isSending, - onCheckBoxTap: (value) {print('CheckBox taped');}, - ) - ); - }); + onTap: () {print('Item taped');}, + child: UnspentCoinsListItem( + address: item.address, + amount: item.amount, + isFrozen: item.isFrozen, + note: item.note, + isSending: item.isSending, + onCheckBoxTap: (value) {print('CheckBox taped');}, + )); + })); } } \ No newline at end of file diff --git a/lib/view_model/unspent_coins/unspent_coins_list_view_model.dart b/lib/view_model/unspent_coins/unspent_coins_list_view_model.dart index 4b765d55e..5f631e52a 100644 --- a/lib/view_model/unspent_coins/unspent_coins_list_view_model.dart +++ b/lib/view_model/unspent_coins/unspent_coins_list_view_model.dart @@ -37,11 +37,12 @@ class UnspentCoinsListViewModel = UnspentCoinsListViewModelBase with _$UnspentCo abstract class UnspentCoinsListViewModelBase with Store { @computed - List get items => 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(); + ObservableList 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 + ))); } \ No newline at end of file