From 28d8cd43dca3f3027cd2076e74490fdf27299cd8 Mon Sep 17 00:00:00 2001 From: Oleksandr Sobol Date: Thu, 23 Apr 2020 22:26:37 +0300 Subject: [PATCH] CWA-201 | added scroll controller to wallet list page --- .../screens/wallet_list/wallet_list_page.dart | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/src/screens/wallet_list/wallet_list_page.dart b/lib/src/screens/wallet_list/wallet_list_page.dart index 4d5f1f262..62591f7f3 100644 --- a/lib/src/screens/wallet_list/wallet_list_page.dart +++ b/lib/src/screens/wallet_list/wallet_list_page.dart @@ -28,6 +28,7 @@ class WalletListBody extends StatefulWidget { class WalletListBodyState extends State { final moneroIcon = Image.asset('assets/images/monero.png', height: 24, width: 24); WalletListStore _walletListStore; + ScrollController scrollController = ScrollController(); @override Widget build(BuildContext context) { @@ -64,6 +65,7 @@ class WalletListBodyState extends State { width: double.infinity, child: CustomScrollView( scrollDirection: Axis.horizontal, + controller: scrollController, slivers: [ SliverPersistentHeader( pinned: false, @@ -105,8 +107,11 @@ class WalletListBodyState extends State { if (index == 0) { return GestureDetector( - onTap: () => walletMenu.action( - walletMenu.listItems.indexOf(item), wallet, isCurrentWallet), + onTap: () { + scrollController.animateTo(0.0, duration: Duration(milliseconds: 500), curve: Curves.fastOutSlowIn); + walletMenu.action( + walletMenu.listItems.indexOf(item), wallet, isCurrentWallet); + }, child: Container( height: 108, width: 108, @@ -127,8 +132,11 @@ class WalletListBodyState extends State { } return GestureDetector( - onTap: () => walletMenu.action( - walletMenu.listItems.indexOf(item), wallet, isCurrentWallet), + onTap: () { + scrollController.animateTo(0.0, duration: Duration(milliseconds: 500), curve: Curves.fastOutSlowIn); + walletMenu.action( + walletMenu.listItems.indexOf(item), wallet, isCurrentWallet); + }, child: Container( height: 108, width: 108,