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: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<PasswordWidget> {
bool _passwordVisible = false;
@override
Widget build(BuildContext context) {
return TextFormField(
return TextField(
autofocus: true,
keyboardType: TextInputType.text,
controller: widget.controller,

View File

@ -72,7 +72,9 @@ class _HomePageState extends State<HomePage> {
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<HomePage> {
// 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<HomePage> {
height: 60,
child: IconButton(
icon: Icon(Icons.arrow_forward,
color: HexColor('#B9BABC'), size: 45),
color: Color(0xFFB9BABC), size: 45),
onPressed: onConnect,
),
)

View File

@ -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;
}

View File

@ -87,138 +87,182 @@ class _RemotePageState extends State<RemotePage> {
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: <Widget>[
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: <Widget>[
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(),
(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(),
(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);
}
}