diff --git a/flutter_hbb/lib/common.dart b/flutter_hbb/lib/common.dart index d10ced032..acdf11e8b 100644 --- a/flutter_hbb/lib/common.dart +++ b/flutter_hbb/lib/common.dart @@ -3,18 +3,6 @@ import 'dart:async'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:tuple/tuple.dart'; -class HexColor extends Color { - HexColor(final String hexColor) : super(_getColorFromHex(hexColor)); - - static int _getColorFromHex(String hexColor) { - hexColor = hexColor.toUpperCase().replaceAll('#', ''); - if (hexColor.length == 6) { - hexColor = 'FF' + hexColor; - } - return int.parse(hexColor, radix: 16); - } -} - class MyTheme { MyTheme._(); static const Color grayBg = Color(0xFFEEEEEE); @@ -112,7 +100,7 @@ class _PasswordWidgetState extends State { bool _passwordVisible = false; @override Widget build(BuildContext context) { - return TextFormField( + return TextField( autofocus: true, keyboardType: TextInputType.text, controller: widget.controller, diff --git a/flutter_hbb/lib/home_page.dart b/flutter_hbb/lib/home_page.dart index 527ed41ee..1a7de8666 100644 --- a/flutter_hbb/lib/home_page.dart +++ b/flutter_hbb/lib/home_page.dart @@ -72,7 +72,9 @@ class _HomePageState extends State { Expanded( child: Container( padding: const EdgeInsets.only(left: 16, right: 16), - child: TextFormField( + child: TextField( + autocorrect: false, + enableSuggestions: false, style: TextStyle( fontFamily: 'WorkSans', fontWeight: FontWeight.bold, @@ -82,18 +84,18 @@ class _HomePageState extends State { // keyboardType: TextInputType.number, decoration: InputDecoration( labelText: 'Remote ID', - hintText: 'Enter your remote ID', + // hintText: 'Enter your remote ID', border: InputBorder.none, helperStyle: TextStyle( fontWeight: FontWeight.bold, fontSize: 16, - color: HexColor('#B9BABC'), + color: Color(0xFFB9BABC), ), labelStyle: TextStyle( fontWeight: FontWeight.w600, fontSize: 16, letterSpacing: 0.2, - color: HexColor('#B9BABC'), + color: Color(0xFFB9BABC), ), ), autofocus: false, @@ -106,7 +108,7 @@ class _HomePageState extends State { height: 60, child: IconButton( icon: Icon(Icons.arrow_forward, - color: HexColor('#B9BABC'), size: 45), + color: Color(0xFFB9BABC), size: 45), onPressed: onConnect, ), ) diff --git a/flutter_hbb/lib/model.dart b/flutter_hbb/lib/model.dart index cc7f4dfdc..56e541748 100644 --- a/flutter_hbb/lib/model.dart +++ b/flutter_hbb/lib/model.dart @@ -132,7 +132,7 @@ class FfiModel with ChangeNotifier { _display = _pi.displays[_pi.currentDisplay]; FFI.cursorModel.updateDisplayOrigin(_display.x, _display.y); } - if (displays.length > 1) { + if (displays.length > 0) { showLoading('Waiting for image...'); _waitForImage = true; } diff --git a/flutter_hbb/lib/remote_page.dart b/flutter_hbb/lib/remote_page.dart index c5bb1c2ff..4f9e22919 100644 --- a/flutter_hbb/lib/remote_page.dart +++ b/flutter_hbb/lib/remote_page.dart @@ -87,138 +87,182 @@ class _RemotePageState extends State { return false; }, child: Scaffold( - floatingActionButton: _showBar - ? null - : FloatingActionButton( - mini: true, - child: Icon(Icons.expand_less), - backgroundColor: MyTheme.accent50, - onPressed: () { - setState(() => _showBar = !_showBar); - }), - bottomNavigationBar: _showBar - ? BottomAppBar( - elevation: 10, - color: MyTheme.accent, - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row(children: [ - IconButton( - color: Colors.white, - icon: Icon(Icons.clear), - onPressed: () { - close(); - }, - ), - IconButton( - color: Colors.white, - icon: Icon(Icons.keyboard), - onPressed: () { - SystemChrome.setEnabledSystemUIOverlays( - SystemUiOverlay.values); - _focusNode.requestFocus(); - SystemChannels.textInput - .invokeMethod('TextInput.show'); - }), - Transform.rotate( - angle: 15 * math.pi / 180, - child: IconButton( - color: Colors.white, - icon: Icon(Icons.flash_on), - onPressed: () { - showActions(context); - }, - )), - IconButton( - color: Colors.white, - icon: Icon(Icons.tv), - onPressed: () { - showOptions(context); - }, - ), - Container( - color: _pan ? Colors.blue[500] : null, - child: IconButton( - color: Colors.white, - icon: Icon(Icons.pan_tool), - onPressed: () { - setState(() => _pan = !_pan); - }, - )) - ]), + floatingActionButton: _showBar + ? null + : FloatingActionButton( + mini: true, + child: Icon(Icons.expand_less), + backgroundColor: MyTheme.accent50, + onPressed: () { + setState(() => _showBar = !_showBar); + }), + bottomNavigationBar: _showBar + ? BottomAppBar( + elevation: 10, + color: MyTheme.accent, + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row(children: [ + IconButton( + color: Colors.white, + icon: Icon(Icons.clear), + onPressed: () { + close(); + }, + ), IconButton( color: Colors.white, - icon: Icon(Icons.expand_more), + icon: Icon(Icons.keyboard), onPressed: () { - setState(() => _showBar = !_showBar); + SystemChrome.setEnabledSystemUIOverlays( + SystemUiOverlay.values); + _focusNode.requestFocus(); + SystemChannels.textInput + .invokeMethod('TextInput.show'); }), - ], - ), - ) - : null, - body: FlutterEasyLoading( - child: Container( - color: MyTheme.canvasColor, - child: RawGestureDetector( - gestures: { - MultiTouchGestureRecognizer: - GestureRecognizerFactoryWithHandlers< - MultiTouchGestureRecognizer>( - () => MultiTouchGestureRecognizer(), - (MultiTouchGestureRecognizer instance) { - instance.onMultiTap = ( - touchCount, - addOrRemove, - ) => - print('$touchCount, $addOrRemove'); - }, - ), + Transform.rotate( + angle: 15 * math.pi / 180, + child: IconButton( + color: Colors.white, + icon: Icon(Icons.flash_on), + onPressed: () { + showActions(context); + }, + )), + IconButton( + color: Colors.white, + icon: Icon(Icons.tv), + onPressed: () { + showOptions(context); + }, + ), + Container( + color: _pan ? Colors.blue[500] : null, + child: IconButton( + color: Colors.white, + icon: Icon(Icons.pan_tool), + onPressed: () { + setState(() => _pan = !_pan); + }, + )) + ]), + IconButton( + color: Colors.white, + icon: Icon(Icons.expand_more), + onPressed: () { + setState(() => _showBar = !_showBar); + }), + ], + ), + ) + : null, + body: RawGestureDetector( + gestures: { + MultiTouchGestureRecognizer: + GestureRecognizerFactoryWithHandlers< + MultiTouchGestureRecognizer>( + () => MultiTouchGestureRecognizer(), + (MultiTouchGestureRecognizer instance) { + instance.onMultiTap = ( + touchCount, + addOrRemove, + ) => + print('$touchCount, $addOrRemove'); }, - child: GestureDetector( - onTap: () { - if (_pan) return; - }, - onDoubleTap: () { - if (_pan) return; - }, - onLongPress: () { - if (_pan) return; - }, - child: InteractiveViewer( - constrained: false, - panEnabled: _pan, - onInteractionUpdate: (details) { - // print('$details'); - }, - onInteractionStart: (s) { - print('$s'); - }, - onInteractionEnd: (x) { - print('$x'); - }, - child: Stack(children: [ - ImagePaint(), - CursorPaint(), - SizedBox( - width: 0, - height: 0, - child: _bottom < 100 - ? Container() - : TextField( - textInputAction: TextInputAction.newline, - autocorrect: false, - enableSuggestions: false, - focusNode: _focusNode, - maxLines: null, - keyboardType: TextInputType.multiline, - onChanged: (x) => print('$x'), - ), - ), - ])), - )), - )))); + ), + TapGestureRecognizer: + GestureRecognizerFactoryWithHandlers( + () => TapGestureRecognizer(), + (TapGestureRecognizer instance) { + instance.onTap = () { + print('tap'); + }; + }, + ), + ImmediateMultiDragGestureRecognizer: + GestureRecognizerFactoryWithHandlers< + ImmediateMultiDragGestureRecognizer>( + () => ImmediateMultiDragGestureRecognizer(), + (ImmediateMultiDragGestureRecognizer instance) { + instance + ..onStart = (x) { + return CustomDrag(); + }; + }, + ), + LongPressGestureRecognizer: + GestureRecognizerFactoryWithHandlers< + LongPressGestureRecognizer>( + () => LongPressGestureRecognizer(), + (LongPressGestureRecognizer instance) { + instance.onLongPress = () { + print('long press'); + }; + }, + ), + PanGestureRecognizer: + GestureRecognizerFactoryWithHandlers( + () => PanGestureRecognizer(), + (PanGestureRecognizer instance) { + instance + ..onStart = (detail) { + print('pan start'); + } + ..onUpdate = (detail) { + print('$detail'); + }; + }, + ), + ScaleGestureRecognizer: GestureRecognizerFactoryWithHandlers< + ScaleGestureRecognizer>( + () => ScaleGestureRecognizer(), + (ScaleGestureRecognizer instance) { + instance + ..onStart = (detail) { + print('scale start'); + } + ..onUpdate = (detail) { + print('$detail'); + }; + }, + ), + DoubleTapGestureRecognizer: + GestureRecognizerFactoryWithHandlers< + DoubleTapGestureRecognizer>( + () => DoubleTapGestureRecognizer(), + (DoubleTapGestureRecognizer instance) { + instance.onDoubleTap = () { + print('double tap'); + }; + }, + ), + }, + child: FlutterEasyLoading( + child: Container( + color: MyTheme.canvasColor, + child: Stack(children: [ + ImagePaint(), + CursorPaint(), + SizedBox( + width: 0, + height: 0, + child: _bottom < 100 + ? Container() + : TextField( + textInputAction: TextInputAction.newline, + autocorrect: false, + enableSuggestions: false, + focusNode: _focusNode, + maxLines: null, + keyboardType: TextInputType.multiline, + onChanged: (x) => print('$x'), + ), + ), + ])), + )), + )); } void close() { @@ -329,7 +373,6 @@ void wrongPasswordDialog(String id, BuildContext context) { FlatButton( textColor: MyTheme.accent, onPressed: () { - Navigator.pop(context); enterPasswordDialog(id, context); }, child: Text('Retry'), @@ -443,10 +486,11 @@ class MultiTouchGestureRecognizer extends MultiTapGestureRecognizer { var numberOfTouches = 0; MultiTouchGestureRecognizer() { - super.onTapDown = (pointer, details) => addTouch(pointer, details); - super.onTapUp = (pointer, details) => removeTouch(pointer, details); - super.onTapCancel = (pointer) => cancelTouch(pointer); - super.onTap = (pointer) => captureDefaultTap(pointer); + this + ..onTapDown = addTouch + ..onTapUp = removeTouch + ..onTapCancel = cancelTouch + ..onTap = captureDefaultTap; } void addTouch(int pointer, TapDownDetails details) { @@ -460,11 +504,28 @@ class MultiTouchGestureRecognizer extends MultiTapGestureRecognizer { } void cancelTouch(int pointer) { - numberOfTouches = 0; + numberOfTouches--; + print('$numberOfTouches x'); } - void captureDefaultTap(int pointer) {} + void captureDefaultTap(int pointer) { + print('$pointer'); + } } typedef MultiTouchGestureRecognizerCallback = void Function( int touchCount, bool addOrRemove); + +typedef OnUpdate(DragUpdateDetails details); + +class CustomDrag extends Drag { + @override + void update(DragUpdateDetails details) { + print('xx $details'); + } + + @override + void end(DragEndDetails details) { + super.end(details); + } +}