mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-28 23:59:05 +08:00
8c3e77001c
Signed-off-by: Kingtous <kingtous@qq.com>
106 lines
3.1 KiB
Dart
106 lines
3.1 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:bitsdojo_window/bitsdojo_window.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_hbb/desktop/pages/desktop_home_page.dart';
|
|
import 'package:flutter_hbb/desktop/screen/desktop_remote_screen.dart';
|
|
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:window_manager/window_manager.dart';
|
|
|
|
import 'common.dart';
|
|
import 'mobile/pages/home_page.dart';
|
|
import 'mobile/pages/server_page.dart';
|
|
import 'mobile/pages/settings_page.dart';
|
|
import 'models/model.dart';
|
|
|
|
int? windowId;
|
|
|
|
Future<Null> main(List<String> args) async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await FFI.ffiModel.init();
|
|
// await Firebase.initializeApp();
|
|
if (isAndroid) {
|
|
toAndroidChannelInit();
|
|
}
|
|
refreshCurrentUser();
|
|
runRustDeskApp(args);
|
|
}
|
|
|
|
void runRustDeskApp(List<String> args) async {
|
|
if (!isDesktop) {
|
|
runApp(App());
|
|
return;
|
|
}
|
|
// main window
|
|
await windowManager.ensureInitialized();
|
|
if (args.isNotEmpty && args.first == 'multi_window') {
|
|
windowId = int.parse(args[1]);
|
|
final argument = args[2].isEmpty
|
|
? Map<String, dynamic>()
|
|
: jsonDecode(args[2]) as Map<String, dynamic>;
|
|
int type = argument['type'] ?? -1;
|
|
WindowType wType = type.windowType;
|
|
switch (wType) {
|
|
case WindowType.RemoteDesktop:
|
|
runApp(DesktopRemoteScreen(
|
|
params: argument,
|
|
));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
} else {
|
|
// disable tray
|
|
// initTray();
|
|
FFI.serverModel.startService();
|
|
runApp(App());
|
|
doWhenWindowReady(() {
|
|
const initialSize = Size(1280, 720);
|
|
appWindow.minSize = initialSize;
|
|
appWindow.size = initialSize;
|
|
appWindow.alignment = Alignment.center;
|
|
appWindow.show();
|
|
});
|
|
}
|
|
}
|
|
|
|
class App extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// final analytics = FirebaseAnalytics.instance;
|
|
return MultiProvider(
|
|
providers: [
|
|
ChangeNotifierProvider.value(value: FFI.ffiModel),
|
|
ChangeNotifierProvider.value(value: FFI.imageModel),
|
|
ChangeNotifierProvider.value(value: FFI.cursorModel),
|
|
ChangeNotifierProvider.value(value: FFI.canvasModel),
|
|
],
|
|
child: MaterialApp(
|
|
navigatorKey: globalKey,
|
|
debugShowCheckedModeBanner: false,
|
|
title: 'RustDesk',
|
|
theme: ThemeData(
|
|
primarySwatch: Colors.blue,
|
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
|
),
|
|
home: isDesktop
|
|
? DesktopHomePage()
|
|
: !isAndroid
|
|
? WebHomePage()
|
|
: HomePage(),
|
|
navigatorObservers: [
|
|
// FirebaseAnalyticsObserver(analytics: analytics),
|
|
FlutterSmartDialog.observer
|
|
],
|
|
builder: FlutterSmartDialog.init(
|
|
builder: isAndroid
|
|
? (_, child) => AccessibilityListener(
|
|
child: child,
|
|
)
|
|
: null)),
|
|
);
|
|
}
|
|
}
|