prepare keyboard

This commit is contained in:
open-trade 2020-11-20 17:51:49 +08:00
parent 5d11700bdd
commit adea49ee88
2 changed files with 92 additions and 81 deletions

View File

@ -79,7 +79,7 @@ class _HomePageState extends State<HomePage> {
fontSize: 30,
color: Color(0xFF00B6F0),
),
keyboardType: TextInputType.number,
// keyboardType: TextInputType.number,
decoration: InputDecoration(
labelText: 'Remote ID',
border: InputBorder.none,

View File

@ -23,6 +23,7 @@ class _RemotePageState extends State<RemotePage> {
Timer _interval;
bool _showBar = true;
double _bottom = 0;
final FocusNode _focusNode = FocusNode();
@override
void initState() {
@ -39,6 +40,7 @@ class _RemotePageState extends State<RemotePage> {
@override
void dispose() {
_focusNode.dispose();
super.dispose();
FFI.close();
_interval.cancel();
@ -72,12 +74,19 @@ class _RemotePageState extends State<RemotePage> {
}
}
void _handleKeyEvent(RawKeyEvent event) {
print('$event');
}
@override
Widget build(BuildContext context) {
// Size size = MediaQueryData.fromWindow(ui.window).size;
// MediaQuery.of(context).size.height;
EasyLoading.instance.loadingStyle = EasyLoadingStyle.light;
return WillPopScope(
return RawKeyboardListener(
focusNode: _focusNode,
onKey: _handleKeyEvent,
child: WillPopScope(
onWillPop: () async {
close();
return false;
@ -110,9 +119,11 @@ class _RemotePageState extends State<RemotePage> {
IconButton(
color: Colors.white,
icon: Icon(Icons.keyboard),
onPressed: () => SystemChannels.textInput
.invokeMethod('TextInput.show'),
),
onPressed: () {
SystemChannels.textInput
.invokeMethod('TextInput.show');
_focusNode.requestFocus();
}),
Transform.rotate(
angle: 15 * math.pi / 180,
child: IconButton(
@ -159,7 +170,7 @@ class _RemotePageState extends State<RemotePage> {
CursorPaint(),
]),
),
))));
)))));
}
void close() {