InteractiveView buggy

This commit is contained in:
open-trade 2020-11-23 01:16:17 +08:00
parent 06cb5b6c35
commit 8e529399c3
4 changed files with 204 additions and 153 deletions

View File

@ -3,18 +3,6 @@ import 'dart:async';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:tuple/tuple.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 { class MyTheme {
MyTheme._(); MyTheme._();
static const Color grayBg = Color(0xFFEEEEEE); static const Color grayBg = Color(0xFFEEEEEE);
@ -112,7 +100,7 @@ class _PasswordWidgetState extends State<PasswordWidget> {
bool _passwordVisible = false; bool _passwordVisible = false;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return TextFormField( return TextField(
autofocus: true, autofocus: true,
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
controller: widget.controller, controller: widget.controller,

View File

@ -72,7 +72,9 @@ class _HomePageState extends State<HomePage> {
Expanded( Expanded(
child: Container( child: Container(
padding: const EdgeInsets.only(left: 16, right: 16), padding: const EdgeInsets.only(left: 16, right: 16),
child: TextFormField( child: TextField(
autocorrect: false,
enableSuggestions: false,
style: TextStyle( style: TextStyle(
fontFamily: 'WorkSans', fontFamily: 'WorkSans',
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -82,18 +84,18 @@ class _HomePageState extends State<HomePage> {
// keyboardType: TextInputType.number, // keyboardType: TextInputType.number,
decoration: InputDecoration( decoration: InputDecoration(
labelText: 'Remote ID', labelText: 'Remote ID',
hintText: 'Enter your remote ID', // hintText: 'Enter your remote ID',
border: InputBorder.none, border: InputBorder.none,
helperStyle: TextStyle( helperStyle: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 16, fontSize: 16,
color: HexColor('#B9BABC'), color: Color(0xFFB9BABC),
), ),
labelStyle: TextStyle( labelStyle: TextStyle(
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
fontSize: 16, fontSize: 16,
letterSpacing: 0.2, letterSpacing: 0.2,
color: HexColor('#B9BABC'), color: Color(0xFFB9BABC),
), ),
), ),
autofocus: false, autofocus: false,
@ -106,7 +108,7 @@ class _HomePageState extends State<HomePage> {
height: 60, height: 60,
child: IconButton( child: IconButton(
icon: Icon(Icons.arrow_forward, icon: Icon(Icons.arrow_forward,
color: HexColor('#B9BABC'), size: 45), color: Color(0xFFB9BABC), size: 45),
onPressed: onConnect, onPressed: onConnect,
), ),
) )

View File

@ -132,7 +132,7 @@ class FfiModel with ChangeNotifier {
_display = _pi.displays[_pi.currentDisplay]; _display = _pi.displays[_pi.currentDisplay];
FFI.cursorModel.updateDisplayOrigin(_display.x, _display.y); FFI.cursorModel.updateDisplayOrigin(_display.x, _display.y);
} }
if (displays.length > 1) { if (displays.length > 0) {
showLoading('Waiting for image...'); showLoading('Waiting for image...');
_waitForImage = true; _waitForImage = true;
} }

View File

@ -158,10 +158,7 @@ class _RemotePageState extends State<RemotePage> {
), ),
) )
: null, : null,
body: FlutterEasyLoading( body: RawGestureDetector(
child: Container(
color: MyTheme.canvasColor,
child: RawGestureDetector(
gestures: { gestures: {
MultiTouchGestureRecognizer: MultiTouchGestureRecognizer:
GestureRecognizerFactoryWithHandlers< GestureRecognizerFactoryWithHandlers<
@ -175,29 +172,76 @@ class _RemotePageState extends State<RemotePage> {
print('$touchCount, $addOrRemove'); print('$touchCount, $addOrRemove');
}, },
), ),
TapGestureRecognizer:
GestureRecognizerFactoryWithHandlers<TapGestureRecognizer>(
() => TapGestureRecognizer(),
(TapGestureRecognizer instance) {
instance.onTap = () {
print('tap');
};
}, },
child: GestureDetector( ),
onTap: () { ImmediateMultiDragGestureRecognizer:
if (_pan) return; GestureRecognizerFactoryWithHandlers<
ImmediateMultiDragGestureRecognizer>(
() => ImmediateMultiDragGestureRecognizer(),
(ImmediateMultiDragGestureRecognizer instance) {
instance
..onStart = (x) {
return CustomDrag();
};
}, },
onDoubleTap: () { ),
if (_pan) return; LongPressGestureRecognizer:
GestureRecognizerFactoryWithHandlers<
LongPressGestureRecognizer>(
() => LongPressGestureRecognizer(),
(LongPressGestureRecognizer instance) {
instance.onLongPress = () {
print('long press');
};
}, },
onLongPress: () { ),
if (_pan) return; PanGestureRecognizer:
GestureRecognizerFactoryWithHandlers<PanGestureRecognizer>(
() => PanGestureRecognizer(),
(PanGestureRecognizer instance) {
instance
..onStart = (detail) {
print('pan start');
}
..onUpdate = (detail) {
print('$detail');
};
}, },
child: InteractiveViewer( ),
constrained: false, ScaleGestureRecognizer: GestureRecognizerFactoryWithHandlers<
panEnabled: _pan, ScaleGestureRecognizer>(
onInteractionUpdate: (details) { () => ScaleGestureRecognizer(),
// print('$details'); (ScaleGestureRecognizer instance) {
instance
..onStart = (detail) {
print('scale start');
}
..onUpdate = (detail) {
print('$detail');
};
}, },
onInteractionStart: (s) { ),
print('$s'); DoubleTapGestureRecognizer:
GestureRecognizerFactoryWithHandlers<
DoubleTapGestureRecognizer>(
() => DoubleTapGestureRecognizer(),
(DoubleTapGestureRecognizer instance) {
instance.onDoubleTap = () {
print('double tap');
};
}, },
onInteractionEnd: (x) { ),
print('$x');
}, },
child: FlutterEasyLoading(
child: Container(
color: MyTheme.canvasColor,
child: Stack(children: [ child: Stack(children: [
ImagePaint(), ImagePaint(),
CursorPaint(), CursorPaint(),
@ -218,7 +262,7 @@ class _RemotePageState extends State<RemotePage> {
), ),
])), ])),
)), )),
)))); ));
} }
void close() { void close() {
@ -329,7 +373,6 @@ void wrongPasswordDialog(String id, BuildContext context) {
FlatButton( FlatButton(
textColor: MyTheme.accent, textColor: MyTheme.accent,
onPressed: () { onPressed: () {
Navigator.pop(context);
enterPasswordDialog(id, context); enterPasswordDialog(id, context);
}, },
child: Text('Retry'), child: Text('Retry'),
@ -443,10 +486,11 @@ class MultiTouchGestureRecognizer extends MultiTapGestureRecognizer {
var numberOfTouches = 0; var numberOfTouches = 0;
MultiTouchGestureRecognizer() { MultiTouchGestureRecognizer() {
super.onTapDown = (pointer, details) => addTouch(pointer, details); this
super.onTapUp = (pointer, details) => removeTouch(pointer, details); ..onTapDown = addTouch
super.onTapCancel = (pointer) => cancelTouch(pointer); ..onTapUp = removeTouch
super.onTap = (pointer) => captureDefaultTap(pointer); ..onTapCancel = cancelTouch
..onTap = captureDefaultTap;
} }
void addTouch(int pointer, TapDownDetails details) { void addTouch(int pointer, TapDownDetails details) {
@ -460,11 +504,28 @@ class MultiTouchGestureRecognizer extends MultiTapGestureRecognizer {
} }
void cancelTouch(int pointer) { void cancelTouch(int pointer) {
numberOfTouches = 0; numberOfTouches--;
print('$numberOfTouches x');
} }
void captureDefaultTap(int pointer) {} void captureDefaultTap(int pointer) {
print('$pointer');
}
} }
typedef MultiTouchGestureRecognizerCallback = void Function( typedef MultiTouchGestureRecognizerCallback = void Function(
int touchCount, bool addOrRemove); 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);
}
}