From 3998f549e4575a5e6a7acdc660d4e7ef50d2930d Mon Sep 17 00:00:00 2001 From: Junyuan Feng Date: Sun, 4 Dec 2022 15:52:41 +0800 Subject: [PATCH] fix: IME awayls float --- lib/app.dart | 65 ++++++++++++++++++++---------------- lib/data/res/build_data.dart | 8 ++--- lib/view/page/convert.dart | 1 + lib/view/page/home.dart | 21 ++++++------ lib/view/page/ping.dart | 3 +- 5 files changed, 54 insertions(+), 44 deletions(-) diff --git a/lib/app.dart b/lib/app.dart index c6c4a98c..e5a39f2b 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -7,17 +7,18 @@ import 'package:toolbox/generated/l10n.dart'; import 'package:toolbox/locator.dart'; import 'package:toolbox/view/page/home.dart'; +const Set interactiveStates = { + MaterialState.pressed, + MaterialState.hovered, + MaterialState.focused, + MaterialState.selected +}; + class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); MaterialStateProperty getMaterialStateColor(Color primaryColor) { return MaterialStateProperty.resolveWith((states) { - const Set interactiveStates = { - MaterialState.pressed, - MaterialState.hovered, - MaterialState.focused, - MaterialState.selected - }; if (states.any(interactiveStates.contains)) { return primaryColor; } @@ -38,11 +39,9 @@ class MyApp extends StatelessWidget { S.delegate, GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, - GlobalCupertinoLocalizations.delegate, ], supportedLocales: S.delegate.supportedLocales, title: BuildData.name, - debugShowCheckedModeBanner: false, theme: ThemeData( primaryColor: primaryColor, appBarTheme: AppBarTheme(backgroundColor: primaryColor), @@ -52,36 +51,44 @@ class MyApp extends StatelessWidget { primaryIconTheme: IconThemeData(color: primaryColor), switchTheme: SwitchThemeData( thumbColor: getMaterialStateColor(primaryColor), - trackColor: - getMaterialStateColor(primaryColor.withOpacity(0.7)), + trackColor: getMaterialStateColor( + primaryColor.withOpacity(0.7), + ), ), buttonTheme: ButtonThemeData(splashColor: primaryColor), inputDecorationTheme: InputDecorationTheme( - labelStyle: textStyle, - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: primaryColor))), + labelStyle: textStyle, + focusedBorder: UnderlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + ), radioTheme: RadioThemeData( fillColor: getMaterialStateColor(primaryColor), ), ), darkTheme: ThemeData.dark().copyWith( - primaryColor: primaryColor, - floatingActionButtonTheme: FloatingActionButtonThemeData( - backgroundColor: primaryColor), - iconTheme: IconThemeData(color: primaryColor), - primaryIconTheme: IconThemeData(color: primaryColor), - switchTheme: SwitchThemeData( - thumbColor: getMaterialStateColor(primaryColor), - trackColor: - getMaterialStateColor(primaryColor.withOpacity(0.7)), + primaryColor: primaryColor, + floatingActionButtonTheme: + FloatingActionButtonThemeData(backgroundColor: primaryColor), + iconTheme: IconThemeData(color: primaryColor), + primaryIconTheme: IconThemeData(color: primaryColor), + switchTheme: SwitchThemeData( + thumbColor: getMaterialStateColor(primaryColor), + trackColor: getMaterialStateColor( + primaryColor.withOpacity(0.7), ), - buttonTheme: ButtonThemeData(splashColor: primaryColor), - inputDecorationTheme: InputDecorationTheme( - labelStyle: textStyle, - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: primaryColor))), - radioTheme: RadioThemeData( - fillColor: getMaterialStateColor(primaryColor))), + ), + buttonTheme: ButtonThemeData(splashColor: primaryColor), + inputDecorationTheme: InputDecorationTheme( + labelStyle: textStyle, + focusedBorder: UnderlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + ), + radioTheme: RadioThemeData( + fillColor: getMaterialStateColor(primaryColor), + ), + ), home: MyHomePage(primaryColor: primaryColor), ); }); diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 423a06ec..86255117 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,9 +2,9 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 160; + static const int build = 162; static const String engine = - "Flutter 3.3.4 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision eb6d86ee27 (7 weeks ago) • 2022-10-04 22:31:45 -0700\nEngine • revision c08d7d5efc\nTools • Dart 2.18.2 • DevTools 2.15.0\n"; - static const String buildAt = "2022-11-21 20:31:38.507008"; - static const int modifications = 8; + "Flutter 3.3.9 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision b8f7f1f986 (11 days ago) • 2022-11-23 06:43:51 +0900\nEngine • revision 8f2221fbef\nTools • Dart 2.18.5 • DevTools 2.15.0\n"; + static const String buildAt = "2022-12-04 15:36:33.518958"; + static const int modifications = 4; } diff --git a/lib/view/page/convert.dart b/lib/view/page/convert.dart index c31360bd..74f4de66 100644 --- a/lib/view/page/convert.dart +++ b/lib/view/page/convert.dart @@ -63,6 +63,7 @@ class _ConvertPageState extends State } }, tooltip: s.convert, + heroTag: 'convert fab', child: const Icon(Icons.send), ), ); diff --git a/lib/view/page/home.dart b/lib/view/page/home.dart index e5461686..064ca46b 100644 --- a/lib/view/page/home.dart +++ b/lib/view/page/home.dart @@ -87,15 +87,16 @@ class _MyHomePageState extends State Widget build(BuildContext context) { super.build(context); return WillPopScope( - child: _buildMain(context), - onWillPop: () { - final scaffold = Scaffold.of(context); - if (scaffold.isDrawerOpen) { - scaffold.closeDrawer(); - return Future.value(false); - } - return Future.value(true); - }); + child: _buildMain(context), + onWillPop: () { + final scaffold = Scaffold.of(context); + if (scaffold.isDrawerOpen) { + scaffold.closeDrawer(); + return Future.value(false); + } + return Future.value(true); + }, + ); } Widget _buildMain(BuildContext context) { @@ -116,7 +117,7 @@ class _MyHomePageState extends State physics: const ClampingScrollPhysics(), controller: _pageController, onPageChanged: (i) { - FocusScope.of(context).unfocus(); + FocusScope.of(context).requestFocus(FocusNode()); _selectIndex = i; setState(() {}); }, diff --git a/lib/view/page/ping.dart b/lib/view/page/ping.dart index 0aac02c2..432eb6cd 100644 --- a/lib/view/page/ping.dart +++ b/lib/view/page/ping.dart @@ -71,7 +71,7 @@ class _PingPageState extends State ), ])), floatingActionButton: FloatingActionButton( - child: const Icon(Icons.play_arrow), + heroTag: 'ping fab', onPressed: () { try { doPing(); @@ -79,6 +79,7 @@ class _PingPageState extends State showSnackBar(context, Text('Error: \n$e')); } }, + child: const Icon(Icons.play_arrow), ), ); }