From a0820e8a7358fb25d304979fba1d9cfe0519925a Mon Sep 17 00:00:00 2001 From: Serhii Date: Tue, 16 Apr 2024 02:04:49 +0300 Subject: [PATCH] pull to refresh (#1389) --- lib/src/screens/dashboard/dashboard_page.dart | 21 ++++++++++++++----- .../dashboard/dashboard_view_model.dart | 4 ++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index 820e94928..52a4d8f61 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -51,14 +51,25 @@ class DashboardPage extends StatelessWidget { @override Widget build(BuildContext context) { + final screenHeight = MediaQuery.of(context).size.height; return Scaffold( body: Observer( builder: (_) { - final dashboardPageView = _DashboardPageView( - balancePage: balancePage, - bottomSheetService: bottomSheetService, - dashboardViewModel: dashboardViewModel, - addressListViewModel: addressListViewModel, + final dashboardPageView = RefreshIndicator( + displacement: screenHeight * 0.1, + onRefresh: () async => await dashboardViewModel.refreshDashboard(), + child: SingleChildScrollView( + physics: AlwaysScrollableScrollPhysics(), + child: Container( + height: screenHeight, + child: _DashboardPageView( + balancePage: balancePage, + bottomSheetService: bottomSheetService, + dashboardViewModel: dashboardViewModel, + addressListViewModel: addressListViewModel, + ), + ), + ), ); if (DeviceInfo.instance.isDesktop) { diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index ef43ddf40..ef521c311 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -547,4 +547,8 @@ abstract class DashboardViewModelBase with Store { return ServicesResponse([], false, ''); } } + + Future refreshDashboard() async { + reconnect(); + } }