From dc1a38db91b37f9b104d48cc36ca30a97e7805e9 Mon Sep 17 00:00:00 2001 From: julian Date: Sat, 14 Jan 2023 12:17:55 -0600 Subject: [PATCH] main wallets/exchange/buy page navigation fix --- lib/pages/home_view/home_view.dart | 33 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/pages/home_view/home_view.dart b/lib/pages/home_view/home_view.dart index c11485271..ecf5679fd 100644 --- a/lib/pages/home_view/home_view.dart +++ b/lib/pages/home_view/home_view.dart @@ -104,6 +104,16 @@ class _HomeViewState extends ConsumerState { // } // } + bool _lock = false; + + Future _animateToPage(int index) async { + await _pageController.animateToPage( + index, + duration: const Duration(milliseconds: 300), + curve: Curves.decelerate, + ); + } + @override void initState() { _pageController = PageController(); @@ -315,38 +325,31 @@ class _HomeViewState extends ConsumerState { builder: (_, _ref, __) { _ref.listen(homeViewPageIndexStateProvider, (previous, next) { - if (next is int) { + if (next is int && next >= 0 && next <= 2) { if (next == 1) { _exchangeDataLoadingService.loadAll(ref); } // if (next == 2) { // _buyDataLoadingService.loadAll(ref); // } - if (next >= 0 && next <= 2) { - _pageController.animateToPage( - next, - duration: const Duration(milliseconds: 300), - curve: Curves.decelerate, - ); - } + + _lock = true; + _animateToPage(next).then((value) => _lock = false); } }); return PageView( controller: _pageController, children: _children, onPageChanged: (pageIndex) { - ref.read(homeViewPageIndexStateProvider.state).state = - pageIndex; + if (!_lock) { + ref.read(homeViewPageIndexStateProvider.state).state = + pageIndex; + } }, ); }, ), ), - // Expanded( - // child: HomeStack( - // children: _children, - // ), - // ), ], ), ),