mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-05-11 18:36:11 +02:00
add desktop
This commit is contained in:
parent
222245a60c
commit
a23fa7fc66
7 changed files with 28 additions and 13 deletions
|
@ -11,6 +11,7 @@ final navigationBarKey = GlobalKey();
|
||||||
var isAndroid = false;
|
var isAndroid = false;
|
||||||
var isIOS = false;
|
var isIOS = false;
|
||||||
var isWeb = false;
|
var isWeb = false;
|
||||||
|
var isWebDesktop = false;
|
||||||
var isDesktop = false;
|
var isDesktop = false;
|
||||||
var version = "";
|
var version = "";
|
||||||
int androidVersion = 0;
|
int androidVersion = 0;
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_hbb/pages/desktop_home_page.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:firebase_analytics/firebase_analytics.dart';
|
import 'package:firebase_analytics/firebase_analytics.dart';
|
||||||
|
@ -16,7 +19,9 @@ Future<Null> main() async {
|
||||||
await a;
|
await a;
|
||||||
await b;
|
await b;
|
||||||
refreshCurrentUser();
|
refreshCurrentUser();
|
||||||
toAndroidChannelInit();
|
if (Platform.isAndroid) {
|
||||||
|
toAndroidChannelInit();
|
||||||
|
}
|
||||||
runApp(App());
|
runApp(App());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +44,11 @@ class App extends StatelessWidget {
|
||||||
primarySwatch: Colors.blue,
|
primarySwatch: Colors.blue,
|
||||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||||
),
|
),
|
||||||
home: !isAndroid ? WebHomePage() : HomePage(),
|
home: isDesktop
|
||||||
|
? DesktopHomePage()
|
||||||
|
: !isAndroid
|
||||||
|
? WebHomePage()
|
||||||
|
: HomePage(),
|
||||||
navigatorObservers: [
|
navigatorObservers: [
|
||||||
FirebaseAnalyticsObserver(analytics: analytics),
|
FirebaseAnalyticsObserver(analytics: analytics),
|
||||||
FlutterSmartDialog.observer
|
FlutterSmartDialog.observer
|
||||||
|
|
|
@ -282,7 +282,7 @@ class ImageModel with ChangeNotifier {
|
||||||
|
|
||||||
void update(ui.Image? image) {
|
void update(ui.Image? image) {
|
||||||
if (_image == null && image != null) {
|
if (_image == null && image != null) {
|
||||||
if (isDesktop) {
|
if (isWebDesktop) {
|
||||||
FFI.canvasModel.updateViewStyle();
|
FFI.canvasModel.updateViewStyle();
|
||||||
} else {
|
} else {
|
||||||
final size = MediaQueryData.fromWindow(ui.window).size;
|
final size = MediaQueryData.fromWindow(ui.window).size;
|
||||||
|
@ -394,7 +394,7 @@ class CanvasModel with ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetOffset() {
|
void resetOffset() {
|
||||||
if (isDesktop) {
|
if (isWebDesktop) {
|
||||||
updateViewStyle();
|
updateViewStyle();
|
||||||
} else {
|
} else {
|
||||||
_x = 0;
|
_x = 0;
|
||||||
|
@ -783,7 +783,7 @@ class FFI {
|
||||||
|
|
||||||
static void close() {
|
static void close() {
|
||||||
chatModel.close();
|
chatModel.close();
|
||||||
if (FFI.imageModel.image != null && !isDesktop) {
|
if (FFI.imageModel.image != null && !isWebDesktop) {
|
||||||
savePreference(id, cursorModel.x, cursorModel.y, canvasModel.x,
|
savePreference(id, cursorModel.x, cursorModel.y, canvasModel.x,
|
||||||
canvasModel.y, canvasModel.scale, ffiModel.pi.currentDisplay);
|
canvasModel.y, canvasModel.scale, ffiModel.pi.currentDisplay);
|
||||||
}
|
}
|
||||||
|
@ -919,7 +919,7 @@ void savePreference(String id, double xCursor, double yCursor, double xCanvas,
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>?> getPreference(String id) async {
|
Future<Map<String, dynamic>?> getPreference(String id) async {
|
||||||
if (!isDesktop) return null;
|
if (!isWebDesktop) return null;
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
var p = prefs.getString('peer' + id);
|
var p = prefs.getString('peer' + id);
|
||||||
if (p == null) return null;
|
if (p == null) return null;
|
||||||
|
|
|
@ -59,6 +59,11 @@ class PlatformFFI {
|
||||||
static Future<Null> init() async {
|
static Future<Null> init() async {
|
||||||
isIOS = Platform.isIOS;
|
isIOS = Platform.isIOS;
|
||||||
isAndroid = Platform.isAndroid;
|
isAndroid = Platform.isAndroid;
|
||||||
|
isDesktop = Platform.isWindows || Platform.isMacOS || Platform.isLinux;
|
||||||
|
if (isDesktop) {
|
||||||
|
// TODO
|
||||||
|
return;
|
||||||
|
}
|
||||||
final dylib = Platform.isAndroid
|
final dylib = Platform.isAndroid
|
||||||
? DynamicLibrary.open('librustdesk.so')
|
? DynamicLibrary.open('librustdesk.so')
|
||||||
: DynamicLibrary.process();
|
: DynamicLibrary.process();
|
||||||
|
|
|
@ -20,7 +20,7 @@ class PlatformFFI {
|
||||||
|
|
||||||
static Future<Null> init() async {
|
static Future<Null> init() async {
|
||||||
isWeb = true;
|
isWeb = true;
|
||||||
isDesktop = !context.callMethod('isMobile');
|
isWebDesktop = !context.callMethod('isMobile');
|
||||||
context.callMethod('init');
|
context.callMethod('init');
|
||||||
version = getByName('version');
|
version = getByName('version');
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,8 +211,8 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||||
width: width,
|
width: width,
|
||||||
child: Card(
|
child: Card(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: !isDesktop ? () => connect('${p.id}') : null,
|
onTap: !isWebDesktop ? () => connect('${p.id}') : null,
|
||||||
onDoubleTap: isDesktop ? () => connect('${p.id}') : null,
|
onDoubleTap: isWebDesktop ? () => connect('${p.id}') : null,
|
||||||
onLongPressStart: (details) {
|
onLongPressStart: (details) {
|
||||||
final x = details.globalPosition.dx;
|
final x = details.globalPosition.dx;
|
||||||
final y = details.globalPosition.dy;
|
final y = details.globalPosition.dy;
|
||||||
|
|
|
@ -28,7 +28,7 @@ class RemotePage extends StatefulWidget {
|
||||||
class _RemotePageState extends State<RemotePage> {
|
class _RemotePageState extends State<RemotePage> {
|
||||||
Timer? _interval;
|
Timer? _interval;
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
bool _showBar = !isDesktop;
|
bool _showBar = !isWebDesktop;
|
||||||
double _bottom = 0;
|
double _bottom = 0;
|
||||||
String _value = '';
|
String _value = '';
|
||||||
double _scale = 1;
|
double _scale = 1;
|
||||||
|
@ -256,7 +256,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||||
OverlayEntry(builder: (context) {
|
OverlayEntry(builder: (context) {
|
||||||
return Container(
|
return Container(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
child: isDesktop
|
child: isWebDesktop
|
||||||
? getBodyForDesktopWithListener(keyboard)
|
? getBodyForDesktopWithListener(keyboard)
|
||||||
: SafeArea(
|
: SafeArea(
|
||||||
child: Container(
|
child: Container(
|
||||||
|
@ -397,7 +397,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
] +
|
] +
|
||||||
(isDesktop
|
(isWebDesktop
|
||||||
? []
|
? []
|
||||||
: FFI.ffiModel.isPeerAndroid
|
: FFI.ffiModel.isPeerAndroid
|
||||||
? [
|
? [
|
||||||
|
@ -641,7 +641,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||||
)
|
)
|
||||||
])),
|
])),
|
||||||
value: 'enter_os_password'));
|
value: 'enter_os_password'));
|
||||||
if (!isDesktop) {
|
if (!isWebDesktop) {
|
||||||
if (perms['keyboard'] != false && perms['clipboard'] != false) {
|
if (perms['keyboard'] != false && perms['clipboard'] != false) {
|
||||||
more.add(PopupMenuItem<String>(
|
more.add(PopupMenuItem<String>(
|
||||||
child: Text(translate('Paste')), value: 'paste'));
|
child: Text(translate('Paste')), value: 'paste'));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue