From bda4684f50396912c865d48b78f41a7e669939cd Mon Sep 17 00:00:00 2001 From: fosse Date: Thu, 7 Sep 2023 12:05:27 -0400 Subject: [PATCH] nodes pages fixes --- .../screens/settings/manage_nodes_page.dart | 3 + .../settings/manage_pow_nodes_page.dart | 62 ++++++++++--------- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/lib/src/screens/settings/manage_nodes_page.dart b/lib/src/screens/settings/manage_nodes_page.dart index 4b1034f2b..bd9b07467 100644 --- a/lib/src/screens/settings/manage_nodes_page.dart +++ b/lib/src/screens/settings/manage_nodes_page.dart @@ -42,6 +42,9 @@ class ManageNodesPage extends BasePage { return nodeListViewModel.nodes.length; }, itemBuilder: (_, index) { + if (index > nodeListViewModel.nodes.length - 1) { + return SizedBox(); + } return Observer( builder: (context) { final node = nodeListViewModel.nodes[index]; diff --git a/lib/src/screens/settings/manage_pow_nodes_page.dart b/lib/src/screens/settings/manage_pow_nodes_page.dart index 723695ac9..7392b670c 100644 --- a/lib/src/screens/settings/manage_pow_nodes_page.dart +++ b/lib/src/screens/settings/manage_pow_nodes_page.dart @@ -1,14 +1,11 @@ import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; -import 'package:cake_wallet/src/screens/nodes/widgets/node_list_row.dart'; import 'package:cake_wallet/src/screens/nodes/widgets/pow_node_list_row.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/src/widgets/standard_list.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; -import 'package:cake_wallet/view_model/node_list/node_list_view_model.dart'; import 'package:cake_wallet/view_model/node_list/pow_node_list_view_model.dart'; -import 'package:cw_core/node.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; @@ -45,36 +42,43 @@ class ManagePowNodesPage extends BasePage { return nodeListViewModel.nodes.length; }, itemBuilder: (_, index) { - final node = nodeListViewModel.nodes[index]; - final isSelected = node.keyIndex == nodeListViewModel.currentNode.keyIndex; - final nodeListRow = PowNodeListRow( - title: node.uriRaw, - node: node, - isSelected: isSelected, - onTap: (_) async { - if (isSelected) { - return; + return Observer( + builder: (context) { + if (index > nodeListViewModel.nodes.length - 1) { + return SizedBox(); } + final node = nodeListViewModel.nodes[index]; + final isSelected = node.keyIndex == nodeListViewModel.currentNode.keyIndex; + final nodeListRow = PowNodeListRow( + title: node.uriRaw, + node: node, + isSelected: isSelected, + onTap: (_) async { + if (isSelected) { + return; + } - await showPopUp( - context: context, - builder: (BuildContext context) { - return AlertWithTwoActions( - alertTitle: S.of(context).change_current_node_title, - alertContent: nodeListViewModel.getAlertContent(node.uriRaw), - leftButtonText: S.of(context).cancel, - rightButtonText: S.of(context).change, - actionLeftButton: () => Navigator.of(context).pop(), - actionRightButton: () async { - await nodeListViewModel.setAsCurrent(node); - Navigator.of(context).pop(); - }, - ); - }); + await showPopUp( + context: context, + builder: (BuildContext context) { + return AlertWithTwoActions( + alertTitle: S.of(context).change_current_node_title, + alertContent: nodeListViewModel.getAlertContent(node.uriRaw), + leftButtonText: S.of(context).cancel, + rightButtonText: S.of(context).change, + actionLeftButton: () => Navigator.of(context).pop(), + actionRightButton: () async { + await nodeListViewModel.setAsCurrent(node); + Navigator.of(context).pop(); + }, + ); + }); + }, + ); + + return nodeListRow; }, ); - - return nodeListRow; }, ), );