From 364fb780845677ba08fd3a61755ae4006d03c9af Mon Sep 17 00:00:00 2001 From: open-trade Date: Sun, 22 Nov 2020 21:08:19 +0800 Subject: [PATCH] permissions --- flutter_hbb/lib/model.dart | 33 ++++++++++++++++++++++++-------- flutter_hbb/lib/remote_page.dart | 6 +----- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/flutter_hbb/lib/model.dart b/flutter_hbb/lib/model.dart index 46dd6d0dc..5db8636d0 100644 --- a/flutter_hbb/lib/model.dart +++ b/flutter_hbb/lib/model.dart @@ -1,3 +1,5 @@ +import 'dart:html'; + import 'package:ffi/ffi.dart'; import 'package:path_provider/path_provider.dart'; import 'dart:io'; @@ -23,22 +25,35 @@ typedef F5 = Pointer Function(); // https://juejin.im/post/6844903864852807694 class FfiModel with ChangeNotifier { - PeerInfo _pi = PeerInfo(); - Display _display = Display(); - bool _decoding = false; - bool _waitForImage = false; + PeerInfo _pi; + Display _display; + bool _decoding; + bool _waitForImage; + final _permissions = Map(); + + get permissions => _permissions; FfiModel() { - init(); + clear(); + () async { + await FFI.init(); + notifyListeners(); + }(); } - Future init() async { - await FFI.init(); - notifyListeners(); + void updatePermission(Map evt) { + evt.forEach((k, v) { + if (k == 'name') return; + _permissions[k] = v == 'true'; + }); } void clear() { + _pi = PeerInfo(); + _display = Display(); _decoding = false; + _waitForImage = false; + _permissions.clear(); } void update( @@ -62,6 +77,8 @@ class FfiModel with ChangeNotifier { FFI.cursorModel.updateCursorId(evt); } else if (name == 'cursor_position') { FFI.cursorModel.updateCursorPosition(evt); + } else if (name == 'permission') { + FFI.ffiModel.updatePermission(evt); } } if (!_decoding) { diff --git a/flutter_hbb/lib/remote_page.dart b/flutter_hbb/lib/remote_page.dart index 558cdd5e1..c5bb1c2ff 100644 --- a/flutter_hbb/lib/remote_page.dart +++ b/flutter_hbb/lib/remote_page.dart @@ -76,10 +76,6 @@ class _RemotePageState extends State { } } - void _handleKeyEvent(RawKeyEvent event) { - print('$event'); - } - @override Widget build(BuildContext context) { // Size size = MediaQueryData.fromWindow(ui.window).size; @@ -210,7 +206,7 @@ class _RemotePageState extends State { height: 0, child: _bottom < 100 ? Container() - : TextFormField( + : TextField( textInputAction: TextInputAction.newline, autocorrect: false, enableSuggestions: false,