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, fontSize: 30,
color: Color(0xFF00B6F0), color: Color(0xFF00B6F0),
), ),
keyboardType: TextInputType.number, // keyboardType: TextInputType.number,
decoration: InputDecoration( decoration: InputDecoration(
labelText: 'Remote ID', labelText: 'Remote ID',
border: InputBorder.none, border: InputBorder.none,

View File

@ -23,6 +23,7 @@ class _RemotePageState extends State<RemotePage> {
Timer _interval; Timer _interval;
bool _showBar = true; bool _showBar = true;
double _bottom = 0; double _bottom = 0;
final FocusNode _focusNode = FocusNode();
@override @override
void initState() { void initState() {
@ -39,6 +40,7 @@ class _RemotePageState extends State<RemotePage> {
@override @override
void dispose() { void dispose() {
_focusNode.dispose();
super.dispose(); super.dispose();
FFI.close(); FFI.close();
_interval.cancel(); _interval.cancel();
@ -72,94 +74,103 @@ class _RemotePageState extends State<RemotePage> {
} }
} }
void _handleKeyEvent(RawKeyEvent event) {
print('$event');
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// Size size = MediaQueryData.fromWindow(ui.window).size; // Size size = MediaQueryData.fromWindow(ui.window).size;
// MediaQuery.of(context).size.height; // MediaQuery.of(context).size.height;
EasyLoading.instance.loadingStyle = EasyLoadingStyle.light; EasyLoading.instance.loadingStyle = EasyLoadingStyle.light;
return WillPopScope( return RawKeyboardListener(
onWillPop: () async { focusNode: _focusNode,
close(); onKey: _handleKeyEvent,
return false; child: WillPopScope(
}, onWillPop: () async {
child: Scaffold( close();
floatingActionButton: _showBar return false;
? null },
: FloatingActionButton( child: Scaffold(
mini: true, floatingActionButton: _showBar
child: Icon(Icons.expand_less), ? null
backgroundColor: MyTheme.accent50, : FloatingActionButton(
onPressed: () { mini: true,
setState(() => _showBar = !_showBar); child: Icon(Icons.expand_less),
}), backgroundColor: MyTheme.accent50,
bottomNavigationBar: _showBar onPressed: () {
? BottomAppBar( setState(() => _showBar = !_showBar);
color: MyTheme.accent, }),
child: Row( bottomNavigationBar: _showBar
mainAxisSize: MainAxisSize.max, ? BottomAppBar(
mainAxisAlignment: MainAxisAlignment.spaceBetween, color: MyTheme.accent,
children: <Widget>[ child: Row(
Row(children: [ mainAxisSize: MainAxisSize.max,
IconButton( mainAxisAlignment: MainAxisAlignment.spaceBetween,
color: Colors.white, children: <Widget>[
icon: Icon(Icons.clear), Row(children: [
onPressed: () { IconButton(
close();
},
),
IconButton(
color: Colors.white,
icon: Icon(Icons.keyboard),
onPressed: () => SystemChannels.textInput
.invokeMethod('TextInput.show'),
),
Transform.rotate(
angle: 15 * math.pi / 180,
child: IconButton(
color: Colors.white, color: Colors.white,
icon: Icon(Icons.flash_on), icon: Icon(Icons.clear),
onPressed: () { onPressed: () {
showActions(context); close();
}, },
)), ),
IconButton( IconButton(
color: Colors.white, color: Colors.white,
icon: Icon(Icons.tv), icon: Icon(Icons.keyboard),
onPressed: () { onPressed: () {
showOptions(context); SystemChannels.textInput
}, .invokeMethod('TextInput.show');
), _focusNode.requestFocus();
IconButton( }),
color: Colors.white, Transform.rotate(
icon: Icon(Icons.settings), angle: 15 * math.pi / 180,
onPressed: () {}, child: IconButton(
) color: Colors.white,
]), icon: Icon(Icons.flash_on),
IconButton( onPressed: () {
color: Colors.white, showActions(context);
icon: Icon(Icons.expand_more), },
onPressed: () { )),
setState(() => _showBar = !_showBar); IconButton(
}), color: Colors.white,
], icon: Icon(Icons.tv),
), onPressed: () {
) showOptions(context);
: null, },
body: FlutterEasyLoading( ),
child: Container( IconButton(
color: MyTheme.canvasColor, color: Colors.white,
child: InteractiveViewer( icon: Icon(Icons.settings),
constrained: false, onPressed: () {},
panEnabled: true, )
onInteractionUpdate: (details) { ]),
print('$details'); IconButton(
}, color: Colors.white,
child: Stack(children: [ icon: Icon(Icons.expand_more),
ImagePaint(), onPressed: () {
CursorPaint(), setState(() => _showBar = !_showBar);
]), }),
), ],
)))); ),
)
: null,
body: FlutterEasyLoading(
child: Container(
color: MyTheme.canvasColor,
child: InteractiveViewer(
constrained: false,
panEnabled: true,
onInteractionUpdate: (details) {
print('$details');
},
child: Stack(children: [
ImagePaint(),
CursorPaint(),
]),
),
)))));
} }
void close() { void close() {