mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-18 15:53:00 +08:00
image shown now
This commit is contained in:
parent
0ba74ef7ec
commit
df58f3230e
@ -189,55 +189,59 @@ Future<Null> enterPasswordDialog(String id, BuildContext context) async {
|
||||
_hasDialog = true;
|
||||
final controller = TextEditingController();
|
||||
var remember = FFI.getByName('remember', arg: id) == 'true';
|
||||
var dialog = AlertDialog(
|
||||
title: Text('Please enter your password'),
|
||||
contentPadding: const EdgeInsets.all(20.0),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextField(
|
||||
autofocus: true,
|
||||
obscureText: true,
|
||||
controller: controller,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Password',
|
||||
var dialog = StatefulBuilder(builder: (context, setState) {
|
||||
return AlertDialog(
|
||||
title: Text('Please enter your password'),
|
||||
contentPadding: const EdgeInsets.all(20.0),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextField(
|
||||
autofocus: true,
|
||||
obscureText: true,
|
||||
controller: controller,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Password',
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(
|
||||
'Remember the password',
|
||||
),
|
||||
leading: Checkbox(
|
||||
value: remember,
|
||||
onChanged: (v) {
|
||||
setState(() {
|
||||
remember = v;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
FlatButton(
|
||||
textColor: MyTheme.accent,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text('Cancel'),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(
|
||||
'Remember the password',
|
||||
),
|
||||
leading: Checkbox(
|
||||
value: remember,
|
||||
onChanged: (v) {
|
||||
remember = v;
|
||||
},
|
||||
),
|
||||
FlatButton(
|
||||
textColor: MyTheme.accent,
|
||||
onPressed: () {
|
||||
var text = controller.text.trim();
|
||||
if (text == '') return;
|
||||
FFI.login(text, remember);
|
||||
showLoading('Logging in...');
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
FlatButton(
|
||||
textColor: MyTheme.accent,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text('Cancel'),
|
||||
),
|
||||
FlatButton(
|
||||
textColor: MyTheme.accent,
|
||||
onPressed: () {
|
||||
var text = controller.text.trim();
|
||||
if (text == '') return;
|
||||
FFI.login(text, remember);
|
||||
showLoading('Logging in...');
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text('OK'),
|
||||
),
|
||||
],
|
||||
);
|
||||
);
|
||||
});
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
|
@ -3,6 +3,7 @@ import 'common.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'dart:ui' as ui;
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'dart:convert';
|
||||
import 'dart:async';
|
||||
|
||||
class RemotePage extends StatefulWidget {
|
||||
@ -17,11 +18,9 @@ class RemotePage extends StatefulWidget {
|
||||
// https://github.com/hanxu317317/flutter_plan_demo/blob/master/lib/src/enter.dart
|
||||
class _RemotePageState extends State<RemotePage> {
|
||||
Timer _interval;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
ui.Image image;
|
||||
ui.Image _image;
|
||||
PeerInfo _pi = PeerInfo();
|
||||
Display _display = Display();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -44,22 +43,61 @@ class _RemotePageState extends State<RemotePage> {
|
||||
|
||||
void interval() {
|
||||
var evt = FFI.popEvent();
|
||||
if (evt == null) return;
|
||||
var name = evt['name'];
|
||||
if (name == 'msgbox') {
|
||||
handleMsgbox(evt);
|
||||
if (evt != null) {
|
||||
var name = evt['name'];
|
||||
if (name == 'msgbox') {
|
||||
handleMsgbox(evt);
|
||||
} else if (name == 'peer_info') {
|
||||
handlePeerInfo(evt);
|
||||
} else if (name == 'switch_display') {
|
||||
handleSwitchDisplay(evt);
|
||||
}
|
||||
}
|
||||
var rgba = FFI.getRgba();
|
||||
if (rgba != null) {
|
||||
ui.decodeImageFromPixels(rgba, width, height, ui.PixelFormat.rgba8888,
|
||||
(_image) {
|
||||
ui.decodeImageFromPixels(
|
||||
rgba, _display.width, _display.height, ui.PixelFormat.bgra8888,
|
||||
(__image) {
|
||||
setState(() {
|
||||
image = _image;
|
||||
_image = __image;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void handleSwitchDisplay(Map<String, dynamic> evt) {
|
||||
_pi.currentDisplay = int.parse(evt['display']);
|
||||
_display.x = int.parse(evt['x']);
|
||||
_display.y = int.parse(evt['y']);
|
||||
_display.width = int.parse(evt['width']);
|
||||
_display.height = int.parse(evt['height']);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void handlePeerInfo(Map<String, dynamic> evt) {
|
||||
dismissLoading();
|
||||
_pi.username = evt['username'];
|
||||
_pi.hostname = evt['hostname'];
|
||||
_pi.platform = evt['platform'];
|
||||
_pi.sasEnabled = evt['sas_enabled'] == "true";
|
||||
_pi.currentDisplay = int.parse(evt['current_display']);
|
||||
List<dynamic> displays = json.decode(evt['displays']);
|
||||
_pi.displays = List<Display>();
|
||||
for (int i = 0; i < displays.length; ++i) {
|
||||
Map<String, dynamic> d0 = displays[i];
|
||||
var d = Display();
|
||||
d.x = d0['x'];
|
||||
d.y = d0['y'];
|
||||
d.width = d0['width'];
|
||||
d.height = d0['height'];
|
||||
_pi.displays.add(d);
|
||||
}
|
||||
if (_pi.currentDisplay < _pi.displays.length) {
|
||||
_display = _pi.displays[_pi.currentDisplay];
|
||||
}
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void handleMsgbox(Map<String, dynamic> evt) {
|
||||
var type = evt['type'];
|
||||
var title = evt['title'];
|
||||
@ -81,9 +119,11 @@ class _RemotePageState extends State<RemotePage> {
|
||||
SystemChrome.setEnabledSystemUIOverlays([]);
|
||||
return FlutterEasyLoading(
|
||||
child: GestureDetector(
|
||||
child: CustomPaint(
|
||||
painter: new ImageEditor(image: image),
|
||||
),
|
||||
child: Container(
|
||||
child: CustomPaint(
|
||||
painter: new ImageEditor(image: _image),
|
||||
),
|
||||
color: MyTheme.grayBg),
|
||||
onPanStart: (DragDownDetails) {
|
||||
print('onPanStart $DragDownDetails');
|
||||
// hero.moveTo(DragDownDetails.globalPosition.dx, DragDownDetails.globalPosition.dy);
|
||||
@ -113,3 +153,19 @@ class ImageEditor extends CustomPainter {
|
||||
return oldDelegate != this;
|
||||
}
|
||||
}
|
||||
|
||||
class Display {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
}
|
||||
|
||||
class PeerInfo {
|
||||
String username;
|
||||
String hostname;
|
||||
String platform;
|
||||
bool sasEnabled;
|
||||
int currentDisplay;
|
||||
List<Display> displays;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user