mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-18 07:44:26 +01:00
Auto unfocus to hide IME
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 85;
|
||||
static const String engine = "Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 77d935af4d (5 weeks ago) • 2021-12-16 08:37:33 -0800\nEngine • revision 890a5fca2e\nTools • Dart 2.15.1\n";
|
||||
static const String buildAt = "2022-01-18 13:38:59.083528";
|
||||
static const int modifications = 1;
|
||||
static const int build = 86;
|
||||
static const String engine =
|
||||
"Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 77d935af4d (5 weeks ago) • 2021-12-16 08:37:33 -0800\nEngine • revision 890a5fca2e\nTools • Dart 2.15.1\n";
|
||||
static const String buildAt = "2022-01-19 16:54:18.470020";
|
||||
static const int modifications = 0;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,5 @@ class SettingStore extends PersistentStore {
|
||||
property('primaryColor', defaultValue: Colors.deepPurpleAccent.value);
|
||||
StoreProperty<int> get serverStatusUpdateInterval =>
|
||||
property('serverStatusUpdateInterval', defaultValue: 3);
|
||||
StoreProperty<int> get launchPage =>
|
||||
property('launchPage', defaultValue: 0);
|
||||
StoreProperty<int> get launchPage => property('launchPage', defaultValue: 0);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:clipboard/clipboard.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/core/utils.dart';
|
||||
import 'package:toolbox/data/res/color.dart';
|
||||
import 'package:toolbox/view/widget/input_field.dart';
|
||||
|
||||
class ConvertPage extends StatefulWidget {
|
||||
const ConvertPage({Key? key}) : super(key: key);
|
||||
@@ -82,14 +83,14 @@ class _ConvertPageState extends State<ConvertPage>
|
||||
case 3:
|
||||
return Uri.decodeFull(text);
|
||||
default:
|
||||
return 'Unknown';
|
||||
return 'Unknown Convert Method';
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildInputTop() {
|
||||
return SizedBox(
|
||||
height: _media.size.height * 0.33,
|
||||
child: _buildInput(_textEditingController),
|
||||
child: buildInput(context, _textEditingController),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -161,20 +162,7 @@ class _ConvertPageState extends State<ConvertPage>
|
||||
Widget _buildResult() {
|
||||
return SizedBox(
|
||||
height: _media.size.height * 0.33,
|
||||
child: _buildInput(_textEditingControllerResult),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInput(TextEditingController controller) {
|
||||
return Card(
|
||||
child: TextField(
|
||||
maxLines: 20,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Theme.of(context).cardColor,
|
||||
filled: true,
|
||||
border: InputBorder.none),
|
||||
controller: controller,
|
||||
),
|
||||
child: buildInput(context, _textEditingControllerResult),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,15 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
super.initState();
|
||||
_serverProvider = locator<ServerProvider>();
|
||||
WidgetsBinding.instance?.addObserver(this);
|
||||
_tabController = TabController(initialIndex: locator<SettingStore>().launchPage.fetch()!, length: tabs.length, vsync: this);
|
||||
_tabController = TabController(
|
||||
initialIndex: locator<SettingStore>().launchPage.fetch()!,
|
||||
length: tabs.length,
|
||||
vsync: this);
|
||||
_tabController.addListener(() {
|
||||
if (_tabController.index == 0) {
|
||||
FocusScope.of(context).unfocus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:dart_ping_ios/dart_ping_ios.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/core/utils.dart';
|
||||
import 'package:toolbox/data/res/color.dart';
|
||||
import 'package:toolbox/view/widget/input_field.dart';
|
||||
|
||||
class PingPage extends StatefulWidget {
|
||||
const PingPage({Key? key}) : super(key: key);
|
||||
@@ -44,9 +45,10 @@ class _PingPageState extends State<PingPage>
|
||||
padding: const EdgeInsets.symmetric(horizontal: 7),
|
||||
child: Column(children: [
|
||||
const SizedBox(height: 13),
|
||||
_buildInputTop(),
|
||||
buildInput(context, _textEditingController,
|
||||
maxLines: 1, hint: 'Type here.'),
|
||||
_buildControl(),
|
||||
_buildResult(),
|
||||
buildInput(context, _textEditingControllerResult, hint: 'Result here.'),
|
||||
])),
|
||||
onTap: () => FocusScope.of(context).requestFocus(FocusNode()),
|
||||
),
|
||||
@@ -68,7 +70,9 @@ class _PingPageState extends State<PingPage>
|
||||
return SizedBox(
|
||||
height: 57,
|
||||
child: Card(
|
||||
child: Row(
|
||||
child: InkWell(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
TextButton(
|
||||
@@ -109,28 +113,7 @@ class _PingPageState extends State<PingPage>
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInputTop() {
|
||||
return _buildInput(_textEditingController, maxLines: 1, hint: 'Type here.');
|
||||
}
|
||||
|
||||
Widget _buildResult() {
|
||||
return _buildInput(_textEditingControllerResult, hint: 'Result here.');
|
||||
}
|
||||
|
||||
Widget _buildInput(TextEditingController controller, {int maxLines = 20, String? hint}) {
|
||||
return Card(
|
||||
child: TextField(
|
||||
maxLines: maxLines,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Theme.of(context).cardColor,
|
||||
hintText: hint,
|
||||
filled: true,
|
||||
border: InputBorder.none),
|
||||
controller: controller,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
title: Text(
|
||||
e,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontSize: 14,
|
||||
color: _theme.textTheme.bodyText2!.color!.withAlpha(177)),
|
||||
),
|
||||
trailing: _buildRadio(tabs.indexOf(e)),
|
||||
|
||||
16
lib/view/widget/input_field.dart
Normal file
16
lib/view/widget/input_field.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Widget buildInput(BuildContext context, TextEditingController controller,
|
||||
{int maxLines = 20, String? hint}) {
|
||||
return Card(
|
||||
child: TextField(
|
||||
maxLines: maxLines,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Theme.of(context).cardColor,
|
||||
hintText: hint,
|
||||
filled: true,
|
||||
border: InputBorder.none),
|
||||
controller: controller,
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user