From 2db4c1caeb03003429c7993fe1e1242c35c617da Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Thu, 22 Aug 2024 10:25:29 +0800 Subject: [PATCH] opt: hide keyboard when switching login methods --- lib/pages/login/view.dart | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/pages/login/view.dart b/lib/pages/login/view.dart index 73e42fbd..7ad7e2d9 100644 --- a/lib/pages/login/view.dart +++ b/lib/pages/login/view.dart @@ -456,14 +456,24 @@ class _LoginPageState extends State { ) : null, ), - body: TabBarView( - physics: const AlwaysScrollableScrollPhysics(), - controller: _loginPageCtr.tabController, - children: [ - tabViewOuter(loginByPassword()), - tabViewOuter(loginBySmS()), - tabViewOuter(loginByQRCode()), - ], + body: NotificationListener( + onNotification: (notification) { + if (notification is ScrollUpdateNotification) { + if (notification.metrics.axis == Axis.horizontal) { + FocusScope.of(context).unfocus(); + } + } + return true; + }, + child: TabBarView( + physics: const AlwaysScrollableScrollPhysics(), + controller: _loginPageCtr.tabController, + children: [ + tabViewOuter(loginByPassword()), + tabViewOuter(loginBySmS()), + tabViewOuter(loginByQRCode()), + ], + ), ), ); }); @@ -479,5 +489,4 @@ class _LoginPageState extends State { child: child, ))); } - }