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