2020-11-17 01:22:14 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'common.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
2020-11-17 11:12:55 +08:00
|
|
|
import 'dart:ui' as ui;
|
2020-11-17 12:08:31 +08:00
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
|
|
import 'dart:async';
|
2020-11-17 01:22:14 +08:00
|
|
|
|
|
|
|
class RemotePage extends StatefulWidget {
|
|
|
|
RemotePage({Key key, this.id}) : super(key: key);
|
|
|
|
|
|
|
|
final String id;
|
|
|
|
|
|
|
|
@override
|
|
|
|
_RemotePageState createState() => _RemotePageState();
|
|
|
|
}
|
|
|
|
|
2020-11-17 12:08:31 +08:00
|
|
|
// https://github.com/hanxu317317/flutter_plan_demo/blob/master/lib/src/enter.dart
|
2020-11-17 01:22:14 +08:00
|
|
|
class _RemotePageState extends State<RemotePage> {
|
2020-11-17 12:08:31 +08:00
|
|
|
Timer _interval;
|
|
|
|
|
2020-11-17 11:12:55 +08:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
FFI.connect(widget.id);
|
2020-11-17 12:08:31 +08:00
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
showLoading("Connecting...");
|
|
|
|
_interval =
|
|
|
|
Timer.periodic(Duration(milliseconds: 30), (timer) => interval());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
2020-11-17 12:41:23 +08:00
|
|
|
FFI.close();
|
2020-11-17 12:08:31 +08:00
|
|
|
_interval.cancel();
|
|
|
|
dismissLoading();
|
|
|
|
}
|
|
|
|
|
|
|
|
void interval() {
|
2020-11-17 12:41:23 +08:00
|
|
|
print(DateTime.now());
|
2020-11-17 11:12:55 +08:00
|
|
|
}
|
2020-11-17 01:22:14 +08:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-11-17 12:08:31 +08:00
|
|
|
// Size size = MediaQueryData.fromWindow(ui.window).size;
|
2020-11-17 12:41:23 +08:00
|
|
|
// MediaQuery.of(context).size.height;
|
2020-11-17 01:22:14 +08:00
|
|
|
// https://stackoverflow.com/questions/46640116/make-flutter-application-fullscreen
|
|
|
|
SystemChrome.setEnabledSystemUIOverlays([]);
|
2020-11-17 12:08:31 +08:00
|
|
|
return FlutterEasyLoading(
|
2020-11-17 12:41:23 +08:00
|
|
|
child: GestureDetector(
|
|
|
|
child: CustomPaint(
|
|
|
|
painter: new ImageEditor(image: null),
|
|
|
|
),
|
|
|
|
onPanStart: (DragDownDetails) {
|
|
|
|
print("onPanStart $DragDownDetails");
|
|
|
|
// hero.moveTo(DragDownDetails.globalPosition.dx, DragDownDetails.globalPosition.dy);
|
|
|
|
},
|
|
|
|
onPanUpdate: (DragDownDetails) {
|
|
|
|
print("onPanUpdate $DragDownDetails");
|
|
|
|
// hero.moveTo(DragDownDetails.globalPosition.dx, DragDownDetails.globalPosition.dy);
|
|
|
|
}));
|
2020-11-17 11:12:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ImageEditor extends CustomPainter {
|
|
|
|
ImageEditor({
|
|
|
|
this.image,
|
|
|
|
});
|
|
|
|
|
|
|
|
ui.Image image;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void paint(Canvas canvas, Size size) {
|
2020-11-17 12:08:31 +08:00
|
|
|
if (image == null) return;
|
2020-11-17 11:12:55 +08:00
|
|
|
canvas.drawImage(image, new Offset(0.0, 0.0), new Paint());
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool shouldRepaint(CustomPainter oldDelegate) {
|
2020-11-17 12:08:31 +08:00
|
|
|
return oldDelegate != this;
|
2020-11-17 01:22:14 +08:00
|
|
|
}
|
|
|
|
}
|