mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Merge branch 'rustdesk/master'
This commit is contained in:
13
flutter/.gitignore
vendored
13
flutter/.gitignore
vendored
@@ -45,15 +45,14 @@ jniLibs
|
||||
|
||||
# flutter rust bridge
|
||||
lib/generated_bridge.dart
|
||||
lib/generated_bridge.freezed.dart
|
||||
|
||||
# Flutter Generated Files
|
||||
linux/flutter/generated_plugin_registrant.cc
|
||||
linux/flutter/generated_plugin_registrant.h
|
||||
linux/flutter/generated_plugins.cmake
|
||||
macos/Flutter/GeneratedPluginRegistrant.swift
|
||||
windows/flutter/generated_plugin_registrant.cc
|
||||
windows/flutter/generated_plugin_registrant.h
|
||||
windows/flutter/generated_plugins.cmake
|
||||
**/flutter/GeneratedPluginRegistrant.swift
|
||||
**/flutter/generated_plugin_registrant.cc
|
||||
**/flutter/generated_plugin_registrant.h
|
||||
**/flutter/generated_plugins.cmake
|
||||
**/Runner/bridge_generated.h
|
||||
flutter_export_environment.sh
|
||||
Flutter-Generated.xcconfig
|
||||
key.jks
|
||||
|
||||
@@ -1,10 +1,36 @@
|
||||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
# This file should be version controlled.
|
||||
|
||||
version:
|
||||
revision: 8874f21e79d7ec66d0457c7ab338348e31b17f1d
|
||||
revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
|
||||
channel: stable
|
||||
|
||||
project_type: app
|
||||
|
||||
# Tracks metadata for the flutter migrate command
|
||||
migration:
|
||||
platforms:
|
||||
- platform: root
|
||||
create_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
|
||||
base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
|
||||
- platform: linux
|
||||
create_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
|
||||
base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
|
||||
- platform: macos
|
||||
create_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
|
||||
base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
|
||||
- platform: windows
|
||||
create_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
|
||||
base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
|
||||
|
||||
# User provided section
|
||||
|
||||
# List of Local paths (relative to this file) that should be
|
||||
# ignored by the migrate tool.
|
||||
#
|
||||
# Files that are not part of the templates will be ignored by default.
|
||||
unmanaged_files:
|
||||
- 'lib/main.dart'
|
||||
- 'ios/Runner.xcodeproj/project.pbxproj'
|
||||
|
||||
16
flutter/README.md
Normal file
16
flutter/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# flutter_hbb
|
||||
|
||||
A new Flutter project.
|
||||
|
||||
## Getting Started
|
||||
|
||||
This project is a starting point for a Flutter application.
|
||||
|
||||
A few resources to get you started if this is your first Flutter project:
|
||||
|
||||
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
|
||||
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
|
||||
|
||||
For help getting started with Flutter development, view the
|
||||
[online documentation](https://docs.flutter.dev/), which offers tutorials,
|
||||
samples, guidance on mobile development, and a full API reference.
|
||||
29
flutter/analysis_options.yaml
Normal file
29
flutter/analysis_options.yaml
Normal file
@@ -0,0 +1,29 @@
|
||||
# This file configures the analyzer, which statically analyzes Dart code to
|
||||
# check for errors, warnings, and lints.
|
||||
#
|
||||
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
|
||||
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
|
||||
# invoked from the command line by running `flutter analyze`.
|
||||
|
||||
# The following line activates a set of recommended lints for Flutter apps,
|
||||
# packages, and plugins designed to encourage good coding practices.
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
linter:
|
||||
# The lint rules applied to this project can be customized in the
|
||||
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
|
||||
# included above or to enable additional rules. A list of all available lints
|
||||
# and their documentation is published at
|
||||
# https://dart-lang.github.io/linter/lints/index.html.
|
||||
#
|
||||
# Instead of disabling a lint rule for the entire project in the
|
||||
# section below, it can also be suppressed for a single line of code
|
||||
# or a specific dart file by using the `// ignore: name_of_lint` and
|
||||
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
|
||||
# producing the lint.
|
||||
rules:
|
||||
# avoid_print: false # Uncomment to disable the `avoid_print` rule
|
||||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
|
||||
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
BIN
flutter/assets/logo.ico
Normal file
BIN
flutter/assets/logo.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
BIN
flutter/assets/peer_searchbar.ttf
Normal file
BIN
flutter/assets/peer_searchbar.ttf
Normal file
Binary file not shown.
BIN
flutter/assets/tabbar.ttf
Normal file
BIN
flutter/assets/tabbar.ttf
Normal file
Binary file not shown.
30
flutter/lib/cm_main.dart
Normal file
30
flutter/lib/cm_main.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/consts.dart';
|
||||
import 'package:flutter_hbb/main.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
import 'common.dart';
|
||||
import 'desktop/pages/server_page.dart';
|
||||
import 'models/server_model.dart';
|
||||
|
||||
/// -t lib/cm_main.dart to test cm
|
||||
void main(List<String> args) async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await windowManager.ensureInitialized();
|
||||
await windowManager.setSize(Size(400, 600));
|
||||
await windowManager.setAlignment(Alignment.topRight);
|
||||
await initEnv(kAppTypeMain);
|
||||
gFFI.serverModel.clients
|
||||
.add(Client(0, false, false, "UserA", "123123123", true, false, false));
|
||||
gFFI.serverModel.clients
|
||||
.add(Client(1, false, false, "UserB", "221123123", true, false, false));
|
||||
gFFI.serverModel.clients
|
||||
.add(Client(2, false, false, "UserC", "331123123", true, false, false));
|
||||
gFFI.serverModel.clients
|
||||
.add(Client(3, false, false, "UserD", "441123123", true, false, false));
|
||||
runApp(GetMaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: getCurrentTheme(),
|
||||
home: DesktopServerPage()));
|
||||
}
|
||||
@@ -1,25 +1,136 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:back_button_interceptor/back_button_interceptor.dart';
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:async';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
|
||||
import 'package:flutter_hbb/models/peer_model.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
import 'models/model.dart';
|
||||
import 'models/platform_model.dart';
|
||||
|
||||
final globalKey = GlobalKey<NavigatorState>();
|
||||
final navigationBarKey = GlobalKey();
|
||||
|
||||
var isAndroid = false;
|
||||
var isIOS = false;
|
||||
final isAndroid = Platform.isAndroid;
|
||||
final isIOS = Platform.isIOS;
|
||||
final isDesktop = Platform.isWindows || Platform.isMacOS || Platform.isLinux;
|
||||
var isWeb = false;
|
||||
var isDesktop = false;
|
||||
var isWebDesktop = false;
|
||||
var version = "";
|
||||
int androidVersion = 0;
|
||||
|
||||
typedef F = String Function(String);
|
||||
typedef FMethod = String Function(String, dynamic);
|
||||
|
||||
class Translator {
|
||||
static late F call;
|
||||
late final iconKeyboard = MemoryImage(Uint8List.fromList(base64Decode(
|
||||
"iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAgVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////9d3yJTAAAAKnRSTlMA0Gd/0y8ILZgbJffDPUwV2nvzt+TMqZxyU7CMb1pYQyzsvKunkXE4AwJnNC24AAAA+0lEQVQ4y83O2U7DMBCF4ZMxk9rZk26kpQs7nPd/QJy4EiLbLf01N5Y/2YP/qxDFQvGB5NPC/ZpVnfJx4b5xyGfF95rkHvNCWH1u+N6J6T0sC7gqRy8uGPfBLEbozPXUjlkQKwGaFPNizwQbwkx0TDvhCii34ExZCSQVBdzIOEOyeclSHgBGXkpeygXSQgStACtWx4Z8rr8COHOvfEP/IbbsQAToFUAAV1M408IIjIGYAPoCSNRP7DQutfQTqxuAiH7UUg1FaJR2AGrrx52sK2ye28LZ0wBAEyR6y8X+NADhm1B4fgiiHXbRrTrxpwEY9RdM9wsepnvFHfUDwYEeiwAJr/gAAAAASUVORK5CYII=")));
|
||||
late final iconClipboard = MemoryImage(Uint8List.fromList(base64Decode(
|
||||
'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAjVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8DizOFAAAALnRSTlMAnIsyZy8YZF3NSAuabRL34cq6trCScyZ4qI9CQDwV+fPl2tnTwzkeB+m/pIFK/Xx0ewAAAQlJREFUOMudktduhDAQRWep69iY3tle0+7/f16Qg7MsJUQ5Dwh8jzRzhemJPIaf3GiW7eFQfOwDPp1ek/iMnKgBi5PrhJAhZAa1lCxE9pw5KWMswOMAQXuQOvqTB7tLFJ36wimKLrufZTzUaoRtdthqRA2vEwS+tR4qguiElRKk1YMrYfUQRkwLmwVBYDMvJKF8R0o3V2MOhNrfo+hXSYYjPn1L/S+n438t8gWh+q1F+cYFBMm1Jh8Ia7y2OWXQxMMRLqr2eTc1crSD84cWfEGwYM4LlaACEee2ZjsQXJxR3qmYb+GpC8ZfNM5oh3yxxbxgQE7lEkb3ZvvH1BiRHn1bu02ICcKGWr4AudUkyYxmvywAAAAASUVORK5CYII=')));
|
||||
late final iconAudio = MemoryImage(Uint8List.fromList(base64Decode(
|
||||
'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAk1BMVEUAAAD////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////ROyVeAAAAMHRSTlMAgfz08DDqCAThvraZjEcoGA751JxzbGdfTRP25NrIpaGTcEM+HAvMuKinhXhWNx9Yzm/gAAABFUlEQVQ4y82S2XLCMAxFheMsQNghCQFalkL39vz/11V4GpNk0r629+Va1pmxPFfyh1ravOP2Y1ydJmBO0lYP3r+PyQ62s2Y7fgF6VRXOYdToT++ogIuoVhCUtX7YpwJG3F8f6V8rr3WABwwUahlEvr8y3IBniGKdKYBQ5OGQpukQakBpIVcfwptIhJcf8hWGakdndAAhBInIGHbdQGJg6jjbDUgEE5EpmB+AAM4uj6gb+AQT6wdhITLvAHJ4VCtgoAlG1tpNA0gWON/f4ioHdSADc1bfgt+PZFkDlD6ojWF+kVoaHlhvFjPHuVRrefohY1GdcFm1N8JvwEyrJ/X2Th2rIoVgIi3Fo6Xf0z5k8psKu5f/oi+nHjjI92o36AAAAABJRU5ErkJggg==')));
|
||||
late final iconFile = MemoryImage(Uint8List.fromList(base64Decode(
|
||||
'iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAMAAADVRocKAAAAUVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////8IN+deAAAAGnRSTlMAH+CAESEN8jyZkcIb5N/ONy3vmHhmiGjUm7UwS+YAAAHZSURBVGje7dnbboMwDIBhBwgQoFAO7Ta//4NOqCAXYZQstatq4r+r5ubrgQSpg8iyC4ZURa+PlIpQYGiwrzyeHtYZjAL8T05O4H8BbbKvFgRa4NoBU8pXeYEkDDgaaLQBcwJrmeErJQB/7wes3QBWGnCIX0+AQycL1PO6BMwPa0nA4ZxbgTvOjUYMGPHRnZkQAY4mxPZBjmy53E7ukSkFKYB/D4XsWZQx64sCeYebOogGsoOBYvv6/UCb8F0IOBZ0TlP6lEYdANY350AJqB9/qPVuOI5evw4A1hgLigAlepnyxW80bcCcwN++A2s82Vcu02ta+ceq9BoL5KGTTRwQPlpqA3gCnwWU2kCDgeWRQPj2jAPCDxgCMjhI6uZnToDpvd/BJeFrJQB/fsAa02gCt3mi1wNuy8GgBNDZlysBNNSrADVSjcJl6vCpUn6jOdx0kz0q6PMhQRa4465SFKhx35cgUCBTwj2/NHwZAb71qR8GEP2H1XcmAtBPTEO67GP6FUUAIKGABbDLQ0EArhN2sAIGesRO+iyy+RMAjckVTlMCKFVAbh/4Af9OPgG61SkDVco3BQGT3GXaDAnTIAcYZDuBTwGsAGDxuBFeAQqIqwoFMlAVLrHr/wId5MPt0nilGgAAAABJRU5ErkJggg==')));
|
||||
late final iconRestart = MemoryImage(Uint8List.fromList(base64Decode(
|
||||
'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAB7BAAAewQHDaVRTAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAbhJREFUWIXVlrFqFGEUhb+7UYxaWCQKlrKKxaZSQVGDJih2tj6MD2DnMwiWvoAIRnENIpZiYxEro6IooiS7SPwsMgNLkk3mjmYmnmb45/73nMNwz/x/qH3gMu2gH6rAU+Blw+Lngau4jpmGxVF7qp1iPWjaQKnZ2WnXbuP/NqAeUPc3ZkA9XDwvqc+BVWCgPlJ7tRwUKThZce819b46VH+pfXVRXVO/q2cSul3VOgZUl0ejq86r39TXI8mqZKDuDEwCw3IREQvAbWAGmMsQZQ0sAl3gHPB1Q+0e8BuYzRDuy2yOiFVgaUxtRf0ETGc4syk4rc6PqU0Cx9j8Zf6dAeAK8Fi9sUXtFjABvEgxJlNwRP2svlNPjbw/q35U36oTFbnyMSwabxb/gB/qA3VBHagrauV7RW0DRfP1IvMlXqkXkhz1DYyQTKtHa/Z2VVMx3IiI+PI3/bCHjuOpFrSnAMpL6QfgTcMGesDx0kBr2BMzsNyi/vtQu8CJlgwsRbZDnWP90NkKaxHxJMOXMqAeAn5u0ydwMCKGY+qbkB3C2W3EKWoXk5zVoHbUZ+6Mh7tl4G4F8RJ3qvL+AfV3r5Vdpj70AAAAAElFTkSuQmCC')));
|
||||
|
||||
class IconFont {
|
||||
static const _family1 = 'Tabbar';
|
||||
static const _family2 = 'PeerSearchbar';
|
||||
IconFont._();
|
||||
|
||||
static const IconData max = IconData(0xe606, fontFamily: _family1);
|
||||
static const IconData restore = IconData(0xe607, fontFamily: _family1);
|
||||
static const IconData close = IconData(0xe668, fontFamily: _family1);
|
||||
static const IconData min = IconData(0xe609, fontFamily: _family1);
|
||||
static const IconData add = IconData(0xe664, fontFamily: _family1);
|
||||
static const IconData menu = IconData(0xe628, fontFamily: _family1);
|
||||
static const IconData search = IconData(0xe6a4, fontFamily: _family2);
|
||||
static const IconData round_close = IconData(0xe6ed, fontFamily: _family2);
|
||||
}
|
||||
|
||||
class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
|
||||
const ColorThemeExtension({
|
||||
required this.bg,
|
||||
required this.grayBg,
|
||||
required this.text,
|
||||
required this.lightText,
|
||||
required this.lighterText,
|
||||
required this.placeholder,
|
||||
required this.border,
|
||||
});
|
||||
|
||||
final Color? bg;
|
||||
final Color? grayBg;
|
||||
final Color? text;
|
||||
final Color? lightText;
|
||||
final Color? lighterText;
|
||||
final Color? placeholder;
|
||||
final Color? border;
|
||||
|
||||
static const light = ColorThemeExtension(
|
||||
bg: Color(0xFFFFFFFF),
|
||||
grayBg: Color(0xFFEEEEEE),
|
||||
text: Color(0xFF222222),
|
||||
lightText: Color(0xFF666666),
|
||||
lighterText: Color(0xFF888888),
|
||||
placeholder: Color(0xFFAAAAAA),
|
||||
border: Color(0xFFCCCCCC),
|
||||
);
|
||||
|
||||
static const dark = ColorThemeExtension(
|
||||
bg: Color(0xFF252525),
|
||||
grayBg: Color(0xFF141414),
|
||||
text: Color(0xFFFFFFFF),
|
||||
lightText: Color(0xFF999999),
|
||||
lighterText: Color(0xFF777777),
|
||||
placeholder: Color(0xFF555555),
|
||||
border: Color(0xFF555555),
|
||||
);
|
||||
|
||||
@override
|
||||
ThemeExtension<ColorThemeExtension> copyWith(
|
||||
{Color? bg,
|
||||
Color? grayBg,
|
||||
Color? text,
|
||||
Color? lightText,
|
||||
Color? lighterText,
|
||||
Color? placeholder,
|
||||
Color? border}) {
|
||||
return ColorThemeExtension(
|
||||
bg: bg ?? this.bg,
|
||||
grayBg: grayBg ?? this.grayBg,
|
||||
text: text ?? this.text,
|
||||
lightText: lightText ?? this.lightText,
|
||||
lighterText: lighterText ?? this.lighterText,
|
||||
placeholder: placeholder ?? this.placeholder,
|
||||
border: border ?? this.border,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
ThemeExtension<ColorThemeExtension> lerp(
|
||||
ThemeExtension<ColorThemeExtension>? other, double t) {
|
||||
if (other is! ColorThemeExtension) {
|
||||
return this;
|
||||
}
|
||||
return ColorThemeExtension(
|
||||
bg: Color.lerp(bg, other.bg, t),
|
||||
grayBg: Color.lerp(grayBg, other.grayBg, t),
|
||||
text: Color.lerp(text, other.text, t),
|
||||
lightText: Color.lerp(lightText, other.lightText, t),
|
||||
lighterText: Color.lerp(lighterText, other.lighterText, t),
|
||||
placeholder: Color.lerp(placeholder, other.placeholder, t),
|
||||
border: Color.lerp(border, other.border, t),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyTheme {
|
||||
@@ -34,6 +145,48 @@ class MyTheme {
|
||||
static const Color border = Color(0xFFCCCCCC);
|
||||
static const Color idColor = Color(0xFF00B6F0);
|
||||
static const Color darkGray = Color(0xFFB9BABC);
|
||||
static const Color cmIdColor = Color(0xFF21790B);
|
||||
static const Color dark = Colors.black87;
|
||||
static const Color button = Color(0xFF2C8CFF);
|
||||
static const Color hoverBorder = Color(0xFF999999);
|
||||
|
||||
static ThemeData lightTheme = ThemeData(
|
||||
brightness: Brightness.light,
|
||||
primarySwatch: Colors.blue,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
tabBarTheme: TabBarTheme(
|
||||
labelColor: Colors.black87,
|
||||
),
|
||||
splashColor: Colors.transparent,
|
||||
highlightColor: Colors.transparent,
|
||||
).copyWith(
|
||||
extensions: <ThemeExtension<dynamic>>[
|
||||
ColorThemeExtension.light,
|
||||
],
|
||||
);
|
||||
static ThemeData darkTheme = ThemeData(
|
||||
brightness: Brightness.dark,
|
||||
primarySwatch: Colors.blue,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
tabBarTheme: TabBarTheme(
|
||||
labelColor: Colors.white70,
|
||||
),
|
||||
splashColor: Colors.transparent,
|
||||
highlightColor: Colors.transparent,
|
||||
).copyWith(
|
||||
extensions: <ThemeExtension<dynamic>>[
|
||||
ColorThemeExtension.dark,
|
||||
],
|
||||
);
|
||||
|
||||
static ColorThemeExtension color(BuildContext context) {
|
||||
return Theme.of(context).extension<ColorThemeExtension>()!;
|
||||
}
|
||||
}
|
||||
|
||||
bool isDarkTheme() {
|
||||
final isDark = "Y" == Get.find<SharedPreferences>().getString("darkTheme");
|
||||
return isDark;
|
||||
}
|
||||
|
||||
final ButtonStyle flatButtonStyle = TextButton.styleFrom(
|
||||
@@ -44,17 +197,151 @@ final ButtonStyle flatButtonStyle = TextButton.styleFrom(
|
||||
),
|
||||
);
|
||||
|
||||
void showToast(String text, {Duration? duration}) {
|
||||
SmartDialog.showToast(text, displayTime: duration);
|
||||
String formatDurationToTime(Duration duration) {
|
||||
var totalTime = duration.inSeconds;
|
||||
final secs = totalTime % 60;
|
||||
totalTime = (totalTime - secs) ~/ 60;
|
||||
final mins = totalTime % 60;
|
||||
totalTime = (totalTime - mins) ~/ 60;
|
||||
return "${totalTime.toString().padLeft(2, "0")}:${mins.toString().padLeft(2, "0")}:${secs.toString().padLeft(2, "0")}";
|
||||
}
|
||||
|
||||
void showLoading(String text, {bool clickMaskDismiss = false}) {
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showLoading(
|
||||
clickMaskDismiss: false,
|
||||
builder: (context) {
|
||||
return Container(
|
||||
color: MyTheme.white,
|
||||
closeConnection({String? id}) {
|
||||
if (isAndroid || isIOS) {
|
||||
Navigator.popUntil(globalKey.currentContext!, ModalRoute.withName("/"));
|
||||
} else {
|
||||
final controller = Get.find<DesktopTabController>();
|
||||
controller.closeBy(id);
|
||||
}
|
||||
}
|
||||
|
||||
void window_on_top(int? id) {
|
||||
if (id == null) {
|
||||
// main window
|
||||
windowManager.restore();
|
||||
windowManager.show();
|
||||
windowManager.focus();
|
||||
} else {
|
||||
WindowController.fromWindowId(id)
|
||||
..focus()
|
||||
..show();
|
||||
}
|
||||
}
|
||||
|
||||
typedef DialogBuilder = CustomAlertDialog Function(
|
||||
StateSetter setState, void Function([dynamic]) close);
|
||||
|
||||
class Dialog<T> {
|
||||
OverlayEntry? entry;
|
||||
Completer<T?> completer = Completer<T?>();
|
||||
|
||||
Dialog();
|
||||
|
||||
void complete(T? res) {
|
||||
try {
|
||||
if (!completer.isCompleted) {
|
||||
completer.complete(res);
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint("Dialog complete catch error: $e");
|
||||
} finally {
|
||||
entry?.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class OverlayDialogManager {
|
||||
OverlayState? _overlayState;
|
||||
Map<String, Dialog> _dialogs = Map();
|
||||
int _tagCount = 0;
|
||||
|
||||
/// By default OverlayDialogManager use global overlay
|
||||
OverlayDialogManager() {
|
||||
_overlayState = globalKey.currentState?.overlay;
|
||||
}
|
||||
|
||||
void setOverlayState(OverlayState? overlayState) {
|
||||
_overlayState = overlayState;
|
||||
}
|
||||
|
||||
void dismissAll() {
|
||||
_dialogs.forEach((key, value) {
|
||||
value.complete(null);
|
||||
BackButtonInterceptor.removeByName(key);
|
||||
});
|
||||
_dialogs.clear();
|
||||
}
|
||||
|
||||
void dismissByTag(String tag) {
|
||||
_dialogs[tag]?.complete(null);
|
||||
_dialogs.remove(tag);
|
||||
BackButtonInterceptor.removeByName(tag);
|
||||
}
|
||||
|
||||
Future<T?> show<T>(DialogBuilder builder,
|
||||
{bool clickMaskDismiss = false,
|
||||
bool backDismiss = false,
|
||||
String? tag,
|
||||
bool useAnimation = true,
|
||||
bool forceGlobal = false}) {
|
||||
final overlayState =
|
||||
forceGlobal ? globalKey.currentState?.overlay : _overlayState;
|
||||
|
||||
if (overlayState == null) {
|
||||
return Future.error(
|
||||
"[OverlayDialogManager] Failed to show dialog, _overlayState is null, call [setOverlayState] first");
|
||||
}
|
||||
|
||||
final _tag;
|
||||
if (tag != null) {
|
||||
_tag = tag;
|
||||
} else {
|
||||
_tag = _tagCount.toString();
|
||||
_tagCount++;
|
||||
}
|
||||
|
||||
final dialog = Dialog<T>();
|
||||
_dialogs[_tag] = dialog;
|
||||
|
||||
final close = ([res]) {
|
||||
_dialogs.remove(_tag);
|
||||
dialog.complete(res);
|
||||
BackButtonInterceptor.removeByName(_tag);
|
||||
};
|
||||
dialog.entry = OverlayEntry(builder: (_) {
|
||||
bool innerClicked = false;
|
||||
return Listener(
|
||||
onPointerUp: (_) {
|
||||
if (!innerClicked && clickMaskDismiss) {
|
||||
close();
|
||||
}
|
||||
innerClicked = false;
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.black12,
|
||||
child: StatefulBuilder(builder: (context, setState) {
|
||||
return Listener(
|
||||
onPointerUp: (_) => innerClicked = true,
|
||||
child: builder(setState, close),
|
||||
);
|
||||
})));
|
||||
});
|
||||
overlayState.insert(dialog.entry!);
|
||||
BackButtonInterceptor.add((stopDefaultButtonEvent, routeInfo) {
|
||||
if (backDismiss) {
|
||||
close();
|
||||
}
|
||||
return true;
|
||||
}, name: _tag);
|
||||
return dialog.completer.future;
|
||||
}
|
||||
|
||||
void showLoading(String text,
|
||||
{bool clickMaskDismiss = false,
|
||||
bool showCancel = true,
|
||||
VoidCallback? onCancel}) {
|
||||
show((setState, close) => CustomAlertDialog(
|
||||
content: Container(
|
||||
constraints: BoxConstraints(maxWidth: 240),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -64,74 +351,64 @@ void showLoading(String text, {bool clickMaskDismiss = false}) {
|
||||
Center(child: CircularProgressIndicator()),
|
||||
SizedBox(height: 20),
|
||||
Center(
|
||||
child: Text(Translator.call(text),
|
||||
child: Text(translate(text),
|
||||
style: TextStyle(fontSize: 15))),
|
||||
SizedBox(height: 20),
|
||||
Center(
|
||||
child: TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
SmartDialog.dismiss();
|
||||
backToHome();
|
||||
},
|
||||
child: Text(Translator.call('Cancel'),
|
||||
style: TextStyle(color: MyTheme.accent))))
|
||||
]));
|
||||
});
|
||||
Offstage(
|
||||
offstage: !showCancel,
|
||||
child: Center(
|
||||
child: TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
dismissAll();
|
||||
if (onCancel != null) {
|
||||
onCancel();
|
||||
}
|
||||
},
|
||||
child: Text(translate('Cancel'),
|
||||
style: TextStyle(color: MyTheme.accent)))))
|
||||
]))));
|
||||
}
|
||||
}
|
||||
|
||||
backToHome() {
|
||||
Navigator.popUntil(globalKey.currentContext!, ModalRoute.withName("/"));
|
||||
}
|
||||
|
||||
typedef DialogBuilder = CustomAlertDialog Function(
|
||||
StateSetter setState, void Function([dynamic]) close);
|
||||
|
||||
class DialogManager {
|
||||
static int _tag = 0;
|
||||
|
||||
static dismissByTag(String tag, [result]) {
|
||||
SmartDialog.dismiss(tag: tag, result: result);
|
||||
}
|
||||
|
||||
static Future<T?> show<T>(DialogBuilder builder,
|
||||
{bool clickMaskDismiss = false,
|
||||
bool backDismiss = false,
|
||||
String? tag,
|
||||
bool useAnimation = true}) async {
|
||||
final t;
|
||||
if (tag != null) {
|
||||
t = tag;
|
||||
} else {
|
||||
_tag += 1;
|
||||
t = _tag.toString();
|
||||
}
|
||||
SmartDialog.dismiss(status: SmartStatus.allToast);
|
||||
SmartDialog.dismiss(status: SmartStatus.loading);
|
||||
final close = ([res]) {
|
||||
SmartDialog.dismiss(tag: t, result: res);
|
||||
};
|
||||
final res = await SmartDialog.show<T>(
|
||||
tag: t,
|
||||
clickMaskDismiss: clickMaskDismiss,
|
||||
backDismiss: backDismiss,
|
||||
useAnimation: useAnimation,
|
||||
builder: (_) => StatefulBuilder(
|
||||
builder: (_, setState) => builder(setState, close)));
|
||||
return res;
|
||||
}
|
||||
void showToast(String text, {Duration timeout = const Duration(seconds: 2)}) {
|
||||
final overlayState = globalKey.currentState?.overlay;
|
||||
if (overlayState == null) return;
|
||||
final entry = OverlayEntry(builder: (_) {
|
||||
return IgnorePointer(
|
||||
child: Align(
|
||||
alignment: Alignment(0.0, 0.8),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withOpacity(0.6),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(20),
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 5),
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
decoration: TextDecoration.none,
|
||||
fontWeight: FontWeight.w300,
|
||||
fontSize: 18,
|
||||
color: Colors.white),
|
||||
),
|
||||
)));
|
||||
});
|
||||
overlayState.insert(entry);
|
||||
Future.delayed(timeout, () {
|
||||
entry.remove();
|
||||
});
|
||||
}
|
||||
|
||||
class CustomAlertDialog extends StatelessWidget {
|
||||
CustomAlertDialog(
|
||||
{required this.title,
|
||||
required this.content,
|
||||
required this.actions,
|
||||
this.contentPadding});
|
||||
{this.title, required this.content, this.actions, this.contentPadding});
|
||||
|
||||
final Widget title;
|
||||
final Widget? title;
|
||||
final Widget content;
|
||||
final List<Widget> actions;
|
||||
final List<Widget>? actions;
|
||||
final double? contentPadding;
|
||||
|
||||
@override
|
||||
@@ -147,7 +424,9 @@ class CustomAlertDialog extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
void msgBox(String type, String title, String text, {bool? hasCancel}) {
|
||||
void msgBox(
|
||||
String type, String title, String text, OverlayDialogManager dialogManager,
|
||||
{bool? hasCancel}) {
|
||||
var wrap = (String text, void Function() onPressed) => ButtonTheme(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
@@ -158,29 +437,43 @@ void msgBox(String type, String title, String text, {bool? hasCancel}) {
|
||||
child: TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: onPressed,
|
||||
child: Text(Translator.call(text),
|
||||
style: TextStyle(color: MyTheme.accent))));
|
||||
child:
|
||||
Text(translate(text), style: TextStyle(color: MyTheme.accent))));
|
||||
|
||||
SmartDialog.dismiss();
|
||||
final buttons = [
|
||||
wrap(Translator.call('OK'), () {
|
||||
SmartDialog.dismiss();
|
||||
backToHome();
|
||||
})
|
||||
];
|
||||
dialogManager.dismissAll();
|
||||
List<Widget> buttons = [];
|
||||
if (type != "connecting" && type != "success" && type.indexOf("nook") < 0) {
|
||||
buttons.insert(
|
||||
0,
|
||||
wrap(translate('OK'), () {
|
||||
dialogManager.dismissAll();
|
||||
closeConnection();
|
||||
}));
|
||||
}
|
||||
if (hasCancel == null) {
|
||||
hasCancel = type != 'error';
|
||||
// hasCancel = type != 'error';
|
||||
hasCancel = type.indexOf("error") < 0 &&
|
||||
type.indexOf("nocancel") < 0 &&
|
||||
type != "restarting";
|
||||
}
|
||||
if (hasCancel) {
|
||||
buttons.insert(
|
||||
0,
|
||||
wrap(Translator.call('Cancel'), () {
|
||||
SmartDialog.dismiss();
|
||||
wrap(translate('Cancel'), () {
|
||||
dialogManager.dismissAll();
|
||||
}));
|
||||
}
|
||||
DialogManager.show((setState, close) => CustomAlertDialog(
|
||||
// TODO: test this button
|
||||
if (type.indexOf("hasclose") >= 0) {
|
||||
buttons.insert(
|
||||
0,
|
||||
wrap(translate('Close'), () {
|
||||
dialogManager.dismissAll();
|
||||
}));
|
||||
}
|
||||
dialogManager.show((setState, close) => CustomAlertDialog(
|
||||
title: Text(translate(title), style: TextStyle(fontSize: 21)),
|
||||
content: Text(Translator.call(text), style: TextStyle(fontSize: 15)),
|
||||
content: Text(translate(text), style: TextStyle(fontSize: 15)),
|
||||
actions: buttons));
|
||||
}
|
||||
|
||||
@@ -275,21 +568,28 @@ class PermissionManager {
|
||||
}
|
||||
|
||||
static Future<bool> check(String type) {
|
||||
if (isDesktop) {
|
||||
return Future.value(true);
|
||||
}
|
||||
if (!permissions.contains(type))
|
||||
return Future.error("Wrong permission!$type");
|
||||
return FFI.invokeMethod("check_permission", type);
|
||||
return gFFI.invokeMethod("check_permission", type);
|
||||
}
|
||||
|
||||
static Future<bool> request(String type) {
|
||||
if (isDesktop) {
|
||||
return Future.value(true);
|
||||
}
|
||||
if (!permissions.contains(type))
|
||||
return Future.error("Wrong permission!$type");
|
||||
|
||||
FFI.invokeMethod("request_permission", type);
|
||||
gFFI.invokeMethod("request_permission", type);
|
||||
if (type == "ignore_battery_optimizations") {
|
||||
return Future.value(false);
|
||||
}
|
||||
_current = type;
|
||||
_completer = Completer<bool>();
|
||||
gFFI.invokeMethod("request_permission", type);
|
||||
|
||||
// timeout
|
||||
_timer?.cancel();
|
||||
@@ -325,3 +625,118 @@ RadioListTile<T> getRadio<T>(
|
||||
dense: true,
|
||||
);
|
||||
}
|
||||
|
||||
CheckboxListTile getToggle(
|
||||
String id, void Function(void Function()) setState, option, name,
|
||||
{FFI? ffi}) {
|
||||
final opt = bind.sessionGetToggleOptionSync(id: id, arg: option);
|
||||
return CheckboxListTile(
|
||||
value: opt,
|
||||
onChanged: (v) {
|
||||
setState(() {
|
||||
bind.sessionToggleOption(id: id, value: option);
|
||||
});
|
||||
if (option == "show-quality-monitor") {
|
||||
(ffi ?? gFFI).qualityMonitorModel.checkShowQualityMonitor(id);
|
||||
}
|
||||
},
|
||||
dense: true,
|
||||
title: Text(translate(name)));
|
||||
}
|
||||
|
||||
/// find ffi, tag is Remote ID
|
||||
/// for session specific usage
|
||||
FFI ffi(String? tag) {
|
||||
return Get.find<FFI>(tag: tag);
|
||||
}
|
||||
|
||||
/// Global FFI object
|
||||
late FFI _globalFFI;
|
||||
|
||||
FFI get gFFI => _globalFFI;
|
||||
|
||||
Future<void> initGlobalFFI() async {
|
||||
debugPrint("_globalFFI init");
|
||||
_globalFFI = FFI();
|
||||
debugPrint("_globalFFI init end");
|
||||
// after `put`, can also be globally found by Get.find<FFI>();
|
||||
Get.put(_globalFFI, permanent: true);
|
||||
// trigger connection status updater
|
||||
await bind.mainCheckConnectStatus();
|
||||
// global shared preference
|
||||
await Get.putAsync(() => SharedPreferences.getInstance());
|
||||
}
|
||||
|
||||
String translate(String name) {
|
||||
if (name.startsWith('Failed to') && name.contains(': ')) {
|
||||
return name.split(': ').map((x) => translate(x)).join(': ');
|
||||
}
|
||||
return platformFFI.translate(name, localeName);
|
||||
}
|
||||
|
||||
bool option2bool(String option, String value) {
|
||||
bool res;
|
||||
if (option.startsWith("enable-")) {
|
||||
res = value != "N";
|
||||
} else if (option.startsWith("allow-") ||
|
||||
option == "stop-service" ||
|
||||
option == "direct-server" ||
|
||||
option == "stop-rendezvous-service") {
|
||||
res = value == "Y";
|
||||
} else {
|
||||
assert(false);
|
||||
res = value != "N";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
String bool2option(String option, bool b) {
|
||||
String res;
|
||||
if (option.startsWith('enable-')) {
|
||||
res = b ? '' : 'N';
|
||||
} else if (option.startsWith('allow-') ||
|
||||
option == "stop-service" ||
|
||||
option == "direct-server" ||
|
||||
option == "stop-rendezvous-service") {
|
||||
res = b ? 'Y' : '';
|
||||
} else {
|
||||
assert(false);
|
||||
res = b ? 'Y' : 'N';
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Future<bool> matchPeer(String searchText, Peer peer) async {
|
||||
if (searchText.isEmpty) {
|
||||
return true;
|
||||
}
|
||||
if (peer.id.toLowerCase().contains(searchText)) {
|
||||
return true;
|
||||
}
|
||||
if (peer.hostname.toLowerCase().contains(searchText) ||
|
||||
peer.username.toLowerCase().contains(searchText)) {
|
||||
return true;
|
||||
}
|
||||
final alias = await bind.mainGetPeerOption(id: peer.id, key: 'alias');
|
||||
if (alias.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
return alias.toLowerCase().contains(searchText);
|
||||
}
|
||||
|
||||
Future<List<Peer>>? matchPeers(String searchText, List<Peer> peers) async {
|
||||
searchText = searchText.trim();
|
||||
if (searchText.isEmpty) {
|
||||
return peers;
|
||||
}
|
||||
searchText = searchText.toLowerCase();
|
||||
final matches =
|
||||
await Future.wait(peers.map((peer) => matchPeer(searchText, peer)));
|
||||
final filteredList = List<Peer>.empty(growable: true);
|
||||
for (var i = 0; i < peers.length; i++) {
|
||||
if (matches[i]) {
|
||||
filteredList.add(peers[i]);
|
||||
}
|
||||
}
|
||||
return filteredList;
|
||||
}
|
||||
|
||||
4
flutter/lib/common/formatter/id_formatter.dart
Normal file
4
flutter/lib/common/formatter/id_formatter.dart
Normal file
@@ -0,0 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// TODO: Divide every 3 number to display ID
|
||||
class IdFormController extends TextEditingController {}
|
||||
11
flutter/lib/consts.dart
Normal file
11
flutter/lib/consts.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
const double kDesktopRemoteTabBarHeight = 28.0;
|
||||
|
||||
/// [kAppTypeMain] used by 'Desktop Main Page' , 'Mobile (Client and Server)' , 'Desktop CM Page'
|
||||
const String kAppTypeMain = "main";
|
||||
const String kAppTypeDesktopRemote = "remote";
|
||||
const String kAppTypeDesktopFileTransfer = "file transfer";
|
||||
const String kTabLabelHomePage = "Home";
|
||||
const String kTabLabelSettingPage = "Settings";
|
||||
|
||||
const int kDefaultDisplayWidth = 1280;
|
||||
const int kDefaultDisplayHeight = 720;
|
||||
1167
flutter/lib/desktop/pages/connection_page.dart
Normal file
1167
flutter/lib/desktop/pages/connection_page.dart
Normal file
File diff suppressed because it is too large
Load Diff
126
flutter/lib/desktop/pages/connection_tab_page.dart
Normal file
126
flutter/lib/desktop/pages/connection_tab_page.dart
Normal file
@@ -0,0 +1,126 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/consts.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/remote_page.dart';
|
||||
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
|
||||
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../models/model.dart';
|
||||
|
||||
class ConnectionTabPage extends StatefulWidget {
|
||||
final Map<String, dynamic> params;
|
||||
|
||||
const ConnectionTabPage({Key? key, required this.params}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ConnectionTabPage> createState() => _ConnectionTabPageState(params);
|
||||
}
|
||||
|
||||
class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
final tabController = Get.put(DesktopTabController());
|
||||
static final Rx<String> _fullscreenID = "".obs;
|
||||
static final IconData selectedIcon = Icons.desktop_windows_sharp;
|
||||
static final IconData unselectedIcon = Icons.desktop_windows_outlined;
|
||||
|
||||
var connectionMap = RxList<Widget>.empty(growable: true);
|
||||
|
||||
_ConnectionTabPageState(Map<String, dynamic> params) {
|
||||
if (params['id'] != null) {
|
||||
tabController.add(TabInfo(
|
||||
key: params['id'],
|
||||
label: params['id'],
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
page: RemotePage(
|
||||
key: ValueKey(params['id']),
|
||||
id: params['id'],
|
||||
tabBarHeight:
|
||||
_fullscreenID.value.isNotEmpty ? 0 : kDesktopRemoteTabBarHeight,
|
||||
fullscreenID: _fullscreenID,
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
tabController.onRemove = (_, id) => onRemoveId(id);
|
||||
|
||||
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
|
||||
print(
|
||||
"call ${call.method} with args ${call.arguments} from window ${fromWindowId}");
|
||||
// for simplify, just replace connectionId
|
||||
if (call.method == "new_remote_desktop") {
|
||||
final args = jsonDecode(call.arguments);
|
||||
final id = args['id'];
|
||||
window_on_top(windowId());
|
||||
tabController.add(TabInfo(
|
||||
key: id,
|
||||
label: id,
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
page: RemotePage(
|
||||
key: ValueKey(id),
|
||||
id: id,
|
||||
tabBarHeight: _fullscreenID.value.isNotEmpty
|
||||
? 0
|
||||
: kDesktopRemoteTabBarHeight,
|
||||
fullscreenID: _fullscreenID,
|
||||
)));
|
||||
} else if (call.method == "onDestroy") {
|
||||
tabController.state.value.tabs.forEach((tab) {
|
||||
print("executing onDestroy hook, closing ${tab.label}}");
|
||||
final tag = tab.label;
|
||||
ffi(tag).close().then((_) {
|
||||
Get.delete<FFI>(tag: tag);
|
||||
});
|
||||
});
|
||||
Get.back();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = isDarkTheme() ? TarBarTheme.dark() : TarBarTheme.light();
|
||||
return SubWindowDragToResizeArea(
|
||||
windowId: windowId(),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: MyTheme.color(context).border!)),
|
||||
child: Scaffold(
|
||||
backgroundColor: MyTheme.color(context).bg,
|
||||
body: Obx(() => DesktopTab(
|
||||
controller: tabController,
|
||||
theme: theme,
|
||||
isMainWindow: false,
|
||||
showTabBar: _fullscreenID.value.isEmpty,
|
||||
tail: AddButton(
|
||||
theme: theme,
|
||||
).paddingOnly(left: 10),
|
||||
pageViewBuilder: (pageView) {
|
||||
WindowController.fromWindowId(windowId())
|
||||
.setFullscreen(_fullscreenID.value.isNotEmpty);
|
||||
return pageView;
|
||||
},
|
||||
))),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void onRemoveId(String id) {
|
||||
ffi(id).close();
|
||||
if (tabController.state.value.tabs.length == 0) {
|
||||
WindowController.fromWindowId(windowId()).close();
|
||||
}
|
||||
}
|
||||
|
||||
int windowId() {
|
||||
return widget.params["windowId"];
|
||||
}
|
||||
}
|
||||
1034
flutter/lib/desktop/pages/desktop_home_page.dart
Normal file
1034
flutter/lib/desktop/pages/desktop_home_page.dart
Normal file
File diff suppressed because it is too large
Load Diff
1455
flutter/lib/desktop/pages/desktop_setting_page.dart
Normal file
1455
flutter/lib/desktop/pages/desktop_setting_page.dart
Normal file
File diff suppressed because it is too large
Load Diff
66
flutter/lib/desktop/pages/desktop_tab_page.dart
Normal file
66
flutter/lib/desktop/pages/desktop_tab_page.dart
Normal file
@@ -0,0 +1,66 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/consts.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/desktop_home_page.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/desktop_setting_page.dart';
|
||||
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
class DesktopTabPage extends StatefulWidget {
|
||||
const DesktopTabPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<DesktopTabPage> createState() => _DesktopTabPageState();
|
||||
}
|
||||
|
||||
class _DesktopTabPageState extends State<DesktopTabPage> {
|
||||
final tabController = DesktopTabController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
tabController.add(TabInfo(
|
||||
key: kTabLabelHomePage,
|
||||
label: kTabLabelHomePage,
|
||||
selectedIcon: Icons.home_sharp,
|
||||
unselectedIcon: Icons.home_outlined,
|
||||
closable: false,
|
||||
page: DesktopHomePage(
|
||||
key: const ValueKey(kTabLabelHomePage),
|
||||
)));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final dark = isDarkTheme();
|
||||
return DragToResizeArea(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: MyTheme.color(context).border!)),
|
||||
child: Scaffold(
|
||||
backgroundColor: MyTheme.color(context).bg,
|
||||
body: DesktopTab(
|
||||
controller: tabController,
|
||||
theme: dark ? TarBarTheme.dark() : TarBarTheme.light(),
|
||||
isMainWindow: true,
|
||||
tail: ActionIcon(
|
||||
message: 'Settings',
|
||||
icon: IconFont.menu,
|
||||
theme: dark ? TarBarTheme.dark() : TarBarTheme.light(),
|
||||
onTap: onAddSetting,
|
||||
is_close: false,
|
||||
),
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void onAddSetting() {
|
||||
tabController.add(TabInfo(
|
||||
key: kTabLabelSettingPage,
|
||||
label: kTabLabelSettingPage,
|
||||
selectedIcon: Icons.build_sharp,
|
||||
unselectedIcon: Icons.build_outlined,
|
||||
page: DesktopSettingPage(key: const ValueKey(kTabLabelSettingPage))));
|
||||
}
|
||||
}
|
||||
867
flutter/lib/desktop/pages/file_manager_page.dart
Normal file
867
flutter/lib/desktop/pages/file_manager_page.dart
Normal file
@@ -0,0 +1,867 @@
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:desktop_drop/desktop_drop.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_breadcrumb/flutter_breadcrumb.dart';
|
||||
import 'package:flutter_hbb/mobile/pages/file_manager_page.dart';
|
||||
import 'package:flutter_hbb/models/file_model.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
import '../../models/model.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
|
||||
enum LocationStatus { bread, textField }
|
||||
|
||||
class FileManagerPage extends StatefulWidget {
|
||||
FileManagerPage({Key? key, required this.id}) : super(key: key);
|
||||
final String id;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _FileManagerPageState();
|
||||
}
|
||||
|
||||
class _FileManagerPageState extends State<FileManagerPage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
final _localSelectedItems = SelectedItems();
|
||||
final _remoteSelectedItems = SelectedItems();
|
||||
|
||||
final _locationStatusLocal = LocationStatus.bread.obs;
|
||||
final _locationStatusRemote = LocationStatus.bread.obs;
|
||||
final FocusNode _locationNodeLocal =
|
||||
FocusNode(debugLabel: "locationNodeLocal");
|
||||
final FocusNode _locationNodeRemote =
|
||||
FocusNode(debugLabel: "locationNodeRemote");
|
||||
final _searchTextLocal = "".obs;
|
||||
final _searchTextRemote = "".obs;
|
||||
final _breadCrumbScrollerLocal = ScrollController();
|
||||
final _breadCrumbScrollerRemote = ScrollController();
|
||||
|
||||
final _dropMaskVisible = false.obs;
|
||||
|
||||
ScrollController getBreadCrumbScrollController(bool isLocal) {
|
||||
return isLocal ? _breadCrumbScrollerLocal : _breadCrumbScrollerRemote;
|
||||
}
|
||||
|
||||
late FFI _ffi;
|
||||
|
||||
FileModel get model => _ffi.fileModel;
|
||||
|
||||
SelectedItems getSelectedItem(bool isLocal) {
|
||||
return isLocal ? _localSelectedItems : _remoteSelectedItems;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_ffi = FFI();
|
||||
_ffi.connect(widget.id, isFileTransfer: true);
|
||||
Get.put(_ffi, tag: 'ft_${widget.id}');
|
||||
// _ffi.ffiModel.updateEventListener(widget.id);
|
||||
if (!Platform.isLinux) {
|
||||
Wakelock.enable();
|
||||
}
|
||||
print("init success with id ${widget.id}");
|
||||
// register location listener
|
||||
_locationNodeLocal.addListener(onLocalLocationFocusChanged);
|
||||
_locationNodeRemote.addListener(onRemoteLocationFocusChanged);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
model.onClose();
|
||||
_ffi.close();
|
||||
_ffi.dialogManager.dismissAll();
|
||||
if (!Platform.isLinux) {
|
||||
Wakelock.disable();
|
||||
}
|
||||
Get.delete<FFI>(tag: 'ft_${widget.id}');
|
||||
_locationNodeLocal.removeListener(onLocalLocationFocusChanged);
|
||||
_locationNodeRemote.removeListener(onRemoteLocationFocusChanged);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Overlay(initialEntries: [
|
||||
OverlayEntry(builder: (context) {
|
||||
_ffi.dialogManager.setOverlayState(Overlay.of(context));
|
||||
return ChangeNotifierProvider.value(
|
||||
value: _ffi.fileModel,
|
||||
child: Consumer<FileModel>(builder: (_context, _model, _child) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
if (model.selectMode) {
|
||||
model.toggleSelectMode();
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: MyTheme.color(context).bg,
|
||||
body: Row(
|
||||
children: [
|
||||
Flexible(flex: 3, child: body(isLocal: true)),
|
||||
Flexible(flex: 3, child: body(isLocal: false)),
|
||||
Flexible(flex: 2, child: statusList())
|
||||
],
|
||||
),
|
||||
));
|
||||
}));
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
||||
Widget menu({bool isLocal = false}) {
|
||||
return PopupMenuButton<String>(
|
||||
icon: Icon(Icons.more_vert),
|
||||
itemBuilder: (context) {
|
||||
return [
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
model.getCurrentShowHidden(isLocal)
|
||||
? Icons.check_box_outlined
|
||||
: Icons.check_box_outline_blank,
|
||||
color: Colors.black),
|
||||
SizedBox(width: 5),
|
||||
Text(translate("Show Hidden Files"))
|
||||
],
|
||||
),
|
||||
value: "hidden",
|
||||
)
|
||||
];
|
||||
},
|
||||
onSelected: (v) {
|
||||
if (v == "hidden") {
|
||||
model.toggleShowHidden(local: isLocal);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Widget body({bool isLocal = false}) {
|
||||
final fd = model.getCurrentDir(isLocal);
|
||||
final entries = fd.entries;
|
||||
final sortIndex = (SortBy style) {
|
||||
switch (style) {
|
||||
case SortBy.Name:
|
||||
return 1;
|
||||
case SortBy.Type:
|
||||
return 0;
|
||||
case SortBy.Modified:
|
||||
return 2;
|
||||
case SortBy.Size:
|
||||
return 3;
|
||||
}
|
||||
}(model.getSortStyle(isLocal));
|
||||
final sortAscending =
|
||||
isLocal ? model.localSortAscending : model.remoteSortAscending;
|
||||
return Container(
|
||||
decoration: BoxDecoration(border: Border.all(color: Colors.black26)),
|
||||
margin: const EdgeInsets.all(16.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: DropTarget(
|
||||
onDragDone: (detail) => handleDragDone(detail, isLocal),
|
||||
onDragEntered: (enter) {
|
||||
_dropMaskVisible.value = true;
|
||||
},
|
||||
onDragExited: (exit) {
|
||||
_dropMaskVisible.value = false;
|
||||
},
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
headTools(isLocal),
|
||||
Expanded(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: ObxValue<RxString>(
|
||||
(searchText) {
|
||||
final filteredEntries = searchText.isEmpty
|
||||
? entries.where((element) {
|
||||
if (searchText.isEmpty) {
|
||||
return true;
|
||||
} else {
|
||||
return element.name.contains(searchText.value);
|
||||
}
|
||||
}).toList(growable: false)
|
||||
: entries;
|
||||
return DataTable(
|
||||
key: ValueKey(isLocal ? 0 : 1),
|
||||
showCheckboxColumn: true,
|
||||
dataRowHeight: 25,
|
||||
headingRowHeight: 30,
|
||||
columnSpacing: 8,
|
||||
showBottomBorder: true,
|
||||
sortColumnIndex: sortIndex,
|
||||
sortAscending: sortAscending,
|
||||
columns: [
|
||||
DataColumn(label: Text(translate(" "))), // icon
|
||||
DataColumn(
|
||||
label: Text(
|
||||
translate("Name"),
|
||||
),
|
||||
onSort: (columnIndex, ascending) {
|
||||
model.changeSortStyle(SortBy.Name,
|
||||
isLocal: isLocal, ascending: ascending);
|
||||
}),
|
||||
DataColumn(
|
||||
label: Text(
|
||||
translate("Modified"),
|
||||
),
|
||||
onSort: (columnIndex, ascending) {
|
||||
model.changeSortStyle(SortBy.Modified,
|
||||
isLocal: isLocal, ascending: ascending);
|
||||
}),
|
||||
DataColumn(
|
||||
label: Text(translate("Size")),
|
||||
onSort: (columnIndex, ascending) {
|
||||
model.changeSortStyle(SortBy.Size,
|
||||
isLocal: isLocal, ascending: ascending);
|
||||
}),
|
||||
],
|
||||
rows: filteredEntries.map((entry) {
|
||||
final sizeStr = entry.isFile
|
||||
? readableFileSize(entry.size.toDouble())
|
||||
: "";
|
||||
return DataRow(
|
||||
key: ValueKey(entry.name),
|
||||
onSelectChanged: (s) {
|
||||
if (s != null) {
|
||||
if (s) {
|
||||
getSelectedItem(isLocal)
|
||||
.add(isLocal, entry);
|
||||
} else {
|
||||
getSelectedItem(isLocal).remove(entry);
|
||||
}
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
selected:
|
||||
getSelectedItem(isLocal).contains(entry),
|
||||
cells: [
|
||||
DataCell(Icon(
|
||||
entry.isFile
|
||||
? Icons.feed_outlined
|
||||
: Icons.folder,
|
||||
size: 25)),
|
||||
DataCell(
|
||||
ConstrainedBox(
|
||||
constraints:
|
||||
BoxConstraints(maxWidth: 100),
|
||||
child: Tooltip(
|
||||
message: entry.name,
|
||||
child: Text(entry.name,
|
||||
overflow: TextOverflow.ellipsis),
|
||||
)), onTap: () {
|
||||
if (entry.isDirectory) {
|
||||
openDirectory(entry.path, isLocal: isLocal);
|
||||
if (isLocal) {
|
||||
_localSelectedItems.clear();
|
||||
} else {
|
||||
_remoteSelectedItems.clear();
|
||||
}
|
||||
} else {
|
||||
// Perform file-related tasks.
|
||||
final _selectedItems =
|
||||
getSelectedItem(isLocal);
|
||||
if (_selectedItems.contains(entry)) {
|
||||
_selectedItems.remove(entry);
|
||||
} else {
|
||||
_selectedItems.add(isLocal, entry);
|
||||
}
|
||||
setState(() {});
|
||||
}
|
||||
}),
|
||||
DataCell(Text(
|
||||
entry
|
||||
.lastModified()
|
||||
.toString()
|
||||
.replaceAll(".000", "") +
|
||||
" ",
|
||||
style: TextStyle(
|
||||
fontSize: 12, color: MyTheme.darkGray),
|
||||
)),
|
||||
DataCell(Text(
|
||||
sizeStr,
|
||||
style: TextStyle(
|
||||
fontSize: 12, color: MyTheme.darkGray),
|
||||
)),
|
||||
]);
|
||||
}).toList(growable: false),
|
||||
);
|
||||
},
|
||||
isLocal ? _searchTextLocal : _searchTextRemote,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)),
|
||||
// Center(child: listTail(isLocal: isLocal)),
|
||||
// Expanded(
|
||||
// child: ListView.builder(
|
||||
// itemCount: entries.length + 1,
|
||||
// itemBuilder: (context, index) {
|
||||
// if (index >= entries.length) {
|
||||
// return listTail(isLocal: isLocal);
|
||||
// }
|
||||
// var selected = false;
|
||||
// if (model.selectMode) {
|
||||
// selected = _selectedItems.contains(entries[index]);
|
||||
// }
|
||||
//
|
||||
// final sizeStr = entries[index].isFile
|
||||
// ? readableFileSize(entries[index].size.toDouble())
|
||||
// : "";
|
||||
// return Card(
|
||||
// child: ListTile(
|
||||
// leading: Icon(
|
||||
// entries[index].isFile ? Icons.feed_outlined : Icons.folder,
|
||||
// size: 40),
|
||||
// title: Text(entries[index].name),
|
||||
// selected: selected,
|
||||
// subtitle: Text(
|
||||
// entries[index]
|
||||
// .lastModified()
|
||||
// .toString()
|
||||
// .replaceAll(".000", "") +
|
||||
// " " +
|
||||
// sizeStr,
|
||||
// style: TextStyle(fontSize: 12, color: MyTheme.darkGray),
|
||||
// ),
|
||||
// trailing: needShowCheckBox()
|
||||
// ? Checkbox(
|
||||
// value: selected,
|
||||
// onChanged: (v) {
|
||||
// if (v == null) return;
|
||||
// if (v && !selected) {
|
||||
// _selectedItems.add(isLocal, entries[index]);
|
||||
// } else if (!v && selected) {
|
||||
// _selectedItems.remove(entries[index]);
|
||||
// }
|
||||
// setState(() {});
|
||||
// })
|
||||
// : PopupMenuButton<String>(
|
||||
// icon: Icon(Icons.more_vert),
|
||||
// itemBuilder: (context) {
|
||||
// return [
|
||||
// PopupMenuItem(
|
||||
// child: Text(translate("Delete")),
|
||||
// value: "delete",
|
||||
// ),
|
||||
// PopupMenuItem(
|
||||
// child: Text(translate("Multi Select")),
|
||||
// value: "multi_select",
|
||||
// ),
|
||||
// PopupMenuItem(
|
||||
// child: Text(translate("Properties")),
|
||||
// value: "properties",
|
||||
// enabled: false,
|
||||
// )
|
||||
// ];
|
||||
// },
|
||||
// onSelected: (v) {
|
||||
// if (v == "delete") {
|
||||
// final items = SelectedItems();
|
||||
// items.add(isLocal, entries[index]);
|
||||
// model.removeAction(items);
|
||||
// } else if (v == "multi_select") {
|
||||
// _selectedItems.clear();
|
||||
// model.toggleSelectMode();
|
||||
// }
|
||||
// }),
|
||||
// onTap: () {
|
||||
// if (model.selectMode && !_selectedItems.isOtherPage(isLocal)) {
|
||||
// if (selected) {
|
||||
// _selectedItems.remove(entries[index]);
|
||||
// } else {
|
||||
// _selectedItems.add(isLocal, entries[index]);
|
||||
// }
|
||||
// setState(() {});
|
||||
// return;
|
||||
// }
|
||||
// if (entries[index].isDirectory) {
|
||||
// openDirectory(entries[index].path, isLocal: isLocal);
|
||||
// breadCrumbScrollToEnd(isLocal);
|
||||
// } else {
|
||||
// // Perform file-related tasks.
|
||||
// }
|
||||
// },
|
||||
// onLongPress: () {
|
||||
// _selectedItems.clear();
|
||||
// model.toggleSelectMode();
|
||||
// if (model.selectMode) {
|
||||
// _selectedItems.add(isLocal, entries[index]);
|
||||
// }
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ))
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// transfer status list
|
||||
/// watch transfer status
|
||||
Widget statusList() {
|
||||
return PreferredSize(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(top: 16.0, bottom: 16.0, right: 16.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
decoration: BoxDecoration(border: Border.all(color: Colors.grey)),
|
||||
child: Obx(
|
||||
() => ListView.builder(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final item = model.jobTable[index];
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Transform.rotate(
|
||||
angle: item.isRemote ? pi : 0,
|
||||
child: Icon(Icons.send)),
|
||||
SizedBox(
|
||||
width: 16.0,
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Tooltip(
|
||||
message: item.jobName,
|
||||
child: Text(
|
||||
'${item.jobName}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
)),
|
||||
Wrap(
|
||||
children: [
|
||||
Text(
|
||||
'${item.state.display()} ${max(0, item.fileNum)}/${item.fileCount} '),
|
||||
Text(
|
||||
'${translate("files")} ${readableFileSize(item.totalSize.toDouble())} '),
|
||||
Offstage(
|
||||
offstage:
|
||||
item.state != JobState.inProgress,
|
||||
child: Text(
|
||||
'${readableFileSize(item.speed) + "/s"} ')),
|
||||
Offstage(
|
||||
offstage: item.totalSize <= 0,
|
||||
child: Text(
|
||||
'${(item.finishedSize.toDouble() * 100 / item.totalSize.toDouble()).toStringAsFixed(2)}%'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Offstage(
|
||||
offstage: item.state != JobState.paused,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
model.resumeJob(item.id);
|
||||
},
|
||||
icon: Icon(Icons.restart_alt_rounded)),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.delete),
|
||||
onPressed: () {
|
||||
model.jobTable.removeAt(index);
|
||||
model.cancelJob(item.id);
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
Divider(
|
||||
height: 2.0,
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
itemCount: model.jobTable.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
preferredSize: Size(200, double.infinity));
|
||||
}
|
||||
|
||||
goBack({bool? isLocal}) {
|
||||
model.goToParentDirectory(isLocal: isLocal);
|
||||
}
|
||||
|
||||
Widget headTools(bool isLocal) {
|
||||
final _locationStatus =
|
||||
isLocal ? _locationStatusLocal : _locationStatusRemote;
|
||||
final _locationFocus = isLocal ? _locationNodeLocal : _locationNodeRemote;
|
||||
final _searchTextObs = isLocal ? _searchTextLocal : _searchTextRemote;
|
||||
return Container(
|
||||
child: Column(
|
||||
children: [
|
||||
// symbols
|
||||
PreferredSize(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(color: Colors.blue),
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: FutureBuilder<String>(
|
||||
future: bind.sessionGetPlatform(
|
||||
id: _ffi.id, isRemote: !isLocal),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData && snapshot.data!.isNotEmpty) {
|
||||
return getPlatformImage('${snapshot.data}');
|
||||
} else {
|
||||
return CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
);
|
||||
}
|
||||
})),
|
||||
Text(isLocal
|
||||
? translate("Local Computer")
|
||||
: translate("Remote Computer"))
|
||||
.marginOnly(left: 8.0)
|
||||
],
|
||||
),
|
||||
preferredSize: Size(double.infinity, 70)),
|
||||
// buttons
|
||||
Row(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
model.goHome(isLocal: isLocal);
|
||||
},
|
||||
icon: Icon(Icons.home_outlined)),
|
||||
IconButton(
|
||||
icon: Icon(Icons.arrow_upward),
|
||||
onPressed: () {
|
||||
goBack(isLocal: isLocal);
|
||||
},
|
||||
),
|
||||
menu(isLocal: isLocal),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
_locationStatus.value =
|
||||
_locationStatus.value == LocationStatus.bread
|
||||
? LocationStatus.textField
|
||||
: LocationStatus.bread;
|
||||
Future.delayed(Duration.zero, () {
|
||||
if (_locationStatus.value == LocationStatus.textField) {
|
||||
_locationFocus.requestFocus();
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
decoration:
|
||||
BoxDecoration(border: Border.all(color: Colors.black12)),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Obx(() =>
|
||||
_locationStatus.value == LocationStatus.bread
|
||||
? buildBread(isLocal)
|
||||
: buildPathLocation(isLocal))),
|
||||
DropdownButton<String>(
|
||||
isDense: true,
|
||||
underline: Offstage(),
|
||||
items: [
|
||||
// TODO: favourite
|
||||
DropdownMenuItem(
|
||||
child: Text('/'),
|
||||
value: '/',
|
||||
)
|
||||
],
|
||||
onChanged: (path) {
|
||||
if (path is String && path.isNotEmpty) {
|
||||
openDirectory(path, isLocal: isLocal);
|
||||
}
|
||||
})
|
||||
],
|
||||
)),
|
||||
)),
|
||||
PopupMenuButton(
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
enabled: false,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(minWidth: 200),
|
||||
child: TextField(
|
||||
controller:
|
||||
TextEditingController(text: _searchTextObs.value),
|
||||
autofocus: true,
|
||||
decoration:
|
||||
InputDecoration(prefixIcon: Icon(Icons.search)),
|
||||
onChanged: (searchText) =>
|
||||
onSearchText(searchText, isLocal),
|
||||
),
|
||||
))
|
||||
],
|
||||
child: Icon(Icons.search),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
model.refresh(isLocal: isLocal);
|
||||
},
|
||||
icon: Icon(Icons.refresh)),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
textDirection: isLocal ? TextDirection.ltr : TextDirection.rtl,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
isLocal ? MainAxisAlignment.start : MainAxisAlignment.end,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
final name = TextEditingController();
|
||||
_ffi.dialogManager
|
||||
.show((setState, close) => CustomAlertDialog(
|
||||
title: Text(translate("Create Folder")),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: translate(
|
||||
"Please enter the folder name"),
|
||||
),
|
||||
controller: name,
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: () => close(false),
|
||||
child: Text(translate("Cancel"))),
|
||||
ElevatedButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
if (name.value.text.isNotEmpty) {
|
||||
model.createDir(
|
||||
PathUtil.join(
|
||||
model
|
||||
.getCurrentDir(
|
||||
isLocal)
|
||||
.path,
|
||||
name.value.text,
|
||||
model.getCurrentIsWindows(
|
||||
isLocal)),
|
||||
isLocal: isLocal);
|
||||
close();
|
||||
}
|
||||
},
|
||||
child: Text(translate("OK")))
|
||||
]));
|
||||
},
|
||||
icon: Icon(Icons.create_new_folder_outlined)),
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
final items = isLocal
|
||||
? _localSelectedItems
|
||||
: _remoteSelectedItems;
|
||||
await (model.removeAction(items, isLocal: isLocal));
|
||||
items.clear();
|
||||
},
|
||||
icon: Icon(Icons.delete_forever_outlined)),
|
||||
],
|
||||
),
|
||||
),
|
||||
TextButton.icon(
|
||||
onPressed: () {
|
||||
final items = getSelectedItem(isLocal);
|
||||
model.sendFiles(items, isRemote: !isLocal);
|
||||
items.clear();
|
||||
},
|
||||
icon: Transform.rotate(
|
||||
angle: isLocal ? 0 : pi,
|
||||
child: Icon(
|
||||
Icons.send,
|
||||
),
|
||||
),
|
||||
label: Text(
|
||||
isLocal ? translate('Send') : translate('Receive'),
|
||||
)),
|
||||
],
|
||||
).marginOnly(top: 8.0)
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
Widget listTail({bool isLocal = false}) {
|
||||
final dir = isLocal ? model.currentLocalDir : model.currentRemoteDir;
|
||||
return Container(
|
||||
height: 100,
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(30, 5, 30, 0),
|
||||
child: Text(
|
||||
dir.path,
|
||||
style: TextStyle(color: MyTheme.darkGray),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(2),
|
||||
child: Text(
|
||||
"${translate("Total")}: ${dir.entries.length} ${translate("items")}",
|
||||
style: TextStyle(color: MyTheme.darkGray),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
/// Get the image for the current [platform].
|
||||
Widget getPlatformImage(String platform) {
|
||||
platform = platform.toLowerCase();
|
||||
if (platform == 'mac os')
|
||||
platform = 'mac';
|
||||
else if (platform != 'linux' && platform != 'android') platform = 'win';
|
||||
return Image.asset('assets/$platform.png', width: 25, height: 25);
|
||||
}
|
||||
|
||||
void onLocalLocationFocusChanged() {
|
||||
debugPrint("focus changed on local");
|
||||
if (_locationNodeLocal.hasFocus) {
|
||||
// ignore
|
||||
} else {
|
||||
// lost focus, change to bread
|
||||
_locationStatusLocal.value = LocationStatus.bread;
|
||||
}
|
||||
}
|
||||
|
||||
void onRemoteLocationFocusChanged() {
|
||||
debugPrint("focus changed on remote");
|
||||
if (_locationNodeRemote.hasFocus) {
|
||||
// ignore
|
||||
} else {
|
||||
// lost focus, change to bread
|
||||
_locationStatusRemote.value = LocationStatus.bread;
|
||||
}
|
||||
}
|
||||
|
||||
Widget buildBread(bool isLocal) {
|
||||
final items = getPathBreadCrumbItems(isLocal, (list) {
|
||||
var path = "";
|
||||
for (var item in list) {
|
||||
path = PathUtil.join(path, item, model.getCurrentIsWindows(isLocal));
|
||||
}
|
||||
openDirectory(path, isLocal: isLocal);
|
||||
});
|
||||
return items.isEmpty
|
||||
? Offstage()
|
||||
: BreadCrumb(
|
||||
items: items,
|
||||
divider: Text("/").paddingSymmetric(horizontal: 4.0),
|
||||
overflow: ScrollableOverflow(
|
||||
controller: getBreadCrumbScrollController(isLocal)),
|
||||
);
|
||||
}
|
||||
|
||||
List<BreadCrumbItem> getPathBreadCrumbItems(
|
||||
bool isLocal, void Function(List<String>) onPressed) {
|
||||
final path = model.getCurrentDir(isLocal).path;
|
||||
final list = PathUtil.split(path, model.getCurrentIsWindows(isLocal));
|
||||
final breadCrumbList = List<BreadCrumbItem>.empty(growable: true);
|
||||
breadCrumbList.addAll(list.asMap().entries.map((e) => BreadCrumbItem(
|
||||
content: TextButton(
|
||||
child: Text(e.value),
|
||||
style:
|
||||
ButtonStyle(minimumSize: MaterialStateProperty.all(Size(0, 0))),
|
||||
onPressed: () => onPressed(list.sublist(0, e.key + 1))))));
|
||||
return breadCrumbList;
|
||||
}
|
||||
|
||||
breadCrumbScrollToEnd(bool isLocal) {
|
||||
Future.delayed(Duration(milliseconds: 200), () {
|
||||
final _breadCrumbScroller = getBreadCrumbScrollController(isLocal);
|
||||
_breadCrumbScroller.animateTo(
|
||||
_breadCrumbScroller.position.maxScrollExtent,
|
||||
duration: Duration(milliseconds: 200),
|
||||
curve: Curves.fastLinearToSlowEaseIn);
|
||||
});
|
||||
}
|
||||
|
||||
Widget buildPathLocation(bool isLocal) {
|
||||
return TextField(
|
||||
focusNode: isLocal ? _locationNodeLocal : _locationNodeRemote,
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
isDense: true,
|
||||
prefix: Padding(padding: EdgeInsets.only(left: 4.0)),
|
||||
),
|
||||
controller:
|
||||
TextEditingController(text: model.getCurrentDir(isLocal).path),
|
||||
onSubmitted: (path) {
|
||||
openDirectory(path, isLocal: isLocal);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
onSearchText(String searchText, bool isLocal) {
|
||||
if (isLocal) {
|
||||
_searchTextLocal.value = searchText;
|
||||
} else {
|
||||
_searchTextRemote.value = searchText;
|
||||
}
|
||||
}
|
||||
|
||||
openDirectory(String path, {bool isLocal = false}) {
|
||||
model.openDirectory(path, isLocal: isLocal).then((_) {
|
||||
print("scroll");
|
||||
breadCrumbScrollToEnd(isLocal);
|
||||
});
|
||||
}
|
||||
|
||||
void handleDragDone(DropDoneDetails details, bool isLocal) {
|
||||
if (isLocal) {
|
||||
// ignore local
|
||||
return;
|
||||
}
|
||||
var items = SelectedItems();
|
||||
details.files.forEach((file) {
|
||||
final f = File(file.path);
|
||||
items.add(
|
||||
true,
|
||||
Entry()
|
||||
..path = file.path
|
||||
..name = file.name
|
||||
..size =
|
||||
FileSystemEntity.isDirectorySync(f.path) ? 0 : f.lengthSync());
|
||||
});
|
||||
model.sendFiles(items, isRemote: false);
|
||||
}
|
||||
}
|
||||
102
flutter/lib/desktop/pages/file_manager_tab_page.dart
Normal file
102
flutter/lib/desktop/pages/file_manager_tab_page.dart
Normal file
@@ -0,0 +1,102 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/file_manager_page.dart';
|
||||
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
|
||||
import 'package:flutter_hbb/models/model.dart';
|
||||
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
/// File Transfer for multi tabs
|
||||
class FileManagerTabPage extends StatefulWidget {
|
||||
final Map<String, dynamic> params;
|
||||
|
||||
const FileManagerTabPage({Key? key, required this.params}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<FileManagerTabPage> createState() => _FileManagerTabPageState(params);
|
||||
}
|
||||
|
||||
class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
||||
final tabController = Get.put(DesktopTabController());
|
||||
|
||||
static final IconData selectedIcon = Icons.file_copy_sharp;
|
||||
static final IconData unselectedIcon = Icons.file_copy_outlined;
|
||||
|
||||
_FileManagerTabPageState(Map<String, dynamic> params) {
|
||||
tabController.add(TabInfo(
|
||||
key: params['id'],
|
||||
label: params['id'],
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
page: FileManagerPage(key: ValueKey(params['id']), id: params['id'])));
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
tabController.onRemove = (_, id) => onRemoveId(id);
|
||||
|
||||
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
|
||||
print(
|
||||
"call ${call.method} with args ${call.arguments} from window ${fromWindowId}");
|
||||
// for simplify, just replace connectionId
|
||||
if (call.method == "new_file_transfer") {
|
||||
final args = jsonDecode(call.arguments);
|
||||
final id = args['id'];
|
||||
window_on_top(windowId());
|
||||
tabController.add(TabInfo(
|
||||
key: id,
|
||||
label: id,
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
page: FileManagerPage(key: ValueKey(id), id: id)));
|
||||
} else if (call.method == "onDestroy") {
|
||||
tabController.state.value.tabs.forEach((tab) {
|
||||
print("executing onDestroy hook, closing ${tab.label}}");
|
||||
final tag = tab.label;
|
||||
ffi(tag).close().then((_) {
|
||||
Get.delete<FFI>(tag: tag);
|
||||
});
|
||||
});
|
||||
Get.back();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = isDarkTheme() ? TarBarTheme.dark() : TarBarTheme.light();
|
||||
return SubWindowDragToResizeArea(
|
||||
windowId: windowId(),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: MyTheme.color(context).border!)),
|
||||
child: Scaffold(
|
||||
backgroundColor: MyTheme.color(context).bg,
|
||||
body: DesktopTab(
|
||||
controller: tabController,
|
||||
theme: theme,
|
||||
isMainWindow: false,
|
||||
tail: AddButton(
|
||||
theme: theme,
|
||||
).paddingOnly(left: 10),
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void onRemoveId(String id) {
|
||||
ffi("ft_$id").close();
|
||||
if (tabController.state.value.tabs.length == 0) {
|
||||
WindowController.fromWindowId(windowId()).close();
|
||||
}
|
||||
}
|
||||
|
||||
int windowId() {
|
||||
return widget.params["windowId"];
|
||||
}
|
||||
}
|
||||
1254
flutter/lib/desktop/pages/remote_page.dart
Normal file
1254
flutter/lib/desktop/pages/remote_page.dart
Normal file
File diff suppressed because it is too large
Load Diff
574
flutter/lib/desktop/pages/server_page.dart
Normal file
574
flutter/lib/desktop/pages/server_page.dart
Normal file
@@ -0,0 +1,574 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
|
||||
import 'package:flutter_hbb/mobile/pages/chat_page.dart';
|
||||
import 'package:flutter_hbb/models/chat_model.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
import '../../models/server_model.dart';
|
||||
|
||||
class DesktopServerPage extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() => _DesktopServerPageState();
|
||||
}
|
||||
|
||||
class _DesktopServerPageState extends State<DesktopServerPage>
|
||||
with WindowListener, AutomaticKeepAliveClientMixin {
|
||||
@override
|
||||
void initState() {
|
||||
gFFI.ffiModel.updateEventListener("");
|
||||
windowManager.addListener(this);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
windowManager.removeListener(this);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowClose() {
|
||||
gFFI.serverModel.closeAll();
|
||||
gFFI.close();
|
||||
super.onWindowClose();
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider.value(value: gFFI.serverModel),
|
||||
ChangeNotifierProvider.value(value: gFFI.chatModel),
|
||||
],
|
||||
child: Consumer<ServerModel>(
|
||||
builder: (context, serverModel, child) => Container(
|
||||
decoration: BoxDecoration(
|
||||
border:
|
||||
Border.all(color: MyTheme.color(context).border!)),
|
||||
child: Scaffold(
|
||||
backgroundColor: MyTheme.color(context).bg,
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(child: ConnectionManager()),
|
||||
SizedBox.fromSize(size: Size(0, 15.0)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)));
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
||||
|
||||
class ConnectionManager extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() => ConnectionManagerState();
|
||||
}
|
||||
|
||||
class ConnectionManagerState extends State<ConnectionManager> {
|
||||
@override
|
||||
void initState() {
|
||||
gFFI.serverModel.updateClientState();
|
||||
gFFI.serverModel.tabController.onSelected = (index) =>
|
||||
gFFI.chatModel.changeCurrentID(gFFI.serverModel.clients[index].id);
|
||||
// test
|
||||
// gFFI.serverModel.clients.forEach((client) {
|
||||
// DesktopTabBar.onAdd(
|
||||
// gFFI.serverModel.tabs,
|
||||
// TabInfo(
|
||||
// key: client.id.toString(), label: client.name, closable: false));
|
||||
// });
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final serverModel = Provider.of<ServerModel>(context);
|
||||
return serverModel.clients.isEmpty
|
||||
? Column(
|
||||
children: [
|
||||
buildTitleBar(Offstage()),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(translate("Waiting")),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: DesktopTab(
|
||||
theme: isDarkTheme() ? TarBarTheme.dark() : TarBarTheme.light(),
|
||||
showTitle: false,
|
||||
showMaximize: false,
|
||||
showMinimize: false,
|
||||
controller: serverModel.tabController,
|
||||
isMainWindow: true,
|
||||
pageViewBuilder: (pageView) => Row(children: [
|
||||
Expanded(child: pageView),
|
||||
Consumer<ChatModel>(
|
||||
builder: (_, model, child) => model.isShowChatPage
|
||||
? Expanded(child: Scaffold(body: ChatPage()))
|
||||
: Offstage())
|
||||
]));
|
||||
}
|
||||
|
||||
Widget buildTitleBar(Widget middle) {
|
||||
return GestureDetector(
|
||||
onPanDown: (d) {
|
||||
windowManager.startDragging();
|
||||
},
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
_AppIcon(),
|
||||
Expanded(child: middle),
|
||||
const SizedBox(
|
||||
width: 4.0,
|
||||
),
|
||||
_CloseButton()
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildTab(Client client) {
|
||||
return Tab(
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 80,
|
||||
child: Text(
|
||||
"${client.name}",
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget buildConnectionCard(Client client) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
key: ValueKey(client.id),
|
||||
children: [
|
||||
_CmHeader(client: client),
|
||||
client.isFileTransfer ? Offstage() : _PrivilegeBoard(client: client),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: _CmControlPanel(client: client),
|
||||
))
|
||||
],
|
||||
).paddingSymmetric(vertical: 8.0, horizontal: 8.0);
|
||||
}
|
||||
|
||||
class _AppIcon extends StatelessWidget {
|
||||
const _AppIcon({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 4.0),
|
||||
child: Image.asset(
|
||||
'assets/logo.ico',
|
||||
width: 30,
|
||||
height: 30,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _CloseButton extends StatelessWidget {
|
||||
const _CloseButton({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Ink(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
windowManager.close();
|
||||
},
|
||||
child: Icon(
|
||||
Icons.close,
|
||||
size: 30,
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _CmHeader extends StatefulWidget {
|
||||
final Client client;
|
||||
|
||||
const _CmHeader({Key? key, required this.client}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<_CmHeader> createState() => _CmHeaderState();
|
||||
}
|
||||
|
||||
class _CmHeaderState extends State<_CmHeader>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
Client get client => widget.client;
|
||||
|
||||
var _time = 0.obs;
|
||||
Timer? _timer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_timer = Timer.periodic(Duration(seconds: 1), (_) {
|
||||
_time.value = _time.value + 1;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// icon
|
||||
Container(
|
||||
width: 90,
|
||||
height: 90,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(color: str2color(client.name)),
|
||||
child: Text(
|
||||
"${client.name[0]}",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold, color: Colors.white, fontSize: 65),
|
||||
),
|
||||
).marginOnly(left: 4.0, right: 8.0),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
FittedBox(
|
||||
child: Text(
|
||||
"${client.name}",
|
||||
style: TextStyle(
|
||||
color: MyTheme.cmIdColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
maxLines: 1,
|
||||
)),
|
||||
FittedBox(
|
||||
child: Text("(${client.peerId})",
|
||||
style:
|
||||
TextStyle(color: MyTheme.cmIdColor, fontSize: 14))),
|
||||
SizedBox(
|
||||
height: 16.0,
|
||||
),
|
||||
FittedBox(
|
||||
child: Row(
|
||||
children: [
|
||||
Text("${translate("Connected")}").marginOnly(right: 8.0),
|
||||
Obx(() => Text(
|
||||
"${formatDurationToTime(Duration(seconds: _time.value))}"))
|
||||
],
|
||||
))
|
||||
],
|
||||
),
|
||||
),
|
||||
Offstage(
|
||||
offstage: client.isFileTransfer,
|
||||
child: IconButton(
|
||||
onPressed: () => gFFI.chatModel.toggleCMChatPage(client.id),
|
||||
icon: Icon(Icons.message_outlined),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
||||
|
||||
class _PrivilegeBoard extends StatefulWidget {
|
||||
final Client client;
|
||||
|
||||
const _PrivilegeBoard({Key? key, required this.client}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _PrivilegeBoardState();
|
||||
}
|
||||
|
||||
class _PrivilegeBoardState extends State<_PrivilegeBoard> {
|
||||
late final client = widget.client;
|
||||
Widget buildPermissionIcon(bool enabled, ImageProvider icon,
|
||||
Function(bool)? onTap, String? tooltip) {
|
||||
return Tooltip(
|
||||
message: tooltip ?? "",
|
||||
child: Ink(
|
||||
decoration:
|
||||
BoxDecoration(color: enabled ? MyTheme.accent80 : Colors.grey),
|
||||
padding: EdgeInsets.all(4.0),
|
||||
child: InkWell(
|
||||
onTap: () => onTap?.call(!enabled),
|
||||
child: Image(
|
||||
image: icon,
|
||||
width: 50,
|
||||
height: 50,
|
||||
fit: BoxFit.scaleDown,
|
||||
),
|
||||
),
|
||||
).marginSymmetric(horizontal: 4.0),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(top: 16.0, bottom: 8.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
translate("Permissions"),
|
||||
style: TextStyle(fontSize: 16),
|
||||
).marginOnly(left: 4.0),
|
||||
SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
FittedBox(
|
||||
child: Row(
|
||||
children: [
|
||||
buildPermissionIcon(client.keyboard, iconKeyboard, (enabled) {
|
||||
bind.cmSwitchPermission(
|
||||
connId: client.id, name: "keyboard", enabled: enabled);
|
||||
setState(() {
|
||||
client.keyboard = enabled;
|
||||
});
|
||||
}, null),
|
||||
buildPermissionIcon(client.clipboard, iconClipboard, (enabled) {
|
||||
bind.cmSwitchPermission(
|
||||
connId: client.id, name: "clipboard", enabled: enabled);
|
||||
setState(() {
|
||||
client.clipboard = enabled;
|
||||
});
|
||||
}, null),
|
||||
buildPermissionIcon(client.audio, iconAudio, (enabled) {
|
||||
bind.cmSwitchPermission(
|
||||
connId: client.id, name: "audio", enabled: enabled);
|
||||
setState(() {
|
||||
client.audio = enabled;
|
||||
});
|
||||
}, null),
|
||||
buildPermissionIcon(client.file, iconFile, (enabled) {
|
||||
bind.cmSwitchPermission(
|
||||
connId: client.id, name: "file", enabled: enabled);
|
||||
setState(() {
|
||||
client.file = enabled;
|
||||
});
|
||||
}, null),
|
||||
buildPermissionIcon(client.restart, iconRestart, (enabled) {
|
||||
bind.cmSwitchPermission(
|
||||
connId: client.id, name: "restart", enabled: enabled);
|
||||
setState(() {
|
||||
client.restart = enabled;
|
||||
});
|
||||
}, null),
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _CmControlPanel extends StatelessWidget {
|
||||
final Client client;
|
||||
|
||||
const _CmControlPanel({Key? key, required this.client}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<ServerModel>(builder: (_, model, child) {
|
||||
return client.authorized
|
||||
? buildAuthorized(context)
|
||||
: buildUnAuthorized(context);
|
||||
});
|
||||
}
|
||||
|
||||
buildAuthorized(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Ink(
|
||||
width: 200,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.redAccent, borderRadius: BorderRadius.circular(10)),
|
||||
child: InkWell(
|
||||
onTap: () => handleDisconnect(context),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
translate("Disconnect"),
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
],
|
||||
)),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
buildUnAuthorized(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Ink(
|
||||
width: 100,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: MyTheme.accent, borderRadius: BorderRadius.circular(10)),
|
||||
child: InkWell(
|
||||
onTap: () => handleAccept(context),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
translate("Accept"),
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
],
|
||||
)),
|
||||
),
|
||||
SizedBox(
|
||||
width: 30,
|
||||
),
|
||||
Ink(
|
||||
width: 100,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: Colors.grey)),
|
||||
child: InkWell(
|
||||
onTap: () => handleDisconnect(context),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
translate("Cancel"),
|
||||
style: TextStyle(),
|
||||
),
|
||||
],
|
||||
)),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void handleDisconnect(BuildContext context) {
|
||||
bind.cmCloseConnection(connId: client.id);
|
||||
}
|
||||
|
||||
void handleAccept(BuildContext context) {
|
||||
final model = Provider.of<ServerModel>(context, listen: false);
|
||||
model.sendLoginResponse(client, true);
|
||||
}
|
||||
}
|
||||
|
||||
class PaddingCard extends StatelessWidget {
|
||||
PaddingCard({required this.child, this.title, this.titleIcon});
|
||||
|
||||
final String? title;
|
||||
final IconData? titleIcon;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final children = [child];
|
||||
if (title != null) {
|
||||
children.insert(
|
||||
0,
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 5.0),
|
||||
child: Row(
|
||||
children: [
|
||||
titleIcon != null
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(right: 10),
|
||||
child: Icon(titleIcon,
|
||||
color: MyTheme.accent80, size: 30))
|
||||
: SizedBox.shrink(),
|
||||
Text(
|
||||
title!,
|
||||
style: TextStyle(
|
||||
fontFamily: 'WorkSans',
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20,
|
||||
color: MyTheme.accent80,
|
||||
),
|
||||
)
|
||||
],
|
||||
)));
|
||||
}
|
||||
return Container(
|
||||
width: double.maxFinite,
|
||||
child: Card(
|
||||
margin: EdgeInsets.fromLTRB(15.0, 15.0, 15.0, 0),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 30.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: children,
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Widget clientInfo(Client client) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 8),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: -1,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(right: 12),
|
||||
child: CircleAvatar(
|
||||
child: Text(client.name[0]),
|
||||
backgroundColor: MyTheme.border))),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(client.name,
|
||||
style: TextStyle(color: MyTheme.idColor, fontSize: 18)),
|
||||
SizedBox(width: 8),
|
||||
Text(client.peerId,
|
||||
style: TextStyle(color: MyTheme.idColor, fontSize: 10))
|
||||
]))
|
||||
],
|
||||
),
|
||||
]));
|
||||
}
|
||||
29
flutter/lib/desktop/screen/desktop_file_transfer_screen.dart
Normal file
29
flutter/lib/desktop/screen/desktop_file_transfer_screen.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/file_manager_tab_page.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
/// multi-tab file transfer remote screen
|
||||
class DesktopFileTransferScreen extends StatelessWidget {
|
||||
final Map<String, dynamic> params;
|
||||
|
||||
const DesktopFileTransferScreen({Key? key, required this.params})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider.value(value: gFFI.ffiModel),
|
||||
ChangeNotifierProvider.value(value: gFFI.imageModel),
|
||||
ChangeNotifierProvider.value(value: gFFI.cursorModel),
|
||||
ChangeNotifierProvider.value(value: gFFI.canvasModel),
|
||||
],
|
||||
child: Scaffold(
|
||||
body: FileManagerTabPage(
|
||||
params: params,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
27
flutter/lib/desktop/screen/desktop_remote_screen.dart
Normal file
27
flutter/lib/desktop/screen/desktop_remote_screen.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/connection_tab_page.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
/// multi-tab desktop remote screen
|
||||
class DesktopRemoteScreen extends StatelessWidget {
|
||||
final Map<String, dynamic> params;
|
||||
|
||||
const DesktopRemoteScreen({Key? key, required this.params}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider.value(value: gFFI.ffiModel),
|
||||
ChangeNotifierProvider.value(value: gFFI.imageModel),
|
||||
ChangeNotifierProvider.value(value: gFFI.cursorModel),
|
||||
ChangeNotifierProvider.value(value: gFFI.canvasModel),
|
||||
],
|
||||
child: Scaffold(
|
||||
body: ConnectionTabPage(
|
||||
params: params,
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
275
flutter/lib/desktop/widgets/peer_widget.dart
Normal file
275
flutter/lib/desktop/widgets/peer_widget.dart
Normal file
@@ -0,0 +1,275 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:visibility_detector/visibility_detector.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
import '../../models/peer_model.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
import 'peercard_widget.dart';
|
||||
|
||||
typedef OffstageFunc = bool Function(Peer peer);
|
||||
typedef PeerCardWidgetFunc = Widget Function(Peer peer);
|
||||
|
||||
/// for peer search text, global obs value
|
||||
final peerSearchText = "".obs;
|
||||
final peerSearchTextController =
|
||||
TextEditingController(text: peerSearchText.value);
|
||||
|
||||
class _PeerWidget extends StatefulWidget {
|
||||
late final _peers;
|
||||
late final OffstageFunc _offstageFunc;
|
||||
late final PeerCardWidgetFunc _peerCardWidgetFunc;
|
||||
|
||||
_PeerWidget(Peers peers, OffstageFunc offstageFunc,
|
||||
PeerCardWidgetFunc peerCardWidgetFunc,
|
||||
{Key? key})
|
||||
: super(key: key) {
|
||||
_peers = peers;
|
||||
_offstageFunc = offstageFunc;
|
||||
_peerCardWidgetFunc = peerCardWidgetFunc;
|
||||
}
|
||||
|
||||
@override
|
||||
_PeerWidgetState createState() => _PeerWidgetState();
|
||||
}
|
||||
|
||||
/// State for the peer widget.
|
||||
class _PeerWidgetState extends State<_PeerWidget> with WindowListener {
|
||||
static const int _maxQueryCount = 3;
|
||||
|
||||
var _curPeers = Set<String>();
|
||||
var _lastChangeTime = DateTime.now();
|
||||
var _lastQueryPeers = Set<String>();
|
||||
var _lastQueryTime = DateTime.now().subtract(Duration(hours: 1));
|
||||
var _queryCoun = 0;
|
||||
var _exit = false;
|
||||
|
||||
_PeerWidgetState() {
|
||||
_startCheckOnlines();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
windowManager.addListener(this);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
windowManager.removeListener(this);
|
||||
_exit = true;
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowFocus() {
|
||||
_queryCoun = 0;
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowMinimize() {
|
||||
_queryCoun = _maxQueryCount;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final space = 12.0;
|
||||
return ChangeNotifierProvider<Peers>(
|
||||
create: (context) => super.widget._peers,
|
||||
child: Consumer<Peers>(
|
||||
builder: (context, peers, child) => peers.peers.isEmpty
|
||||
? Center(
|
||||
child: Text(translate("Empty")),
|
||||
)
|
||||
: SingleChildScrollView(
|
||||
child: ObxValue<RxString>((searchText) {
|
||||
return FutureBuilder<List<Peer>>(
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
final peers = snapshot.data!;
|
||||
final cards = <Widget>[];
|
||||
for (final peer in peers) {
|
||||
cards.add(Offstage(
|
||||
key: ValueKey("off${peer.id}"),
|
||||
offstage: super.widget._offstageFunc(peer),
|
||||
child: Obx(
|
||||
() => SizedBox(
|
||||
width: 220,
|
||||
height:
|
||||
peerCardUiType.value == PeerUiType.grid
|
||||
? 140
|
||||
: 42,
|
||||
child: VisibilityDetector(
|
||||
key: ValueKey(peer.id),
|
||||
onVisibilityChanged: (info) {
|
||||
final peerId =
|
||||
(info.key as ValueKey).value;
|
||||
if (info.visibleFraction > 0.00001) {
|
||||
_curPeers.add(peerId);
|
||||
} else {
|
||||
_curPeers.remove(peerId);
|
||||
}
|
||||
_lastChangeTime = DateTime.now();
|
||||
},
|
||||
child: super
|
||||
.widget
|
||||
._peerCardWidgetFunc(peer),
|
||||
),
|
||||
),
|
||||
)));
|
||||
}
|
||||
return Wrap(
|
||||
spacing: space,
|
||||
runSpacing: space,
|
||||
children: cards);
|
||||
} else {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
},
|
||||
future: matchPeers(searchText.value, peers.peers),
|
||||
);
|
||||
}, peerSearchText),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
// ignore: todo
|
||||
// TODO: variables walk through async tasks?
|
||||
void _startCheckOnlines() {
|
||||
() async {
|
||||
while (!_exit) {
|
||||
final now = DateTime.now();
|
||||
if (!setEquals(_curPeers, _lastQueryPeers)) {
|
||||
if (now.difference(_lastChangeTime) > Duration(seconds: 1)) {
|
||||
if (_curPeers.length > 0) {
|
||||
platformFFI.ffiBind
|
||||
.queryOnlines(ids: _curPeers.toList(growable: false));
|
||||
_lastQueryPeers = {..._curPeers};
|
||||
_lastQueryTime = DateTime.now();
|
||||
_queryCoun = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (_queryCoun < _maxQueryCount) {
|
||||
if (now.difference(_lastQueryTime) > Duration(seconds: 20)) {
|
||||
if (_curPeers.length > 0) {
|
||||
platformFFI.ffiBind
|
||||
.queryOnlines(ids: _curPeers.toList(growable: false));
|
||||
_lastQueryTime = DateTime.now();
|
||||
_queryCoun += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
await Future.delayed(Duration(milliseconds: 300));
|
||||
}
|
||||
}();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class BasePeerWidget extends StatelessWidget {
|
||||
late final _name;
|
||||
late final _loadEvent;
|
||||
late final OffstageFunc _offstageFunc;
|
||||
late final PeerCardWidgetFunc _peerCardWidgetFunc;
|
||||
late final List<Peer> _initPeers;
|
||||
|
||||
BasePeerWidget({Key? key}) : super(key: key) {}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return _PeerWidget(Peers(_name, _loadEvent, _initPeers), _offstageFunc,
|
||||
_peerCardWidgetFunc);
|
||||
}
|
||||
}
|
||||
|
||||
class RecentPeerWidget extends BasePeerWidget {
|
||||
RecentPeerWidget({Key? key}) : super(key: key) {
|
||||
super._name = "recent peer";
|
||||
super._loadEvent = "load_recent_peers";
|
||||
super._offstageFunc = (Peer _peer) => false;
|
||||
super._peerCardWidgetFunc = (Peer peer) => RecentPeerCard(
|
||||
peer: peer,
|
||||
);
|
||||
super._initPeers = [];
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final widget = super.build(context);
|
||||
bind.mainLoadRecentPeers();
|
||||
return widget;
|
||||
}
|
||||
}
|
||||
|
||||
class FavoritePeerWidget extends BasePeerWidget {
|
||||
FavoritePeerWidget({Key? key}) : super(key: key) {
|
||||
super._name = "favorite peer";
|
||||
super._loadEvent = "load_fav_peers";
|
||||
super._offstageFunc = (Peer _peer) => false;
|
||||
super._peerCardWidgetFunc = (Peer peer) => FavoritePeerCard(peer: peer);
|
||||
super._initPeers = [];
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final widget = super.build(context);
|
||||
bind.mainLoadFavPeers();
|
||||
return widget;
|
||||
}
|
||||
}
|
||||
|
||||
class DiscoveredPeerWidget extends BasePeerWidget {
|
||||
DiscoveredPeerWidget({Key? key}) : super(key: key) {
|
||||
super._name = "discovered peer";
|
||||
super._loadEvent = "load_lan_peers";
|
||||
super._offstageFunc = (Peer _peer) => false;
|
||||
super._peerCardWidgetFunc = (Peer peer) => DiscoveredPeerCard(peer: peer);
|
||||
super._initPeers = [];
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final widget = super.build(context);
|
||||
bind.mainLoadLanPeers();
|
||||
return widget;
|
||||
}
|
||||
}
|
||||
|
||||
class AddressBookPeerWidget extends BasePeerWidget {
|
||||
AddressBookPeerWidget({Key? key}) : super(key: key) {
|
||||
super._name = "address book peer";
|
||||
super._offstageFunc =
|
||||
(Peer peer) => !_hitTag(gFFI.abModel.selectedTags, peer.tags);
|
||||
super._peerCardWidgetFunc = (Peer peer) => AddressBookPeerCard(peer: peer);
|
||||
super._initPeers = _loadPeers();
|
||||
}
|
||||
|
||||
List<Peer> _loadPeers() {
|
||||
return gFFI.abModel.peers.map((e) {
|
||||
return Peer.fromJson(e['id'], e);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
bool _hitTag(List<dynamic> selectedTags, List<dynamic> idents) {
|
||||
if (selectedTags.isEmpty) {
|
||||
return true;
|
||||
}
|
||||
if (idents.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
for (final tag in selectedTags) {
|
||||
if (!idents.contains(tag)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
666
flutter/lib/desktop/widgets/peercard_widget.dart
Normal file
666
flutter/lib/desktop/widgets/peercard_widget.dart
Normal file
@@ -0,0 +1,666 @@
|
||||
import 'package:contextmenu/contextmenu.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
import '../../models/model.dart';
|
||||
import '../../models/peer_model.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
|
||||
typedef PopupMenuItemsFunc = Future<List<PopupMenuItem<String>>> Function();
|
||||
|
||||
enum PeerType { recent, fav, discovered, ab }
|
||||
|
||||
enum PeerUiType { grid, list }
|
||||
|
||||
final peerCardUiType = PeerUiType.grid.obs;
|
||||
|
||||
class _PeerCard extends StatefulWidget {
|
||||
final Peer peer;
|
||||
final PopupMenuItemsFunc popupMenuItemsFunc;
|
||||
final PeerType type;
|
||||
|
||||
_PeerCard(
|
||||
{required this.peer,
|
||||
required this.popupMenuItemsFunc,
|
||||
Key? key,
|
||||
required this.type})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_PeerCardState createState() => _PeerCardState();
|
||||
}
|
||||
|
||||
/// State for the connection page.
|
||||
class _PeerCardState extends State<_PeerCard>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
var _menuPos = RelativeRect.fill;
|
||||
final double _cardRadis = 20;
|
||||
final double _borderWidth = 2;
|
||||
final RxBool _iconMoreHover = false.obs;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
final peer = super.widget.peer;
|
||||
var deco = Rx<BoxDecoration?>(BoxDecoration(
|
||||
border: Border.all(color: Colors.transparent, width: _borderWidth),
|
||||
borderRadius: peerCardUiType.value == PeerUiType.grid
|
||||
? BorderRadius.circular(_cardRadis)
|
||||
: null));
|
||||
return MouseRegion(
|
||||
onEnter: (evt) {
|
||||
deco.value = BoxDecoration(
|
||||
border: Border.all(color: MyTheme.button, width: _borderWidth),
|
||||
borderRadius: peerCardUiType.value == PeerUiType.grid
|
||||
? BorderRadius.circular(_cardRadis)
|
||||
: null);
|
||||
},
|
||||
onExit: (evt) {
|
||||
deco.value = BoxDecoration(
|
||||
border: Border.all(color: Colors.transparent, width: _borderWidth),
|
||||
borderRadius: peerCardUiType.value == PeerUiType.grid
|
||||
? BorderRadius.circular(_cardRadis)
|
||||
: null);
|
||||
},
|
||||
child: GestureDetector(
|
||||
onDoubleTap: () => _connect(peer.id),
|
||||
child: Obx(() => peerCardUiType.value == PeerUiType.grid
|
||||
? _buildPeerCard(context, peer, deco)
|
||||
: _buildPeerTile(context, peer, deco))),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPeerTile(
|
||||
BuildContext context, Peer peer, Rx<BoxDecoration?> deco) {
|
||||
final greyStyle =
|
||||
TextStyle(fontSize: 12, color: MyTheme.color(context).lighterText);
|
||||
return Obx(
|
||||
() => Container(
|
||||
foregroundDecoration: deco.value,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: str2color('${peer.id}${peer.platform}', 0x7f),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: _getPlatformImage('${peer.platform}', 30).paddingAll(6),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(color: MyTheme.color(context).bg),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Row(children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(0, 4, 4, 4),
|
||||
child: CircleAvatar(
|
||||
radius: 5,
|
||||
backgroundColor: peer.online
|
||||
? Colors.green
|
||||
: Colors.yellow)),
|
||||
Text(
|
||||
'${peer.id}',
|
||||
style: TextStyle(fontWeight: FontWeight.w400),
|
||||
),
|
||||
]),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: FutureBuilder<String>(
|
||||
future: bind.mainGetPeerOption(
|
||||
id: peer.id, key: 'alias'),
|
||||
builder: (_, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
final name = snapshot.data!.isEmpty
|
||||
? '${peer.username}@${peer.hostname}'
|
||||
: snapshot.data!;
|
||||
return Tooltip(
|
||||
message: name,
|
||||
waitDuration: Duration(seconds: 1),
|
||||
child: Text(
|
||||
name,
|
||||
style: greyStyle,
|
||||
textAlign: TextAlign.start,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// alias has not arrived
|
||||
return Text(
|
||||
'${peer.username}@${peer.hostname}',
|
||||
style: greyStyle,
|
||||
textAlign: TextAlign.start,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
_actionMore(peer),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 4.0),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPeerCard(
|
||||
BuildContext context, Peer peer, Rx<BoxDecoration?> deco) {
|
||||
return Card(
|
||||
color: Colors.transparent,
|
||||
elevation: 0,
|
||||
margin: EdgeInsets.zero,
|
||||
child: Obx(
|
||||
() => Container(
|
||||
foregroundDecoration: deco.value,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(_cardRadis - _borderWidth),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
color: str2color('${peer.id}${peer.platform}', 0x7f),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(6),
|
||||
child:
|
||||
_getPlatformImage('${peer.platform}', 60),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: FutureBuilder<String>(
|
||||
future: bind.mainGetPeerOption(
|
||||
id: peer.id, key: 'alias'),
|
||||
builder: (_, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
final name = snapshot.data!.isEmpty
|
||||
? '${peer.username}@${peer.hostname}'
|
||||
: snapshot.data!;
|
||||
return Tooltip(
|
||||
message: name,
|
||||
waitDuration: Duration(seconds: 1),
|
||||
child: Text(
|
||||
name,
|
||||
style: TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 12),
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// alias has not arrived
|
||||
return Center(
|
||||
child: Text(
|
||||
'${peer.username}@${peer.hostname}',
|
||||
style: TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 12),
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
));
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
).paddingAll(4.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
color: MyTheme.color(context).bg,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(0, 4, 8, 4),
|
||||
child: CircleAvatar(
|
||||
radius: 5,
|
||||
backgroundColor: peer.online
|
||||
? Colors.green
|
||||
: Colors.yellow)),
|
||||
Text('${peer.id}')
|
||||
]).paddingSymmetric(vertical: 8),
|
||||
_actionMore(peer),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 12.0),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _actionMore(Peer peer) => Listener(
|
||||
onPointerDown: (e) {
|
||||
final x = e.position.dx;
|
||||
final y = e.position.dy;
|
||||
_menuPos = RelativeRect.fromLTRB(x, y, x, y);
|
||||
},
|
||||
onPointerUp: (_) => _showPeerMenu(context, peer.id),
|
||||
child: MouseRegion(
|
||||
onEnter: (_) => _iconMoreHover.value = true,
|
||||
onExit: (_) => _iconMoreHover.value = false,
|
||||
child: CircleAvatar(
|
||||
radius: 14,
|
||||
backgroundColor: _iconMoreHover.value
|
||||
? MyTheme.color(context).grayBg!
|
||||
: MyTheme.color(context).bg!,
|
||||
child: Icon(Icons.more_vert,
|
||||
size: 18,
|
||||
color: _iconMoreHover.value
|
||||
? MyTheme.color(context).text
|
||||
: MyTheme.color(context).lightText))));
|
||||
|
||||
/// Connect to a peer with [id].
|
||||
/// If [isFileTransfer], starts a session only for file transfer.
|
||||
void _connect(String id, {bool isFileTransfer = false}) async {
|
||||
if (id == '') return;
|
||||
id = id.replaceAll(' ', '');
|
||||
if (isFileTransfer) {
|
||||
await rustDeskWinManager.new_file_transfer(id);
|
||||
} else {
|
||||
await rustDeskWinManager.new_remote_desktop(id);
|
||||
}
|
||||
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||
if (!currentFocus.hasPrimaryFocus) {
|
||||
currentFocus.unfocus();
|
||||
}
|
||||
}
|
||||
|
||||
/// Show the peer menu and handle user's choice.
|
||||
/// User might remove the peer or send a file to the peer.
|
||||
void _showPeerMenu(BuildContext context, String id) async {
|
||||
var value = await showMenu(
|
||||
context: context,
|
||||
position: _menuPos,
|
||||
items: await super.widget.popupMenuItemsFunc(),
|
||||
elevation: 8,
|
||||
);
|
||||
if (value == 'remove') {
|
||||
await bind.mainRemovePeer(id: id);
|
||||
removePreference(id);
|
||||
Get.forceAppUpdate(); // TODO use inner model / state
|
||||
} else if (value == 'file') {
|
||||
_connect(id, isFileTransfer: true);
|
||||
} else if (value == 'add-fav') {
|
||||
final favs = (await bind.mainGetFav()).toList();
|
||||
if (favs.indexOf(id) < 0) {
|
||||
favs.add(id);
|
||||
bind.mainStoreFav(favs: favs);
|
||||
}
|
||||
} else if (value == 'remove-fav') {
|
||||
final favs = (await bind.mainGetFav()).toList();
|
||||
if (favs.remove(id)) {
|
||||
bind.mainStoreFav(favs: favs);
|
||||
Get.forceAppUpdate(); // TODO use inner model / state
|
||||
}
|
||||
} else if (value == 'connect') {
|
||||
_connect(id, isFileTransfer: false);
|
||||
} else if (value == 'ab-delete') {
|
||||
gFFI.abModel.deletePeer(id);
|
||||
await gFFI.abModel.updateAb();
|
||||
setState(() {});
|
||||
} else if (value == 'ab-edit-tag') {
|
||||
_abEditTag(id);
|
||||
} else if (value == 'rename') {
|
||||
_rename(id);
|
||||
} else if (value == 'unremember-password') {
|
||||
await bind.mainForgetPassword(id: id);
|
||||
} else if (value == 'force-always-relay') {
|
||||
String value;
|
||||
String oldValue =
|
||||
await bind.mainGetPeerOption(id: id, key: 'force-always-relay');
|
||||
if (oldValue.isEmpty) {
|
||||
value = 'Y';
|
||||
} else {
|
||||
value = '';
|
||||
}
|
||||
await bind.mainSetPeerOption(
|
||||
id: id, key: 'force-always-relay', value: value);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildTag(String tagName, RxList<dynamic> rxTags,
|
||||
{Function()? onTap}) {
|
||||
return ContextMenuArea(
|
||||
width: 100,
|
||||
builder: (context) => [
|
||||
ListTile(
|
||||
title: Text(translate("Delete")),
|
||||
onTap: () {
|
||||
gFFI.abModel.deleteTag(tagName);
|
||||
gFFI.abModel.updateAb();
|
||||
Future.delayed(Duration.zero, () => Get.back());
|
||||
},
|
||||
)
|
||||
],
|
||||
child: GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Obx(
|
||||
() => Container(
|
||||
decoration: BoxDecoration(
|
||||
color: rxTags.contains(tagName) ? Colors.blue : null,
|
||||
border: Border.all(color: MyTheme.darkGray),
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
margin: EdgeInsets.symmetric(horizontal: 4.0, vertical: 8.0),
|
||||
padding: EdgeInsets.symmetric(vertical: 2.0, horizontal: 8.0),
|
||||
child: Text(
|
||||
tagName,
|
||||
style: TextStyle(
|
||||
color: rxTags.contains(tagName) ? MyTheme.white : null),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Get the image for the current [platform].
|
||||
Widget _getPlatformImage(String platform, double size) {
|
||||
platform = platform.toLowerCase();
|
||||
if (platform == 'mac os')
|
||||
platform = 'mac';
|
||||
else if (platform != 'linux' && platform != 'android') platform = 'win';
|
||||
return Image.asset('assets/$platform.png', height: size, width: size);
|
||||
}
|
||||
|
||||
void _abEditTag(String id) {
|
||||
var isInProgress = false;
|
||||
|
||||
final tags = List.of(gFFI.abModel.tags);
|
||||
var selectedTag = gFFI.abModel.getPeerTags(id).obs;
|
||||
|
||||
gFFI.dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate("Edit Tag")),
|
||||
content: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
child: Wrap(
|
||||
children: tags
|
||||
.map((e) => _buildTag(e, selectedTag, onTap: () {
|
||||
if (selectedTag.contains(e)) {
|
||||
selectedTag.remove(e);
|
||||
} else {
|
||||
selectedTag.add(e);
|
||||
}
|
||||
}))
|
||||
.toList(growable: false),
|
||||
),
|
||||
),
|
||||
Offstage(offstage: !isInProgress, child: LinearProgressIndicator())
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
close();
|
||||
},
|
||||
child: Text(translate("Cancel"))),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
isInProgress = true;
|
||||
});
|
||||
gFFI.abModel.changeTagForPeer(id, selectedTag);
|
||||
await gFFI.abModel.updateAb();
|
||||
close();
|
||||
},
|
||||
child: Text(translate("OK"))),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void _rename(String id) async {
|
||||
var isInProgress = false;
|
||||
var name = await bind.mainGetPeerOption(id: id, key: 'alias');
|
||||
if (widget.type == PeerType.ab) {
|
||||
final peer = gFFI.abModel.peers.firstWhere((p) => id == p['id']);
|
||||
if (peer == null) {
|
||||
// this should not happen
|
||||
} else {
|
||||
name = peer['alias'] ?? "";
|
||||
}
|
||||
}
|
||||
final k = GlobalKey<FormState>();
|
||||
gFFI.dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate("Rename")),
|
||||
content: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
child: Form(
|
||||
key: k,
|
||||
child: TextFormField(
|
||||
controller: TextEditingController(text: name),
|
||||
decoration: InputDecoration(border: OutlineInputBorder()),
|
||||
onChanged: (newStr) {
|
||||
name = newStr;
|
||||
},
|
||||
validator: (s) {
|
||||
if (s == null || s.isEmpty) {
|
||||
return translate("Empty");
|
||||
}
|
||||
return null;
|
||||
},
|
||||
onSaved: (s) {
|
||||
name = s ?? "unnamed";
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Offstage(offstage: !isInProgress, child: LinearProgressIndicator())
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
close();
|
||||
},
|
||||
child: Text(translate("Cancel"))),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
isInProgress = true;
|
||||
});
|
||||
if (k.currentState != null) {
|
||||
if (k.currentState!.validate()) {
|
||||
k.currentState!.save();
|
||||
await bind.mainSetPeerOption(
|
||||
id: id, key: 'alias', value: name);
|
||||
if (widget.type == PeerType.ab) {
|
||||
gFFI.abModel.setPeerOption(id, 'alias', name);
|
||||
await gFFI.abModel.updateAb();
|
||||
} else {
|
||||
Future.delayed(Duration.zero, () {
|
||||
this.setState(() {});
|
||||
});
|
||||
}
|
||||
close();
|
||||
}
|
||||
}
|
||||
setState(() {
|
||||
isInProgress = false;
|
||||
});
|
||||
},
|
||||
child: Text(translate("OK"))),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
||||
|
||||
abstract class BasePeerCard extends StatelessWidget {
|
||||
final Peer peer;
|
||||
final PeerType type;
|
||||
|
||||
BasePeerCard({required this.peer, required this.type, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return _PeerCard(
|
||||
peer: peer,
|
||||
popupMenuItemsFunc: _getPopupMenuItems,
|
||||
type: type,
|
||||
);
|
||||
}
|
||||
|
||||
@protected
|
||||
Future<List<PopupMenuItem<String>>> _getPopupMenuItems();
|
||||
}
|
||||
|
||||
class RecentPeerCard extends BasePeerCard {
|
||||
RecentPeerCard({required Peer peer, Key? key})
|
||||
: super(peer: peer, key: key, type: PeerType.recent);
|
||||
|
||||
Future<List<PopupMenuItem<String>>> _getPopupMenuItems() async {
|
||||
return [
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Connect')), value: 'connect'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Transfer File')), value: 'file'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('TCP Tunneling')), value: 'tcp-tunnel'),
|
||||
await _forceAlwaysRelayMenuItem(peer.id),
|
||||
PopupMenuItem<String>(child: Text(translate('Rename')), value: 'rename'),
|
||||
PopupMenuItem<String>(child: Text(translate('Remove')), value: 'remove'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Unremember Password')),
|
||||
value: 'unremember-password'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Add to Favorites')), value: 'add-fav'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
class FavoritePeerCard extends BasePeerCard {
|
||||
FavoritePeerCard({required Peer peer, Key? key})
|
||||
: super(peer: peer, key: key, type: PeerType.fav);
|
||||
|
||||
Future<List<PopupMenuItem<String>>> _getPopupMenuItems() async {
|
||||
return [
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Connect')), value: 'connect'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Transfer File')), value: 'file'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('TCP Tunneling')), value: 'tcp-tunnel'),
|
||||
await _forceAlwaysRelayMenuItem(peer.id),
|
||||
PopupMenuItem<String>(child: Text(translate('Rename')), value: 'rename'),
|
||||
PopupMenuItem<String>(child: Text(translate('Remove')), value: 'remove'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Unremember Password')),
|
||||
value: 'unremember-password'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Remove from Favorites')), value: 'remove-fav'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
class DiscoveredPeerCard extends BasePeerCard {
|
||||
DiscoveredPeerCard({required Peer peer, Key? key})
|
||||
: super(peer: peer, key: key, type: PeerType.discovered);
|
||||
|
||||
Future<List<PopupMenuItem<String>>> _getPopupMenuItems() async {
|
||||
return [
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Connect')), value: 'connect'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Transfer File')), value: 'file'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('TCP Tunneling')), value: 'tcp-tunnel'),
|
||||
await _forceAlwaysRelayMenuItem(peer.id),
|
||||
PopupMenuItem<String>(child: Text(translate('Rename')), value: 'rename'),
|
||||
PopupMenuItem<String>(child: Text(translate('Remove')), value: 'remove'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Unremember Password')),
|
||||
value: 'unremember-password'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Add to Favorites')), value: 'add-fav'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
class AddressBookPeerCard extends BasePeerCard {
|
||||
AddressBookPeerCard({required Peer peer, Key? key})
|
||||
: super(peer: peer, key: key, type: PeerType.ab);
|
||||
|
||||
Future<List<PopupMenuItem<String>>> _getPopupMenuItems() async {
|
||||
return [
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Connect')), value: 'connect'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Transfer File')), value: 'file'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('TCP Tunneling')), value: 'tcp-tunnel'),
|
||||
await _forceAlwaysRelayMenuItem(peer.id),
|
||||
PopupMenuItem<String>(child: Text(translate('Rename')), value: 'rename'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Remove')), value: 'ab-delete'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Unremember Password')),
|
||||
value: 'unremember-password'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Add to Favorites')), value: 'add-fav'),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Edit Tag')), value: 'ab-edit-tag'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Future<PopupMenuItem<String>> _forceAlwaysRelayMenuItem(String id) async {
|
||||
bool force_always_relay =
|
||||
(await bind.mainGetPeerOption(id: id, key: 'force-always-relay'))
|
||||
.isNotEmpty;
|
||||
return PopupMenuItem<String>(
|
||||
child: Row(
|
||||
children: [
|
||||
Offstage(
|
||||
offstage: !force_always_relay,
|
||||
child: Icon(Icons.check),
|
||||
),
|
||||
Text(translate('Always connect via relay')),
|
||||
],
|
||||
),
|
||||
value: 'force-always-relay');
|
||||
}
|
||||
589
flutter/lib/desktop/widgets/tabbar_widget.dart
Normal file
589
flutter/lib/desktop/widgets/tabbar_widget.dart
Normal file
@@ -0,0 +1,589 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/consts.dart';
|
||||
import 'package:flutter_hbb/main.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
import 'package:scroll_pos/scroll_pos.dart';
|
||||
|
||||
import '../../utils/multi_window_manager.dart';
|
||||
|
||||
const double _kTabBarHeight = kDesktopRemoteTabBarHeight;
|
||||
const double _kIconSize = 18;
|
||||
const double _kDividerIndent = 10;
|
||||
const double _kActionIconSize = 12;
|
||||
|
||||
class TabInfo {
|
||||
final String key;
|
||||
final String label;
|
||||
final IconData? selectedIcon;
|
||||
final IconData? unselectedIcon;
|
||||
final bool closable;
|
||||
final Widget page;
|
||||
|
||||
TabInfo(
|
||||
{required this.key,
|
||||
required this.label,
|
||||
this.selectedIcon,
|
||||
this.unselectedIcon,
|
||||
this.closable = true,
|
||||
required this.page});
|
||||
}
|
||||
|
||||
class DesktopTabState {
|
||||
final List<TabInfo> tabs = [];
|
||||
final ScrollPosController scrollController =
|
||||
ScrollPosController(itemCount: 0);
|
||||
final PageController pageController = PageController();
|
||||
int selected = 0;
|
||||
|
||||
DesktopTabState() {
|
||||
scrollController.itemCount = tabs.length;
|
||||
}
|
||||
}
|
||||
|
||||
class DesktopTabController {
|
||||
final state = DesktopTabState().obs;
|
||||
|
||||
/// index, key
|
||||
Function(int, String)? onRemove;
|
||||
|
||||
Function(int)? onSelected;
|
||||
|
||||
void add(TabInfo tab) {
|
||||
if (!isDesktop) return;
|
||||
final index = state.value.tabs.indexWhere((e) => e.key == tab.key);
|
||||
int toIndex;
|
||||
if (index >= 0) {
|
||||
toIndex = index;
|
||||
} else {
|
||||
state.update((val) {
|
||||
val!.tabs.add(tab);
|
||||
});
|
||||
toIndex = state.value.tabs.length - 1;
|
||||
assert(toIndex >= 0);
|
||||
}
|
||||
try {
|
||||
jumpTo(toIndex);
|
||||
} catch (e) {
|
||||
// call before binding controller will throw
|
||||
debugPrint("Failed to jumpTo: $e");
|
||||
}
|
||||
}
|
||||
|
||||
void remove(int index) {
|
||||
if (!isDesktop) return;
|
||||
final len = state.value.tabs.length;
|
||||
if (index < 0 || index > len - 1) return;
|
||||
final key = state.value.tabs[index].key;
|
||||
final currentSelected = state.value.selected;
|
||||
int toIndex = 0;
|
||||
if (index == len - 1) {
|
||||
toIndex = max(0, currentSelected - 1);
|
||||
} else if (index < len - 1 && index < currentSelected) {
|
||||
toIndex = max(0, currentSelected - 1);
|
||||
}
|
||||
state.value.tabs.removeAt(index);
|
||||
state.value.scrollController.itemCount = state.value.tabs.length;
|
||||
jumpTo(toIndex);
|
||||
onRemove?.call(index, key);
|
||||
}
|
||||
|
||||
void jumpTo(int index) {
|
||||
state.update((val) {
|
||||
val!.selected = index;
|
||||
val.pageController.jumpToPage(index);
|
||||
val.scrollController.scrollToItem(index, center: true, animate: true);
|
||||
});
|
||||
onSelected?.call(index);
|
||||
}
|
||||
|
||||
void closeBy(String? key) {
|
||||
if (!isDesktop) return;
|
||||
assert(onRemove != null);
|
||||
if (key == null) {
|
||||
if (state.value.selected < state.value.tabs.length) {
|
||||
remove(state.value.selected);
|
||||
}
|
||||
} else {
|
||||
state.value.tabs.indexWhere((tab) => tab.key == key);
|
||||
remove(state.value.selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DesktopTab extends StatelessWidget {
|
||||
final Function(String)? onTabClose;
|
||||
final TarBarTheme theme;
|
||||
final bool isMainWindow;
|
||||
final bool showTabBar;
|
||||
final bool showLogo;
|
||||
final bool showTitle;
|
||||
final bool showMinimize;
|
||||
final bool showMaximize;
|
||||
final bool showClose;
|
||||
final Widget Function(Widget pageView)? pageViewBuilder;
|
||||
final Widget? tail;
|
||||
|
||||
final DesktopTabController controller;
|
||||
late final state = controller.state;
|
||||
|
||||
DesktopTab(
|
||||
{required this.controller,
|
||||
required this.isMainWindow,
|
||||
this.theme = const TarBarTheme.light(),
|
||||
this.onTabClose,
|
||||
this.showTabBar = true,
|
||||
this.showLogo = true,
|
||||
this.showTitle = true,
|
||||
this.showMinimize = true,
|
||||
this.showMaximize = true,
|
||||
this.showClose = true,
|
||||
this.pageViewBuilder,
|
||||
this.tail});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(children: [
|
||||
Offstage(
|
||||
offstage: !showTabBar,
|
||||
child: Container(
|
||||
height: _kTabBarHeight,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: _kTabBarHeight - 1,
|
||||
child: _buildBar(),
|
||||
),
|
||||
Divider(
|
||||
height: 1,
|
||||
thickness: 1,
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
Expanded(
|
||||
child: pageViewBuilder != null
|
||||
? pageViewBuilder!(_buildPageView())
|
||||
: _buildPageView())
|
||||
]);
|
||||
}
|
||||
|
||||
Widget _buildPageView() {
|
||||
return Obx(() => PageView(
|
||||
controller: state.value.pageController,
|
||||
children:
|
||||
state.value.tabs.map((tab) => tab.page).toList(growable: false)));
|
||||
}
|
||||
|
||||
Widget _buildBar() {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Row(children: [
|
||||
Offstage(
|
||||
offstage: !showLogo,
|
||||
child: Image.asset(
|
||||
'assets/logo.ico',
|
||||
width: 20,
|
||||
height: 20,
|
||||
)),
|
||||
Offstage(
|
||||
offstage: !showTitle,
|
||||
child: Text(
|
||||
"RustDesk",
|
||||
style: TextStyle(fontSize: 13),
|
||||
).marginOnly(left: 2))
|
||||
]).marginOnly(
|
||||
left: 5,
|
||||
right: 10,
|
||||
),
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onPanStart: (_) {
|
||||
if (isMainWindow) {
|
||||
windowManager.startDragging();
|
||||
} else {
|
||||
WindowController.fromWindowId(windowId!)
|
||||
.startDragging();
|
||||
}
|
||||
},
|
||||
child: _ListView(
|
||||
controller: controller,
|
||||
onTabClose: onTabClose,
|
||||
theme: theme,
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Offstage(offstage: tail == null, child: tail),
|
||||
WindowActionPanel(
|
||||
mainTab: isMainWindow,
|
||||
theme: theme,
|
||||
showMinimize: showMinimize,
|
||||
showMaximize: showMaximize,
|
||||
showClose: showClose,
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class WindowActionPanel extends StatelessWidget {
|
||||
final bool mainTab;
|
||||
final TarBarTheme theme;
|
||||
|
||||
final bool showMinimize;
|
||||
final bool showMaximize;
|
||||
final bool showClose;
|
||||
|
||||
const WindowActionPanel(
|
||||
{Key? key,
|
||||
required this.mainTab,
|
||||
required this.theme,
|
||||
this.showMinimize = true,
|
||||
this.showMaximize = true,
|
||||
this.showClose = true})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Offstage(
|
||||
offstage: !showMinimize,
|
||||
child: ActionIcon(
|
||||
message: 'Minimize',
|
||||
icon: IconFont.min,
|
||||
theme: theme,
|
||||
onTap: () {
|
||||
if (mainTab) {
|
||||
windowManager.minimize();
|
||||
} else {
|
||||
WindowController.fromWindowId(windowId!).minimize();
|
||||
}
|
||||
},
|
||||
is_close: false,
|
||||
)),
|
||||
// TODO: drag makes window restore
|
||||
Offstage(
|
||||
offstage: !showMaximize,
|
||||
child: FutureBuilder(builder: (context, snapshot) {
|
||||
RxBool is_maximized = false.obs;
|
||||
if (mainTab) {
|
||||
windowManager.isMaximized().then((maximized) {
|
||||
is_maximized.value = maximized;
|
||||
});
|
||||
} else {
|
||||
final wc = WindowController.fromWindowId(windowId!);
|
||||
wc.isMaximized().then((maximized) {
|
||||
is_maximized.value = maximized;
|
||||
});
|
||||
}
|
||||
return Obx(
|
||||
() => ActionIcon(
|
||||
message: is_maximized.value ? "Restore" : "Maximize",
|
||||
icon: is_maximized.value ? IconFont.restore : IconFont.max,
|
||||
theme: theme,
|
||||
onTap: () {
|
||||
if (mainTab) {
|
||||
if (is_maximized.value) {
|
||||
windowManager.unmaximize();
|
||||
} else {
|
||||
windowManager.maximize();
|
||||
}
|
||||
} else {
|
||||
// TODO: subwindow is maximized but first query result is not maximized.
|
||||
final wc = WindowController.fromWindowId(windowId!);
|
||||
if (is_maximized.value) {
|
||||
wc.unmaximize();
|
||||
} else {
|
||||
wc.maximize();
|
||||
}
|
||||
}
|
||||
is_maximized.value = !is_maximized.value;
|
||||
},
|
||||
is_close: false,
|
||||
),
|
||||
);
|
||||
})),
|
||||
Offstage(
|
||||
offstage: !showClose,
|
||||
child: ActionIcon(
|
||||
message: 'Close',
|
||||
icon: IconFont.close,
|
||||
theme: theme,
|
||||
onTap: () {
|
||||
if (mainTab) {
|
||||
windowManager.close();
|
||||
} else {
|
||||
WindowController.fromWindowId(windowId!).close();
|
||||
}
|
||||
},
|
||||
is_close: true,
|
||||
)),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class _ListView extends StatelessWidget {
|
||||
final DesktopTabController controller;
|
||||
late final Rx<DesktopTabState> state;
|
||||
final Function(String key)? onTabClose;
|
||||
final TarBarTheme theme;
|
||||
|
||||
_ListView(
|
||||
{required this.controller, required this.onTabClose, required this.theme})
|
||||
: this.state = controller.state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Obx(() => ListView(
|
||||
controller: state.value.scrollController,
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
physics: BouncingScrollPhysics(),
|
||||
children: state.value.tabs.asMap().entries.map((e) {
|
||||
final index = e.key;
|
||||
final tab = e.value;
|
||||
return _Tab(
|
||||
index: index,
|
||||
label: tab.label,
|
||||
selectedIcon: tab.selectedIcon,
|
||||
unselectedIcon: tab.unselectedIcon,
|
||||
closable: tab.closable,
|
||||
selected: state.value.selected,
|
||||
onClose: () => controller.remove(index),
|
||||
onSelected: () => controller.jumpTo(index),
|
||||
theme: theme,
|
||||
);
|
||||
}).toList()));
|
||||
}
|
||||
}
|
||||
|
||||
class _Tab extends StatelessWidget {
|
||||
late final int index;
|
||||
late final String label;
|
||||
late final IconData? selectedIcon;
|
||||
late final IconData? unselectedIcon;
|
||||
late final bool closable;
|
||||
late final int selected;
|
||||
late final Function() onClose;
|
||||
late final Function() onSelected;
|
||||
final RxBool _hover = false.obs;
|
||||
late final TarBarTheme theme;
|
||||
|
||||
_Tab(
|
||||
{Key? key,
|
||||
required this.index,
|
||||
required this.label,
|
||||
this.selectedIcon,
|
||||
this.unselectedIcon,
|
||||
required this.closable,
|
||||
required this.selected,
|
||||
required this.onClose,
|
||||
required this.onSelected,
|
||||
required this.theme})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool show_icon = selectedIcon != null && unselectedIcon != null;
|
||||
bool is_selected = index == selected;
|
||||
bool show_divider = index != selected - 1 && index != selected;
|
||||
return Ink(
|
||||
child: InkWell(
|
||||
onHover: (hover) => _hover.value = hover,
|
||||
onTap: () => onSelected(),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
height: _kTabBarHeight,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Offstage(
|
||||
offstage: !show_icon,
|
||||
child: Icon(
|
||||
is_selected ? selectedIcon : unselectedIcon,
|
||||
size: _kIconSize,
|
||||
color: is_selected
|
||||
? theme.selectedtabIconColor
|
||||
: theme.unSelectedtabIconColor,
|
||||
).paddingOnly(right: 5)),
|
||||
Text(
|
||||
translate(label),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: is_selected
|
||||
? theme.selectedTextColor
|
||||
: theme.unSelectedTextColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
Offstage(
|
||||
offstage: !closable,
|
||||
child: Obx((() => _CloseButton(
|
||||
visiable: _hover.value,
|
||||
tabSelected: is_selected,
|
||||
onClose: () => onClose(),
|
||||
theme: theme,
|
||||
))),
|
||||
)
|
||||
])).paddingSymmetric(horizontal: 10),
|
||||
Offstage(
|
||||
offstage: !show_divider,
|
||||
child: VerticalDivider(
|
||||
width: 1,
|
||||
indent: _kDividerIndent,
|
||||
endIndent: _kDividerIndent,
|
||||
color: theme.dividerColor,
|
||||
thickness: 1,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _CloseButton extends StatelessWidget {
|
||||
final bool visiable;
|
||||
final bool tabSelected;
|
||||
final Function onClose;
|
||||
late final TarBarTheme theme;
|
||||
|
||||
_CloseButton({
|
||||
Key? key,
|
||||
required this.visiable,
|
||||
required this.tabSelected,
|
||||
required this.onClose,
|
||||
required this.theme,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: _kIconSize,
|
||||
child: Offstage(
|
||||
offstage: !visiable,
|
||||
child: InkWell(
|
||||
customBorder: RoundedRectangleBorder(),
|
||||
onTap: () => onClose(),
|
||||
child: Icon(
|
||||
Icons.close,
|
||||
size: _kIconSize,
|
||||
color: tabSelected
|
||||
? theme.selectedIconColor
|
||||
: theme.unSelectedIconColor,
|
||||
),
|
||||
),
|
||||
)).paddingOnly(left: 5);
|
||||
}
|
||||
}
|
||||
|
||||
class ActionIcon extends StatelessWidget {
|
||||
final String message;
|
||||
final IconData icon;
|
||||
final TarBarTheme theme;
|
||||
final Function() onTap;
|
||||
final bool is_close;
|
||||
const ActionIcon({
|
||||
Key? key,
|
||||
required this.message,
|
||||
required this.icon,
|
||||
required this.theme,
|
||||
required this.onTap,
|
||||
required this.is_close,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
RxBool hover = false.obs;
|
||||
return Obx(() => Tooltip(
|
||||
message: translate(message),
|
||||
waitDuration: Duration(seconds: 1),
|
||||
child: InkWell(
|
||||
hoverColor:
|
||||
is_close ? Color.fromARGB(255, 196, 43, 28) : theme.hoverColor,
|
||||
onHover: (value) => hover.value = value,
|
||||
child: Container(
|
||||
height: _kTabBarHeight - 1,
|
||||
width: _kTabBarHeight - 1,
|
||||
child: Icon(
|
||||
icon,
|
||||
color: hover.value && is_close
|
||||
? Colors.white
|
||||
: theme.unSelectedIconColor,
|
||||
size: _kActionIconSize,
|
||||
),
|
||||
),
|
||||
onTap: onTap,
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class AddButton extends StatelessWidget {
|
||||
late final TarBarTheme theme;
|
||||
|
||||
AddButton({
|
||||
Key? key,
|
||||
required this.theme,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ActionIcon(
|
||||
message: 'New Connection',
|
||||
icon: IconFont.add,
|
||||
theme: theme,
|
||||
onTap: () =>
|
||||
rustDeskWinManager.call(WindowType.Main, "main_window_on_top", ""),
|
||||
is_close: false);
|
||||
}
|
||||
}
|
||||
|
||||
class TarBarTheme {
|
||||
final Color unSelectedtabIconColor;
|
||||
final Color selectedtabIconColor;
|
||||
final Color selectedTextColor;
|
||||
final Color unSelectedTextColor;
|
||||
final Color selectedIconColor;
|
||||
final Color unSelectedIconColor;
|
||||
final Color dividerColor;
|
||||
final Color hoverColor;
|
||||
|
||||
const TarBarTheme.light()
|
||||
: unSelectedtabIconColor = const Color.fromARGB(255, 162, 203, 241),
|
||||
selectedtabIconColor = MyTheme.accent,
|
||||
selectedTextColor = const Color.fromARGB(255, 26, 26, 26),
|
||||
unSelectedTextColor = const Color.fromARGB(255, 96, 96, 96),
|
||||
selectedIconColor = const Color.fromARGB(255, 26, 26, 26),
|
||||
unSelectedIconColor = const Color.fromARGB(255, 96, 96, 96),
|
||||
dividerColor = const Color.fromARGB(255, 238, 238, 238),
|
||||
hoverColor = const Color.fromARGB(
|
||||
51, 158, 158, 158); // Colors.grey; //0xFF9E9E9E
|
||||
|
||||
const TarBarTheme.dark()
|
||||
: unSelectedtabIconColor = const Color.fromARGB(255, 30, 65, 98),
|
||||
selectedtabIconColor = MyTheme.accent,
|
||||
selectedTextColor = const Color.fromARGB(255, 255, 255, 255),
|
||||
unSelectedTextColor = const Color.fromARGB(255, 207, 207, 207),
|
||||
selectedIconColor = const Color.fromARGB(255, 215, 215, 215),
|
||||
unSelectedIconColor = const Color.fromARGB(255, 255, 255, 255),
|
||||
dividerColor = const Color.fromARGB(255, 64, 64, 64),
|
||||
hoverColor = Colors.black26;
|
||||
}
|
||||
70
flutter/lib/desktop/widgets/titlebar_widget.dart
Normal file
70
flutter/lib/desktop/widgets/titlebar_widget.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
const sidebarColor = Color(0xFF0C6AF6);
|
||||
const backgroundStartColor = Color(0xFF0583EA);
|
||||
const backgroundEndColor = Color(0xFF0697EA);
|
||||
|
||||
class DesktopTitleBar extends StatelessWidget {
|
||||
final Widget? child;
|
||||
|
||||
const DesktopTitleBar({Key? key, this.child}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [backgroundStartColor, backgroundEndColor],
|
||||
stops: [0.0, 1.0]),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: child ?? Offstage(),
|
||||
)
|
||||
// const WindowButtons()
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// final buttonColors = WindowButtonColors(
|
||||
// iconNormal: const Color(0xFF805306),
|
||||
// mouseOver: const Color(0xFFF6A00C),
|
||||
// mouseDown: const Color(0xFF805306),
|
||||
// iconMouseOver: const Color(0xFF805306),
|
||||
// iconMouseDown: const Color(0xFFFFD500));
|
||||
//
|
||||
// final closeButtonColors = WindowButtonColors(
|
||||
// mouseOver: const Color(0xFFD32F2F),
|
||||
// mouseDown: const Color(0xFFB71C1C),
|
||||
// iconNormal: const Color(0xFF805306),
|
||||
// iconMouseOver: Colors.white);
|
||||
//
|
||||
// class WindowButtons extends StatelessWidget {
|
||||
// const WindowButtons({Key? key}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Row(
|
||||
// children: [
|
||||
// MinimizeWindowButton(colors: buttonColors, onPressed: () {
|
||||
// windowManager.minimize();
|
||||
// },),
|
||||
// MaximizeWindowButton(colors: buttonColors, onPressed: () async {
|
||||
// if (await windowManager.isMaximized()) {
|
||||
// windowManager.restore();
|
||||
// } else {
|
||||
// windowManager.maximize();
|
||||
// }
|
||||
// },),
|
||||
// CloseWindowButton(colors: closeButtonColors, onPressed: () {
|
||||
// windowManager.close();
|
||||
// },),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
@@ -1,55 +1,211 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:firebase_analytics/firebase_analytics.dart';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'common.dart';
|
||||
import 'models/model.dart';
|
||||
import 'pages/home_page.dart';
|
||||
import 'pages/server_page.dart';
|
||||
import 'pages/settings_page.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
Future<Null> main() async {
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/desktop_tab_page.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/server_page.dart';
|
||||
import 'package:flutter_hbb/desktop/screen/desktop_file_transfer_screen.dart';
|
||||
import 'package:flutter_hbb/desktop/screen/desktop_remote_screen.dart';
|
||||
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
// import 'package:window_manager/window_manager.dart';
|
||||
|
||||
import 'common.dart';
|
||||
import 'consts.dart';
|
||||
import 'mobile/pages/home_page.dart';
|
||||
import 'mobile/pages/server_page.dart';
|
||||
import 'mobile/pages/settings_page.dart';
|
||||
import 'models/platform_model.dart';
|
||||
|
||||
int? windowId;
|
||||
|
||||
Future<Null> main(List<String> args) async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
var a = FFI.ffiModel.init();
|
||||
var b = Firebase.initializeApp();
|
||||
await a;
|
||||
await b;
|
||||
print("launch args: $args");
|
||||
|
||||
if (!isDesktop) {
|
||||
runMobileApp();
|
||||
return;
|
||||
}
|
||||
// main window
|
||||
if (args.isNotEmpty && args.first == 'multi_window') {
|
||||
windowId = int.parse(args[1]);
|
||||
WindowController.fromWindowId(windowId!).showTitleBar(false);
|
||||
final argument = args[2].isEmpty
|
||||
? Map<String, dynamic>()
|
||||
: jsonDecode(args[2]) as Map<String, dynamic>;
|
||||
int type = argument['type'] ?? -1;
|
||||
argument['windowId'] = windowId;
|
||||
WindowType wType = type.windowType;
|
||||
switch (wType) {
|
||||
case WindowType.RemoteDesktop:
|
||||
runRemoteScreen(argument);
|
||||
break;
|
||||
case WindowType.FileTransfer:
|
||||
runFileTransferScreen(argument);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (args.isNotEmpty && args.first == '--cm') {
|
||||
print("--cm started");
|
||||
await windowManager.ensureInitialized();
|
||||
runConnectionManagerScreen();
|
||||
} else {
|
||||
await windowManager.ensureInitialized();
|
||||
windowManager.setPreventClose(true);
|
||||
runMainApp(true);
|
||||
}
|
||||
}
|
||||
|
||||
ThemeData getCurrentTheme() {
|
||||
return isDarkTheme() ? MyTheme.darkTheme : MyTheme.lightTheme;
|
||||
}
|
||||
|
||||
Future<void> initEnv(String appType) async {
|
||||
await platformFFI.init(appType);
|
||||
// global FFI, use this **ONLY** for global configuration
|
||||
// for convenience, use global FFI on mobile platform
|
||||
// focus on multi-ffi on desktop first
|
||||
await initGlobalFFI();
|
||||
// await Firebase.initializeApp();
|
||||
refreshCurrentUser();
|
||||
toAndroidChannelInit();
|
||||
}
|
||||
|
||||
void runMainApp(bool startService) async {
|
||||
WindowOptions windowOptions = getHiddenTitleBarWindowOptions(Size(1280, 720));
|
||||
await Future.wait([
|
||||
initEnv(kAppTypeMain),
|
||||
windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||
await windowManager.show();
|
||||
await windowManager.focus();
|
||||
})
|
||||
]);
|
||||
if (startService) {
|
||||
// await windowManager.ensureInitialized();
|
||||
// disable tray
|
||||
// initTray();
|
||||
gFFI.serverModel.startService();
|
||||
}
|
||||
runApp(App());
|
||||
}
|
||||
|
||||
void runMobileApp() async {
|
||||
await initEnv(kAppTypeMain);
|
||||
if (isAndroid) androidChannelInit();
|
||||
runApp(App());
|
||||
}
|
||||
|
||||
void runRemoteScreen(Map<String, dynamic> argument) async {
|
||||
await initEnv(kAppTypeDesktopRemote);
|
||||
runApp(GetMaterialApp(
|
||||
navigatorKey: globalKey,
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'RustDesk - Remote Desktop',
|
||||
theme: getCurrentTheme(),
|
||||
home: DesktopRemoteScreen(
|
||||
params: argument,
|
||||
),
|
||||
navigatorObservers: [
|
||||
// FirebaseAnalyticsObserver(analytics: analytics),
|
||||
],
|
||||
builder: _keepScaleBuilder(),
|
||||
));
|
||||
}
|
||||
|
||||
void runFileTransferScreen(Map<String, dynamic> argument) async {
|
||||
await initEnv(kAppTypeDesktopFileTransfer);
|
||||
runApp(
|
||||
GetMaterialApp(
|
||||
navigatorKey: globalKey,
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'RustDesk - File Transfer',
|
||||
theme: getCurrentTheme(),
|
||||
home: DesktopFileTransferScreen(params: argument),
|
||||
navigatorObservers: [
|
||||
// FirebaseAnalyticsObserver(analytics: analytics),
|
||||
],
|
||||
builder: _keepScaleBuilder(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void runConnectionManagerScreen() async {
|
||||
// initialize window
|
||||
WindowOptions windowOptions = getHiddenTitleBarWindowOptions(Size(300, 400));
|
||||
await Future.wait([
|
||||
initEnv(kAppTypeMain),
|
||||
windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||
await windowManager.setAlignment(Alignment.topRight);
|
||||
await windowManager.show();
|
||||
await windowManager.focus();
|
||||
})
|
||||
]);
|
||||
runApp(GetMaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: getCurrentTheme(),
|
||||
home: DesktopServerPage(),
|
||||
builder: _keepScaleBuilder()));
|
||||
}
|
||||
|
||||
WindowOptions getHiddenTitleBarWindowOptions(Size size) {
|
||||
return WindowOptions(
|
||||
size: size,
|
||||
center: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
skipTaskbar: false,
|
||||
titleBarStyle: TitleBarStyle.hidden,
|
||||
);
|
||||
}
|
||||
|
||||
class App extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final analytics = FirebaseAnalytics.instance;
|
||||
// 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),
|
||||
// global configuration
|
||||
// use session related FFI when in remote control or file transfer page
|
||||
ChangeNotifierProvider.value(value: gFFI.ffiModel),
|
||||
ChangeNotifierProvider.value(value: gFFI.imageModel),
|
||||
ChangeNotifierProvider.value(value: gFFI.cursorModel),
|
||||
ChangeNotifierProvider.value(value: gFFI.canvasModel),
|
||||
ChangeNotifierProvider.value(value: gFFI.abModel),
|
||||
ChangeNotifierProvider.value(value: gFFI.userModel),
|
||||
],
|
||||
child: MaterialApp(
|
||||
navigatorKey: globalKey,
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'RustDesk',
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.blue,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
),
|
||||
home: !isAndroid ? WebHomePage() : HomePage(key: homeKey),
|
||||
navigatorObservers: [
|
||||
FirebaseAnalyticsObserver(analytics: analytics),
|
||||
FlutterSmartDialog.observer
|
||||
],
|
||||
builder: FlutterSmartDialog.init(
|
||||
builder: isAndroid
|
||||
? (_, child) => AccessibilityListener(
|
||||
child: child,
|
||||
)
|
||||
: null)),
|
||||
child: GetMaterialApp(
|
||||
navigatorKey: globalKey,
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'RustDesk',
|
||||
theme: getCurrentTheme(),
|
||||
home: isDesktop
|
||||
? DesktopTabPage()
|
||||
: !isAndroid
|
||||
? WebHomePage()
|
||||
: HomePage(),
|
||||
navigatorObservers: [
|
||||
// FirebaseAnalyticsObserver(analytics: analytics),
|
||||
],
|
||||
builder: isAndroid
|
||||
? (_, child) => AccessibilityListener(
|
||||
child: child,
|
||||
)
|
||||
: _keepScaleBuilder(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_keepScaleBuilder() {
|
||||
return (BuildContext context, Widget? child) {
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(
|
||||
textScaleFactor: 1.0,
|
||||
),
|
||||
child: child ?? Container(),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,10 +3,16 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/models/chat_model.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../models/model.dart';
|
||||
|
||||
import 'home_page.dart';
|
||||
|
||||
class ChatPage extends StatelessWidget implements PageShape {
|
||||
late final ChatModel chatModel;
|
||||
|
||||
ChatPage({ChatModel? chatModel}) {
|
||||
this.chatModel = chatModel ?? gFFI.chatModel;
|
||||
}
|
||||
|
||||
@override
|
||||
final title = translate("Chat");
|
||||
|
||||
@@ -18,7 +24,8 @@ class ChatPage extends StatelessWidget implements PageShape {
|
||||
PopupMenuButton<int>(
|
||||
icon: Icon(Icons.group),
|
||||
itemBuilder: (context) {
|
||||
final chatModel = FFI.chatModel;
|
||||
// only mobile need [appBarActions], just bind gFFI.chatModel
|
||||
final chatModel = gFFI.chatModel;
|
||||
return chatModel.messages.entries.map((entry) {
|
||||
final id = entry.key;
|
||||
final user = entry.value.chatUser;
|
||||
@@ -29,40 +36,43 @@ class ChatPage extends StatelessWidget implements PageShape {
|
||||
}).toList();
|
||||
},
|
||||
onSelected: (id) {
|
||||
FFI.chatModel.changeCurrentID(id);
|
||||
gFFI.chatModel.changeCurrentID(id);
|
||||
})
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChangeNotifierProvider.value(
|
||||
value: FFI.chatModel,
|
||||
value: chatModel,
|
||||
child: Container(
|
||||
color: MyTheme.grayBg,
|
||||
child: Consumer<ChatModel>(builder: (context, chatModel, child) {
|
||||
final currentUser = chatModel.currentUser;
|
||||
return Stack(
|
||||
children: [
|
||||
DashChat(
|
||||
onSend: (chatMsg) {
|
||||
chatModel.send(chatMsg);
|
||||
},
|
||||
currentUser: chatModel.me,
|
||||
messages:
|
||||
chatModel.messages[chatModel.currentID]?.chatMessages ??
|
||||
[],
|
||||
messageOptions: MessageOptions(
|
||||
showOtherUsersAvatar: false,
|
||||
showTime: true,
|
||||
messageDecorationBuilder: (_, __, ___) =>
|
||||
defaultMessageDecoration(
|
||||
color: MyTheme.accent80,
|
||||
borderTopLeft: 8,
|
||||
borderTopRight: 8,
|
||||
borderBottomRight: 8,
|
||||
borderBottomLeft: 8,
|
||||
)),
|
||||
),
|
||||
LayoutBuilder(builder: (context, constraints) {
|
||||
return DashChat(
|
||||
onSend: (chatMsg) {
|
||||
chatModel.send(chatMsg);
|
||||
},
|
||||
currentUser: chatModel.me,
|
||||
messages: chatModel
|
||||
.messages[chatModel.currentID]?.chatMessages ??
|
||||
[],
|
||||
messageOptions: MessageOptions(
|
||||
showOtherUsersAvatar: false,
|
||||
showTime: true,
|
||||
maxWidth: constraints.maxWidth * 0.7,
|
||||
messageDecorationBuilder: (_, __, ___) =>
|
||||
defaultMessageDecoration(
|
||||
color: MyTheme.accent80,
|
||||
borderTopLeft: 8,
|
||||
borderTopRight: 8,
|
||||
borderBottomRight: 8,
|
||||
borderBottomLeft: 8,
|
||||
)),
|
||||
);
|
||||
}),
|
||||
chatModel.currentID == ChatModel.clientModeID
|
||||
? SizedBox.shrink()
|
||||
: Padding(
|
||||
@@ -1,15 +1,20 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/pages/file_manager_page.dart';
|
||||
import 'package:flutter_hbb/mobile/pages/file_manager_page.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'dart:async';
|
||||
import '../common.dart';
|
||||
import '../models/model.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
import '../../models/model.dart';
|
||||
import '../../models/peer_model.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
import 'home_page.dart';
|
||||
import 'remote_page.dart';
|
||||
import 'settings_page.dart';
|
||||
import 'scan_page.dart';
|
||||
import 'settings_page.dart';
|
||||
|
||||
/// Connection page for connecting to a remote peer.
|
||||
class ConnectionPage extends StatefulWidget implements PageShape {
|
||||
ConnectionPage({Key? key}) : super(key: key);
|
||||
|
||||
@@ -26,17 +31,32 @@ class ConnectionPage extends StatefulWidget implements PageShape {
|
||||
_ConnectionPageState createState() => _ConnectionPageState();
|
||||
}
|
||||
|
||||
/// State for the connection page.
|
||||
class _ConnectionPageState extends State<ConnectionPage> {
|
||||
/// Controller for the id input bar.
|
||||
final _idController = TextEditingController();
|
||||
|
||||
/// Update url. If it's not null, means an update is available.
|
||||
var _updateUrl = '';
|
||||
var _menuPos;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (_idController.text.isEmpty) {
|
||||
() async {
|
||||
final lastRemoteId = await bind.mainGetLastRemoteId();
|
||||
if (lastRemoteId != _idController.text) {
|
||||
setState(() {
|
||||
_idController.text = lastRemoteId;
|
||||
});
|
||||
}
|
||||
}();
|
||||
}
|
||||
if (isAndroid) {
|
||||
Timer(Duration(seconds: 5), () {
|
||||
_updateUrl = FFI.getByName('software_update_url');
|
||||
Timer(Duration(seconds: 5), () async {
|
||||
_updateUrl = await bind.mainGetSoftwareUpdateUrl();
|
||||
;
|
||||
if (_updateUrl.isNotEmpty) setState(() {});
|
||||
});
|
||||
}
|
||||
@@ -45,7 +65,6 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Provider.of<FfiModel>(context);
|
||||
if (_idController.text.isEmpty) _idController.text = FFI.getId();
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
@@ -60,11 +79,15 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
);
|
||||
}
|
||||
|
||||
/// Callback for the connect button.
|
||||
/// Connects to the selected peer.
|
||||
void onConnect() {
|
||||
var id = _idController.text.trim();
|
||||
connect(id);
|
||||
}
|
||||
|
||||
/// Connect to a peer with [id].
|
||||
/// If [isFileTransfer], starts a session only for file transfer.
|
||||
void connect(String id, {bool isFileTransfer = false}) async {
|
||||
if (id == '') return;
|
||||
id = id.replaceAll(' ', '');
|
||||
@@ -94,6 +117,8 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
}
|
||||
}
|
||||
|
||||
/// UI for software update.
|
||||
/// If [_updateUrl] is not empty, shows a button to update the software.
|
||||
Widget getUpdateUI() {
|
||||
return _updateUrl.isEmpty
|
||||
? SizedBox(height: 0)
|
||||
@@ -114,6 +139,8 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
color: Colors.white, fontWeight: FontWeight.bold))));
|
||||
}
|
||||
|
||||
/// UI for the search bar.
|
||||
/// Search for a peer and connect to it if the id exists.
|
||||
Widget getSearchBarUI() {
|
||||
var w = Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16.0, 8.0, 16.0, 0.0),
|
||||
@@ -187,6 +214,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// Get the image for the current [platform].
|
||||
Widget getPlatformImage(String platform) {
|
||||
platform = platform.toLowerCase();
|
||||
if (platform == 'mac os')
|
||||
@@ -195,55 +223,66 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
return Image.asset('assets/$platform.png', width: 24, height: 24);
|
||||
}
|
||||
|
||||
/// Get all the saved peers.
|
||||
Widget getPeers() {
|
||||
final size = MediaQuery.of(context).size;
|
||||
final windowWidth = MediaQuery.of(context).size.width;
|
||||
final space = 8.0;
|
||||
var width = size.width - 2 * space;
|
||||
var width = windowWidth - 2 * space;
|
||||
final minWidth = 320.0;
|
||||
if (size.width > minWidth + 2 * space) {
|
||||
final n = (size.width / (minWidth + 2 * space)).floor();
|
||||
width = size.width / n - 2 * space;
|
||||
if (windowWidth > minWidth + 2 * space) {
|
||||
final n = (windowWidth / (minWidth + 2 * space)).floor();
|
||||
width = windowWidth / n - 2 * space;
|
||||
}
|
||||
final cards = <Widget>[];
|
||||
var peers = FFI.peers();
|
||||
peers.forEach((p) {
|
||||
cards.add(Container(
|
||||
width: width,
|
||||
child: Card(
|
||||
child: GestureDetector(
|
||||
onTap: !isDesktop ? () => connect('${p.id}') : null,
|
||||
onDoubleTap: isDesktop ? () => connect('${p.id}') : null,
|
||||
onLongPressStart: (details) {
|
||||
final x = details.globalPosition.dx;
|
||||
final y = details.globalPosition.dy;
|
||||
_menuPos = RelativeRect.fromLTRB(x, y, x, y);
|
||||
showPeerMenu(context, p.id);
|
||||
},
|
||||
child: ListTile(
|
||||
contentPadding: const EdgeInsets.only(left: 12),
|
||||
subtitle: Text('${p.username}@${p.hostname}'),
|
||||
title: Text('${p.id}'),
|
||||
leading: Container(
|
||||
padding: const EdgeInsets.all(6),
|
||||
child: getPlatformImage('${p.platform}'),
|
||||
color: str2color('${p.id}${p.platform}', 0x7f)),
|
||||
trailing: InkWell(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Icon(Icons.more_vert)),
|
||||
onTapDown: (e) {
|
||||
final x = e.globalPosition.dx;
|
||||
final y = e.globalPosition.dy;
|
||||
_menuPos = RelativeRect.fromLTRB(x, y, x, y);
|
||||
},
|
||||
onTap: () {
|
||||
showPeerMenu(context, p.id);
|
||||
}),
|
||||
)))));
|
||||
});
|
||||
return Wrap(children: cards, spacing: space, runSpacing: space);
|
||||
return FutureBuilder<List<Peer>>(
|
||||
future: gFFI.peers(),
|
||||
builder: (context, snapshot) {
|
||||
final cards = <Widget>[];
|
||||
if (snapshot.hasData) {
|
||||
final peers = snapshot.data!;
|
||||
peers.forEach((p) {
|
||||
cards.add(Container(
|
||||
width: width,
|
||||
child: Card(
|
||||
child: GestureDetector(
|
||||
onTap:
|
||||
!isWebDesktop ? () => connect('${p.id}') : null,
|
||||
onDoubleTap:
|
||||
isWebDesktop ? () => connect('${p.id}') : null,
|
||||
onLongPressStart: (details) {
|
||||
final x = details.globalPosition.dx;
|
||||
final y = details.globalPosition.dy;
|
||||
_menuPos = RelativeRect.fromLTRB(x, y, x, y);
|
||||
showPeerMenu(context, p.id);
|
||||
},
|
||||
child: ListTile(
|
||||
contentPadding: const EdgeInsets.only(left: 12),
|
||||
subtitle: Text('${p.username}@${p.hostname}'),
|
||||
title: Text('${p.id}'),
|
||||
leading: Container(
|
||||
padding: const EdgeInsets.all(6),
|
||||
child: getPlatformImage('${p.platform}'),
|
||||
color: str2color('${p.id}${p.platform}', 0x7f)),
|
||||
trailing: InkWell(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Icon(Icons.more_vert)),
|
||||
onTapDown: (e) {
|
||||
final x = e.globalPosition.dx;
|
||||
final y = e.globalPosition.dy;
|
||||
_menuPos = RelativeRect.fromLTRB(x, y, x, y);
|
||||
},
|
||||
onTap: () {
|
||||
showPeerMenu(context, p.id);
|
||||
}),
|
||||
)))));
|
||||
});
|
||||
}
|
||||
return Wrap(children: cards, spacing: space, runSpacing: space);
|
||||
});
|
||||
}
|
||||
|
||||
/// Show the peer menu and handle user's choice.
|
||||
/// User might remove the peer or send a file to the peer.
|
||||
void showPeerMenu(BuildContext context, String id) async {
|
||||
var value = await showMenu(
|
||||
context: context,
|
||||
@@ -261,7 +300,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
elevation: 8,
|
||||
);
|
||||
if (value == 'remove') {
|
||||
setState(() => FFI.setByName('remove', '$id'));
|
||||
setState(() => bind.mainRemovePeer(id: id));
|
||||
() async {
|
||||
removePreference(id);
|
||||
}();
|
||||
@@ -277,10 +316,34 @@ class WebMenu extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _WebMenuState extends State<WebMenu> {
|
||||
String? username;
|
||||
String url = "";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
() async {
|
||||
final usernameRes = await getUsername();
|
||||
final urlRes = await getUrl();
|
||||
var update = false;
|
||||
if (usernameRes != username) {
|
||||
username = usernameRes;
|
||||
update = true;
|
||||
}
|
||||
if (urlRes != url) {
|
||||
url = urlRes;
|
||||
update = true;
|
||||
}
|
||||
|
||||
if (update) {
|
||||
setState(() {});
|
||||
}
|
||||
}();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Provider.of<FfiModel>(context);
|
||||
final username = getUsername();
|
||||
return PopupMenuButton<String>(
|
||||
icon: Icon(Icons.more_vert),
|
||||
itemBuilder: (context) {
|
||||
@@ -298,7 +361,7 @@ class _WebMenuState extends State<WebMenu> {
|
||||
value: "server",
|
||||
)
|
||||
] +
|
||||
(getUrl().contains('admin.rustdesk.com')
|
||||
(url.contains('admin.rustdesk.com')
|
||||
? <PopupMenuItem<String>>[]
|
||||
: [
|
||||
PopupMenuItem(
|
||||
@@ -317,16 +380,16 @@ class _WebMenuState extends State<WebMenu> {
|
||||
},
|
||||
onSelected: (value) {
|
||||
if (value == 'server') {
|
||||
showServerSettings();
|
||||
showServerSettings(gFFI.dialogManager);
|
||||
}
|
||||
if (value == 'about') {
|
||||
showAbout();
|
||||
showAbout(gFFI.dialogManager);
|
||||
}
|
||||
if (value == 'login') {
|
||||
if (username == null) {
|
||||
showLogin();
|
||||
showLogin(gFFI.dialogManager);
|
||||
} else {
|
||||
logout();
|
||||
logout(gFFI.dialogManager);
|
||||
}
|
||||
}
|
||||
if (value == 'scan') {
|
||||
@@ -1,14 +1,13 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/models/file_model.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter_breadcrumb/flutter_breadcrumb.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
import 'package:toggle_switch/toggle_switch.dart';
|
||||
|
||||
import '../common.dart';
|
||||
import '../models/model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_breadcrumb/flutter_breadcrumb.dart';
|
||||
import 'package:flutter_hbb/models/file_model.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toggle_switch/toggle_switch.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
import '../widgets/dialog.dart';
|
||||
|
||||
class FileManagerPage extends StatefulWidget {
|
||||
@@ -20,31 +19,34 @@ class FileManagerPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _FileManagerPageState extends State<FileManagerPage> {
|
||||
final model = FFI.fileModel;
|
||||
final model = gFFI.fileModel;
|
||||
final _selectedItems = SelectedItems();
|
||||
final _breadCrumbScroller = ScrollController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
FFI.connect(widget.id, isFileTransfer: true);
|
||||
showLoading(translate('Connecting...'));
|
||||
FFI.ffiModel.updateEventListener(widget.id);
|
||||
gFFI.connect(widget.id, isFileTransfer: true);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
gFFI.dialogManager
|
||||
.showLoading(translate('Connecting...'), onCancel: closeConnection);
|
||||
});
|
||||
gFFI.ffiModel.updateEventListener(widget.id);
|
||||
Wakelock.enable();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
model.onClose();
|
||||
FFI.close();
|
||||
SmartDialog.dismiss();
|
||||
gFFI.close();
|
||||
gFFI.dialogManager.dismissAll();
|
||||
Wakelock.disable();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ChangeNotifierProvider.value(
|
||||
value: FFI.fileModel,
|
||||
value: gFFI.fileModel,
|
||||
child: Consumer<FileModel>(builder: (_context, _model, _child) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
@@ -59,7 +61,9 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
||||
backgroundColor: MyTheme.grayBg,
|
||||
appBar: AppBar(
|
||||
leading: Row(children: [
|
||||
IconButton(icon: Icon(Icons.close), onPressed: clientClose),
|
||||
IconButton(
|
||||
icon: Icon(Icons.close),
|
||||
onPressed: () => clientClose(gFFI.dialogManager)),
|
||||
]),
|
||||
centerTitle: true,
|
||||
title: ToggleSwitch(
|
||||
@@ -140,8 +144,8 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
||||
model.toggleSelectMode();
|
||||
} else if (v == "folder") {
|
||||
final name = TextEditingController();
|
||||
DialogManager.show(
|
||||
(setState, close) => CustomAlertDialog(
|
||||
gFFI.dialogManager
|
||||
.show((setState, close) => CustomAlertDialog(
|
||||
title: Text(translate("Create Folder")),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -1,9 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/pages/chat_page.dart';
|
||||
import 'package:flutter_hbb/pages/server_page.dart';
|
||||
import 'package:flutter_hbb/pages/settings_page.dart';
|
||||
import '../common.dart';
|
||||
import '../widgets/overlay.dart';
|
||||
import 'package:flutter_hbb/mobile/pages/chat_page.dart';
|
||||
import 'package:flutter_hbb/mobile/pages/server_page.dart';
|
||||
import 'package:flutter_hbb/mobile/pages/settings_page.dart';
|
||||
import '../../common.dart';
|
||||
import 'connection_page.dart';
|
||||
|
||||
abstract class PageShape extends Widget {
|
||||
@@ -12,10 +11,10 @@ abstract class PageShape extends Widget {
|
||||
final List<Widget> appBarActions = [];
|
||||
}
|
||||
|
||||
final homeKey = GlobalKey<_HomePageState>();
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
HomePage({Key? key}) : super(key: key);
|
||||
static final homeKey = GlobalKey<_HomePageState>();
|
||||
|
||||
HomePage() : super(key: homeKey);
|
||||
|
||||
@override
|
||||
_HomePageState createState() => _HomePageState();
|
||||
@@ -79,8 +78,8 @@ class _HomePageState extends State<HomePage> {
|
||||
onTap: (index) => setState(() {
|
||||
// close chat overlay when go chat page
|
||||
if (index == 1 && _selectedIndex != index) {
|
||||
hideChatIconOverlay();
|
||||
hideChatWindowOverlay();
|
||||
gFFI.chatModel.hideChatIconOverlay();
|
||||
gFFI.chatModel.hideChatWindowOverlay();
|
||||
}
|
||||
_selectedIndex = index;
|
||||
}),
|
||||
@@ -1,17 +1,19 @@
|
||||
import 'dart:async';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/models/chat_model.dart';
|
||||
import 'package:flutter_hbb/widgets/gesture_help.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:async';
|
||||
import 'package:flutter_hbb/mobile/widgets/gesture_help.dart';
|
||||
import 'package:flutter_hbb/models/chat_model.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
import '../common.dart';
|
||||
import '../widgets/gestures.dart';
|
||||
import '../models/model.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
import '../../models/model.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
import '../widgets/dialog.dart';
|
||||
import '../widgets/gestures.dart';
|
||||
import '../widgets/overlay.dart';
|
||||
|
||||
final initText = '\1' * 1024;
|
||||
@@ -28,7 +30,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;
|
||||
@@ -45,30 +47,32 @@ class _RemotePageState extends State<RemotePage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
FFI.connect(widget.id);
|
||||
gFFI.connect(widget.id);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
||||
showLoading(translate('Connecting...'));
|
||||
gFFI.dialogManager
|
||||
.showLoading(translate('Connecting...'), onCancel: closeConnection);
|
||||
_interval =
|
||||
Timer.periodic(Duration(milliseconds: 30), (timer) => interval());
|
||||
});
|
||||
Wakelock.enable();
|
||||
_physicalFocusNode.requestFocus();
|
||||
FFI.ffiModel.updateEventListener(widget.id);
|
||||
FFI.listenToMouse(true);
|
||||
gFFI.ffiModel.updateEventListener(widget.id);
|
||||
gFFI.listenToMouse(true);
|
||||
gFFI.qualityMonitorModel.checkShowQualityMonitor(widget.id);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
hideMobileActionsOverlay();
|
||||
FFI.listenToMouse(false);
|
||||
FFI.invokeMethod("enable_soft_keyboard", true);
|
||||
gFFI.listenToMouse(false);
|
||||
gFFI.invokeMethod("enable_soft_keyboard", true);
|
||||
_mobileFocusNode.dispose();
|
||||
_physicalFocusNode.dispose();
|
||||
FFI.close();
|
||||
gFFI.close();
|
||||
_interval?.cancel();
|
||||
_timer?.cancel();
|
||||
SmartDialog.dismiss();
|
||||
gFFI.dialogManager.dismissAll();
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
||||
overlays: SystemUiOverlay.values);
|
||||
Wakelock.disable();
|
||||
@@ -76,7 +80,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||
}
|
||||
|
||||
void resetTool() {
|
||||
FFI.resetModifiers();
|
||||
gFFI.resetModifiers();
|
||||
}
|
||||
|
||||
bool isKeyboardShown() {
|
||||
@@ -93,10 +97,10 @@ class _RemotePageState extends State<RemotePage> {
|
||||
if (v < 100) {
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
||||
overlays: []);
|
||||
// [pi.version.isNotEmpty] -> check ready or not,avoid login without soft-keyboard
|
||||
if (chatWindowOverlayEntry == null &&
|
||||
FFI.ffiModel.pi.version.isNotEmpty) {
|
||||
FFI.invokeMethod("enable_soft_keyboard", false);
|
||||
// [pi.version.isNotEmpty] -> check ready or not, avoid login without soft-keyboard
|
||||
if (gFFI.chatModel.chatWindowOverlayEntry == null &&
|
||||
gFFI.ffiModel.pi.version.isNotEmpty) {
|
||||
gFFI.invokeMethod("enable_soft_keyboard", false);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -128,12 +132,12 @@ class _RemotePageState extends State<RemotePage> {
|
||||
newValue[common] == oldValue[common];
|
||||
++common) {}
|
||||
for (i = 0; i < oldValue.length - common; ++i) {
|
||||
FFI.inputKey('VK_BACK');
|
||||
gFFI.inputKey('VK_BACK');
|
||||
}
|
||||
if (newValue.length > common) {
|
||||
var s = newValue.substring(common);
|
||||
if (s.length > 1) {
|
||||
FFI.setByName('input_string', s);
|
||||
bind.sessionInputString(id: widget.id, value: s);
|
||||
} else {
|
||||
inputChar(s);
|
||||
}
|
||||
@@ -151,7 +155,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||
// ?
|
||||
} else if (newValue.length < oldValue.length) {
|
||||
final char = 'VK_BACK';
|
||||
FFI.inputKey(char);
|
||||
gFFI.inputKey(char);
|
||||
} else {
|
||||
final content = newValue.substring(oldValue.length);
|
||||
if (content.length > 1) {
|
||||
@@ -167,11 +171,11 @@ class _RemotePageState extends State<RemotePage> {
|
||||
content == '()' ||
|
||||
content == '【】')) {
|
||||
// can not only input content[0], because when input ], [ are also auo insert, which cause ] never be input
|
||||
FFI.setByName('input_string', content);
|
||||
bind.sessionInputString(id: widget.id, value: content);
|
||||
openKeyboard();
|
||||
return;
|
||||
}
|
||||
FFI.setByName('input_string', content);
|
||||
bind.sessionInputString(id: widget.id, value: content);
|
||||
} else {
|
||||
inputChar(content);
|
||||
}
|
||||
@@ -184,11 +188,11 @@ class _RemotePageState extends State<RemotePage> {
|
||||
} else if (char == ' ') {
|
||||
char = 'VK_SPACE';
|
||||
}
|
||||
FFI.inputKey(char);
|
||||
gFFI.inputKey(char);
|
||||
}
|
||||
|
||||
void openKeyboard() {
|
||||
FFI.invokeMethod("enable_soft_keyboard", true);
|
||||
gFFI.invokeMethod("enable_soft_keyboard", true);
|
||||
// destroy first, so that our _value trick can work
|
||||
_value = initText;
|
||||
setState(() => _showEdit = false);
|
||||
@@ -211,7 +215,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||
final label = _logicalKeyMap[e.logicalKey.keyId] ??
|
||||
_physicalKeyMap[e.physicalKey.usbHidUsage] ??
|
||||
e.logicalKey.keyLabel;
|
||||
FFI.inputKey(label, down: down, press: press ?? false);
|
||||
gFFI.inputKey(label, down: down, press: press ?? false);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -219,11 +223,11 @@ class _RemotePageState extends State<RemotePage> {
|
||||
final pi = Provider.of<FfiModel>(context).pi;
|
||||
final hideKeyboard = isKeyboardShown() && _showEdit;
|
||||
final showActionButton = !_showBar || hideKeyboard;
|
||||
final keyboard = FFI.ffiModel.permissions['keyboard'] != false;
|
||||
final keyboard = gFFI.ffiModel.permissions['keyboard'] != false;
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
clientClose();
|
||||
clientClose(gFFI.dialogManager);
|
||||
return false;
|
||||
},
|
||||
child: getRawPointerAndKeyBody(
|
||||
@@ -241,7 +245,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||
setState(() {
|
||||
if (hideKeyboard) {
|
||||
_showEdit = false;
|
||||
FFI.invokeMethod("enable_soft_keyboard", false);
|
||||
gFFI.invokeMethod("enable_soft_keyboard", false);
|
||||
_mobileFocusNode.unfocus();
|
||||
_physicalFocusNode.requestFocus();
|
||||
} else {
|
||||
@@ -257,7 +261,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||
OverlayEntry(builder: (context) {
|
||||
return Container(
|
||||
color: Colors.black,
|
||||
child: isDesktop
|
||||
child: isWebDesktop
|
||||
? getBodyForDesktopWithListener(keyboard)
|
||||
: SafeArea(child:
|
||||
OrientationBuilder(builder: (ctx, orientation) {
|
||||
@@ -265,7 +269,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||
Timer(Duration(milliseconds: 200), () {
|
||||
resetMobileActionsOverlay();
|
||||
_currentOrientation = orientation;
|
||||
FFI.canvasModel.updateViewStyle();
|
||||
gFFI.canvasModel.updateViewStyle();
|
||||
});
|
||||
}
|
||||
return Container(
|
||||
@@ -290,7 +294,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||
});
|
||||
}
|
||||
if (_isPhysicalMouse) {
|
||||
FFI.handleMouse(getEvent(e, 'mousemove'));
|
||||
gFFI.handleMouse(getEvent(e, 'mousemove'));
|
||||
}
|
||||
},
|
||||
onPointerDown: (e) {
|
||||
@@ -302,19 +306,19 @@ class _RemotePageState extends State<RemotePage> {
|
||||
}
|
||||
}
|
||||
if (_isPhysicalMouse) {
|
||||
FFI.handleMouse(getEvent(e, 'mousedown'));
|
||||
gFFI.handleMouse(getEvent(e, 'mousedown'));
|
||||
}
|
||||
},
|
||||
onPointerUp: (e) {
|
||||
if (e.kind != ui.PointerDeviceKind.mouse) return;
|
||||
if (_isPhysicalMouse) {
|
||||
FFI.handleMouse(getEvent(e, 'mouseup'));
|
||||
gFFI.handleMouse(getEvent(e, 'mouseup'));
|
||||
}
|
||||
},
|
||||
onPointerMove: (e) {
|
||||
if (e.kind != ui.PointerDeviceKind.mouse) return;
|
||||
if (_isPhysicalMouse) {
|
||||
FFI.handleMouse(getEvent(e, 'mousemove'));
|
||||
gFFI.handleMouse(getEvent(e, 'mousemove'));
|
||||
}
|
||||
},
|
||||
onPointerSignal: (e) {
|
||||
@@ -327,8 +331,9 @@ class _RemotePageState extends State<RemotePage> {
|
||||
if (dy > 0)
|
||||
dy = -1;
|
||||
else if (dy < 0) dy = 1;
|
||||
FFI.setByName(
|
||||
'send_mouse', '{"type": "wheel", "x": "$dx", "y": "$dy"}');
|
||||
bind.sessionSendMouse(
|
||||
id: widget.id,
|
||||
msg: '{"type": "wheel", "x": "$dx", "y": "$dy"}');
|
||||
}
|
||||
},
|
||||
child: MouseRegion(
|
||||
@@ -350,14 +355,14 @@ class _RemotePageState extends State<RemotePage> {
|
||||
sendRawKey(e, press: true);
|
||||
} else {
|
||||
sendRawKey(e, down: true);
|
||||
if (e.isAltPressed && !FFI.alt) {
|
||||
FFI.alt = true;
|
||||
} else if (e.isControlPressed && !FFI.ctrl) {
|
||||
FFI.ctrl = true;
|
||||
} else if (e.isShiftPressed && !FFI.shift) {
|
||||
FFI.shift = true;
|
||||
} else if (e.isMetaPressed && !FFI.command) {
|
||||
FFI.command = true;
|
||||
if (e.isAltPressed && !gFFI.alt) {
|
||||
gFFI.alt = true;
|
||||
} else if (e.isControlPressed && !gFFI.ctrl) {
|
||||
gFFI.ctrl = true;
|
||||
} else if (e.isShiftPressed && !gFFI.shift) {
|
||||
gFFI.shift = true;
|
||||
} else if (e.isMetaPressed && !gFFI.command) {
|
||||
gFFI.command = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -365,16 +370,16 @@ class _RemotePageState extends State<RemotePage> {
|
||||
if (!_showEdit && e is RawKeyUpEvent) {
|
||||
if (key == LogicalKeyboardKey.altLeft ||
|
||||
key == LogicalKeyboardKey.altRight) {
|
||||
FFI.alt = false;
|
||||
gFFI.alt = false;
|
||||
} else if (key == LogicalKeyboardKey.controlLeft ||
|
||||
key == LogicalKeyboardKey.controlRight) {
|
||||
FFI.ctrl = false;
|
||||
gFFI.ctrl = false;
|
||||
} else if (key == LogicalKeyboardKey.shiftRight ||
|
||||
key == LogicalKeyboardKey.shiftLeft) {
|
||||
FFI.shift = false;
|
||||
gFFI.shift = false;
|
||||
} else if (key == LogicalKeyboardKey.metaLeft ||
|
||||
key == LogicalKeyboardKey.metaRight) {
|
||||
FFI.command = false;
|
||||
gFFI.command = false;
|
||||
}
|
||||
sendRawKey(e);
|
||||
}
|
||||
@@ -397,7 +402,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||
color: Colors.white,
|
||||
icon: Icon(Icons.clear),
|
||||
onPressed: () {
|
||||
clientClose();
|
||||
clientClose(gFFI.dialogManager);
|
||||
},
|
||||
)
|
||||
] +
|
||||
@@ -407,13 +412,13 @@ class _RemotePageState extends State<RemotePage> {
|
||||
icon: Icon(Icons.tv),
|
||||
onPressed: () {
|
||||
setState(() => _showEdit = false);
|
||||
showOptions();
|
||||
showOptions(widget.id, gFFI.dialogManager);
|
||||
},
|
||||
)
|
||||
] +
|
||||
(isDesktop
|
||||
(isWebDesktop
|
||||
? []
|
||||
: FFI.ffiModel.isPeerAndroid
|
||||
: gFFI.ffiModel.isPeerAndroid
|
||||
? [
|
||||
IconButton(
|
||||
color: Colors.white,
|
||||
@@ -434,7 +439,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||
onPressed: openKeyboard),
|
||||
IconButton(
|
||||
color: Colors.white,
|
||||
icon: Icon(FFI.ffiModel.touchMode
|
||||
icon: Icon(gFFI.ffiModel.touchMode
|
||||
? Icons.touch_app
|
||||
: Icons.mouse),
|
||||
onPressed: changeTouchMode,
|
||||
@@ -447,9 +452,9 @@ class _RemotePageState extends State<RemotePage> {
|
||||
color: Colors.white,
|
||||
icon: Icon(Icons.message),
|
||||
onPressed: () {
|
||||
FFI.chatModel
|
||||
gFFI.chatModel
|
||||
.changeCurrentID(ChatModel.clientModeID);
|
||||
toggleChatOverlay();
|
||||
gFFI.chatModel.toggleChatOverlay();
|
||||
},
|
||||
)
|
||||
]) +
|
||||
@@ -459,7 +464,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||
icon: Icon(Icons.more_vert),
|
||||
onPressed: () {
|
||||
setState(() => _showEdit = false);
|
||||
showActions();
|
||||
showActions(widget.id);
|
||||
},
|
||||
),
|
||||
]),
|
||||
@@ -486,101 +491,102 @@ class _RemotePageState extends State<RemotePage> {
|
||||
|
||||
Offset _cacheLongPressPosition = Offset(0, 0);
|
||||
Widget getBodyForMobileWithGesture() {
|
||||
final touchMode = FFI.ffiModel.touchMode;
|
||||
final touchMode = gFFI.ffiModel.touchMode;
|
||||
return getMixinGestureDetector(
|
||||
child: getBodyForMobile(),
|
||||
onTapUp: (d) {
|
||||
if (touchMode) {
|
||||
FFI.cursorModel.touch(
|
||||
gFFI.cursorModel.touch(
|
||||
d.localPosition.dx, d.localPosition.dy, MouseButtons.left);
|
||||
} else {
|
||||
FFI.tap(MouseButtons.left);
|
||||
gFFI.tap(MouseButtons.left);
|
||||
}
|
||||
},
|
||||
onDoubleTapDown: (d) {
|
||||
if (touchMode) {
|
||||
FFI.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
||||
gFFI.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
||||
}
|
||||
},
|
||||
onDoubleTap: () {
|
||||
FFI.tap(MouseButtons.left);
|
||||
FFI.tap(MouseButtons.left);
|
||||
gFFI.tap(MouseButtons.left);
|
||||
gFFI.tap(MouseButtons.left);
|
||||
},
|
||||
onLongPressDown: (d) {
|
||||
if (touchMode) {
|
||||
gFFI.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
||||
_cacheLongPressPosition = d.localPosition;
|
||||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
if (touchMode) {
|
||||
FFI.cursorModel
|
||||
gFFI.cursorModel
|
||||
.move(_cacheLongPressPosition.dx, _cacheLongPressPosition.dy);
|
||||
}
|
||||
FFI.tap(MouseButtons.right);
|
||||
gFFI.tap(MouseButtons.right);
|
||||
},
|
||||
onDoubleFinerTap: (d) {
|
||||
if (!touchMode) {
|
||||
FFI.tap(MouseButtons.right);
|
||||
gFFI.tap(MouseButtons.right);
|
||||
}
|
||||
},
|
||||
onHoldDragStart: (d) {
|
||||
if (!touchMode) {
|
||||
FFI.sendMouse('down', MouseButtons.left);
|
||||
gFFI.sendMouse('down', MouseButtons.left);
|
||||
}
|
||||
},
|
||||
onHoldDragUpdate: (d) {
|
||||
if (!touchMode) {
|
||||
FFI.cursorModel.updatePan(d.delta.dx, d.delta.dy, touchMode);
|
||||
gFFI.cursorModel.updatePan(d.delta.dx, d.delta.dy, touchMode);
|
||||
}
|
||||
},
|
||||
onHoldDragEnd: (_) {
|
||||
if (!touchMode) {
|
||||
FFI.sendMouse('up', MouseButtons.left);
|
||||
gFFI.sendMouse('up', MouseButtons.left);
|
||||
}
|
||||
},
|
||||
onOneFingerPanStart: (d) {
|
||||
if (touchMode) {
|
||||
FFI.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
||||
FFI.sendMouse('down', MouseButtons.left);
|
||||
gFFI.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
||||
gFFI.sendMouse('down', MouseButtons.left);
|
||||
} else {
|
||||
final cursorX = FFI.cursorModel.x;
|
||||
final cursorY = FFI.cursorModel.y;
|
||||
final cursorX = gFFI.cursorModel.x;
|
||||
final cursorY = gFFI.cursorModel.y;
|
||||
final visible =
|
||||
FFI.cursorModel.getVisibleRect().inflate(1); // extend edges
|
||||
gFFI.cursorModel.getVisibleRect().inflate(1); // extend edges
|
||||
final size = MediaQueryData.fromWindow(ui.window).size;
|
||||
if (!visible.contains(Offset(cursorX, cursorY))) {
|
||||
FFI.cursorModel.move(size.width / 2, size.height / 2);
|
||||
gFFI.cursorModel.move(size.width / 2, size.height / 2);
|
||||
}
|
||||
}
|
||||
},
|
||||
onOneFingerPanUpdate: (d) {
|
||||
FFI.cursorModel.updatePan(d.delta.dx, d.delta.dy, touchMode);
|
||||
gFFI.cursorModel.updatePan(d.delta.dx, d.delta.dy, touchMode);
|
||||
},
|
||||
onOneFingerPanEnd: (d) {
|
||||
if (touchMode) {
|
||||
FFI.sendMouse('up', MouseButtons.left);
|
||||
gFFI.sendMouse('up', MouseButtons.left);
|
||||
}
|
||||
},
|
||||
// scale + pan event
|
||||
onTwoFingerScaleUpdate: (d) {
|
||||
FFI.canvasModel.updateScale(d.scale / _scale);
|
||||
gFFI.canvasModel.updateScale(d.scale / _scale);
|
||||
_scale = d.scale;
|
||||
FFI.canvasModel.panX(d.focalPointDelta.dx);
|
||||
FFI.canvasModel.panY(d.focalPointDelta.dy);
|
||||
gFFI.canvasModel.panX(d.focalPointDelta.dx);
|
||||
gFFI.canvasModel.panY(d.focalPointDelta.dy);
|
||||
},
|
||||
onTwoFingerScaleEnd: (d) {
|
||||
_scale = 1;
|
||||
FFI.setByName('peer_option', '{"name": "view-style", "value": ""}');
|
||||
bind.sessionPeerOption(id: widget.id, name: "view-style", value: "");
|
||||
},
|
||||
onThreeFingerVerticalDragUpdate: FFI.ffiModel.isPeerAndroid
|
||||
onThreeFingerVerticalDragUpdate: gFFI.ffiModel.isPeerAndroid
|
||||
? null
|
||||
: (d) {
|
||||
_mouseScrollIntegral += d.delta.dy / 4;
|
||||
if (_mouseScrollIntegral > 1) {
|
||||
FFI.scroll(1);
|
||||
gFFI.scroll(1);
|
||||
_mouseScrollIntegral = 0;
|
||||
} else if (_mouseScrollIntegral < -1) {
|
||||
FFI.scroll(-1);
|
||||
gFFI.scroll(-1);
|
||||
_mouseScrollIntegral = 0;
|
||||
}
|
||||
});
|
||||
@@ -617,8 +623,9 @@ class _RemotePageState extends State<RemotePage> {
|
||||
|
||||
Widget getBodyForDesktopWithListener(bool keyboard) {
|
||||
var paints = <Widget>[ImagePaint()];
|
||||
if (keyboard ||
|
||||
FFI.getByName('toggle_option', 'show-remote-cursor') == 'true') {
|
||||
final cursor = bind.sessionGetToggleOptionSync(
|
||||
id: widget.id, arg: 'show-remote-cursor');
|
||||
if (keyboard || cursor) {
|
||||
paints.add(CursorPaint());
|
||||
}
|
||||
return Container(
|
||||
@@ -626,15 +633,16 @@ class _RemotePageState extends State<RemotePage> {
|
||||
}
|
||||
|
||||
int lastMouseDownButtons = 0;
|
||||
|
||||
Map<String, dynamic> getEvent(PointerEvent evt, String type) {
|
||||
final Map<String, dynamic> out = {};
|
||||
out['type'] = type;
|
||||
out['x'] = evt.position.dx;
|
||||
out['y'] = evt.position.dy;
|
||||
if (FFI.alt) out['alt'] = 'true';
|
||||
if (FFI.shift) out['shift'] = 'true';
|
||||
if (FFI.ctrl) out['ctrl'] = 'true';
|
||||
if (FFI.command) out['command'] = 'true';
|
||||
if (gFFI.alt) out['alt'] = 'true';
|
||||
if (gFFI.shift) out['shift'] = 'true';
|
||||
if (gFFI.ctrl) out['ctrl'] = 'true';
|
||||
if (gFFI.command) out['command'] = 'true';
|
||||
out['buttons'] = evt
|
||||
.buttons; // left button: 1, right button: 2, middle button: 4, 1 | 2 = 3 (left + right)
|
||||
if (evt.buttons != 0) {
|
||||
@@ -645,13 +653,13 @@ class _RemotePageState extends State<RemotePage> {
|
||||
return out;
|
||||
}
|
||||
|
||||
void showActions() {
|
||||
void showActions(String id) async {
|
||||
final size = MediaQuery.of(context).size;
|
||||
final x = 120.0;
|
||||
final y = size.height;
|
||||
final more = <PopupMenuItem<String>>[];
|
||||
final pi = FFI.ffiModel.pi;
|
||||
final perms = FFI.ffiModel.permissions;
|
||||
final pi = gFFI.ffiModel.pi;
|
||||
final perms = gFFI.ffiModel.permissions;
|
||||
if (pi.version.isNotEmpty) {
|
||||
more.add(PopupMenuItem<String>(
|
||||
child: Text(translate('Refresh')), value: 'refresh'));
|
||||
@@ -663,14 +671,13 @@ class _RemotePageState extends State<RemotePage> {
|
||||
TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
showSetOSPassword(false);
|
||||
showSetOSPassword(id, false, gFFI.dialogManager);
|
||||
},
|
||||
child: Icon(Icons.edit, color: MyTheme.accent),
|
||||
)
|
||||
])),
|
||||
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'));
|
||||
@@ -687,14 +694,15 @@ class _RemotePageState extends State<RemotePage> {
|
||||
more.add(PopupMenuItem<String>(
|
||||
child: Text(translate('Insert Lock')), value: 'lock'));
|
||||
if (pi.platform == 'Windows' &&
|
||||
FFI.getByName('toggle_option', 'privacy-mode') != 'true') {
|
||||
await bind.sessionGetToggleOption(id: id, arg: 'privacy-mode') !=
|
||||
true) {
|
||||
more.add(PopupMenuItem<String>(
|
||||
child: Text(translate(
|
||||
(FFI.ffiModel.inputBlocked ? 'Unb' : 'B') + 'lock user input')),
|
||||
child: Text(translate((gFFI.ffiModel.inputBlocked ? 'Unb' : 'B') +
|
||||
'lock user input')),
|
||||
value: 'block-input'));
|
||||
}
|
||||
}
|
||||
if (FFI.ffiModel.permissions["restart"] != false &&
|
||||
if (gFFI.ffiModel.permissions["restart"] != false &&
|
||||
(pi.platform == "Linux" ||
|
||||
pi.platform == "Windows" ||
|
||||
pi.platform == "Mac OS")) {
|
||||
@@ -709,33 +717,37 @@ class _RemotePageState extends State<RemotePage> {
|
||||
elevation: 8,
|
||||
);
|
||||
if (value == 'cad') {
|
||||
FFI.setByName('ctrl_alt_del');
|
||||
bind.sessionCtrlAltDel(id: widget.id);
|
||||
} else if (value == 'lock') {
|
||||
FFI.setByName('lock_screen');
|
||||
bind.sessionLockScreen(id: widget.id);
|
||||
} else if (value == 'block-input') {
|
||||
FFI.setByName('toggle_option',
|
||||
(FFI.ffiModel.inputBlocked ? 'un' : '') + 'block-input');
|
||||
FFI.ffiModel.inputBlocked = !FFI.ffiModel.inputBlocked;
|
||||
bind.sessionToggleOption(
|
||||
id: widget.id,
|
||||
value: (gFFI.ffiModel.inputBlocked ? 'un' : '') + 'block-input');
|
||||
gFFI.ffiModel.inputBlocked = !gFFI.ffiModel.inputBlocked;
|
||||
} else if (value == 'refresh') {
|
||||
FFI.setByName('refresh');
|
||||
bind.sessionRefresh(id: widget.id);
|
||||
} else if (value == 'paste') {
|
||||
() async {
|
||||
ClipboardData? data = await Clipboard.getData(Clipboard.kTextPlain);
|
||||
if (data != null && data.text != null) {
|
||||
FFI.setByName('input_string', '${data.text}');
|
||||
bind.sessionInputString(id: widget.id, value: data.text ?? "");
|
||||
}
|
||||
}();
|
||||
} else if (value == 'enter_os_password') {
|
||||
var password = FFI.getByName('peer_option', "os-password");
|
||||
if (password != "") {
|
||||
FFI.setByName('input_os_password', password);
|
||||
// FIXME:
|
||||
// null means no session of id
|
||||
// empty string means no password
|
||||
var password = await bind.sessionGetOption(id: id, arg: "os-password");
|
||||
if (password != null) {
|
||||
bind.sessionInputOsPassword(id: widget.id, value: password);
|
||||
} else {
|
||||
showSetOSPassword(true);
|
||||
showSetOSPassword(id, true, gFFI.dialogManager);
|
||||
}
|
||||
} else if (value == 'reset_canvas') {
|
||||
FFI.cursorModel.reset();
|
||||
gFFI.cursorModel.reset();
|
||||
} else if (value == 'restart') {
|
||||
showRestartRemoteDevice(pi, widget.id);
|
||||
showRestartRemoteDevice(pi, widget.id, gFFI.dialogManager);
|
||||
}
|
||||
}();
|
||||
}
|
||||
@@ -754,12 +766,12 @@ class _RemotePageState extends State<RemotePage> {
|
||||
return SingleChildScrollView(
|
||||
padding: EdgeInsets.symmetric(vertical: 10),
|
||||
child: GestureHelp(
|
||||
touchMode: FFI.ffiModel.touchMode,
|
||||
touchMode: gFFI.ffiModel.touchMode,
|
||||
onTouchModeChange: (t) {
|
||||
FFI.ffiModel.toggleTouchMode();
|
||||
final v = FFI.ffiModel.touchMode ? 'Y' : '';
|
||||
FFI.setByName('peer_option',
|
||||
'{"name": "touch-mode", "value": "$v"}');
|
||||
gFFI.ffiModel.toggleTouchMode();
|
||||
final v = gFFI.ffiModel.touchMode ? 'Y' : '';
|
||||
bind.sessionPeerOption(
|
||||
id: widget.id, name: "touch", value: v);
|
||||
}));
|
||||
}));
|
||||
}
|
||||
@@ -790,21 +802,21 @@ class _RemotePageState extends State<RemotePage> {
|
||||
style: TextStyle(color: Colors.white, fontSize: 11)),
|
||||
onPressed: onPressed);
|
||||
};
|
||||
final pi = FFI.ffiModel.pi;
|
||||
final pi = gFFI.ffiModel.pi;
|
||||
final isMac = pi.platform == "Mac OS";
|
||||
final modifiers = <Widget>[
|
||||
wrap('Ctrl ', () {
|
||||
setState(() => FFI.ctrl = !FFI.ctrl);
|
||||
}, FFI.ctrl),
|
||||
setState(() => gFFI.ctrl = !gFFI.ctrl);
|
||||
}, gFFI.ctrl),
|
||||
wrap(' Alt ', () {
|
||||
setState(() => FFI.alt = !FFI.alt);
|
||||
}, FFI.alt),
|
||||
setState(() => gFFI.alt = !gFFI.alt);
|
||||
}, gFFI.alt),
|
||||
wrap('Shift', () {
|
||||
setState(() => FFI.shift = !FFI.shift);
|
||||
}, FFI.shift),
|
||||
setState(() => gFFI.shift = !gFFI.shift);
|
||||
}, gFFI.shift),
|
||||
wrap(isMac ? ' Cmd ' : ' Win ', () {
|
||||
setState(() => FFI.command = !FFI.command);
|
||||
}, FFI.command),
|
||||
setState(() => gFFI.command = !gFFI.command);
|
||||
}, gFFI.command),
|
||||
];
|
||||
final keys = <Widget>[
|
||||
wrap(
|
||||
@@ -836,44 +848,44 @@ class _RemotePageState extends State<RemotePage> {
|
||||
for (var i = 1; i <= 12; ++i) {
|
||||
final name = 'F' + i.toString();
|
||||
fn.add(wrap(name, () {
|
||||
FFI.inputKey('VK_' + name);
|
||||
gFFI.inputKey('VK_' + name);
|
||||
}));
|
||||
}
|
||||
final more = <Widget>[
|
||||
SizedBox(width: 9999),
|
||||
wrap('Esc', () {
|
||||
FFI.inputKey('VK_ESCAPE');
|
||||
gFFI.inputKey('VK_ESCAPE');
|
||||
}),
|
||||
wrap('Tab', () {
|
||||
FFI.inputKey('VK_TAB');
|
||||
gFFI.inputKey('VK_TAB');
|
||||
}),
|
||||
wrap('Home', () {
|
||||
FFI.inputKey('VK_HOME');
|
||||
gFFI.inputKey('VK_HOME');
|
||||
}),
|
||||
wrap('End', () {
|
||||
FFI.inputKey('VK_END');
|
||||
gFFI.inputKey('VK_END');
|
||||
}),
|
||||
wrap('Del', () {
|
||||
FFI.inputKey('VK_DELETE');
|
||||
gFFI.inputKey('VK_DELETE');
|
||||
}),
|
||||
wrap('PgUp', () {
|
||||
FFI.inputKey('VK_PRIOR');
|
||||
gFFI.inputKey('VK_PRIOR');
|
||||
}),
|
||||
wrap('PgDn', () {
|
||||
FFI.inputKey('VK_NEXT');
|
||||
gFFI.inputKey('VK_NEXT');
|
||||
}),
|
||||
SizedBox(width: 9999),
|
||||
wrap('', () {
|
||||
FFI.inputKey('VK_LEFT');
|
||||
gFFI.inputKey('VK_LEFT');
|
||||
}, false, Icons.keyboard_arrow_left),
|
||||
wrap('', () {
|
||||
FFI.inputKey('VK_UP');
|
||||
gFFI.inputKey('VK_UP');
|
||||
}, false, Icons.keyboard_arrow_up),
|
||||
wrap('', () {
|
||||
FFI.inputKey('VK_DOWN');
|
||||
gFFI.inputKey('VK_DOWN');
|
||||
}, false, Icons.keyboard_arrow_down),
|
||||
wrap('', () {
|
||||
FFI.inputKey('VK_RIGHT');
|
||||
gFFI.inputKey('VK_RIGHT');
|
||||
}, false, Icons.keyboard_arrow_right),
|
||||
wrap(isMac ? 'Cmd+C' : 'Ctrl+C', () {
|
||||
sendPrompt(isMac, 'VK_C');
|
||||
@@ -906,7 +918,7 @@ class ImagePaint extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final m = Provider.of<ImageModel>(context);
|
||||
final c = Provider.of<CanvasModel>(context);
|
||||
final adjust = FFI.cursorModel.adjustForKeyboard();
|
||||
final adjust = gFFI.cursorModel.adjustForKeyboard();
|
||||
var s = c.scale;
|
||||
return CustomPaint(
|
||||
painter: new ImagePainter(
|
||||
@@ -920,7 +932,7 @@ class CursorPaint extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final m = Provider.of<CursorModel>(context);
|
||||
final c = Provider.of<CanvasModel>(context);
|
||||
final adjust = FFI.cursorModel.adjustForKeyboard();
|
||||
final adjust = gFFI.cursorModel.adjustForKeyboard();
|
||||
var s = c.scale;
|
||||
return CustomPaint(
|
||||
painter: new ImagePainter(
|
||||
@@ -961,7 +973,7 @@ class ImagePainter extends CustomPainter {
|
||||
class QualityMonitor extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) => ChangeNotifierProvider.value(
|
||||
value: FFI.qualityMonitorModel,
|
||||
value: gFFI.qualityMonitorModel,
|
||||
child: Consumer<QualityMonitorModel>(
|
||||
builder: (context, qualityMonitorModel, child) => Positioned(
|
||||
top: 10,
|
||||
@@ -974,23 +986,23 @@ class QualityMonitor extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Speed: ${qualityMonitorModel.data.speed}",
|
||||
"Speed: ${qualityMonitorModel.data.speed ?? ''}",
|
||||
style: TextStyle(color: MyTheme.grayBg),
|
||||
),
|
||||
Text(
|
||||
"FPS: ${qualityMonitorModel.data.fps}",
|
||||
"FPS: ${qualityMonitorModel.data.fps ?? ''}",
|
||||
style: TextStyle(color: MyTheme.grayBg),
|
||||
),
|
||||
Text(
|
||||
"Delay: ${qualityMonitorModel.data.delay} ms",
|
||||
"Delay: ${qualityMonitorModel.data.delay ?? ''} ms",
|
||||
style: TextStyle(color: MyTheme.grayBg),
|
||||
),
|
||||
Text(
|
||||
"Target Bitrate: ${qualityMonitorModel.data.targetBitrate}kb",
|
||||
"Target Bitrate: ${qualityMonitorModel.data.targetBitrate ?? ''}kb",
|
||||
style: TextStyle(color: MyTheme.grayBg),
|
||||
),
|
||||
Text(
|
||||
"Codec: ${qualityMonitorModel.data.codecFormat}",
|
||||
"Codec: ${qualityMonitorModel.data.codecFormat ?? ''}",
|
||||
style: TextStyle(color: MyTheme.grayBg),
|
||||
),
|
||||
],
|
||||
@@ -999,29 +1011,14 @@ class QualityMonitor extends StatelessWidget {
|
||||
: SizedBox.shrink())));
|
||||
}
|
||||
|
||||
CheckboxListTile getToggle(
|
||||
void Function(void Function()) setState, option, name) {
|
||||
return CheckboxListTile(
|
||||
value: FFI.getByName('toggle_option', option) == 'true',
|
||||
onChanged: (v) {
|
||||
setState(() {
|
||||
FFI.setByName('toggle_option', option);
|
||||
});
|
||||
if (option == "show-quality-monitor") {
|
||||
FFI.qualityMonitorModel.checkShowQualityMonitor();
|
||||
}
|
||||
},
|
||||
dense: true,
|
||||
title: Text(translate(name)));
|
||||
}
|
||||
|
||||
void showOptions() {
|
||||
String quality = FFI.getByName('image_quality');
|
||||
void showOptions(String id, OverlayDialogManager dialogManager) async {
|
||||
String quality = await bind.sessionGetImageQuality(id: id) ?? 'balanced';
|
||||
if (quality == '') quality = 'balanced';
|
||||
String viewStyle = FFI.getByName('peer_option', 'view-style');
|
||||
String viewStyle =
|
||||
await bind.sessionGetOption(id: id, arg: 'view-style') ?? '';
|
||||
var displays = <Widget>[];
|
||||
final pi = FFI.ffiModel.pi;
|
||||
final image = FFI.ffiModel.getConnectionImage();
|
||||
final pi = gFFI.ffiModel.pi;
|
||||
final image = gFFI.ffiModel.getConnectionImage();
|
||||
if (image != null)
|
||||
displays.add(Padding(padding: const EdgeInsets.only(top: 8), child: image));
|
||||
if (pi.displays.length > 1) {
|
||||
@@ -1031,8 +1028,8 @@ void showOptions() {
|
||||
children.add(InkWell(
|
||||
onTap: () {
|
||||
if (i == cur) return;
|
||||
FFI.setByName('switch_display', i.toString());
|
||||
SmartDialog.dismiss();
|
||||
bind.sessionSwitchDisplay(id: id, value: i);
|
||||
gFFI.dialogManager.dismissAll();
|
||||
},
|
||||
child: Ink(
|
||||
width: 40,
|
||||
@@ -1055,36 +1052,36 @@ void showOptions() {
|
||||
if (displays.isNotEmpty) {
|
||||
displays.add(Divider(color: MyTheme.border));
|
||||
}
|
||||
final perms = FFI.ffiModel.permissions;
|
||||
final perms = gFFI.ffiModel.permissions;
|
||||
|
||||
DialogManager.show((setState, close) {
|
||||
dialogManager.show((setState, close) {
|
||||
final more = <Widget>[];
|
||||
if (perms['audio'] != false) {
|
||||
more.add(getToggle(setState, 'disable-audio', 'Mute'));
|
||||
more.add(getToggle(id, setState, 'disable-audio', 'Mute'));
|
||||
}
|
||||
if (perms['keyboard'] != false) {
|
||||
if (perms['clipboard'] != false)
|
||||
more.add(getToggle(setState, 'disable-clipboard', 'Disable clipboard'));
|
||||
more.add(
|
||||
getToggle(id, setState, 'disable-clipboard', 'Disable clipboard'));
|
||||
more.add(getToggle(
|
||||
setState, 'lock-after-session-end', 'Lock after session end'));
|
||||
id, setState, 'lock-after-session-end', 'Lock after session end'));
|
||||
if (pi.platform == 'Windows') {
|
||||
more.add(getToggle(setState, 'privacy-mode', 'Privacy mode'));
|
||||
more.add(getToggle(id, setState, 'privacy-mode', 'Privacy mode'));
|
||||
}
|
||||
}
|
||||
var setQuality = (String? value) {
|
||||
if (value == null) return;
|
||||
setState(() {
|
||||
quality = value;
|
||||
FFI.setByName('image_quality', value);
|
||||
bind.sessionSetImageQuality(id: id, value: value);
|
||||
});
|
||||
};
|
||||
var setViewStyle = (String? value) {
|
||||
if (value == null) return;
|
||||
setState(() {
|
||||
viewStyle = value;
|
||||
FFI.setByName(
|
||||
'peer_option', '{"name": "view-style", "value": "$value"}');
|
||||
FFI.canvasModel.updateViewStyle();
|
||||
bind.sessionPeerOption(id: id, name: "view-style", value: value);
|
||||
gFFI.canvasModel.updateViewStyle();
|
||||
});
|
||||
};
|
||||
return CustomAlertDialog(
|
||||
@@ -1101,9 +1098,10 @@ void showOptions() {
|
||||
getRadio('Balanced', 'balanced', quality, setQuality),
|
||||
getRadio('Optimize reaction time', 'low', quality, setQuality),
|
||||
Divider(color: MyTheme.border),
|
||||
getToggle(setState, 'show-remote-cursor', 'Show remote cursor'),
|
||||
getToggle(
|
||||
setState, 'show-quality-monitor', 'Show quality monitor'),
|
||||
id, setState, 'show-remote-cursor', 'Show remote cursor'),
|
||||
getToggle(id, setState, 'show-quality-monitor',
|
||||
'Show quality monitor'),
|
||||
] +
|
||||
more),
|
||||
actions: [],
|
||||
@@ -1112,33 +1110,13 @@ void showOptions() {
|
||||
}, clickMaskDismiss: true, backDismiss: true);
|
||||
}
|
||||
|
||||
void showRestartRemoteDevice(PeerInfo pi, String id) async {
|
||||
final res =
|
||||
await DialogManager.show<bool>((setState, close) => CustomAlertDialog(
|
||||
title: Row(children: [
|
||||
Icon(Icons.warning_amber_sharp,
|
||||
color: Colors.redAccent, size: 28),
|
||||
SizedBox(width: 10),
|
||||
Text(translate("Restart Remote Device")),
|
||||
]),
|
||||
content: Text(
|
||||
"${translate('Are you sure you want to restart')} \n${pi.username}@${pi.hostname}($id) ?"),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => close(), child: Text(translate("Cancel"))),
|
||||
ElevatedButton(
|
||||
onPressed: () => close(true), child: Text(translate("OK"))),
|
||||
],
|
||||
));
|
||||
if (res == true) FFI.setByName('restart_remote_device');
|
||||
}
|
||||
|
||||
void showSetOSPassword(bool login) {
|
||||
void showSetOSPassword(
|
||||
String id, bool login, OverlayDialogManager dialogManager) async {
|
||||
final controller = TextEditingController();
|
||||
var password = FFI.getByName('peer_option', "os-password");
|
||||
var autoLogin = FFI.getByName('peer_option', "auto-login") != "";
|
||||
var password = await bind.sessionGetOption(id: id, arg: "os-password") ?? "";
|
||||
var autoLogin = await bind.sessionGetOption(id: id, arg: "auto-login") != "";
|
||||
controller.text = password;
|
||||
DialogManager.show((setState, close) {
|
||||
dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate('OS Password')),
|
||||
content: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
@@ -1169,12 +1147,11 @@ void showSetOSPassword(bool login) {
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
var text = controller.text.trim();
|
||||
FFI.setByName(
|
||||
'peer_option', '{"name": "os-password", "value": "$text"}');
|
||||
FFI.setByName('peer_option',
|
||||
'{"name": "auto-login", "value": "${autoLogin ? 'Y' : ''}"}');
|
||||
bind.sessionPeerOption(id: id, name: "os-password", value: text);
|
||||
bind.sessionPeerOption(
|
||||
id: id, name: "auto-login", value: autoLogin ? 'Y' : '');
|
||||
if (text != "" && login) {
|
||||
FFI.setByName('input_os_password', text);
|
||||
bind.sessionInputOsPassword(id: id, value: text);
|
||||
}
|
||||
close();
|
||||
},
|
||||
@@ -1185,17 +1162,17 @@ void showSetOSPassword(bool login) {
|
||||
}
|
||||
|
||||
void sendPrompt(bool isMac, String key) {
|
||||
final old = isMac ? FFI.command : FFI.ctrl;
|
||||
final old = isMac ? gFFI.command : gFFI.ctrl;
|
||||
if (isMac) {
|
||||
FFI.command = true;
|
||||
gFFI.command = true;
|
||||
} else {
|
||||
FFI.ctrl = true;
|
||||
gFFI.ctrl = true;
|
||||
}
|
||||
FFI.inputKey(key);
|
||||
gFFI.inputKey(key);
|
||||
if (isMac) {
|
||||
FFI.command = old;
|
||||
gFFI.command = old;
|
||||
} else {
|
||||
FFI.ctrl = old;
|
||||
gFFI.ctrl = old;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:qr_code_scanner/qr_code_scanner.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:image/image.dart' as img;
|
||||
import 'package:zxing2/qrcode.dart';
|
||||
import 'dart:io';
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import '../common.dart';
|
||||
import '../models/model.dart';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image/image.dart' as img;
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:qr_code_scanner/qr_code_scanner.dart';
|
||||
import 'package:zxing2/qrcode.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
|
||||
class ScanPage extends StatefulWidget {
|
||||
@override
|
||||
@@ -119,7 +121,7 @@ class _ScanPageState extends State<ScanPage> {
|
||||
|
||||
void _onPermissionSet(BuildContext context, QRViewController ctrl, bool p) {
|
||||
if (!p) {
|
||||
showToast('No permisssion');
|
||||
showToast('No permission');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +132,7 @@ class _ScanPageState extends State<ScanPage> {
|
||||
}
|
||||
|
||||
void showServerSettingFromQr(String data) async {
|
||||
backToHome();
|
||||
closeConnection();
|
||||
await controller?.pauseCamera();
|
||||
if (!data.startsWith('config=')) {
|
||||
showToast('Invalid QR code');
|
||||
@@ -142,7 +144,7 @@ class _ScanPageState extends State<ScanPage> {
|
||||
var key = values['key'] != null ? values['key'] as String : '';
|
||||
var api = values['api'] != null ? values['api'] as String : '';
|
||||
Timer(Duration(milliseconds: 60), () {
|
||||
showServerSettingsWithValue(host, '', key, api);
|
||||
showServerSettingsWithValue(host, '', key, api, gFFI.dialogManager);
|
||||
});
|
||||
} catch (e) {
|
||||
showToast('Invalid QR code');
|
||||
@@ -150,55 +152,81 @@ class _ScanPageState extends State<ScanPage> {
|
||||
}
|
||||
}
|
||||
|
||||
void showServerSettingsWithValue(
|
||||
String id, String relay, String key, String api) {
|
||||
final formKey = GlobalKey<FormState>();
|
||||
final id0 = FFI.getByName('option', 'custom-rendezvous-server');
|
||||
final relay0 = FFI.getByName('option', 'relay-server');
|
||||
final api0 = FFI.getByName('option', 'api-server');
|
||||
final key0 = FFI.getByName('option', 'key');
|
||||
DialogManager.show((setState, close) {
|
||||
void showServerSettingsWithValue(String id, String relay, String key,
|
||||
String api, OverlayDialogManager dialogManager) async {
|
||||
Map<String, dynamic> oldOptions = jsonDecode(await bind.mainGetOptions());
|
||||
String id0 = oldOptions['custom-rendezvous-server'] ?? "";
|
||||
String relay0 = oldOptions['relay-server'] ?? "";
|
||||
String api0 = oldOptions['api-server'] ?? "";
|
||||
String key0 = oldOptions['key'] ?? "";
|
||||
var isInProgress = false;
|
||||
final idController = TextEditingController(text: id);
|
||||
final relayController = TextEditingController(text: relay);
|
||||
final apiController = TextEditingController(text: api);
|
||||
|
||||
String? idServerMsg;
|
||||
String? relayServerMsg;
|
||||
String? apiServerMsg;
|
||||
|
||||
dialogManager.show((setState, close) {
|
||||
Future<bool> validate() async {
|
||||
if (idController.text != id) {
|
||||
final res = await validateAsync(idController.text);
|
||||
setState(() => idServerMsg = res);
|
||||
if (idServerMsg != null) return false;
|
||||
id = idController.text;
|
||||
}
|
||||
if (relayController.text != relay) {
|
||||
relayServerMsg = await validateAsync(relayController.text);
|
||||
if (relayServerMsg != null) return false;
|
||||
relay = relayController.text;
|
||||
}
|
||||
if (apiController.text != relay) {
|
||||
apiServerMsg = await validateAsync(apiController.text);
|
||||
if (apiServerMsg != null) return false;
|
||||
api = apiController.text;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate('ID/Relay Server')),
|
||||
content: Form(
|
||||
key: formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
TextFormField(
|
||||
initialValue: id,
|
||||
controller: idController,
|
||||
decoration: InputDecoration(
|
||||
labelText: translate('ID Server'),
|
||||
),
|
||||
validator: validate,
|
||||
onSaved: (String? value) {
|
||||
if (value != null) id = value.trim();
|
||||
},
|
||||
labelText: translate('ID Server'),
|
||||
errorText: idServerMsg),
|
||||
)
|
||||
] +
|
||||
(isAndroid
|
||||
? [
|
||||
TextFormField(
|
||||
initialValue: relay,
|
||||
controller: relayController,
|
||||
decoration: InputDecoration(
|
||||
labelText: translate('Relay Server'),
|
||||
),
|
||||
validator: validate,
|
||||
onSaved: (String? value) {
|
||||
if (value != null) relay = value.trim();
|
||||
},
|
||||
labelText: translate('Relay Server'),
|
||||
errorText: relayServerMsg),
|
||||
)
|
||||
]
|
||||
: []) +
|
||||
[
|
||||
TextFormField(
|
||||
initialValue: api,
|
||||
controller: apiController,
|
||||
decoration: InputDecoration(
|
||||
labelText: translate('API Server'),
|
||||
),
|
||||
validator: validate,
|
||||
onSaved: (String? value) {
|
||||
if (value != null) api = value.trim();
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
validator: (v) {
|
||||
if (v != null && v.length > 0) {
|
||||
if (!(v.startsWith('http://') ||
|
||||
v.startsWith("https://"))) {
|
||||
return translate("invalid_http");
|
||||
}
|
||||
}
|
||||
return apiServerMsg;
|
||||
},
|
||||
),
|
||||
TextFormField(
|
||||
@@ -206,11 +234,13 @@ void showServerSettingsWithValue(
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Key',
|
||||
),
|
||||
validator: null,
|
||||
onSaved: (String? value) {
|
||||
onChanged: (String? value) {
|
||||
if (value != null) key = value.trim();
|
||||
},
|
||||
),
|
||||
Offstage(
|
||||
offstage: !isInProgress,
|
||||
child: LinearProgressIndicator())
|
||||
])),
|
||||
actions: [
|
||||
TextButton(
|
||||
@@ -222,24 +252,28 @@ void showServerSettingsWithValue(
|
||||
),
|
||||
TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
if (formKey.currentState != null &&
|
||||
formKey.currentState!.validate()) {
|
||||
formKey.currentState!.save();
|
||||
if (id != id0)
|
||||
FFI.setByName('option',
|
||||
'{"name": "custom-rendezvous-server", "value": "$id"}');
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
idServerMsg = null;
|
||||
relayServerMsg = null;
|
||||
apiServerMsg = null;
|
||||
isInProgress = true;
|
||||
});
|
||||
if (await validate()) {
|
||||
if (id != id0) {
|
||||
bind.mainSetOption(key: "custom-rendezvous-server", value: id);
|
||||
}
|
||||
if (relay != relay0)
|
||||
FFI.setByName(
|
||||
'option', '{"name": "relay-server", "value": "$relay"}');
|
||||
if (key != key0)
|
||||
FFI.setByName('option', '{"name": "key", "value": "$key"}');
|
||||
bind.mainSetOption(key: "relay-server", value: relay);
|
||||
if (key != key0) bind.mainSetOption(key: "key", value: key);
|
||||
if (api != api0)
|
||||
FFI.setByName(
|
||||
'option', '{"name": "api-server", "value": "$api"}');
|
||||
FFI.ffiModel.updateUser();
|
||||
bind.mainSetOption(key: "api-server", value: api);
|
||||
gFFI.ffiModel.updateUser();
|
||||
close();
|
||||
}
|
||||
setState(() {
|
||||
isInProgress = false;
|
||||
});
|
||||
},
|
||||
child: Text(translate('OK')),
|
||||
),
|
||||
@@ -248,11 +282,11 @@ void showServerSettingsWithValue(
|
||||
});
|
||||
}
|
||||
|
||||
String? validate(value) {
|
||||
Future<String?> validateAsync(String value) async {
|
||||
value = value.trim();
|
||||
if (value.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
final res = FFI.getByName('test_if_valid_server', value);
|
||||
final res = await bind.mainTestIfValidServer(server: value);
|
||||
return res.isEmpty ? null : res;
|
||||
}
|
||||
@@ -1,17 +1,13 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/models/model.dart';
|
||||
import 'package:flutter_hbb/widgets/dialog.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:flutter_hbb/mobile/widgets/dialog.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../common.dart';
|
||||
import '../models/server_model.dart';
|
||||
import '../../common.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
import '../../models/server_model.dart';
|
||||
import 'home_page.dart';
|
||||
import '../models/model.dart';
|
||||
|
||||
class ServerPage extends StatelessWidget implements PageShape {
|
||||
class ServerPage extends StatefulWidget implements PageShape {
|
||||
@override
|
||||
final title = translate("Share Screen");
|
||||
|
||||
@@ -35,14 +31,14 @@ class ServerPage extends StatelessWidget implements PageShape {
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0),
|
||||
value: "setPermanentPassword",
|
||||
enabled:
|
||||
FFI.serverModel.verificationMethod != kUseTemporaryPassword,
|
||||
gFFI.serverModel.verificationMethod != kUseTemporaryPassword,
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Text(translate("Set temporary password length")),
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0),
|
||||
value: "setTemporaryPasswordLength",
|
||||
enabled:
|
||||
FFI.serverModel.verificationMethod != kUsePermanentPassword,
|
||||
gFFI.serverModel.verificationMethod != kUsePermanentPassword,
|
||||
),
|
||||
const PopupMenuDivider(),
|
||||
PopupMenuItem(
|
||||
@@ -53,7 +49,7 @@ class ServerPage extends StatelessWidget implements PageShape {
|
||||
title: Text(translate("Use temporary password")),
|
||||
trailing: Icon(
|
||||
Icons.check,
|
||||
color: FFI.serverModel.verificationMethod ==
|
||||
color: gFFI.serverModel.verificationMethod ==
|
||||
kUseTemporaryPassword
|
||||
? null
|
||||
: Color(0xFFFFFFFF),
|
||||
@@ -66,7 +62,7 @@ class ServerPage extends StatelessWidget implements PageShape {
|
||||
title: Text(translate("Use permanent password")),
|
||||
trailing: Icon(
|
||||
Icons.check,
|
||||
color: FFI.serverModel.verificationMethod ==
|
||||
color: gFFI.serverModel.verificationMethod ==
|
||||
kUsePermanentPassword
|
||||
? null
|
||||
: Color(0xFFFFFFFF),
|
||||
@@ -79,9 +75,9 @@ class ServerPage extends StatelessWidget implements PageShape {
|
||||
title: Text(translate("Use both passwords")),
|
||||
trailing: Icon(
|
||||
Icons.check,
|
||||
color: FFI.serverModel.verificationMethod !=
|
||||
color: gFFI.serverModel.verificationMethod !=
|
||||
kUseTemporaryPassword &&
|
||||
FFI.serverModel.verificationMethod !=
|
||||
gFFI.serverModel.verificationMethod !=
|
||||
kUsePermanentPassword
|
||||
? null
|
||||
: Color(0xFFFFFFFF),
|
||||
@@ -93,29 +89,37 @@ class ServerPage extends StatelessWidget implements PageShape {
|
||||
if (value == "changeID") {
|
||||
// TODO
|
||||
} else if (value == "setPermanentPassword") {
|
||||
setPermanentPasswordDialog();
|
||||
setPermanentPasswordDialog(gFFI.dialogManager);
|
||||
} else if (value == "setTemporaryPasswordLength") {
|
||||
setTemporaryPasswordLengthDialog();
|
||||
setTemporaryPasswordLengthDialog(gFFI.dialogManager);
|
||||
} else if (value == kUsePermanentPassword ||
|
||||
value == kUseTemporaryPassword ||
|
||||
value == kUseBothPasswords) {
|
||||
Map<String, String> msg = Map()
|
||||
..["name"] = "verification-method"
|
||||
..["value"] = value;
|
||||
FFI.setByName('option', jsonEncode(msg));
|
||||
FFI.serverModel.updatePasswordModel();
|
||||
bind.mainSetOption(key: "verification-method", value: value);
|
||||
gFFI.serverModel.updatePasswordModel();
|
||||
}
|
||||
})
|
||||
];
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _ServerPageState();
|
||||
}
|
||||
|
||||
class _ServerPageState extends State<ServerPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
gFFI.serverModel.checkAndroidPermission();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
checkService();
|
||||
return ChangeNotifierProvider.value(
|
||||
value: FFI.serverModel,
|
||||
value: gFFI.serverModel,
|
||||
child: Consumer<ServerModel>(
|
||||
builder: (context, serverModel, child) => SingleChildScrollView(
|
||||
controller: FFI.serverModel.controller,
|
||||
controller: gFFI.serverModel.controller,
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
@@ -132,16 +136,16 @@ class ServerPage extends StatelessWidget implements PageShape {
|
||||
}
|
||||
|
||||
void checkService() async {
|
||||
FFI.invokeMethod("check_service"); // jvm
|
||||
gFFI.invokeMethod("check_service"); // jvm
|
||||
// for Android 10/11,MANAGE_EXTERNAL_STORAGE permission from a system setting page
|
||||
if (PermissionManager.isWaitingFile() && !FFI.serverModel.fileOk) {
|
||||
if (PermissionManager.isWaitingFile() && !gFFI.serverModel.fileOk) {
|
||||
PermissionManager.complete("file", await PermissionManager.check("file"));
|
||||
debugPrint("file permission finished");
|
||||
}
|
||||
}
|
||||
|
||||
class ServerInfo extends StatelessWidget {
|
||||
final model = FFI.serverModel;
|
||||
final model = gFFI.serverModel;
|
||||
final emptyController = TextEditingController(text: "-");
|
||||
|
||||
@override
|
||||
@@ -183,9 +187,8 @@ class ServerInfo extends StatelessWidget {
|
||||
? null
|
||||
: IconButton(
|
||||
icon: const Icon(Icons.refresh),
|
||||
onPressed: () {
|
||||
FFI.setByName("temporary_password");
|
||||
})),
|
||||
onPressed: () =>
|
||||
bind.mainUpdateTemporaryPassword())),
|
||||
onSaved: (String? value) {},
|
||||
),
|
||||
],
|
||||
@@ -356,12 +359,12 @@ class ConnectionManager extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final serverModel = Provider.of<ServerModel>(context);
|
||||
return Column(
|
||||
children: serverModel.clients.entries
|
||||
.map((entry) => PaddingCard(
|
||||
title: translate(entry.value.isFileTransfer
|
||||
children: serverModel.clients
|
||||
.map((client) => PaddingCard(
|
||||
title: translate(client.isFileTransfer
|
||||
? "File Connection"
|
||||
: "Screen Connection"),
|
||||
titleIcon: entry.value.isFileTransfer
|
||||
titleIcon: client.isFileTransfer
|
||||
? Icons.folder_outlined
|
||||
: Icons.mobile_screen_share,
|
||||
child: Column(
|
||||
@@ -370,16 +373,14 @@ class ConnectionManager extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: clientInfo(entry.value)),
|
||||
Expanded(child: clientInfo(client)),
|
||||
Expanded(
|
||||
flex: -1,
|
||||
child: entry.value.isFileTransfer ||
|
||||
!entry.value.authorized
|
||||
child: client.isFileTransfer || !client.authorized
|
||||
? SizedBox.shrink()
|
||||
: IconButton(
|
||||
onPressed: () {
|
||||
FFI.chatModel
|
||||
.changeCurrentID(entry.value.id);
|
||||
gFFI.chatModel.changeCurrentID(client.id);
|
||||
final bar =
|
||||
navigationBarKey.currentWidget;
|
||||
if (bar != null) {
|
||||
@@ -393,37 +394,35 @@ class ConnectionManager extends StatelessWidget {
|
||||
)))
|
||||
],
|
||||
),
|
||||
entry.value.authorized
|
||||
client.authorized
|
||||
? SizedBox.shrink()
|
||||
: Text(
|
||||
translate("android_new_connection_tip"),
|
||||
style: TextStyle(color: Colors.black54),
|
||||
),
|
||||
entry.value.authorized
|
||||
client.authorized
|
||||
? ElevatedButton.icon(
|
||||
style: ButtonStyle(
|
||||
backgroundColor:
|
||||
MaterialStateProperty.all(Colors.red)),
|
||||
icon: Icon(Icons.close),
|
||||
onPressed: () {
|
||||
FFI.setByName("close_conn", entry.key.toString());
|
||||
FFI.invokeMethod(
|
||||
"cancel_notification", entry.key);
|
||||
bind.cmCloseConnection(connId: client.id);
|
||||
gFFI.invokeMethod(
|
||||
"cancel_notification", client.id);
|
||||
},
|
||||
label: Text(translate("Close")))
|
||||
: Row(children: [
|
||||
TextButton(
|
||||
child: Text(translate("Dismiss")),
|
||||
onPressed: () {
|
||||
serverModel.sendLoginResponse(
|
||||
entry.value, false);
|
||||
serverModel.sendLoginResponse(client, false);
|
||||
}),
|
||||
SizedBox(width: 20),
|
||||
ElevatedButton(
|
||||
child: Text(translate("Accept")),
|
||||
onPressed: () {
|
||||
serverModel.sendLoginResponse(
|
||||
entry.value, true);
|
||||
serverModel.sendLoginResponse(client, true);
|
||||
}),
|
||||
]),
|
||||
],
|
||||
@@ -511,15 +510,15 @@ Widget clientInfo(Client client) {
|
||||
]));
|
||||
}
|
||||
|
||||
void toAndroidChannelInit() {
|
||||
FFI.setMethodCallHandler((method, arguments) {
|
||||
void androidChannelInit() {
|
||||
gFFI.setMethodCallHandler((method, arguments) {
|
||||
debugPrint("flutter got android msg,$method,$arguments");
|
||||
try {
|
||||
switch (method) {
|
||||
case "start_capture":
|
||||
{
|
||||
SmartDialog.dismiss();
|
||||
FFI.serverModel.updateClientState();
|
||||
gFFI.dialogManager.dismissAll();
|
||||
gFFI.serverModel.updateClientState();
|
||||
break;
|
||||
}
|
||||
case "on_state_changed":
|
||||
@@ -527,7 +526,7 @@ void toAndroidChannelInit() {
|
||||
var name = arguments["name"] as String;
|
||||
var value = arguments["value"] as String == "true";
|
||||
debugPrint("from jvm:on_state_changed,$name:$value");
|
||||
FFI.serverModel.changeStatue(name, value);
|
||||
gFFI.serverModel.changeStatue(name, value);
|
||||
break;
|
||||
}
|
||||
case "on_android_permission_result":
|
||||
@@ -539,7 +538,7 @@ void toAndroidChannelInit() {
|
||||
}
|
||||
case "on_media_projection_canceled":
|
||||
{
|
||||
FFI.serverModel.stopService();
|
||||
gFFI.serverModel.stopService();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,16 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:settings_ui/settings_ui.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../common.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:settings_ui/settings_ui.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
import '../../models/model.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
import '../widgets/dialog.dart';
|
||||
import '../models/model.dart';
|
||||
import 'home_page.dart';
|
||||
import 'scan_page.dart';
|
||||
|
||||
@@ -29,15 +31,38 @@ class SettingsPage extends StatefulWidget implements PageShape {
|
||||
const url = 'https://rustdesk.com/';
|
||||
final _hasIgnoreBattery = androidVersion >= 26;
|
||||
var _ignoreBatteryOpt = false;
|
||||
var _enableAbr = false;
|
||||
|
||||
class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
||||
String? username;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
if (_hasIgnoreBattery) {
|
||||
updateIgnoreBatteryStatus();
|
||||
}
|
||||
|
||||
() async {
|
||||
var update = false;
|
||||
if (_hasIgnoreBattery) {
|
||||
update = await updateIgnoreBatteryStatus();
|
||||
}
|
||||
|
||||
final usernameRes = await getUsername();
|
||||
if (usernameRes != username) {
|
||||
update = true;
|
||||
username = usernameRes;
|
||||
}
|
||||
|
||||
final enableAbrRes = await bind.mainGetOption(key: "enable-abr") != "N";
|
||||
if (enableAbrRes != _enableAbr) {
|
||||
update = true;
|
||||
_enableAbr = enableAbrRes;
|
||||
}
|
||||
|
||||
if (update) {
|
||||
setState(() {});
|
||||
}
|
||||
}();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -49,16 +74,18 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
if (state == AppLifecycleState.resumed) {
|
||||
updateIgnoreBatteryStatus();
|
||||
() async {
|
||||
if (await updateIgnoreBatteryStatus()) {
|
||||
setState(() {});
|
||||
}
|
||||
}();
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> updateIgnoreBatteryStatus() async {
|
||||
final res = await PermissionManager.check("ignore_battery_optimizations");
|
||||
if (_ignoreBatteryOpt != res) {
|
||||
setState(() {
|
||||
_ignoreBatteryOpt = res;
|
||||
});
|
||||
_ignoreBatteryOpt = res;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -68,21 +95,15 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Provider.of<FfiModel>(context);
|
||||
final username = getUsername();
|
||||
final enableAbr = FFI.getByName("option", "enable-abr") != 'N';
|
||||
final enhancementsTiles = [
|
||||
SettingsTile.switchTile(
|
||||
title: Text(translate('Adaptive Bitrate') + '(beta)'),
|
||||
initialValue: enableAbr,
|
||||
title: Text(translate('Adaptive Bitrate') + ' (beta)'),
|
||||
initialValue: _enableAbr,
|
||||
onToggle: (v) {
|
||||
final msg = Map()
|
||||
..["name"] = "enable-abr"
|
||||
..["value"] = "";
|
||||
if (!v) {
|
||||
msg["value"] = "N";
|
||||
}
|
||||
FFI.setByName("option", json.encode(msg));
|
||||
setState(() {});
|
||||
bind.mainSetOption(key: "enable-abr", value: v ? "" : "N");
|
||||
setState(() {
|
||||
_enableAbr = !_enableAbr;
|
||||
});
|
||||
},
|
||||
)
|
||||
];
|
||||
@@ -98,8 +119,8 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
||||
if (v) {
|
||||
PermissionManager.request("ignore_battery_optimizations");
|
||||
} else {
|
||||
final res = await DialogManager.show<bool>(
|
||||
(setState, close) => CustomAlertDialog(
|
||||
final res = await gFFI.dialogManager
|
||||
.show<bool>((setState, close) => CustomAlertDialog(
|
||||
title: Text(translate("Open System Setting")),
|
||||
content: Text(translate(
|
||||
"android_open_battery_optimizations_tip")),
|
||||
@@ -132,9 +153,9 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
||||
leading: Icon(Icons.person),
|
||||
onPressed: (context) {
|
||||
if (username == null) {
|
||||
showLogin();
|
||||
showLogin(gFFI.dialogManager);
|
||||
} else {
|
||||
logout();
|
||||
logout(gFFI.dialogManager);
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -145,13 +166,13 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
||||
title: Text(translate('ID/Relay Server')),
|
||||
leading: Icon(Icons.cloud),
|
||||
onPressed: (context) {
|
||||
showServerSettings();
|
||||
showServerSettings(gFFI.dialogManager);
|
||||
}),
|
||||
SettingsTile.navigation(
|
||||
title: Text(translate('Language')),
|
||||
leading: Icon(Icons.translate),
|
||||
onPressed: (context) {
|
||||
showLanguageSettings();
|
||||
showLanguageSettings(gFFI.dialogManager);
|
||||
})
|
||||
]),
|
||||
SettingsSection(
|
||||
@@ -183,29 +204,27 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
||||
}
|
||||
}
|
||||
|
||||
void showServerSettings() {
|
||||
final id = FFI.getByName('option', 'custom-rendezvous-server');
|
||||
final relay = FFI.getByName('option', 'relay-server');
|
||||
final api = FFI.getByName('option', 'api-server');
|
||||
final key = FFI.getByName('option', 'key');
|
||||
showServerSettingsWithValue(id, relay, key, api);
|
||||
void showServerSettings(OverlayDialogManager dialogManager) async {
|
||||
Map<String, dynamic> options = jsonDecode(await bind.mainGetOptions());
|
||||
String id = options['custom-rendezvous-server'] ?? "";
|
||||
String relay = options['relay-server'] ?? "";
|
||||
String api = options['api-server'] ?? "";
|
||||
String key = options['key'] ?? "";
|
||||
showServerSettingsWithValue(id, relay, key, api, dialogManager);
|
||||
}
|
||||
|
||||
void showLanguageSettings() {
|
||||
void showLanguageSettings(OverlayDialogManager dialogManager) async {
|
||||
try {
|
||||
final langs = json.decode(FFI.getByName('langs')) as List<dynamic>;
|
||||
var lang = FFI.getByName('local_option', 'lang');
|
||||
DialogManager.show((setState, close) {
|
||||
final langs = json.decode(await bind.mainGetLangs()) as List<dynamic>;
|
||||
var lang = await bind.mainGetLocalOption(key: "lang");
|
||||
dialogManager.show((setState, close) {
|
||||
final setLang = (v) {
|
||||
if (lang != v) {
|
||||
setState(() {
|
||||
lang = v;
|
||||
});
|
||||
final msg = Map()
|
||||
..['name'] = 'lang'
|
||||
..['value'] = v;
|
||||
FFI.setByName('local_option', json.encode(msg));
|
||||
homeKey.currentState?.refreshPages();
|
||||
bind.mainSetLocalOption(key: "lang", value: v);
|
||||
HomePage.homeKey.currentState?.refreshPages();
|
||||
Future.delayed(Duration(milliseconds: 200), close);
|
||||
}
|
||||
};
|
||||
@@ -227,8 +246,8 @@ void showLanguageSettings() {
|
||||
} catch (_e) {}
|
||||
}
|
||||
|
||||
void showAbout() {
|
||||
DialogManager.show((setState, close) {
|
||||
void showAbout(OverlayDialogManager dialogManager) {
|
||||
dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate('About') + ' RustDesk'),
|
||||
content: Wrap(direction: Axis.vertical, spacing: 12, children: [
|
||||
@@ -276,8 +295,8 @@ fetch('http://localhost:21114/api/login', {
|
||||
final body = {
|
||||
'username': name,
|
||||
'password': pass,
|
||||
'id': FFI.getByName('server_id'),
|
||||
'uuid': FFI.getByName('uuid')
|
||||
'id': bind.mainGetMyId(),
|
||||
'uuid': bind.mainGetUuid()
|
||||
};
|
||||
try {
|
||||
final response = await http.post(Uri.parse('$url/api/login'),
|
||||
@@ -297,25 +316,22 @@ String parseResp(String body) {
|
||||
}
|
||||
final token = data['access_token'];
|
||||
if (token != null) {
|
||||
FFI.setByName('option', '{"name": "access_token", "value": "$token"}');
|
||||
bind.mainSetOption(key: "access_token", value: token);
|
||||
}
|
||||
final info = data['user'];
|
||||
if (info != null) {
|
||||
final value = json.encode(info);
|
||||
FFI.setByName('option', json.encode({"name": "user_info", "value": value}));
|
||||
FFI.ffiModel.updateUser();
|
||||
bind.mainSetOption(key: "user_info", value: value);
|
||||
gFFI.ffiModel.updateUser();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
void refreshCurrentUser() async {
|
||||
final token = FFI.getByName("option", "access_token");
|
||||
final token = await bind.mainGetOption(key: "access_token");
|
||||
if (token == '') return;
|
||||
final url = getUrl();
|
||||
final body = {
|
||||
'id': FFI.getByName('server_id'),
|
||||
'uuid': FFI.getByName('uuid')
|
||||
};
|
||||
final body = {'id': bind.mainGetMyId(), 'uuid': bind.mainGetUuid()};
|
||||
try {
|
||||
final response = await http.post(Uri.parse('$url/api/currentUser'),
|
||||
headers: {
|
||||
@@ -334,14 +350,11 @@ void refreshCurrentUser() async {
|
||||
}
|
||||
}
|
||||
|
||||
void logout() async {
|
||||
final token = FFI.getByName("option", "access_token");
|
||||
void logout(OverlayDialogManager dialogManager) async {
|
||||
final token = await bind.mainGetOption(key: "access_token");
|
||||
if (token == '') return;
|
||||
final url = getUrl();
|
||||
final body = {
|
||||
'id': FFI.getByName('server_id'),
|
||||
'uuid': FFI.getByName('uuid')
|
||||
};
|
||||
final body = {'id': bind.mainGetMyId(), 'uuid': bind.mainGetUuid()};
|
||||
try {
|
||||
await http.post(Uri.parse('$url/api/logout'),
|
||||
headers: {
|
||||
@@ -355,16 +368,16 @@ void logout() async {
|
||||
resetToken();
|
||||
}
|
||||
|
||||
void resetToken() {
|
||||
FFI.setByName('option', '{"name": "access_token", "value": ""}');
|
||||
FFI.setByName('option', '{"name": "user_info", "value": ""}');
|
||||
FFI.ffiModel.updateUser();
|
||||
void resetToken() async {
|
||||
await bind.mainSetOption(key: "access_token", value: "");
|
||||
await bind.mainSetOption(key: "user_info", value: "");
|
||||
gFFI.ffiModel.updateUser();
|
||||
}
|
||||
|
||||
String getUrl() {
|
||||
var url = FFI.getByName('option', 'api-server');
|
||||
Future<String> getUrl() async {
|
||||
var url = await bind.mainGetOption(key: "api-server");
|
||||
if (url == '') {
|
||||
url = FFI.getByName('option', 'custom-rendezvous-server');
|
||||
url = await bind.mainGetOption(key: "custom-rendezvous-server");
|
||||
if (url != '') {
|
||||
if (url.contains(':')) {
|
||||
final tmp = url.split(':');
|
||||
@@ -383,12 +396,12 @@ String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
void showLogin() {
|
||||
void showLogin(OverlayDialogManager dialogManager) {
|
||||
final passwordController = TextEditingController();
|
||||
final nameController = TextEditingController();
|
||||
var loading = false;
|
||||
var error = '';
|
||||
DialogManager.show((setState, close) {
|
||||
dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate('Login')),
|
||||
content: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
@@ -453,11 +466,11 @@ void showLogin() {
|
||||
});
|
||||
}
|
||||
|
||||
String? getUsername() {
|
||||
final token = FFI.getByName("option", "access_token");
|
||||
Future<String?> getUsername() async {
|
||||
final token = await bind.mainGetOption(key: "access_token");
|
||||
String? username;
|
||||
if (token != "") {
|
||||
final info = FFI.getByName("option", "user_info");
|
||||
final info = await bind.mainGetOption(key: "user_info");
|
||||
if (info != "") {
|
||||
try {
|
||||
Map<String, dynamic> tmp = json.decode(info);
|
||||
@@ -1,33 +1,51 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import '../common.dart';
|
||||
import '../models/model.dart';
|
||||
|
||||
void clientClose() {
|
||||
msgBox('', 'Close', 'Are you sure to close the connection?');
|
||||
import '../../common.dart';
|
||||
import '../../models/model.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
|
||||
void clientClose(OverlayDialogManager dialogManager) {
|
||||
msgBox('', 'Close', 'Are you sure to close the connection?', dialogManager);
|
||||
}
|
||||
|
||||
const SEC1 = Duration(seconds: 1);
|
||||
void showSuccess({Duration duration = SEC1}) {
|
||||
SmartDialog.dismiss();
|
||||
showToast(translate("Successful"), duration: SEC1);
|
||||
void showSuccess() {
|
||||
showToast(translate("Successful"));
|
||||
}
|
||||
|
||||
void showError({Duration duration = SEC1}) {
|
||||
SmartDialog.dismiss();
|
||||
showToast(translate("Error"), duration: SEC1);
|
||||
void showError() {
|
||||
showToast(translate("Error"));
|
||||
}
|
||||
|
||||
void setPermanentPasswordDialog() {
|
||||
final pw = FFI.getByName("permanent_password");
|
||||
void showRestartRemoteDevice(
|
||||
PeerInfo pi, String id, OverlayDialogManager dialogManager) async {
|
||||
final res =
|
||||
await dialogManager.show<bool>((setState, close) => CustomAlertDialog(
|
||||
title: Row(children: [
|
||||
Icon(Icons.warning_amber_sharp,
|
||||
color: Colors.redAccent, size: 28),
|
||||
SizedBox(width: 10),
|
||||
Text(translate("Restart Remote Device")),
|
||||
]),
|
||||
content: Text(
|
||||
"${translate('Are you sure you want to restart')} \n${pi.username}@${pi.hostname}($id) ?"),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => close(), child: Text(translate("Cancel"))),
|
||||
ElevatedButton(
|
||||
onPressed: () => close(true), child: Text(translate("OK"))),
|
||||
],
|
||||
));
|
||||
if (res == true) bind.sessionRestartRemoteDevice(id: id);
|
||||
}
|
||||
|
||||
void setPermanentPasswordDialog(OverlayDialogManager dialogManager) async {
|
||||
final pw = await bind.mainGetPermanentPassword();
|
||||
final p0 = TextEditingController(text: pw);
|
||||
final p1 = TextEditingController(text: pw);
|
||||
var validateLength = false;
|
||||
var validateSame = false;
|
||||
DialogManager.show((setState, close) {
|
||||
dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate('Set your own password')),
|
||||
content: Form(
|
||||
@@ -87,10 +105,12 @@ void setPermanentPasswordDialog() {
|
||||
onPressed: (validateLength && validateSame)
|
||||
? () async {
|
||||
close();
|
||||
showLoading(translate("Waiting"));
|
||||
if (await FFI.serverModel.setPermanentPassword(p0.text)) {
|
||||
dialogManager.showLoading(translate("Waiting"));
|
||||
if (await gFFI.serverModel.setPermanentPassword(p0.text)) {
|
||||
dialogManager.dismissAll();
|
||||
showSuccess();
|
||||
} else {
|
||||
dialogManager.dismissAll();
|
||||
showError();
|
||||
}
|
||||
}
|
||||
@@ -102,24 +122,22 @@ void setPermanentPasswordDialog() {
|
||||
});
|
||||
}
|
||||
|
||||
void setTemporaryPasswordLengthDialog() {
|
||||
void setTemporaryPasswordLengthDialog(
|
||||
OverlayDialogManager dialogManager) async {
|
||||
List<String> lengths = ['6', '8', '10'];
|
||||
String length = FFI.getByName('option', 'temporary-password-length');
|
||||
String length = await bind.mainGetOption(key: "temporary-password-length");
|
||||
var index = lengths.indexOf(length);
|
||||
if (index < 0) index = 0;
|
||||
length = lengths[index];
|
||||
DialogManager.show((setState, close) {
|
||||
dialogManager.show((setState, close) {
|
||||
final setLength = (newValue) {
|
||||
final oldValue = length;
|
||||
if (oldValue == newValue) return;
|
||||
setState(() {
|
||||
length = newValue;
|
||||
});
|
||||
Map<String, String> msg = Map()
|
||||
..["name"] = "temporary-password-length"
|
||||
..["value"] = newValue;
|
||||
FFI.setByName("option", jsonEncode(msg));
|
||||
FFI.setByName("temporary_password");
|
||||
bind.mainSetOption(key: "temporary-password-length", value: newValue);
|
||||
bind.mainUpdateTemporaryPassword();
|
||||
Future.delayed(Duration(milliseconds: 200), () {
|
||||
close();
|
||||
showSuccess();
|
||||
@@ -137,10 +155,11 @@ void setTemporaryPasswordLengthDialog() {
|
||||
}, backDismiss: true, clickMaskDismiss: true);
|
||||
}
|
||||
|
||||
void enterPasswordDialog(String id) {
|
||||
void enterPasswordDialog(String id, OverlayDialogManager dialogManager) async {
|
||||
final controller = TextEditingController();
|
||||
var remember = FFI.getByName('remember', id) == 'true';
|
||||
DialogManager.show((setState, close) {
|
||||
var remember = await bind.sessionGetRemember(id: id) ?? false;
|
||||
dialogManager.dismissAll();
|
||||
dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate('Password Required')),
|
||||
content: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
@@ -165,7 +184,7 @@ void enterPasswordDialog(String id) {
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
close();
|
||||
backToHome();
|
||||
closeConnection();
|
||||
},
|
||||
child: Text(translate('Cancel')),
|
||||
),
|
||||
@@ -174,9 +193,10 @@ void enterPasswordDialog(String id) {
|
||||
onPressed: () {
|
||||
var text = controller.text.trim();
|
||||
if (text == '') return;
|
||||
FFI.login(text, remember);
|
||||
gFFI.login(id, text, remember);
|
||||
close();
|
||||
showLoading(translate('Logging in...'));
|
||||
dialogManager.showLoading(translate('Logging in...'),
|
||||
onCancel: closeConnection);
|
||||
},
|
||||
child: Text(translate('OK')),
|
||||
),
|
||||
@@ -185,8 +205,8 @@ void enterPasswordDialog(String id) {
|
||||
});
|
||||
}
|
||||
|
||||
void wrongPasswordDialog(String id) {
|
||||
DialogManager.show((setState, close) => CustomAlertDialog(
|
||||
void wrongPasswordDialog(String id, OverlayDialogManager dialogManager) {
|
||||
dialogManager.show((setState, close) => CustomAlertDialog(
|
||||
title: Text(translate('Wrong Password')),
|
||||
content: Text(translate('Do you want to enter again?')),
|
||||
actions: [
|
||||
@@ -194,14 +214,14 @@ void wrongPasswordDialog(String id) {
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
close();
|
||||
backToHome();
|
||||
closeConnection();
|
||||
},
|
||||
child: Text(translate('Cancel')),
|
||||
),
|
||||
TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
enterPasswordDialog(id);
|
||||
enterPasswordDialog(id, dialogManager);
|
||||
},
|
||||
child: Text(translate('Retry')),
|
||||
),
|
||||
@@ -243,8 +263,8 @@ class _PasswordWidgetState extends State<PasswordWidget> {
|
||||
//This will obscure text dynamically
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
decoration: InputDecoration(
|
||||
labelText: Translator.call('Password'),
|
||||
hintText: Translator.call('Enter your password'),
|
||||
labelText: translate('Password'),
|
||||
hintText: translate('Enter your password'),
|
||||
// Here is key idea
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:toggle_switch/toggle_switch.dart';
|
||||
|
||||
import '../models/model.dart';
|
||||
import '../../models/model.dart';
|
||||
|
||||
class GestureIcons {
|
||||
static const String _family = 'gestureicons';
|
||||
@@ -1,22 +1,23 @@
|
||||
import 'package:draggable_float_widget/draggable_float_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
|
||||
import '../models/model.dart';
|
||||
import '../../models/chat_model.dart';
|
||||
import '../../models/model.dart';
|
||||
import '../pages/chat_page.dart';
|
||||
|
||||
OverlayEntry? chatIconOverlayEntry;
|
||||
OverlayEntry? chatWindowOverlayEntry;
|
||||
|
||||
OverlayEntry? mobileActionsOverlayEntry;
|
||||
|
||||
class DraggableChatWindow extends StatelessWidget {
|
||||
DraggableChatWindow(
|
||||
{this.position = Offset.zero, required this.width, required this.height});
|
||||
{this.position = Offset.zero,
|
||||
required this.width,
|
||||
required this.height,
|
||||
required this.chatModel});
|
||||
|
||||
final Offset position;
|
||||
final double width;
|
||||
final double height;
|
||||
final ChatModel chatModel;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -27,7 +28,7 @@ class DraggableChatWindow extends StatelessWidget {
|
||||
height: height,
|
||||
builder: (_, onPanUpdate) {
|
||||
return isIOS
|
||||
? ChatPage()
|
||||
? ChatPage(chatModel: chatModel)
|
||||
: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: CustomAppBar(
|
||||
@@ -53,13 +54,13 @@ class DraggableChatWindow extends StatelessWidget {
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
hideChatWindowOverlay();
|
||||
chatModel.hideChatWindowOverlay();
|
||||
},
|
||||
icon: Icon(Icons.keyboard_arrow_down)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
hideChatWindowOverlay();
|
||||
hideChatIconOverlay();
|
||||
chatModel.hideChatWindowOverlay();
|
||||
chatModel.hideChatIconOverlay();
|
||||
},
|
||||
icon: Icon(Icons.close))
|
||||
],
|
||||
@@ -68,7 +69,7 @@ class DraggableChatWindow extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
body: ChatPage(),
|
||||
body: ChatPage(chatModel: chatModel),
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -91,81 +92,6 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
Size get preferredSize => new Size.fromHeight(kToolbarHeight);
|
||||
}
|
||||
|
||||
showChatIconOverlay({Offset offset = const Offset(200, 50)}) {
|
||||
if (chatIconOverlayEntry != null) {
|
||||
chatIconOverlayEntry!.remove();
|
||||
}
|
||||
if (globalKey.currentState == null || globalKey.currentState!.overlay == null)
|
||||
return;
|
||||
final bar = navigationBarKey.currentWidget;
|
||||
if (bar != null) {
|
||||
if ((bar as BottomNavigationBar).currentIndex == 1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
final globalOverlayState = globalKey.currentState!.overlay!;
|
||||
|
||||
final overlay = OverlayEntry(builder: (context) {
|
||||
return DraggableFloatWidget(
|
||||
config: DraggableFloatWidgetBaseConfig(
|
||||
initPositionYInTop: false,
|
||||
initPositionYMarginBorder: 100,
|
||||
borderTopContainTopBar: true,
|
||||
),
|
||||
child: FloatingActionButton(
|
||||
onPressed: () {
|
||||
if (chatWindowOverlayEntry == null) {
|
||||
showChatWindowOverlay();
|
||||
} else {
|
||||
hideChatWindowOverlay();
|
||||
}
|
||||
},
|
||||
child: Icon(Icons.message)));
|
||||
});
|
||||
globalOverlayState.insert(overlay);
|
||||
chatIconOverlayEntry = overlay;
|
||||
}
|
||||
|
||||
hideChatIconOverlay() {
|
||||
if (chatIconOverlayEntry != null) {
|
||||
chatIconOverlayEntry!.remove();
|
||||
chatIconOverlayEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
showChatWindowOverlay() {
|
||||
if (chatWindowOverlayEntry != null) return;
|
||||
if (globalKey.currentState == null || globalKey.currentState!.overlay == null)
|
||||
return;
|
||||
final globalOverlayState = globalKey.currentState!.overlay!;
|
||||
|
||||
final overlay = OverlayEntry(builder: (context) {
|
||||
return DraggableChatWindow(
|
||||
position: Offset(20, 80), width: 250, height: 350);
|
||||
});
|
||||
globalOverlayState.insert(overlay);
|
||||
chatWindowOverlayEntry = overlay;
|
||||
}
|
||||
|
||||
hideChatWindowOverlay() {
|
||||
if (chatWindowOverlayEntry != null) {
|
||||
chatWindowOverlayEntry!.remove();
|
||||
chatWindowOverlayEntry = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
toggleChatOverlay() {
|
||||
if (chatIconOverlayEntry == null || chatWindowOverlayEntry == null) {
|
||||
FFI.invokeMethod("enable_soft_keyboard", true);
|
||||
showChatIconOverlay();
|
||||
showChatWindowOverlay();
|
||||
} else {
|
||||
hideChatIconOverlay();
|
||||
hideChatWindowOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
/// floating buttons of back/home/recent actions for android
|
||||
class DraggableMobileActions extends StatelessWidget {
|
||||
DraggableMobileActions(
|
||||
@@ -254,12 +180,12 @@ showMobileActionsOverlay() {
|
||||
position: Offset(left, top),
|
||||
width: overlayW,
|
||||
height: overlayH,
|
||||
onBackPressed: () => FFI.tap(MouseButtons.right),
|
||||
onHomePressed: () => FFI.tap(MouseButtons.wheel),
|
||||
onBackPressed: () => gFFI.tap(MouseButtons.right),
|
||||
onHomePressed: () => gFFI.tap(MouseButtons.wheel),
|
||||
onRecentPressed: () async {
|
||||
FFI.sendMouse('down', MouseButtons.wheel);
|
||||
gFFI.sendMouse('down', MouseButtons.wheel);
|
||||
await Future.delayed(Duration(milliseconds: 500));
|
||||
FFI.sendMouse('up', MouseButtons.wheel);
|
||||
gFFI.sendMouse('up', MouseButtons.wheel);
|
||||
},
|
||||
);
|
||||
});
|
||||
160
flutter/lib/models/ab_model.dart
Normal file
160
flutter/lib/models/ab_model.dart
Normal file
@@ -0,0 +1,160 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/models/model.dart';
|
||||
import 'package:flutter_hbb/models/platform_model.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class AbModel with ChangeNotifier {
|
||||
var abLoading = false;
|
||||
var abError = "";
|
||||
var tags = [].obs;
|
||||
var peers = [].obs;
|
||||
|
||||
var selectedTags = List<String>.empty(growable: true).obs;
|
||||
|
||||
WeakReference<FFI> parent;
|
||||
|
||||
AbModel(this.parent);
|
||||
|
||||
FFI? get _ffi => parent.target;
|
||||
|
||||
Future<dynamic> getAb() async {
|
||||
abLoading = true;
|
||||
notifyListeners();
|
||||
// request
|
||||
final api = "${await getApiServer()}/api/ab/get";
|
||||
try {
|
||||
final resp =
|
||||
await http.post(Uri.parse(api), headers: await _getHeaders());
|
||||
Map<String, dynamic> json = jsonDecode(resp.body);
|
||||
if (json.containsKey('error')) {
|
||||
abError = json['error'];
|
||||
} else if (json.containsKey('data')) {
|
||||
final data = jsonDecode(json['data']);
|
||||
tags.value = data['tags'];
|
||||
peers.value = data['peers'];
|
||||
}
|
||||
return resp.body;
|
||||
} catch (err) {
|
||||
abError = err.toString();
|
||||
} finally {
|
||||
abLoading = false;
|
||||
}
|
||||
notifyListeners();
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<String> getApiServer() async {
|
||||
return await bind.mainGetApiServer();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
tags.clear();
|
||||
peers.clear();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<Map<String, String>>? _getHeaders() {
|
||||
return _ffi?.getHttpHeaders();
|
||||
}
|
||||
|
||||
///
|
||||
void addId(String id) async {
|
||||
if (idContainBy(id)) {
|
||||
return;
|
||||
}
|
||||
peers.add({"id": id});
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void addTag(String tag) async {
|
||||
if (tagContainBy(tag)) {
|
||||
return;
|
||||
}
|
||||
tags.add(tag);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void changeTagForPeer(String id, List<dynamic> tags) {
|
||||
final it = peers.where((element) => element['id'] == id);
|
||||
if (it.isEmpty) {
|
||||
return;
|
||||
}
|
||||
it.first['tags'] = tags;
|
||||
}
|
||||
|
||||
Future<void> updateAb() async {
|
||||
abLoading = true;
|
||||
notifyListeners();
|
||||
final api = "${await getApiServer()}/api/ab";
|
||||
var authHeaders = await _getHeaders() ?? Map<String, String>();
|
||||
authHeaders['Content-Type'] = "application/json";
|
||||
final body = jsonEncode({
|
||||
"data": jsonEncode({"tags": tags, "peers": peers})
|
||||
});
|
||||
final resp =
|
||||
await http.post(Uri.parse(api), headers: authHeaders, body: body);
|
||||
abLoading = false;
|
||||
await getAb();
|
||||
notifyListeners();
|
||||
debugPrint("resp: ${resp.body}");
|
||||
}
|
||||
|
||||
bool idContainBy(String id) {
|
||||
return peers.where((element) => element['id'] == id).isNotEmpty;
|
||||
}
|
||||
|
||||
bool tagContainBy(String tag) {
|
||||
return tags.where((element) => element == tag).isNotEmpty;
|
||||
}
|
||||
|
||||
void deletePeer(String id) {
|
||||
peers.removeWhere((element) => element['id'] == id);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void deleteTag(String tag) {
|
||||
tags.removeWhere((element) => element == tag);
|
||||
for (var peer in peers) {
|
||||
if (peer['tags'] == null) {
|
||||
continue;
|
||||
}
|
||||
if (((peer['tags']) as List<dynamic>).contains(tag)) {
|
||||
((peer['tags']) as List<dynamic>).remove(tag);
|
||||
}
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void unsetSelectedTags() {
|
||||
selectedTags.clear();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
List<dynamic> getPeerTags(String id) {
|
||||
final it = peers.where((p0) => p0['id'] == id);
|
||||
if (it.isEmpty) {
|
||||
return [];
|
||||
} else {
|
||||
return it.first['tags'] ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
void setPeerOption(String id, String key, String value) {
|
||||
final it = peers.where((p0) => p0['id'] == id);
|
||||
if (it.isEmpty) {
|
||||
debugPrint("${id} is not exists");
|
||||
return;
|
||||
} else {
|
||||
it.first[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
void clear() {
|
||||
peers.clear();
|
||||
tags.clear();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dash_chat_2/dash_chat_2.dart';
|
||||
import 'package:draggable_float_widget/draggable_float_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/models/platform_model.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
import '../widgets/overlay.dart';
|
||||
import '../../mobile/widgets/overlay.dart';
|
||||
import '../common.dart';
|
||||
import 'model.dart';
|
||||
|
||||
class MessageBody {
|
||||
@@ -23,6 +25,14 @@ class MessageBody {
|
||||
class ChatModel with ChangeNotifier {
|
||||
static final clientModeID = -1;
|
||||
|
||||
/// _overlayState:
|
||||
/// Desktop: store session overlay by using [setOverlayState].
|
||||
/// Mobile: always null, use global overlay.
|
||||
/// see [_getOverlayState] in [showChatIconOverlay] or [showChatWindowOverlay]
|
||||
OverlayState? _overlayState;
|
||||
OverlayEntry? chatIconOverlayEntry;
|
||||
OverlayEntry? chatWindowOverlayEntry;
|
||||
|
||||
final ChatUser me = ChatUser(
|
||||
id: "",
|
||||
firstName: "Me",
|
||||
@@ -32,11 +42,19 @@ class ChatModel with ChangeNotifier {
|
||||
..[clientModeID] = MessageBody(me, []);
|
||||
|
||||
var _currentID = clientModeID;
|
||||
late bool _isShowChatPage = false;
|
||||
|
||||
Map<int, MessageBody> get messages => _messages;
|
||||
|
||||
int get currentID => _currentID;
|
||||
|
||||
bool get isShowChatPage => _isShowChatPage;
|
||||
|
||||
WeakReference<FFI> _ffi;
|
||||
|
||||
/// Constructor
|
||||
ChatModel(this._ffi);
|
||||
|
||||
ChatUser get currentUser {
|
||||
final user = messages[currentID]?.chatUser;
|
||||
if (user == null) {
|
||||
@@ -47,12 +65,117 @@ class ChatModel with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
setOverlayState(OverlayState? os) {
|
||||
_overlayState = os;
|
||||
}
|
||||
|
||||
OverlayState? _getOverlayState() {
|
||||
if (_overlayState == null) {
|
||||
if (globalKey.currentState == null ||
|
||||
globalKey.currentState!.overlay == null) return null;
|
||||
return globalKey.currentState!.overlay;
|
||||
} else {
|
||||
return _overlayState;
|
||||
}
|
||||
}
|
||||
|
||||
showChatIconOverlay({Offset offset = const Offset(200, 50)}) {
|
||||
if (chatIconOverlayEntry != null) {
|
||||
chatIconOverlayEntry!.remove();
|
||||
}
|
||||
// mobile check navigationBar
|
||||
final bar = navigationBarKey.currentWidget;
|
||||
if (bar != null) {
|
||||
if ((bar as BottomNavigationBar).currentIndex == 1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final overlayState = _getOverlayState();
|
||||
if (overlayState == null) return;
|
||||
|
||||
final overlay = OverlayEntry(builder: (context) {
|
||||
return DraggableFloatWidget(
|
||||
config: DraggableFloatWidgetBaseConfig(
|
||||
initPositionYInTop: false,
|
||||
initPositionYMarginBorder: 100,
|
||||
borderTopContainTopBar: true,
|
||||
),
|
||||
child: FloatingActionButton(
|
||||
onPressed: () {
|
||||
if (chatWindowOverlayEntry == null) {
|
||||
showChatWindowOverlay();
|
||||
} else {
|
||||
hideChatWindowOverlay();
|
||||
}
|
||||
},
|
||||
child: Icon(Icons.message)));
|
||||
});
|
||||
overlayState.insert(overlay);
|
||||
chatIconOverlayEntry = overlay;
|
||||
}
|
||||
|
||||
hideChatIconOverlay() {
|
||||
if (chatIconOverlayEntry != null) {
|
||||
chatIconOverlayEntry!.remove();
|
||||
chatIconOverlayEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
showChatWindowOverlay() {
|
||||
if (chatWindowOverlayEntry != null) return;
|
||||
final overlayState = _getOverlayState();
|
||||
if (overlayState == null) return;
|
||||
final overlay = OverlayEntry(builder: (context) {
|
||||
return DraggableChatWindow(
|
||||
position: Offset(20, 80), width: 250, height: 350, chatModel: this);
|
||||
});
|
||||
overlayState.insert(overlay);
|
||||
chatWindowOverlayEntry = overlay;
|
||||
}
|
||||
|
||||
hideChatWindowOverlay() {
|
||||
if (chatWindowOverlayEntry != null) {
|
||||
chatWindowOverlayEntry!.remove();
|
||||
chatWindowOverlayEntry = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
toggleChatOverlay() {
|
||||
if (chatIconOverlayEntry == null || chatWindowOverlayEntry == null) {
|
||||
gFFI.invokeMethod("enable_soft_keyboard", true);
|
||||
showChatIconOverlay();
|
||||
showChatWindowOverlay();
|
||||
} else {
|
||||
hideChatIconOverlay();
|
||||
hideChatWindowOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
toggleCMChatPage(int id) async {
|
||||
if (gFFI.chatModel.currentID != id) {
|
||||
gFFI.chatModel.changeCurrentID(id);
|
||||
}
|
||||
if (_isShowChatPage) {
|
||||
_isShowChatPage = !_isShowChatPage;
|
||||
notifyListeners();
|
||||
await windowManager.setSize(Size(400, 600));
|
||||
} else {
|
||||
await windowManager.setSize(Size(800, 600));
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
_isShowChatPage = !_isShowChatPage;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
changeCurrentID(int id) {
|
||||
if (_messages.containsKey(id)) {
|
||||
_currentID = id;
|
||||
notifyListeners();
|
||||
} else {
|
||||
final client = FFI.serverModel.clients[id];
|
||||
final client = _ffi.target?.serverModel.clients
|
||||
.firstWhere((client) => client.id == id);
|
||||
if (client == null) {
|
||||
return debugPrint(
|
||||
"Failed to changeCurrentID,remote user doesn't exist");
|
||||
@@ -67,20 +190,26 @@ class ChatModel with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
receive(int id, String text) {
|
||||
receive(int id, String text) async {
|
||||
if (text.isEmpty) return;
|
||||
// first message show overlay icon
|
||||
// mobile: first message show overlay icon
|
||||
if (chatIconOverlayEntry == null) {
|
||||
showChatIconOverlay();
|
||||
}
|
||||
// desktop: show chat page
|
||||
if (!_isShowChatPage) {
|
||||
toggleCMChatPage(id);
|
||||
}
|
||||
_ffi.target?.serverModel.jumpTo(id);
|
||||
|
||||
late final chatUser;
|
||||
if (id == clientModeID) {
|
||||
chatUser = ChatUser(
|
||||
firstName: FFI.ffiModel.pi.username,
|
||||
id: FFI.getId(),
|
||||
firstName: _ffi.target?.ffiModel.pi.username,
|
||||
id: await bind.mainGetLastRemoteId(),
|
||||
);
|
||||
} else {
|
||||
final client = FFI.serverModel.clients[id];
|
||||
final client = _ffi.target?.serverModel.clients[id];
|
||||
if (client == null) {
|
||||
return debugPrint("Failed to receive msg,user doesn't exist");
|
||||
}
|
||||
@@ -100,12 +229,11 @@ class ChatModel with ChangeNotifier {
|
||||
if (message.text.isNotEmpty) {
|
||||
_messages[_currentID]?.insert(message);
|
||||
if (_currentID == clientModeID) {
|
||||
FFI.setByName("chat_client_mode", message.text);
|
||||
if (_ffi.target != null) {
|
||||
bind.sessionSendChat(id: _ffi.target!.id, text: message.text);
|
||||
}
|
||||
} else {
|
||||
final msg = Map()
|
||||
..["id"] = _currentID
|
||||
..["text"] = message.text;
|
||||
FFI.setByName("chat_server_mode", jsonEncode(msg));
|
||||
bind.cmSendChat(connId: _currentID, msg: message.text);
|
||||
}
|
||||
}
|
||||
notifyListeners();
|
||||
@@ -114,6 +242,7 @@ class ChatModel with ChangeNotifier {
|
||||
close() {
|
||||
hideChatIconOverlay();
|
||||
hideChatWindowOverlay();
|
||||
_overlayState = null;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/pages/file_manager_page.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/mobile/pages/file_manager_page.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:path/path.dart' as Path;
|
||||
|
||||
import 'model.dart';
|
||||
import 'platform_model.dart';
|
||||
|
||||
enum SortBy { Name, Type, Modified, Size }
|
||||
|
||||
@@ -21,6 +23,11 @@ class FileModel extends ChangeNotifier {
|
||||
|
||||
var _jobProgress = JobProgress(); // from rust update
|
||||
|
||||
/// JobTable <jobId, JobProgress>
|
||||
final _jobTable = List<JobProgress>.empty(growable: true).obs;
|
||||
|
||||
RxList<JobProgress> get jobTable => _jobTable;
|
||||
|
||||
bool get isLocal => _isLocal;
|
||||
|
||||
bool get selectMode => _selectMode;
|
||||
@@ -33,6 +40,20 @@ class FileModel extends ChangeNotifier {
|
||||
|
||||
SortBy get sortStyle => _sortStyle;
|
||||
|
||||
SortBy _localSortStyle = SortBy.Name;
|
||||
|
||||
bool _localSortAscending = true;
|
||||
|
||||
bool _remoteSortAscending = true;
|
||||
|
||||
SortBy _remoteSortStyle = SortBy.Name;
|
||||
|
||||
bool get localSortAscending => _localSortAscending;
|
||||
|
||||
SortBy getSortStyle(bool isLocal) {
|
||||
return isLocal ? _localSortStyle : _remoteSortStyle;
|
||||
}
|
||||
|
||||
FileDirectory _currentLocalDir = FileDirectory();
|
||||
|
||||
FileDirectory get currentLocalDir => _currentLocalDir;
|
||||
@@ -43,8 +64,36 @@ class FileModel extends ChangeNotifier {
|
||||
|
||||
FileDirectory get currentDir => _isLocal ? currentLocalDir : currentRemoteDir;
|
||||
|
||||
FileDirectory getCurrentDir(bool isLocal) {
|
||||
return isLocal ? currentLocalDir : currentRemoteDir;
|
||||
}
|
||||
|
||||
String getCurrentShortPath(bool isLocal) {
|
||||
final currentDir = getCurrentDir(isLocal);
|
||||
final currentHome = getCurrentHome(isLocal);
|
||||
if (currentDir.path.startsWith(currentHome)) {
|
||||
var path = currentDir.path.replaceFirst(currentHome, "");
|
||||
if (path.length == 0) return "";
|
||||
if (path[0] == "/" || path[0] == "\\") {
|
||||
// remove more '/' or '\'
|
||||
path = path.replaceFirst(path[0], "");
|
||||
}
|
||||
return path;
|
||||
} else {
|
||||
return currentDir.path.replaceFirst(currentHome, "");
|
||||
}
|
||||
}
|
||||
|
||||
String get currentHome => _isLocal ? _localOption.home : _remoteOption.home;
|
||||
|
||||
String getCurrentHome(bool isLocal) {
|
||||
return isLocal ? _localOption.home : _remoteOption.home;
|
||||
}
|
||||
|
||||
int getJob(int id) {
|
||||
return jobTable.indexWhere((element) => element.id == id);
|
||||
}
|
||||
|
||||
String get currentShortPath {
|
||||
if (currentDir.path.startsWith(currentHome)) {
|
||||
var path = currentDir.path.replaceFirst(currentHome, "");
|
||||
@@ -59,16 +108,43 @@ class FileModel extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
String shortPath(bool isLocal) {
|
||||
final dir = isLocal ? currentLocalDir : currentRemoteDir;
|
||||
if (dir.path.startsWith(currentHome)) {
|
||||
var path = dir.path.replaceFirst(currentHome, "");
|
||||
if (path.length == 0) return "";
|
||||
if (path[0] == "/" || path[0] == "\\") {
|
||||
// remove more '/' or '\'
|
||||
path = path.replaceFirst(path[0], "");
|
||||
}
|
||||
return path;
|
||||
} else {
|
||||
return dir.path.replaceFirst(currentHome, "");
|
||||
}
|
||||
}
|
||||
|
||||
bool get currentShowHidden =>
|
||||
_isLocal ? _localOption.showHidden : _remoteOption.showHidden;
|
||||
|
||||
bool getCurrentShowHidden(bool isLocal) {
|
||||
return isLocal ? _localOption.showHidden : _remoteOption.showHidden;
|
||||
}
|
||||
|
||||
bool get currentIsWindows =>
|
||||
_isLocal ? _localOption.isWindows : _remoteOption.isWindows;
|
||||
|
||||
bool getCurrentIsWindows(bool isLocal) {
|
||||
return isLocal ? _localOption.isWindows : _remoteOption.isWindows;
|
||||
}
|
||||
|
||||
final _fileFetcher = FileFetcher();
|
||||
|
||||
final _jobResultListener = JobResultListener<Map<String, dynamic>>();
|
||||
|
||||
final WeakReference<FFI> parent;
|
||||
|
||||
FileModel(this.parent);
|
||||
|
||||
toggleSelectMode() {
|
||||
if (jobState == JobState.inProgress) {
|
||||
return;
|
||||
@@ -89,16 +165,29 @@ class FileModel extends ChangeNotifier {
|
||||
} else {
|
||||
_remoteOption.showHidden = showHidden ?? !_remoteOption.showHidden;
|
||||
}
|
||||
refresh();
|
||||
refresh(isLocal: local);
|
||||
}
|
||||
|
||||
tryUpdateJobProgress(Map<String, dynamic> evt) {
|
||||
try {
|
||||
int id = int.parse(evt['id']);
|
||||
_jobProgress.id = id;
|
||||
_jobProgress.fileNum = int.parse(evt['file_num']);
|
||||
_jobProgress.speed = double.parse(evt['speed']);
|
||||
_jobProgress.finishedSize = int.parse(evt['finished_size']);
|
||||
if (!isDesktop) {
|
||||
_jobProgress.id = id;
|
||||
_jobProgress.fileNum = int.parse(evt['file_num']);
|
||||
_jobProgress.speed = double.parse(evt['speed']);
|
||||
_jobProgress.finishedSize = int.parse(evt['finished_size']);
|
||||
} else {
|
||||
// Desktop uses jobTable
|
||||
// id = index + 1
|
||||
final jobIndex = getJob(id);
|
||||
if (jobIndex >= 0 && _jobTable.length > jobIndex) {
|
||||
final job = _jobTable[jobIndex];
|
||||
job.fileNum = int.parse(evt['file_num']);
|
||||
job.speed = double.parse(evt['speed']);
|
||||
job.finishedSize = int.parse(evt['finished_size']);
|
||||
debugPrint("update job ${id} with ${evt}");
|
||||
}
|
||||
}
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
debugPrint("Failed to tryUpdateJobProgress,evt:${evt.toString()}");
|
||||
@@ -106,63 +195,107 @@ class FileModel extends ChangeNotifier {
|
||||
}
|
||||
|
||||
receiveFileDir(Map<String, dynamic> evt) {
|
||||
if (_remoteOption.home.isEmpty && evt['is_local'] == "false") {
|
||||
debugPrint("recv file dir:${evt}");
|
||||
if (evt['is_local'] == "false") {
|
||||
// init remote home, the connection will automatic read remote home when established,
|
||||
try {
|
||||
final fd = FileDirectory.fromJson(jsonDecode(evt['value']));
|
||||
fd.format(_remoteOption.isWindows, sort: _sortStyle);
|
||||
_remoteOption.home = fd.path;
|
||||
debugPrint("init remote home:${fd.path}");
|
||||
_currentRemoteDir = fd;
|
||||
notifyListeners();
|
||||
return;
|
||||
if (fd.id > 0) {
|
||||
final jobIndex = getJob(fd.id);
|
||||
if (jobIndex != -1) {
|
||||
final job = jobTable[jobIndex];
|
||||
var totalSize = 0;
|
||||
var fileCount = fd.entries.length;
|
||||
fd.entries.forEach((element) {
|
||||
totalSize += element.size;
|
||||
});
|
||||
job.totalSize = totalSize;
|
||||
job.fileCount = fileCount;
|
||||
debugPrint("update receive details:${fd.path}");
|
||||
}
|
||||
} else if (_remoteOption.home.isEmpty) {
|
||||
_remoteOption.home = fd.path;
|
||||
debugPrint("init remote home:${fd.path}");
|
||||
_currentRemoteDir = fd;
|
||||
}
|
||||
} finally {}
|
||||
}
|
||||
_fileFetcher.tryCompleteTask(evt['value'], evt['is_local']);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
jobDone(Map<String, dynamic> evt) {
|
||||
jobDone(Map<String, dynamic> evt) async {
|
||||
if (_jobResultListener.isListening) {
|
||||
_jobResultListener.complete(evt);
|
||||
return;
|
||||
}
|
||||
_selectMode = false;
|
||||
_jobProgress.state = JobState.done;
|
||||
refresh();
|
||||
if (!isDesktop) {
|
||||
_selectMode = false;
|
||||
_jobProgress.state = JobState.done;
|
||||
} else {
|
||||
int id = int.parse(evt['id']);
|
||||
final jobIndex = getJob(id);
|
||||
if (jobIndex != -1) {
|
||||
final job = jobTable[jobIndex];
|
||||
job.finishedSize = job.totalSize;
|
||||
job.state = JobState.done;
|
||||
job.fileNum = int.parse(evt['file_num']);
|
||||
}
|
||||
}
|
||||
await Future.wait([
|
||||
refresh(isLocal: false),
|
||||
refresh(isLocal: true),
|
||||
]);
|
||||
}
|
||||
|
||||
jobError(Map<String, dynamic> evt) {
|
||||
if (_jobResultListener.isListening) {
|
||||
_jobResultListener.complete(evt);
|
||||
return;
|
||||
if (!isDesktop) {
|
||||
if (_jobResultListener.isListening) {
|
||||
_jobResultListener.complete(evt);
|
||||
return;
|
||||
}
|
||||
_selectMode = false;
|
||||
_jobProgress.clear();
|
||||
_jobProgress.state = JobState.error;
|
||||
} else {
|
||||
int jobIndex = getJob(int.parse(evt['id']));
|
||||
if (jobIndex != -1) {
|
||||
final job = jobTable[jobIndex];
|
||||
job.state = JobState.error;
|
||||
}
|
||||
}
|
||||
|
||||
debugPrint("jobError $evt");
|
||||
_selectMode = false;
|
||||
_jobProgress.clear();
|
||||
_jobProgress.state = JobState.error;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
overrideFileConfirm(Map<String, dynamic> evt) async {
|
||||
final resp = await showFileConfirmDialog(
|
||||
translate("Overwrite"), "${evt['read_path']}", true);
|
||||
final id = int.tryParse(evt['id']) ?? 0;
|
||||
if (false == resp) {
|
||||
cancelJob(int.tryParse(evt['id']) ?? 0);
|
||||
final jobIndex = getJob(id);
|
||||
if (jobIndex != -1) {
|
||||
cancelJob(id);
|
||||
final job = jobTable[jobIndex];
|
||||
job.state = JobState.done;
|
||||
}
|
||||
} else {
|
||||
var msg = Map()
|
||||
..['id'] = evt['id']
|
||||
..['file_num'] = evt['file_num']
|
||||
..['is_upload'] = evt['is_upload']
|
||||
..['remember'] = fileConfirmCheckboxRemember.toString();
|
||||
var need_override = false;
|
||||
if (resp == null) {
|
||||
// skip
|
||||
msg['need_override'] = 'false';
|
||||
need_override = false;
|
||||
} else {
|
||||
// overwrite
|
||||
msg['need_override'] = 'true';
|
||||
need_override = true;
|
||||
}
|
||||
FFI.setByName("set_confirm_override_file", jsonEncode(msg));
|
||||
bind.sessionSetConfirmOverrideFile(
|
||||
id: parent.target?.id ?? "",
|
||||
actId: id,
|
||||
fileNum: int.parse(evt['file_num']),
|
||||
needOverride: need_override,
|
||||
remember: fileConfirmCheckboxRemember,
|
||||
isUpload: evt['is_upload'] == "true");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,20 +305,24 @@ class FileModel extends ChangeNotifier {
|
||||
}
|
||||
|
||||
onReady() async {
|
||||
_localOption.home = FFI.getByName("get_home_dir");
|
||||
_localOption.showHidden =
|
||||
FFI.getByName("peer_option", "local_show_hidden").isNotEmpty;
|
||||
_localOption.home = await bind.mainGetHomeDir();
|
||||
_localOption.showHidden = (await bind.sessionGetPeerOption(
|
||||
id: parent.target?.id ?? "", name: "local_show_hidden"))
|
||||
.isNotEmpty;
|
||||
|
||||
_remoteOption.showHidden =
|
||||
FFI.getByName("peer_option", "remote_show_hidden").isNotEmpty;
|
||||
_remoteOption.isWindows = FFI.ffiModel.pi.platform == "Windows";
|
||||
_remoteOption.showHidden = (await bind.sessionGetPeerOption(
|
||||
id: parent.target?.id ?? "", name: "remote_show_hidden"))
|
||||
.isNotEmpty;
|
||||
_remoteOption.isWindows = parent.target?.ffiModel.pi.platform == "Windows";
|
||||
|
||||
debugPrint("remote platform: ${FFI.ffiModel.pi.platform}");
|
||||
debugPrint("remote platform: ${parent.target?.ffiModel.pi.platform}");
|
||||
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
|
||||
final local = FFI.getByName("peer_option", "local_dir");
|
||||
final remote = FFI.getByName("peer_option", "remote_dir");
|
||||
final local = (await bind.sessionGetPeerOption(
|
||||
id: parent.target?.id ?? "", name: "local_dir"));
|
||||
final remote = (await bind.sessionGetPeerOption(
|
||||
id: parent.target?.id ?? "", name: "remote_dir"));
|
||||
openDirectory(local.isEmpty ? _localOption.home : local, isLocal: true);
|
||||
openDirectory(remote.isEmpty ? _remoteOption.home : remote, isLocal: false);
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
@@ -195,38 +332,40 @@ class FileModel extends ChangeNotifier {
|
||||
if (_currentRemoteDir.path.isEmpty) {
|
||||
openDirectory(_remoteOption.home, isLocal: false);
|
||||
}
|
||||
// load last transfer jobs
|
||||
await bind.sessionLoadLastTransferJobs(id: '${parent.target?.id}');
|
||||
}
|
||||
|
||||
onClose() {
|
||||
SmartDialog.dismiss();
|
||||
parent.target?.dialogManager.dismissAll();
|
||||
jobReset();
|
||||
|
||||
// save config
|
||||
Map<String, String> msg = Map();
|
||||
Map<String, String> msgMap = Map();
|
||||
|
||||
msg["name"] = "local_dir";
|
||||
msg["value"] = _currentLocalDir.path;
|
||||
FFI.setByName('peer_option', jsonEncode(msg));
|
||||
|
||||
msg["name"] = "local_show_hidden";
|
||||
msg["value"] = _localOption.showHidden ? "Y" : "";
|
||||
FFI.setByName('peer_option', jsonEncode(msg));
|
||||
|
||||
msg["name"] = "remote_dir";
|
||||
msg["value"] = _currentRemoteDir.path;
|
||||
FFI.setByName('peer_option', jsonEncode(msg));
|
||||
|
||||
msg["name"] = "remote_show_hidden";
|
||||
msg["value"] = _remoteOption.showHidden ? "Y" : "";
|
||||
FFI.setByName('peer_option', jsonEncode(msg));
|
||||
msgMap["local_dir"] = _currentLocalDir.path;
|
||||
msgMap["local_show_hidden"] = _localOption.showHidden ? "Y" : "";
|
||||
msgMap["remote_dir"] = _currentRemoteDir.path;
|
||||
msgMap["remote_show_hidden"] = _remoteOption.showHidden ? "Y" : "";
|
||||
final id = parent.target?.id ?? "";
|
||||
for (final msg in msgMap.entries) {
|
||||
bind.sessionPeerOption(id: id, name: msg.key, value: msg.value);
|
||||
}
|
||||
_currentLocalDir.clear();
|
||||
_currentRemoteDir.clear();
|
||||
_localOption.clear();
|
||||
_remoteOption.clear();
|
||||
}
|
||||
|
||||
refresh() {
|
||||
openDirectory(currentDir.path);
|
||||
Future refresh({bool? isLocal}) async {
|
||||
if (isDesktop) {
|
||||
isLocal = isLocal ?? _isLocal;
|
||||
await isLocal
|
||||
? openDirectory(currentLocalDir.path, isLocal: isLocal)
|
||||
: openDirectory(currentRemoteDir.path, isLocal: isLocal);
|
||||
} else {
|
||||
await openDirectory(currentDir.path);
|
||||
}
|
||||
}
|
||||
|
||||
openDirectory(String path, {bool? isLocal}) async {
|
||||
@@ -235,6 +374,15 @@ class FileModel extends ChangeNotifier {
|
||||
isLocal ? _localOption.showHidden : _remoteOption.showHidden;
|
||||
final isWindows =
|
||||
isLocal ? _localOption.isWindows : _remoteOption.isWindows;
|
||||
// process /C:\ -> C:\ on Windows
|
||||
if (isLocal
|
||||
? _localOption.isWindows
|
||||
: _remoteOption.isWindows && path.length > 1 && path[0] == '/') {
|
||||
path = path.substring(1);
|
||||
if (path[path.length - 1] != '\\') {
|
||||
path = path + "\\";
|
||||
}
|
||||
}
|
||||
try {
|
||||
final fd = await _fileFetcher.fetchDirectory(path, isLocal, showHidden);
|
||||
fd.format(isWindows, sort: _sortStyle);
|
||||
@@ -245,48 +393,87 @@ class FileModel extends ChangeNotifier {
|
||||
}
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
debugPrint("Failed to openDirectory :$e");
|
||||
debugPrint("Failed to openDirectory ${path} :$e");
|
||||
}
|
||||
}
|
||||
|
||||
goHome() {
|
||||
openDirectory(currentHome);
|
||||
goHome({bool? isLocal}) {
|
||||
isLocal = isLocal ?? _isLocal;
|
||||
openDirectory(getCurrentHome(isLocal), isLocal: isLocal);
|
||||
}
|
||||
|
||||
goToParentDirectory() {
|
||||
final parent = PathUtil.dirname(currentDir.path, currentIsWindows);
|
||||
openDirectory(parent);
|
||||
}
|
||||
|
||||
sendFiles(SelectedItems items) {
|
||||
if (items.isLocal == null) {
|
||||
debugPrint("Failed to sendFiles ,wrong path state");
|
||||
goToParentDirectory({bool? isLocal}) {
|
||||
isLocal = isLocal ?? _isLocal;
|
||||
final isWindows =
|
||||
isLocal ? _localOption.isWindows : _remoteOption.isWindows;
|
||||
final currDir = isLocal ? currentLocalDir : currentRemoteDir;
|
||||
var parent = PathUtil.dirname(currDir.path, isWindows);
|
||||
// specially for C:\, D:\, goto '/'
|
||||
if (parent == currDir.path && isWindows) {
|
||||
openDirectory('/', isLocal: isLocal);
|
||||
return;
|
||||
}
|
||||
_jobProgress.state = JobState.inProgress;
|
||||
final toPath =
|
||||
items.isLocal! ? currentRemoteDir.path : currentLocalDir.path;
|
||||
final isWindows =
|
||||
items.isLocal! ? _localOption.isWindows : _remoteOption.isWindows;
|
||||
final showHidden =
|
||||
items.isLocal! ? _localOption.showHidden : _remoteOption.showHidden;
|
||||
items.items.forEach((from) {
|
||||
_jobId++;
|
||||
final msg = {
|
||||
"id": _jobId.toString(),
|
||||
"path": from.path,
|
||||
"to": PathUtil.join(toPath, from.name, isWindows),
|
||||
"file_num": "0",
|
||||
"show_hidden": showHidden.toString(),
|
||||
"is_remote": (!(items.isLocal!)).toString()
|
||||
};
|
||||
FFI.setByName("send_files", jsonEncode(msg));
|
||||
});
|
||||
openDirectory(parent, isLocal: isLocal);
|
||||
}
|
||||
|
||||
/// isRemote only for desktop now, [isRemote == true] means [remote -> local]
|
||||
sendFiles(SelectedItems items, {bool isRemote = false}) {
|
||||
if (isDesktop) {
|
||||
// desktop sendFiles
|
||||
final toPath = isRemote ? currentLocalDir.path : currentRemoteDir.path;
|
||||
final isWindows =
|
||||
isRemote ? _localOption.isWindows : _remoteOption.isWindows;
|
||||
final showHidden =
|
||||
isRemote ? _localOption.showHidden : _remoteOption.showHidden;
|
||||
items.items.forEach((from) async {
|
||||
final jobId = ++_jobId;
|
||||
_jobTable.add(JobProgress()
|
||||
..jobName = from.path
|
||||
..totalSize = from.size
|
||||
..state = JobState.inProgress
|
||||
..id = jobId
|
||||
..isRemote = isRemote);
|
||||
bind.sessionSendFiles(
|
||||
id: '${parent.target?.id}',
|
||||
actId: _jobId,
|
||||
path: from.path,
|
||||
to: PathUtil.join(toPath, from.name, isWindows),
|
||||
fileNum: 0,
|
||||
includeHidden: showHidden,
|
||||
isRemote: isRemote);
|
||||
print(
|
||||
"path:${from.path}, toPath:${toPath}, to:${PathUtil.join(toPath, from.name, isWindows)}");
|
||||
});
|
||||
} else {
|
||||
if (items.isLocal == null) {
|
||||
debugPrint("Failed to sendFiles ,wrong path state");
|
||||
return;
|
||||
}
|
||||
_jobProgress.state = JobState.inProgress;
|
||||
final toPath =
|
||||
items.isLocal! ? currentRemoteDir.path : currentLocalDir.path;
|
||||
final isWindows =
|
||||
items.isLocal! ? _localOption.isWindows : _remoteOption.isWindows;
|
||||
final showHidden =
|
||||
items.isLocal! ? _localOption.showHidden : _remoteOption.showHidden;
|
||||
items.items.forEach((from) async {
|
||||
_jobId++;
|
||||
await bind.sessionSendFiles(
|
||||
id: await bind.mainGetLastRemoteId(),
|
||||
actId: _jobId,
|
||||
path: from.path,
|
||||
to: PathUtil.join(toPath, from.name, isWindows),
|
||||
fileNum: 0,
|
||||
includeHidden: showHidden,
|
||||
isRemote: !(items.isLocal!));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
bool removeCheckboxRemember = false;
|
||||
|
||||
removeAction(SelectedItems items) async {
|
||||
removeAction(SelectedItems items, {bool? isLocal}) async {
|
||||
isLocal = isLocal ?? _isLocal;
|
||||
removeCheckboxRemember = false;
|
||||
if (items.isLocal == null) {
|
||||
debugPrint("Failed to removeFile, wrong path state");
|
||||
@@ -305,14 +492,14 @@ class FileModel extends ChangeNotifier {
|
||||
entries = [item];
|
||||
} else if (item.isDirectory) {
|
||||
title = translate("Not an empty directory");
|
||||
showLoading(translate("Waiting"));
|
||||
parent.target?.dialogManager.showLoading(translate("Waiting"));
|
||||
final fd = await _fileFetcher.fetchDirectoryRecursive(
|
||||
_jobId, item.path, items.isLocal!, true);
|
||||
if (fd.path.isEmpty) {
|
||||
fd.path = item.path;
|
||||
}
|
||||
fd.format(isWindows);
|
||||
SmartDialog.dismiss();
|
||||
parent.target?.dialogManager.dismissAll();
|
||||
if (fd.entries.isEmpty) {
|
||||
final confirm = await showRemoveDialog(
|
||||
translate(
|
||||
@@ -360,16 +547,18 @@ class FileModel extends ChangeNotifier {
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
print("remove error: ${e}");
|
||||
}
|
||||
}
|
||||
});
|
||||
_selectMode = false;
|
||||
refresh();
|
||||
refresh(isLocal: isLocal);
|
||||
}
|
||||
|
||||
Future<bool?> showRemoveDialog(
|
||||
String title, String content, bool showCheckbox) async {
|
||||
return await DialogManager.show<bool>(
|
||||
return await parent.target?.dialogManager.show<bool>(
|
||||
(setState, Function(bool v) close) => CustomAlertDialog(
|
||||
title: Row(
|
||||
children: [
|
||||
@@ -420,7 +609,7 @@ class FileModel extends ChangeNotifier {
|
||||
Future<bool?> showFileConfirmDialog(
|
||||
String title, String content, bool showCheckbox) async {
|
||||
fileConfirmCheckboxRemember = false;
|
||||
return await DialogManager.show<bool?>(
|
||||
return await parent.target?.dialogManager.show<bool?>(
|
||||
(setState, Function(bool? v) close) => CustomAlertDialog(
|
||||
title: Row(
|
||||
children: [
|
||||
@@ -473,43 +662,122 @@ class FileModel extends ChangeNotifier {
|
||||
}
|
||||
|
||||
sendRemoveFile(String path, int fileNum, bool isLocal) {
|
||||
final msg = {
|
||||
"id": _jobId.toString(),
|
||||
"path": path,
|
||||
"file_num": fileNum.toString(),
|
||||
"is_remote": (!(isLocal)).toString()
|
||||
};
|
||||
FFI.setByName("remove_file", jsonEncode(msg));
|
||||
bind.sessionRemoveFile(
|
||||
id: '${parent.target?.id}',
|
||||
actId: _jobId,
|
||||
path: path,
|
||||
isRemote: !isLocal,
|
||||
fileNum: fileNum);
|
||||
}
|
||||
|
||||
sendRemoveEmptyDir(String path, int fileNum, bool isLocal) {
|
||||
final msg = {
|
||||
"id": _jobId.toString(),
|
||||
"path": path,
|
||||
"is_remote": (!isLocal).toString()
|
||||
};
|
||||
FFI.setByName("remove_all_empty_dirs", jsonEncode(msg));
|
||||
bind.sessionRemoveAllEmptyDirs(
|
||||
id: '${parent.target?.id}',
|
||||
actId: _jobId,
|
||||
path: path,
|
||||
isRemote: !isLocal);
|
||||
}
|
||||
|
||||
createDir(String path) {
|
||||
createDir(String path, {bool? isLocal}) async {
|
||||
isLocal = isLocal ?? this.isLocal;
|
||||
_jobId++;
|
||||
final msg = {
|
||||
"id": _jobId.toString(),
|
||||
"path": path,
|
||||
"is_remote": (!isLocal).toString()
|
||||
};
|
||||
FFI.setByName("create_dir", jsonEncode(msg));
|
||||
bind.sessionCreateDir(
|
||||
id: '${parent.target?.id}',
|
||||
actId: _jobId,
|
||||
path: path,
|
||||
isRemote: !isLocal);
|
||||
}
|
||||
|
||||
cancelJob(int id) {
|
||||
FFI.setByName("cancel_job", id.toString());
|
||||
cancelJob(int id) async {
|
||||
bind.sessionCancelJob(id: '${parent.target?.id}', actId: id);
|
||||
jobReset();
|
||||
}
|
||||
|
||||
changeSortStyle(SortBy sort) {
|
||||
changeSortStyle(SortBy sort, {bool? isLocal, bool ascending = true}) {
|
||||
_sortStyle = sort;
|
||||
_currentLocalDir.changeSortStyle(sort);
|
||||
_currentRemoteDir.changeSortStyle(sort);
|
||||
if (isLocal == null) {
|
||||
// compatible for mobile logic
|
||||
_currentLocalDir.changeSortStyle(sort, ascending: ascending);
|
||||
_currentRemoteDir.changeSortStyle(sort, ascending: ascending);
|
||||
_localSortStyle = sort;
|
||||
_localSortAscending = ascending;
|
||||
_remoteSortStyle = sort;
|
||||
_remoteSortAscending = ascending;
|
||||
} else if (isLocal) {
|
||||
_currentLocalDir.changeSortStyle(sort, ascending: ascending);
|
||||
_localSortStyle = sort;
|
||||
_localSortAscending = ascending;
|
||||
} else {
|
||||
_currentRemoteDir.changeSortStyle(sort, ascending: ascending);
|
||||
_remoteSortStyle = sort;
|
||||
_remoteSortAscending = ascending;
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
initFileFetcher() {
|
||||
_fileFetcher.id = parent.target?.id;
|
||||
}
|
||||
|
||||
void updateFolderFiles(Map<String, dynamic> evt) {
|
||||
// ret: "{\"id\":1,\"num_entries\":12,\"total_size\":1264822.0}"
|
||||
Map<String, dynamic> info = json.decode(evt['info']);
|
||||
int id = info['id'];
|
||||
int num_entries = info['num_entries'];
|
||||
double total_size = info['total_size'];
|
||||
final jobIndex = getJob(id);
|
||||
if (jobIndex != -1) {
|
||||
final job = jobTable[jobIndex];
|
||||
job.fileCount = num_entries;
|
||||
job.totalSize = total_size.toInt();
|
||||
}
|
||||
debugPrint("update folder files: ${info}");
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool get remoteSortAscending => _remoteSortAscending;
|
||||
|
||||
void loadLastJob(Map<String, dynamic> evt) {
|
||||
debugPrint("load last job: ${evt}");
|
||||
Map<String, dynamic> jobDetail = json.decode(evt['value']);
|
||||
// int id = int.parse(jobDetail['id']);
|
||||
String remote = jobDetail['remote'];
|
||||
String to = jobDetail['to'];
|
||||
bool showHidden = jobDetail['show_hidden'];
|
||||
int fileNum = jobDetail['file_num'];
|
||||
bool isRemote = jobDetail['is_remote'];
|
||||
final currJobId = _jobId++;
|
||||
var jobProgress = JobProgress()
|
||||
..jobName = isRemote ? remote : to
|
||||
..id = currJobId
|
||||
..isRemote = isRemote
|
||||
..fileNum = fileNum
|
||||
..remote = remote
|
||||
..to = to
|
||||
..showHidden = showHidden
|
||||
..state = JobState.paused;
|
||||
jobTable.add(jobProgress);
|
||||
bind.sessionAddJob(
|
||||
id: '${parent.target?.id}',
|
||||
isRemote: isRemote,
|
||||
includeHidden: showHidden,
|
||||
actId: currJobId,
|
||||
path: isRemote ? remote : to,
|
||||
to: isRemote ? to : remote,
|
||||
fileNum: fileNum,
|
||||
);
|
||||
}
|
||||
|
||||
resumeJob(int jobId) {
|
||||
final jobIndex = getJob(jobId);
|
||||
if (jobIndex != -1) {
|
||||
final job = jobTable[jobIndex];
|
||||
bind.sessionResumeJob(
|
||||
id: '${parent.target?.id}', actId: job.id, isRemote: job.isRemote);
|
||||
job.state = JobState.inProgress;
|
||||
} else {
|
||||
debugPrint("jobId ${jobId} is not exists");
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -559,6 +827,17 @@ class FileFetcher {
|
||||
Map<String, Completer<FileDirectory>> remoteTasks = Map();
|
||||
Map<int, Completer<FileDirectory>> readRecursiveTasks = Map();
|
||||
|
||||
String? _id;
|
||||
|
||||
String? get id => _id;
|
||||
|
||||
set id(String? id) {
|
||||
_id = id;
|
||||
}
|
||||
|
||||
// if id == null, means to fetch global FFI
|
||||
FFI get _ffi => ffi(_id ?? "");
|
||||
|
||||
Future<FileDirectory> registerReadTask(bool isLocal, String path) {
|
||||
// final jobs = isLocal?localJobs:remoteJobs; // maybe we will use read local dir async later
|
||||
final tasks = remoteTasks; // bypass now
|
||||
@@ -618,13 +897,14 @@ class FileFetcher {
|
||||
Future<FileDirectory> fetchDirectory(
|
||||
String path, bool isLocal, bool showHidden) async {
|
||||
try {
|
||||
final msg = {"path": path, "show_hidden": showHidden.toString()};
|
||||
if (isLocal) {
|
||||
final res = FFI.getByName("read_local_dir_sync", jsonEncode(msg));
|
||||
final res = await bind.sessionReadLocalDirSync(
|
||||
id: id ?? "", path: path, showHidden: showHidden);
|
||||
final fd = FileDirectory.fromJson(jsonDecode(res));
|
||||
return fd;
|
||||
} else {
|
||||
FFI.setByName("read_remote_dir", jsonEncode(msg));
|
||||
await bind.sessionReadRemoteDir(
|
||||
id: id ?? "", path: path, includeHidden: showHidden);
|
||||
return registerReadTask(isLocal, path);
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -636,13 +916,12 @@ class FileFetcher {
|
||||
int id, String path, bool isLocal, bool showHidden) async {
|
||||
// TODO test Recursive is show hidden default?
|
||||
try {
|
||||
final msg = {
|
||||
"id": id.toString(),
|
||||
"path": path,
|
||||
"show_hidden": showHidden.toString(),
|
||||
"is_remote": (!isLocal).toString()
|
||||
};
|
||||
FFI.setByName("read_dir_recursive", jsonEncode(msg));
|
||||
await bind.sessionReadDirRecursive(
|
||||
id: _ffi.id,
|
||||
actId: id,
|
||||
path: path,
|
||||
isRemote: !isLocal,
|
||||
showHidden: showHidden);
|
||||
return registerReadRecursiveTask(id);
|
||||
} catch (e) {
|
||||
return Future.error(e);
|
||||
@@ -675,8 +954,8 @@ class FileDirectory {
|
||||
}
|
||||
}
|
||||
|
||||
changeSortStyle(SortBy sort) {
|
||||
entries = _sortList(entries, sort);
|
||||
changeSortStyle(SortBy sort, {bool ascending = true}) {
|
||||
entries = _sortList(entries, sort, ascending);
|
||||
}
|
||||
|
||||
clear() {
|
||||
@@ -711,7 +990,24 @@ class Entry {
|
||||
}
|
||||
}
|
||||
|
||||
enum JobState { none, inProgress, done, error }
|
||||
enum JobState { none, inProgress, done, error, paused }
|
||||
|
||||
extension JobStateDisplay on JobState {
|
||||
String display() {
|
||||
switch (this) {
|
||||
case JobState.none:
|
||||
return translate("Waiting");
|
||||
case JobState.inProgress:
|
||||
return translate("Transfer File");
|
||||
case JobState.done:
|
||||
return translate("Finished");
|
||||
case JobState.error:
|
||||
return translate("Error");
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class JobProgress {
|
||||
JobState state = JobState.none;
|
||||
@@ -719,6 +1015,13 @@ class JobProgress {
|
||||
var fileNum = 0;
|
||||
var speed = 0.0;
|
||||
var finishedSize = 0;
|
||||
var totalSize = 0;
|
||||
var fileCount = 0;
|
||||
var isRemote = false;
|
||||
var jobName = "";
|
||||
var remote = "";
|
||||
var to = "";
|
||||
var showHidden = false;
|
||||
|
||||
clear() {
|
||||
state = JobState.none;
|
||||
@@ -726,6 +1029,10 @@ class JobProgress {
|
||||
fileNum = 0;
|
||||
speed = 0;
|
||||
finishedSize = 0;
|
||||
jobName = "";
|
||||
fileCount = 0;
|
||||
remote = "";
|
||||
to = "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -772,7 +1079,7 @@ class DirectoryOption {
|
||||
}
|
||||
|
||||
// code from file_manager pkg after edit
|
||||
List<Entry> _sortList(List<Entry> list, SortBy sortType) {
|
||||
List<Entry> _sortList(List<Entry> list, SortBy sortType, bool ascending) {
|
||||
if (sortType == SortBy.Name) {
|
||||
// making list of only folders.
|
||||
final dirs = list.where((element) => element.isDirectory).toList();
|
||||
@@ -785,7 +1092,9 @@ List<Entry> _sortList(List<Entry> list, SortBy sortType) {
|
||||
files.sort((a, b) => a.name.toLowerCase().compareTo(b.name.toLowerCase()));
|
||||
|
||||
// first folders will go to list (if available) then files will go to list.
|
||||
return [...dirs, ...files];
|
||||
return ascending
|
||||
? [...dirs, ...files]
|
||||
: [...dirs.reversed.toList(), ...files.reversed.toList()];
|
||||
} else if (sortType == SortBy.Modified) {
|
||||
// making the list of Path & DateTime
|
||||
List<_PathStat> _pathStat = [];
|
||||
@@ -800,7 +1109,7 @@ List<Entry> _sortList(List<Entry> list, SortBy sortType) {
|
||||
list.sort((a, b) => _pathStat
|
||||
.indexWhere((element) => element.path == a.name)
|
||||
.compareTo(_pathStat.indexWhere((element) => element.path == b.name)));
|
||||
return list;
|
||||
return ascending ? list : list.reversed.toList();
|
||||
} else if (sortType == SortBy.Type) {
|
||||
// making list of only folders.
|
||||
final dirs = list.where((element) => element.isDirectory).toList();
|
||||
@@ -817,7 +1126,9 @@ List<Entry> _sortList(List<Entry> list, SortBy sortType) {
|
||||
.split('.')
|
||||
.last
|
||||
.compareTo(b.name.toLowerCase().split('.').last));
|
||||
return [...dirs, ...files];
|
||||
return ascending
|
||||
? [...dirs, ...files]
|
||||
: [...dirs.reversed.toList(), ...files.reversed.toList()];
|
||||
} else if (sortType == SortBy.Size) {
|
||||
// create list of path and size
|
||||
Map<String, int> _sizeMap = {};
|
||||
@@ -842,7 +1153,9 @@ List<Entry> _sortList(List<Entry> list, SortBy sortType) {
|
||||
.indexWhere((element) => element.key == a.name)
|
||||
.compareTo(
|
||||
_sizeMapList.indexWhere((element) => element.key == b.name)));
|
||||
return [...dirs, ...files];
|
||||
return ascending
|
||||
? [...dirs, ...files]
|
||||
: [...dirs.reversed.toList(), ...files.reversed.toList()];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,18 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ffi';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:device_info/device_info.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:external_path/external_path.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import '../generated_bridge.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import '../common.dart';
|
||||
import '../generated_bridge.dart';
|
||||
|
||||
class RgbaFrame extends Struct {
|
||||
@Uint32()
|
||||
@@ -19,58 +22,100 @@ class RgbaFrame extends Struct {
|
||||
|
||||
typedef F2 = Pointer<Utf8> Function(Pointer<Utf8>, Pointer<Utf8>);
|
||||
typedef F3 = void Function(Pointer<Utf8>, Pointer<Utf8>);
|
||||
typedef HandleEvent = void Function(Map<String, dynamic> evt);
|
||||
|
||||
/// FFI wrapper around the native Rust core.
|
||||
/// Hides the platform differences.
|
||||
class PlatformFFI {
|
||||
static String _dir = '';
|
||||
static String _homeDir = '';
|
||||
static F2? _getByName;
|
||||
static F3? _setByName;
|
||||
static void Function(Map<String, dynamic>)? _eventCallback;
|
||||
static void Function(Uint8List)? _rgbaCallback;
|
||||
String _dir = '';
|
||||
String _homeDir = '';
|
||||
F2? _translate;
|
||||
var _eventHandlers = Map<String, Map<String, HandleEvent>>();
|
||||
late RustdeskImpl _ffiBind;
|
||||
late String _appType;
|
||||
void Function(Map<String, dynamic>)? _eventCallback;
|
||||
|
||||
PlatformFFI._();
|
||||
|
||||
static final PlatformFFI instance = PlatformFFI._();
|
||||
final _toAndroidChannel = MethodChannel("mChannel");
|
||||
|
||||
RustdeskImpl get ffiBind => _ffiBind;
|
||||
|
||||
static get localeName => Platform.localeName;
|
||||
|
||||
static Future<String> getVersion() async {
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
return packageInfo.version;
|
||||
}
|
||||
|
||||
static String getByName(String name, [String arg = '']) {
|
||||
if (_getByName == null) return '';
|
||||
bool registerEventHandler(
|
||||
String event_name, String handler_name, HandleEvent handler) {
|
||||
debugPrint('registerEventHandler $event_name $handler_name');
|
||||
var handlers = _eventHandlers[event_name];
|
||||
if (handlers == null) {
|
||||
_eventHandlers[event_name] = {handler_name: handler};
|
||||
return true;
|
||||
} else {
|
||||
if (handlers.containsKey(handler_name)) {
|
||||
return false;
|
||||
} else {
|
||||
handlers[handler_name] = handler;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void unregisterEventHandler(String event_name, String handler_name) {
|
||||
debugPrint('unregisterEventHandler $event_name $handler_name');
|
||||
var handlers = _eventHandlers[event_name];
|
||||
if (handlers != null) {
|
||||
handlers.remove(handler_name);
|
||||
}
|
||||
}
|
||||
|
||||
String translate(String name, String locale) {
|
||||
if (_translate == null) return name;
|
||||
var a = name.toNativeUtf8();
|
||||
var b = arg.toNativeUtf8();
|
||||
var p = _getByName!(a, b);
|
||||
var b = locale.toNativeUtf8();
|
||||
var p = _translate!(a, b);
|
||||
assert(p != nullptr);
|
||||
var res = p.toDartString();
|
||||
final res = p.toDartString();
|
||||
calloc.free(p);
|
||||
calloc.free(a);
|
||||
calloc.free(b);
|
||||
return res;
|
||||
}
|
||||
|
||||
static void setByName(String name, [String value = '']) {
|
||||
if (_setByName == null) return;
|
||||
var a = name.toNativeUtf8();
|
||||
var b = value.toNativeUtf8();
|
||||
_setByName!(a, b);
|
||||
calloc.free(a);
|
||||
calloc.free(b);
|
||||
}
|
||||
|
||||
static Future<Null> init() async {
|
||||
isIOS = Platform.isIOS;
|
||||
isAndroid = Platform.isAndroid;
|
||||
/// Init the FFI class, loads the native Rust core library.
|
||||
Future<Null> init(String appType) async {
|
||||
_appType = appType;
|
||||
// if (isDesktop) {
|
||||
// // TODO
|
||||
// return;
|
||||
// }
|
||||
final dylib = Platform.isAndroid
|
||||
? DynamicLibrary.open('librustdesk.so')
|
||||
: DynamicLibrary.process();
|
||||
print('initializing FFI');
|
||||
: Platform.isLinux
|
||||
? DynamicLibrary.open("/usr/lib/rustdesk/librustdesk.so")
|
||||
: Platform.isWindows
|
||||
? DynamicLibrary.open("librustdesk.dll")
|
||||
: Platform.isMacOS
|
||||
? DynamicLibrary.open("librustdesk.dylib")
|
||||
: DynamicLibrary.process();
|
||||
debugPrint('initializing FFI ${_appType}');
|
||||
try {
|
||||
_getByName = dylib.lookupFunction<F2, F2>('get_by_name');
|
||||
_setByName =
|
||||
dylib.lookupFunction<Void Function(Pointer<Utf8>, Pointer<Utf8>), F3>(
|
||||
'set_by_name');
|
||||
_translate = dylib.lookupFunction<F2, F2>('translate');
|
||||
_dir = (await getApplicationDocumentsDirectory()).path;
|
||||
_startListenEvent(RustdeskImpl(dylib));
|
||||
_ffiBind = RustdeskImpl(dylib);
|
||||
_startListenEvent(_ffiBind); // global event
|
||||
try {
|
||||
_homeDir = (await ExternalPath.getExternalStorageDirectories())[0];
|
||||
if (isAndroid) {
|
||||
// only support for android
|
||||
_homeDir = (await ExternalPath.getExternalStorageDirectories())[0];
|
||||
} else {
|
||||
_homeDir = (await getDownloadsDirectory())?.path ?? "";
|
||||
}
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
@@ -81,71 +126,91 @@ class PlatformFFI {
|
||||
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
|
||||
name = '${androidInfo.brand}-${androidInfo.model}';
|
||||
id = androidInfo.id.hashCode.toString();
|
||||
androidVersion = androidInfo.version.sdkInt;
|
||||
} else {
|
||||
androidVersion = androidInfo.version.sdkInt ?? 0;
|
||||
} else if (Platform.isIOS) {
|
||||
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
|
||||
name = iosInfo.utsname.machine;
|
||||
name = iosInfo.utsname.machine ?? "";
|
||||
id = iosInfo.identifierForVendor.hashCode.toString();
|
||||
} else if (Platform.isLinux) {
|
||||
LinuxDeviceInfo linuxInfo = await deviceInfo.linuxInfo;
|
||||
name = linuxInfo.name;
|
||||
id = linuxInfo.machineId ?? linuxInfo.id;
|
||||
} else if (Platform.isWindows) {
|
||||
WindowsDeviceInfo winInfo = await deviceInfo.windowsInfo;
|
||||
name = winInfo.computerName;
|
||||
id = winInfo.computerName;
|
||||
} else if (Platform.isMacOS) {
|
||||
MacOsDeviceInfo macOsInfo = await deviceInfo.macOsInfo;
|
||||
name = macOsInfo.computerName;
|
||||
id = macOsInfo.systemGUID ?? "";
|
||||
}
|
||||
print("info1-id:$id,info2-name:$name,dir:$_dir,homeDir:$_homeDir");
|
||||
setByName('info1', id);
|
||||
setByName('info2', name);
|
||||
setByName('home_dir', _homeDir);
|
||||
setByName('init', _dir);
|
||||
print(
|
||||
"_appType:$_appType,info1-id:$id,info2-name:$name,dir:$_dir,homeDir:$_homeDir");
|
||||
await _ffiBind.mainDeviceId(id: id);
|
||||
await _ffiBind.mainDeviceName(name: name);
|
||||
await _ffiBind.mainSetHomeDir(home: _homeDir);
|
||||
await _ffiBind.mainInit(appDir: _dir);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
version = await getVersion();
|
||||
}
|
||||
|
||||
static void _startListenEvent(RustdeskImpl rustdeskImpl) {
|
||||
() async {
|
||||
await for (final message in rustdeskImpl.startEventStream()) {
|
||||
if (_eventCallback != null) {
|
||||
try {
|
||||
Map<String, dynamic> event = json.decode(message);
|
||||
_eventCallback!(event);
|
||||
} catch (e) {
|
||||
print('json.decode fail(): $e');
|
||||
}
|
||||
bool _tryHandle(Map<String, dynamic> evt) {
|
||||
final name = evt['name'];
|
||||
if (name != null) {
|
||||
final handlers = _eventHandlers[name];
|
||||
if (handlers != null) {
|
||||
if (handlers.isNotEmpty) {
|
||||
handlers.values.forEach((handler) {
|
||||
handler(evt);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Start listening to the Rust core's events and frames.
|
||||
void _startListenEvent(RustdeskImpl rustdeskImpl) {
|
||||
() async {
|
||||
await for (final rgba in rustdeskImpl.startRgbaStream()) {
|
||||
if (_rgbaCallback != null) {
|
||||
_rgbaCallback!(rgba);
|
||||
} else {
|
||||
rgba.clear();
|
||||
await for (final message
|
||||
in rustdeskImpl.startGlobalEventStream(appType: _appType)) {
|
||||
try {
|
||||
Map<String, dynamic> event = json.decode(message);
|
||||
// _tryHandle here may be more flexible than _eventCallback
|
||||
if (!_tryHandle(event)) {
|
||||
if (_eventCallback != null) {
|
||||
_eventCallback!(event);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('json.decode fail(): $e');
|
||||
}
|
||||
}
|
||||
}();
|
||||
}
|
||||
|
||||
static void setEventCallback(void Function(Map<String, dynamic>) fun) async {
|
||||
void setEventCallback(void Function(Map<String, dynamic>) fun) async {
|
||||
_eventCallback = fun;
|
||||
}
|
||||
|
||||
static void setRgbaCallback(void Function(Uint8List) fun) async {
|
||||
_rgbaCallback = fun;
|
||||
}
|
||||
void setRgbaCallback(void Function(Uint8List) fun) async {}
|
||||
|
||||
static void startDesktopWebListener() {}
|
||||
void startDesktopWebListener() {}
|
||||
|
||||
static void stopDesktopWebListener() {}
|
||||
void stopDesktopWebListener() {}
|
||||
|
||||
static void setMethodCallHandler(FMethod callback) {
|
||||
toAndroidChannel.setMethodCallHandler((call) async {
|
||||
void setMethodCallHandler(FMethod callback) {
|
||||
_toAndroidChannel.setMethodCallHandler((call) async {
|
||||
callback(call.method, call.arguments);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
static invokeMethod(String method, [dynamic arguments]) async {
|
||||
invokeMethod(String method, [dynamic arguments]) async {
|
||||
if (!isAndroid) return Future<bool>(() => false);
|
||||
return await toAndroidChannel.invokeMethod(method, arguments);
|
||||
return await _toAndroidChannel.invokeMethod(method, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
final localeName = Platform.localeName;
|
||||
final toAndroidChannel = MethodChannel("mChannel");
|
||||
|
||||
128
flutter/lib/models/peer_model.dart
Normal file
128
flutter/lib/models/peer_model.dart
Normal file
@@ -0,0 +1,128 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'platform_model.dart';
|
||||
|
||||
class Peer {
|
||||
final String id;
|
||||
final String username;
|
||||
final String hostname;
|
||||
final String platform;
|
||||
final List<dynamic> tags;
|
||||
bool online = false;
|
||||
|
||||
Peer.fromJson(String id, Map<String, dynamic> json)
|
||||
: id = id,
|
||||
username = json['username'] ?? '',
|
||||
hostname = json['hostname'] ?? '',
|
||||
platform = json['platform'] ?? '',
|
||||
tags = json['tags'] ?? [];
|
||||
|
||||
Peer({
|
||||
required this.id,
|
||||
required this.username,
|
||||
required this.hostname,
|
||||
required this.platform,
|
||||
required this.tags,
|
||||
});
|
||||
|
||||
Peer.loading()
|
||||
: this(
|
||||
id: '...',
|
||||
username: '...',
|
||||
hostname: '...',
|
||||
platform: '...',
|
||||
tags: []);
|
||||
}
|
||||
|
||||
class Peers extends ChangeNotifier {
|
||||
late String _name;
|
||||
late List<Peer> _peers;
|
||||
late final _loadEvent;
|
||||
static const _cbQueryOnlines = 'callback_query_onlines';
|
||||
|
||||
Peers(String name, String loadEvent, List<Peer> _initPeers) {
|
||||
_name = name;
|
||||
_loadEvent = loadEvent;
|
||||
_peers = _initPeers;
|
||||
platformFFI.registerEventHandler(_cbQueryOnlines, _name, (evt) {
|
||||
_updateOnlineState(evt);
|
||||
});
|
||||
platformFFI.registerEventHandler(_loadEvent, _name, (evt) {
|
||||
_updatePeers(evt);
|
||||
});
|
||||
}
|
||||
|
||||
List<Peer> get peers => _peers;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
platformFFI.unregisterEventHandler(_cbQueryOnlines, _name);
|
||||
platformFFI.unregisterEventHandler(_loadEvent, _name);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Peer getByIndex(int index) {
|
||||
if (index < _peers.length) {
|
||||
return _peers[index];
|
||||
} else {
|
||||
return Peer.loading();
|
||||
}
|
||||
}
|
||||
|
||||
int getPeersCount() {
|
||||
return _peers.length;
|
||||
}
|
||||
|
||||
void _updateOnlineState(Map<String, dynamic> evt) {
|
||||
evt['onlines'].split(',').forEach((online) {
|
||||
for (var i = 0; i < _peers.length; i++) {
|
||||
if (_peers[i].id == online) {
|
||||
_peers[i].online = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
evt['offlines'].split(',').forEach((offline) {
|
||||
for (var i = 0; i < _peers.length; i++) {
|
||||
if (_peers[i].id == offline) {
|
||||
_peers[i].online = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void _updatePeers(Map<String, dynamic> evt) {
|
||||
final onlineStates = _getOnlineStates();
|
||||
_peers = _decodePeers(evt['peers']);
|
||||
_peers.forEach((peer) {
|
||||
final state = onlineStates[peer.id];
|
||||
peer.online = state != null && state != false;
|
||||
});
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Map<String, bool> _getOnlineStates() {
|
||||
var onlineStates = new Map<String, bool>();
|
||||
_peers.forEach((peer) {
|
||||
onlineStates[peer.id] = peer.online;
|
||||
});
|
||||
return onlineStates;
|
||||
}
|
||||
|
||||
List<Peer> _decodePeers(String peersStr) {
|
||||
try {
|
||||
if (peersStr == "") return [];
|
||||
List<dynamic> peers = json.decode(peersStr);
|
||||
return peers
|
||||
.map((s) => s as List<dynamic>)
|
||||
.map((s) =>
|
||||
Peer.fromJson(s[0] as String, s[1] as Map<String, dynamic>))
|
||||
.toList();
|
||||
} catch (e) {
|
||||
print('peers(): $e');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
7
flutter/lib/models/platform_model.dart
Normal file
7
flutter/lib/models/platform_model.dart
Normal file
@@ -0,0 +1,7 @@
|
||||
import 'package:flutter_hbb/generated_bridge.dart';
|
||||
import 'native_model.dart' if (dart.library.html) 'web_model.dart';
|
||||
|
||||
final platformFFI = PlatformFFI.instance;
|
||||
final localeName = PlatformFFI.localeName;
|
||||
|
||||
RustdeskImpl get bind => platformFFI.ffiBind;
|
||||
@@ -1,13 +1,18 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/models/platform_model.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
|
||||
import '../common.dart';
|
||||
import '../pages/server_page.dart';
|
||||
import '../desktop/pages/server_page.dart' as Desktop;
|
||||
import '../desktop/widgets/tabbar_widget.dart';
|
||||
import '../mobile/pages/server_page.dart';
|
||||
import 'model.dart';
|
||||
|
||||
const loginDialogTag = "LOGIN";
|
||||
final _emptyIdShow = translate("Generating ...");
|
||||
const KLoginDialogTag = "LOGIN";
|
||||
|
||||
const kUseTemporaryPassword = "use-temporary-password";
|
||||
const kUsePermanentPassword = "use-permanent-password";
|
||||
@@ -21,11 +26,15 @@ class ServerModel with ChangeNotifier {
|
||||
bool _fileOk = false;
|
||||
int _connectStatus = 0; // Rendezvous Server status
|
||||
String _verificationMethod = "";
|
||||
String _temporaryPasswordLength = "";
|
||||
|
||||
final _serverId = TextEditingController(text: _emptyIdShow);
|
||||
late String _emptyIdShow;
|
||||
late final TextEditingController _serverId;
|
||||
final _serverPasswd = TextEditingController(text: "");
|
||||
|
||||
Map<int, Client> _clients = {};
|
||||
final tabController = DesktopTabController();
|
||||
|
||||
List<Client> _clients = [];
|
||||
|
||||
bool get isStart => _isStart;
|
||||
|
||||
@@ -39,57 +48,50 @@ class ServerModel with ChangeNotifier {
|
||||
|
||||
int get connectStatus => _connectStatus;
|
||||
|
||||
String get verificationMethod => _verificationMethod;
|
||||
String get verificationMethod {
|
||||
final index = [
|
||||
kUseTemporaryPassword,
|
||||
kUsePermanentPassword,
|
||||
kUseBothPasswords
|
||||
].indexOf(_verificationMethod);
|
||||
if (index < 0) {
|
||||
return kUseBothPasswords;
|
||||
}
|
||||
return _verificationMethod;
|
||||
}
|
||||
|
||||
set verificationMethod(String method) {
|
||||
bind.mainSetOption(key: "verification-method", value: method);
|
||||
}
|
||||
|
||||
String get temporaryPasswordLength {
|
||||
final lengthIndex = ["6", "8", "10"].indexOf(_temporaryPasswordLength);
|
||||
if (lengthIndex < 0) {
|
||||
return "6";
|
||||
}
|
||||
return _temporaryPasswordLength;
|
||||
}
|
||||
|
||||
set temporaryPasswordLength(String length) {
|
||||
bind.mainSetOption(key: "temporary-password-length", value: length);
|
||||
}
|
||||
|
||||
TextEditingController get serverId => _serverId;
|
||||
|
||||
TextEditingController get serverPasswd => _serverPasswd;
|
||||
|
||||
Map<int, Client> get clients => _clients;
|
||||
List<Client> get clients => _clients;
|
||||
|
||||
final controller = ScrollController();
|
||||
|
||||
ServerModel() {
|
||||
() async {
|
||||
/**
|
||||
* 1. check android permission
|
||||
* 2. check config
|
||||
* audio true by default (if permission on) (false default < Android 10)
|
||||
* file true by default (if permission on)
|
||||
*/
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
WeakReference<FFI> parent;
|
||||
|
||||
// audio
|
||||
if (androidVersion < 30 || !await PermissionManager.check("audio")) {
|
||||
_audioOk = false;
|
||||
FFI.setByName(
|
||||
'option',
|
||||
jsonEncode(Map()
|
||||
..["name"] = "enable-audio"
|
||||
..["value"] = "N"));
|
||||
} else {
|
||||
final audioOption = FFI.getByName('option', 'enable-audio');
|
||||
_audioOk = audioOption.isEmpty;
|
||||
}
|
||||
ServerModel(this.parent) {
|
||||
_emptyIdShow = translate("Generating ...");
|
||||
_serverId = TextEditingController(text: this._emptyIdShow);
|
||||
|
||||
// file
|
||||
if (!await PermissionManager.check("file")) {
|
||||
_fileOk = false;
|
||||
FFI.setByName(
|
||||
'option',
|
||||
jsonEncode(Map()
|
||||
..["name"] = "enable-file-transfer"
|
||||
..["value"] = "N"));
|
||||
} else {
|
||||
final fileOption = FFI.getByName('option', 'enable-file-transfer');
|
||||
_fileOk = fileOption.isEmpty;
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
}();
|
||||
|
||||
Timer.periodic(Duration(seconds: 1), (timer) {
|
||||
var status = int.tryParse(FFI.getByName('connect_statue')) ?? 0;
|
||||
Timer.periodic(Duration(seconds: 1), (timer) async {
|
||||
var status = await bind.mainGetOnlineStatue();
|
||||
if (status > 0) {
|
||||
status = 1;
|
||||
}
|
||||
@@ -97,9 +99,8 @@ class ServerModel with ChangeNotifier {
|
||||
_connectStatus = status;
|
||||
notifyListeners();
|
||||
}
|
||||
final res =
|
||||
FFI.getByName('check_clients_length', _clients.length.toString());
|
||||
if (res.isNotEmpty) {
|
||||
final res = await bind.mainCheckClientsLength(length: _clients.length);
|
||||
if (res != null) {
|
||||
debugPrint("clients not match!");
|
||||
updateClientState(res);
|
||||
}
|
||||
@@ -108,19 +109,59 @@ class ServerModel with ChangeNotifier {
|
||||
});
|
||||
}
|
||||
|
||||
updatePasswordModel() {
|
||||
var update = false;
|
||||
final temporaryPassword = FFI.getByName("temporary_password");
|
||||
final verificationMethod = FFI.getByName("option", "verification-method");
|
||||
if (_serverPasswd.text != temporaryPassword) {
|
||||
_serverPasswd.text = temporaryPassword;
|
||||
update = true;
|
||||
/// 1. check android permission
|
||||
/// 2. check config
|
||||
/// audio true by default (if permission on) (false default < Android 10)
|
||||
/// file true by default (if permission on)
|
||||
checkAndroidPermission() async {
|
||||
// audio
|
||||
if (androidVersion < 30 || !await PermissionManager.check("audio")) {
|
||||
_audioOk = false;
|
||||
bind.mainSetOption(key: "enable-audio", value: "N");
|
||||
} else {
|
||||
final audioOption = await bind.mainGetOption(key: 'enable-audio');
|
||||
_audioOk = audioOption.isEmpty;
|
||||
}
|
||||
|
||||
// file
|
||||
if (!await PermissionManager.check("file")) {
|
||||
_fileOk = false;
|
||||
bind.mainSetOption(key: "enable-file-transfer", value: "N");
|
||||
} else {
|
||||
final fileOption = await bind.mainGetOption(key: 'enable-file-transfer');
|
||||
_fileOk = fileOption.isEmpty;
|
||||
}
|
||||
|
||||
// input (mouse control) false by default
|
||||
bind.mainSetOption(key: "enable-keyboard", value: "N");
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
updatePasswordModel() async {
|
||||
var update = false;
|
||||
final temporaryPassword = await bind.mainGetTemporaryPassword();
|
||||
final verificationMethod =
|
||||
await bind.mainGetOption(key: "verification-method");
|
||||
final temporaryPasswordLength =
|
||||
await bind.mainGetOption(key: "temporary-password-length");
|
||||
final oldPwdText = _serverPasswd.text;
|
||||
if (_serverPasswd.text != temporaryPassword) {
|
||||
_serverPasswd.text = temporaryPassword;
|
||||
}
|
||||
if (verificationMethod == kUsePermanentPassword) {
|
||||
_serverPasswd.text = '-';
|
||||
}
|
||||
if (oldPwdText != _serverPasswd.text) {
|
||||
update = true;
|
||||
}
|
||||
if (_verificationMethod != verificationMethod) {
|
||||
_verificationMethod = verificationMethod;
|
||||
update = true;
|
||||
}
|
||||
if (_temporaryPasswordLength != temporaryPasswordLength) {
|
||||
_temporaryPasswordLength = temporaryPasswordLength;
|
||||
update = true;
|
||||
}
|
||||
if (update) {
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -136,10 +177,7 @@ class ServerModel with ChangeNotifier {
|
||||
}
|
||||
|
||||
_audioOk = !_audioOk;
|
||||
Map<String, String> res = Map()
|
||||
..["name"] = "enable-audio"
|
||||
..["value"] = _audioOk ? '' : 'N';
|
||||
FFI.setByName('option', jsonEncode(res));
|
||||
bind.mainSetOption(key: "enable-audio", value: _audioOk ? '' : 'N');
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -153,25 +191,25 @@ class ServerModel with ChangeNotifier {
|
||||
}
|
||||
|
||||
_fileOk = !_fileOk;
|
||||
Map<String, String> res = Map()
|
||||
..["name"] = "enable-file-transfer"
|
||||
..["value"] = _fileOk ? '' : 'N';
|
||||
FFI.setByName('option', jsonEncode(res));
|
||||
bind.mainSetOption(key: "enable-file-transfer", value: _fileOk ? '' : 'N');
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
toggleInput() {
|
||||
if (_inputOk) {
|
||||
FFI.invokeMethod("stop_input");
|
||||
parent.target?.invokeMethod("stop_input");
|
||||
} else {
|
||||
showInputWarnAlert();
|
||||
if (parent.target != null) {
|
||||
showInputWarnAlert(parent.target!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Toggle the screen sharing service.
|
||||
toggleService() async {
|
||||
if (_isStart) {
|
||||
final res =
|
||||
await DialogManager.show<bool>((setState, close) => CustomAlertDialog(
|
||||
final res = await parent.target?.dialogManager
|
||||
.show<bool>((setState, close) => CustomAlertDialog(
|
||||
title: Row(children: [
|
||||
Icon(Icons.warning_amber_sharp,
|
||||
color: Colors.redAccent, size: 28),
|
||||
@@ -192,8 +230,8 @@ class ServerModel with ChangeNotifier {
|
||||
stopService();
|
||||
}
|
||||
} else {
|
||||
final res =
|
||||
await DialogManager.show<bool>((setState, close) => CustomAlertDialog(
|
||||
final res = await parent.target?.dialogManager
|
||||
.show<bool>((setState, close) => CustomAlertDialog(
|
||||
title: Row(children: [
|
||||
Icon(Icons.warning_amber_sharp,
|
||||
color: Colors.redAccent, size: 28),
|
||||
@@ -216,34 +254,44 @@ class ServerModel with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// Start the screen sharing service.
|
||||
Future<Null> startService() async {
|
||||
_isStart = true;
|
||||
notifyListeners();
|
||||
FFI.ffiModel.updateEventListener("");
|
||||
await FFI.invokeMethod("init_service");
|
||||
FFI.setByName("start_service");
|
||||
// TODO
|
||||
parent.target?.ffiModel.updateEventListener("");
|
||||
await parent.target?.invokeMethod("init_service");
|
||||
await bind.mainStartService();
|
||||
_fetchID();
|
||||
updateClientState();
|
||||
Wakelock.enable();
|
||||
if (!Platform.isLinux) {
|
||||
// current linux is not supported
|
||||
Wakelock.enable();
|
||||
}
|
||||
}
|
||||
|
||||
/// Stop the screen sharing service.
|
||||
Future<Null> stopService() async {
|
||||
_isStart = false;
|
||||
FFI.serverModel.closeAll();
|
||||
await FFI.invokeMethod("stop_service");
|
||||
FFI.setByName("stop_service");
|
||||
// TODO
|
||||
closeAll();
|
||||
await parent.target?.invokeMethod("stop_service");
|
||||
await bind.mainStopService();
|
||||
notifyListeners();
|
||||
Wakelock.disable();
|
||||
if (!Platform.isLinux) {
|
||||
// current linux is not supported
|
||||
Wakelock.disable();
|
||||
}
|
||||
}
|
||||
|
||||
Future<Null> initInput() async {
|
||||
await FFI.invokeMethod("init_input");
|
||||
await parent.target?.invokeMethod("init_input");
|
||||
}
|
||||
|
||||
Future<bool> setPermanentPassword(String newPW) async {
|
||||
FFI.setByName("permanent_password", newPW);
|
||||
await bind.mainSetPermanentPassword(password: newPW);
|
||||
await Future.delayed(Duration(milliseconds: 500));
|
||||
final pw = FFI.getByName("permanent_password", newPW);
|
||||
final pw = await bind.mainGetPermanentPassword();
|
||||
if (newPW == pw) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -257,7 +305,7 @@ class ServerModel with ChangeNotifier {
|
||||
const maxCount = 10;
|
||||
while (count < maxCount) {
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
final id = FFI.getByName("server_id");
|
||||
final id = await bind.mainGetMyId();
|
||||
if (id.isEmpty) {
|
||||
continue;
|
||||
} else {
|
||||
@@ -284,10 +332,7 @@ class ServerModel with ChangeNotifier {
|
||||
break;
|
||||
case "input":
|
||||
if (_inputOk != value) {
|
||||
Map<String, String> res = Map()
|
||||
..["name"] = "enable-keyboard"
|
||||
..["value"] = value ? '' : 'N';
|
||||
FFI.setByName('option', jsonEncode(res));
|
||||
bind.mainSetOption(key: "enable-keyboard", value: value ? '' : 'N');
|
||||
}
|
||||
_inputOk = value;
|
||||
break;
|
||||
@@ -297,13 +342,25 @@ class ServerModel with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
updateClientState([String? json]) {
|
||||
var res = json ?? FFI.getByName("clients_state");
|
||||
// force
|
||||
updateClientState([String? json]) async {
|
||||
var res = await bind.mainGetClientsState();
|
||||
try {
|
||||
final List clientsJson = jsonDecode(res);
|
||||
if (isDesktop && clientsJson.isEmpty && _clients.isNotEmpty) {
|
||||
// exit cm when >1 peers to no peers
|
||||
exit(0);
|
||||
}
|
||||
_clients.clear();
|
||||
tabController.state.value.tabs.clear();
|
||||
for (var clientJson in clientsJson) {
|
||||
final client = Client.fromJson(clientJson);
|
||||
_clients[client.id] = client;
|
||||
_clients.add(client);
|
||||
tabController.add(TabInfo(
|
||||
key: client.id.toString(),
|
||||
label: client.name,
|
||||
closable: false,
|
||||
page: Desktop.buildConnectionCard(client)));
|
||||
}
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
@@ -314,20 +371,25 @@ class ServerModel with ChangeNotifier {
|
||||
void loginRequest(Map<String, dynamic> evt) {
|
||||
try {
|
||||
final client = Client.fromJson(jsonDecode(evt["client"]));
|
||||
if (_clients.containsKey(client.id)) {
|
||||
if (_clients.any((c) => c.id == client.id)) {
|
||||
return;
|
||||
}
|
||||
_clients[client.id] = client;
|
||||
_clients.add(client);
|
||||
tabController.add(TabInfo(
|
||||
key: client.id.toString(),
|
||||
label: client.name,
|
||||
closable: false,
|
||||
page: Desktop.buildConnectionCard(client)));
|
||||
scrollToBottom();
|
||||
notifyListeners();
|
||||
showLoginDialog(client);
|
||||
if (isAndroid) showLoginDialog(client);
|
||||
} catch (e) {
|
||||
debugPrint("Failed to call loginRequest,error:$e");
|
||||
}
|
||||
}
|
||||
|
||||
void showLoginDialog(Client client) {
|
||||
DialogManager.show(
|
||||
parent.target?.dialogManager.show(
|
||||
(setState, close) => CustomAlertDialog(
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
@@ -373,6 +435,7 @@ class ServerModel with ChangeNotifier {
|
||||
}
|
||||
|
||||
scrollToBottom() {
|
||||
if (isDesktop) return;
|
||||
Future.delayed(Duration(milliseconds: 200), () {
|
||||
controller.animateTo(controller.position.maxScrollExtent,
|
||||
duration: Duration(milliseconds: 200),
|
||||
@@ -380,30 +443,39 @@ class ServerModel with ChangeNotifier {
|
||||
});
|
||||
}
|
||||
|
||||
void sendLoginResponse(Client client, bool res) {
|
||||
final Map<String, dynamic> response = Map();
|
||||
response["id"] = client.id;
|
||||
response["res"] = res;
|
||||
void sendLoginResponse(Client client, bool res) async {
|
||||
if (res) {
|
||||
FFI.setByName("login_res", jsonEncode(response));
|
||||
bind.cmLoginRes(connId: client.id, res: res);
|
||||
if (!client.isFileTransfer) {
|
||||
FFI.invokeMethod("start_capture");
|
||||
parent.target?.invokeMethod("start_capture");
|
||||
}
|
||||
FFI.invokeMethod("cancel_notification", client.id);
|
||||
_clients[client.id]?.authorized = true;
|
||||
parent.target?.invokeMethod("cancel_notification", client.id);
|
||||
client.authorized = true;
|
||||
notifyListeners();
|
||||
} else {
|
||||
FFI.setByName("login_res", jsonEncode(response));
|
||||
FFI.invokeMethod("cancel_notification", client.id);
|
||||
_clients.remove(client.id);
|
||||
bind.cmLoginRes(connId: client.id, res: res);
|
||||
parent.target?.invokeMethod("cancel_notification", client.id);
|
||||
final index = _clients.indexOf(client);
|
||||
tabController.remove(index);
|
||||
_clients.remove(client);
|
||||
}
|
||||
}
|
||||
|
||||
void onClientAuthorized(Map<String, dynamic> evt) {
|
||||
try {
|
||||
final client = Client.fromJson(jsonDecode(evt['client']));
|
||||
DialogManager.dismissByTag(getLoginDialogTag(client.id));
|
||||
_clients[client.id] = client;
|
||||
parent.target?.dialogManager.dismissByTag(getLoginDialogTag(client.id));
|
||||
final index = _clients.indexWhere((c) => c.id == client.id);
|
||||
if (index < 0) {
|
||||
_clients.add(client);
|
||||
} else {
|
||||
_clients[index].authorized = true;
|
||||
}
|
||||
tabController.add(TabInfo(
|
||||
key: client.id.toString(),
|
||||
label: client.name,
|
||||
closable: false,
|
||||
page: Desktop.buildConnectionCard(client)));
|
||||
scrollToBottom();
|
||||
notifyListeners();
|
||||
} catch (e) {}
|
||||
@@ -412,10 +484,12 @@ class ServerModel with ChangeNotifier {
|
||||
void onClientRemove(Map<String, dynamic> evt) {
|
||||
try {
|
||||
final id = int.parse(evt['id'] as String);
|
||||
if (_clients.containsKey(id)) {
|
||||
_clients.remove(id);
|
||||
DialogManager.dismissByTag(getLoginDialogTag(id));
|
||||
FFI.invokeMethod("cancel_notification", id);
|
||||
if (_clients.any((c) => c.id == id)) {
|
||||
final index = _clients.indexWhere((client) => client.id == id);
|
||||
_clients.removeAt(index);
|
||||
tabController.remove(index);
|
||||
parent.target?.dialogManager.dismissByTag(getLoginDialogTag(id));
|
||||
parent.target?.invokeMethod("cancel_notification", id);
|
||||
}
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
@@ -424,10 +498,16 @@ class ServerModel with ChangeNotifier {
|
||||
}
|
||||
|
||||
closeAll() {
|
||||
_clients.forEach((id, client) {
|
||||
FFI.setByName("close_conn", id.toString());
|
||||
_clients.forEach((client) {
|
||||
bind.cmCloseConnection(connId: client.id);
|
||||
});
|
||||
_clients.clear();
|
||||
tabController.state.value.tabs.clear();
|
||||
}
|
||||
|
||||
void jumpTo(int id) {
|
||||
final index = _clients.indexWhere((client) => client.id == id);
|
||||
tabController.jumpTo(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,8 +520,10 @@ class Client {
|
||||
bool keyboard = false;
|
||||
bool clipboard = false;
|
||||
bool audio = false;
|
||||
bool file = false;
|
||||
bool restart = false;
|
||||
|
||||
Client(this.authorized, this.isFileTransfer, this.name, this.peerId,
|
||||
Client(this.id, this.authorized, this.isFileTransfer, this.name, this.peerId,
|
||||
this.keyboard, this.clipboard, this.audio);
|
||||
|
||||
Client.fromJson(Map<String, dynamic> json) {
|
||||
@@ -453,6 +535,8 @@ class Client {
|
||||
keyboard = json['keyboard'];
|
||||
clipboard = json['clipboard'];
|
||||
audio = json['audio'];
|
||||
file = json['file'];
|
||||
restart = json['restart'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@@ -470,11 +554,11 @@ class Client {
|
||||
}
|
||||
|
||||
String getLoginDialogTag(int id) {
|
||||
return loginDialogTag + id.toString();
|
||||
return KLoginDialogTag + id.toString();
|
||||
}
|
||||
|
||||
showInputWarnAlert() {
|
||||
DialogManager.show((setState, close) => CustomAlertDialog(
|
||||
showInputWarnAlert(FFI ffi) {
|
||||
ffi.dialogManager.show((setState, close) => CustomAlertDialog(
|
||||
title: Text(translate("How to get Android input permission?")),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -489,7 +573,7 @@ showInputWarnAlert() {
|
||||
ElevatedButton(
|
||||
child: Text(translate("Open System Setting")),
|
||||
onPressed: () {
|
||||
FFI.serverModel.initInput();
|
||||
ffi.serverModel.initInput();
|
||||
close();
|
||||
}),
|
||||
],
|
||||
|
||||
75
flutter/lib/models/user_model.dart
Normal file
75
flutter/lib/models/user_model.dart
Normal file
@@ -0,0 +1,75 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import 'model.dart';
|
||||
import 'platform_model.dart';
|
||||
|
||||
class UserModel extends ChangeNotifier {
|
||||
var userName = "".obs;
|
||||
WeakReference<FFI> parent;
|
||||
|
||||
UserModel(this.parent);
|
||||
|
||||
Future<String> getUserName() async {
|
||||
if (userName.isNotEmpty) {
|
||||
return userName.value;
|
||||
}
|
||||
final userInfo = await bind.mainGetLocalOption(key: 'user_info');
|
||||
if (userInfo.trim().isEmpty) {
|
||||
return "";
|
||||
}
|
||||
final m = jsonDecode(userInfo);
|
||||
userName.value = m['name'] ?? '';
|
||||
return userName.value;
|
||||
}
|
||||
|
||||
Future<void> logOut() async {
|
||||
debugPrint("start logout");
|
||||
final url = await bind.mainGetApiServer();
|
||||
final _ = await http.post(Uri.parse("$url/api/logout"),
|
||||
body: {
|
||||
"id": await bind.mainGetMyId(),
|
||||
"uuid": await bind.mainGetUuid(),
|
||||
},
|
||||
headers: await _getHeaders());
|
||||
await Future.wait([
|
||||
bind.mainSetLocalOption(key: 'access_token', value: ''),
|
||||
bind.mainSetLocalOption(key: 'user_info', value: ''),
|
||||
bind.mainSetLocalOption(key: 'selected-tags', value: ''),
|
||||
]);
|
||||
parent.target?.abModel.clear();
|
||||
userName.value = "";
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<Map<String, String>>? _getHeaders() {
|
||||
return parent.target?.getHttpHeaders();
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> login(String userName, String pass) async {
|
||||
final url = await bind.mainGetApiServer();
|
||||
try {
|
||||
final resp = await http.post(Uri.parse("$url/api/login"),
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: jsonEncode({
|
||||
"username": userName,
|
||||
"password": pass,
|
||||
"id": await bind.mainGetMyId(),
|
||||
"uuid": await bind.mainGetUuid()
|
||||
}));
|
||||
final body = jsonDecode(resp.body);
|
||||
bind.mainSetLocalOption(
|
||||
key: "access_token", value: body['access_token'] ?? "");
|
||||
bind.mainSetLocalOption(
|
||||
key: "user_info", value: jsonEncode(body['user']));
|
||||
this.userName.value = body['user']?['name'] ?? "";
|
||||
return body;
|
||||
} catch (err) {
|
||||
return {"error": "$err"};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,9 +20,14 @@ class PlatformFFI {
|
||||
context.callMethod('setByName', [name, value]);
|
||||
}
|
||||
|
||||
static Future<Null> init() async {
|
||||
PlatformFFI._();
|
||||
static final PlatformFFI instance = PlatformFFI._();
|
||||
|
||||
static get localeName => window.navigator.language;
|
||||
|
||||
static Future<Null> init(String _appType) async {
|
||||
isWeb = true;
|
||||
isDesktop = !context.callMethod('isMobile');
|
||||
isWebDesktop = !context.callMethod('isMobile');
|
||||
context.callMethod('init');
|
||||
version = getByName('version');
|
||||
}
|
||||
@@ -68,5 +73,3 @@ class PlatformFFI {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
final localeName = window.navigator.language;
|
||||
|
||||
145
flutter/lib/utils/multi_window_manager.dart
Normal file
145
flutter/lib/utils/multi_window_manager.dart
Normal file
@@ -0,0 +1,145 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
/// must keep the order
|
||||
enum WindowType { Main, RemoteDesktop, FileTransfer, PortForward, Unknown }
|
||||
|
||||
extension Index on int {
|
||||
WindowType get windowType {
|
||||
switch (this) {
|
||||
case 0:
|
||||
return WindowType.Main;
|
||||
case 1:
|
||||
return WindowType.RemoteDesktop;
|
||||
case 2:
|
||||
return WindowType.FileTransfer;
|
||||
case 3:
|
||||
return WindowType.PortForward;
|
||||
default:
|
||||
return WindowType.Unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Window Manager
|
||||
/// mainly use it in `Main Window`
|
||||
/// use it in sub window is not recommended
|
||||
class RustDeskMultiWindowManager {
|
||||
RustDeskMultiWindowManager._();
|
||||
|
||||
static final instance = RustDeskMultiWindowManager._();
|
||||
|
||||
int? _remoteDesktopWindowId;
|
||||
int? _fileTransferWindowId;
|
||||
|
||||
Future<dynamic> new_remote_desktop(String remote_id) async {
|
||||
final msg =
|
||||
jsonEncode({"type": WindowType.RemoteDesktop.index, "id": remote_id});
|
||||
|
||||
try {
|
||||
final ids = await DesktopMultiWindow.getAllSubWindowIds();
|
||||
if (!ids.contains(_remoteDesktopWindowId)) {
|
||||
_remoteDesktopWindowId = null;
|
||||
}
|
||||
} on Error {
|
||||
_remoteDesktopWindowId = null;
|
||||
}
|
||||
if (_remoteDesktopWindowId == null) {
|
||||
final remoteDesktopController =
|
||||
await DesktopMultiWindow.createWindow(msg);
|
||||
remoteDesktopController
|
||||
..setFrame(const Offset(0, 0) & const Size(1280, 720))
|
||||
..center()
|
||||
..setTitle("rustdesk - remote desktop")
|
||||
..show();
|
||||
_remoteDesktopWindowId = remoteDesktopController.windowId;
|
||||
} else {
|
||||
return call(WindowType.RemoteDesktop, "new_remote_desktop", msg);
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> new_file_transfer(String remote_id) async {
|
||||
final msg =
|
||||
jsonEncode({"type": WindowType.FileTransfer.index, "id": remote_id});
|
||||
|
||||
try {
|
||||
final ids = await DesktopMultiWindow.getAllSubWindowIds();
|
||||
if (!ids.contains(_fileTransferWindowId)) {
|
||||
_fileTransferWindowId = null;
|
||||
}
|
||||
} on Error {
|
||||
_fileTransferWindowId = null;
|
||||
}
|
||||
if (_fileTransferWindowId == null) {
|
||||
final fileTransferController = await DesktopMultiWindow.createWindow(msg);
|
||||
fileTransferController
|
||||
..setFrame(const Offset(0, 0) & const Size(1280, 720))
|
||||
..center()
|
||||
..setTitle("rustdesk - file transfer")
|
||||
..show();
|
||||
_fileTransferWindowId = fileTransferController.windowId;
|
||||
} else {
|
||||
return call(WindowType.FileTransfer, "new_file_transfer", msg);
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> call(WindowType type, String methodName, dynamic args) async {
|
||||
int? windowId = findWindowByType(type);
|
||||
if (windowId == null) {
|
||||
return;
|
||||
}
|
||||
return await DesktopMultiWindow.invokeMethod(windowId, methodName, args);
|
||||
}
|
||||
|
||||
int? findWindowByType(WindowType type) {
|
||||
switch (type) {
|
||||
case WindowType.Main:
|
||||
return 0;
|
||||
case WindowType.RemoteDesktop:
|
||||
return _remoteDesktopWindowId;
|
||||
case WindowType.FileTransfer:
|
||||
return _fileTransferWindowId;
|
||||
case WindowType.PortForward:
|
||||
break;
|
||||
case WindowType.Unknown:
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void setMethodHandler(
|
||||
Future<dynamic> Function(MethodCall call, int fromWindowId)? handler) {
|
||||
DesktopMultiWindow.setMethodHandler(handler);
|
||||
}
|
||||
|
||||
Future<void> closeAllSubWindows() async {
|
||||
await Future.wait(WindowType.values.map((e) => closeWindows(e)));
|
||||
}
|
||||
|
||||
Future<void> closeWindows(WindowType type) async {
|
||||
if (type == WindowType.Main) {
|
||||
// skip main window, use window manager instead
|
||||
return;
|
||||
}
|
||||
int? wId = findWindowByType(type);
|
||||
if (wId != null) {
|
||||
debugPrint("closing multi window: ${type.toString()}");
|
||||
try {
|
||||
final ids = await DesktopMultiWindow.getAllSubWindowIds();
|
||||
if (!ids.contains(wId)) {
|
||||
// no such window already
|
||||
return;
|
||||
}
|
||||
await WindowController.fromWindowId(wId).close();
|
||||
} on Error {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final rustDeskWinManager = RustDeskMultiWindowManager.instance;
|
||||
23
flutter/lib/utils/tray_manager.dart
Normal file
23
flutter/lib/utils/tray_manager.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:tray_manager/tray_manager.dart';
|
||||
|
||||
import '../common.dart';
|
||||
|
||||
Future<void> initTray({List<MenuItem>? extra_item}) async {
|
||||
List<MenuItem> items = [
|
||||
MenuItem(key: "show", label: translate("show rustdesk")),
|
||||
MenuItem.separator(),
|
||||
MenuItem(key: "quit", label: translate("quit rustdesk")),
|
||||
];
|
||||
if (extra_item != null) {
|
||||
items.insertAll(0, extra_item);
|
||||
}
|
||||
await Future.wait([
|
||||
trayManager
|
||||
.setIcon(Platform.isWindows ? "assets/logo.ico" : "assets/logo.png"),
|
||||
trayManager.setContextMenu(Menu(items: items)),
|
||||
trayManager.setToolTip("rustdesk"),
|
||||
trayManager.setTitle("rustdesk")
|
||||
]);
|
||||
}
|
||||
1
flutter/linux/.gitignore
vendored
Normal file
1
flutter/linux/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
flutter/ephemeral
|
||||
158
flutter/linux/CMakeLists.txt
Normal file
158
flutter/linux/CMakeLists.txt
Normal file
@@ -0,0 +1,158 @@
|
||||
# Project-level configuration.
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(runner LANGUAGES CXX)
|
||||
|
||||
# The name of the executable created for the application. Change this to change
|
||||
# the on-disk name of your application.
|
||||
set(BINARY_NAME "flutter_hbb")
|
||||
# The unique GTK application identifier for this application. See:
|
||||
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
|
||||
set(APPLICATION_ID "com.carriez.flutter_hbb")
|
||||
|
||||
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
|
||||
# versions of CMake.
|
||||
cmake_policy(SET CMP0063 NEW)
|
||||
|
||||
# Load bundled libraries from the lib/ directory relative to the binary.
|
||||
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
|
||||
|
||||
# Root filesystem for cross-building.
|
||||
if(FLUTTER_TARGET_PLATFORM_SYSROOT)
|
||||
set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
|
||||
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
endif()
|
||||
|
||||
# Define build configuration options.
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE "Debug" CACHE
|
||||
STRING "Flutter build mode" FORCE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
"Debug" "Profile" "Release")
|
||||
endif()
|
||||
|
||||
# Compilation settings that should be applied to most targets.
|
||||
#
|
||||
# Be cautious about adding new options here, as plugins use this function by
|
||||
# default. In most cases, you should add new options to specific targets instead
|
||||
# of modifying this function.
|
||||
function(APPLY_STANDARD_SETTINGS TARGET)
|
||||
target_compile_features(${TARGET} PUBLIC cxx_std_14)
|
||||
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
|
||||
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
|
||||
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
|
||||
endfunction()
|
||||
|
||||
# Flutter library and tool build rules.
|
||||
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
|
||||
add_subdirectory(${FLUTTER_MANAGED_DIR})
|
||||
|
||||
# System-level dependencies.
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
|
||||
|
||||
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
|
||||
|
||||
# flutter_rust_bridge
|
||||
find_package(Corrosion REQUIRED)
|
||||
|
||||
corrosion_import_crate(MANIFEST_PATH ../../Cargo.toml
|
||||
# Equivalent to --all-features passed to cargo build
|
||||
# [ALL_FEATURES]
|
||||
# Equivalent to --no-default-features passed to cargo build
|
||||
# [NO_DEFAULT_FEATURES]
|
||||
# Disable linking of standard libraries (required for no_std crates).
|
||||
# [NO_STD]
|
||||
# Specify cargo build profile (e.g. release or a custom profile)
|
||||
# [PROFILE <cargo-profile>]
|
||||
# Only import the specified crates from a workspace
|
||||
# [CRATES <crate1> ... <crateN>]
|
||||
# Enable the specified features
|
||||
# [FEATURES <feature1> ... <featureN>]
|
||||
)
|
||||
|
||||
# Define the application target. To change its name, change BINARY_NAME above,
|
||||
# not the value here, or `flutter run` will no longer work.
|
||||
#
|
||||
# Any new source files that you add to the application should be added here.
|
||||
add_executable(${BINARY_NAME}
|
||||
"main.cc"
|
||||
"my_application.cc"
|
||||
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
|
||||
)
|
||||
|
||||
# Apply the standard set of build settings. This can be removed for applications
|
||||
# that need different build settings.
|
||||
apply_standard_settings(${BINARY_NAME})
|
||||
|
||||
# Add dependency libraries. Add any application-specific dependencies here.
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
|
||||
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE librustdesk)
|
||||
|
||||
# Run the Flutter tool portions of the build. This must not be removed.
|
||||
add_dependencies(${BINARY_NAME} flutter_assemble)
|
||||
|
||||
# Only the install-generated bundle's copy of the executable will launch
|
||||
# correctly, since the resources must in the right relative locations. To avoid
|
||||
# people trying to run the unbundled copy, put it in a subdirectory instead of
|
||||
# the default top-level location.
|
||||
set_target_properties(${BINARY_NAME}
|
||||
PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
|
||||
)
|
||||
|
||||
# Generated plugin build rules, which manage building the plugins and adding
|
||||
# them to the application.
|
||||
include(flutter/generated_plugins.cmake)
|
||||
|
||||
|
||||
# === Installation ===
|
||||
# By default, "installing" just makes a relocatable bundle in the build
|
||||
# directory.
|
||||
set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
|
||||
#if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
|
||||
#endif()
|
||||
|
||||
# Start with a clean build bundle directory every time.
|
||||
install(CODE "
|
||||
file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
|
||||
" COMPONENT Runtime)
|
||||
|
||||
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
|
||||
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
|
||||
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
|
||||
install(FILES "${bundled_library}"
|
||||
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
endforeach(bundled_library)
|
||||
|
||||
# Fully re-copy the assets directory on each build to avoid having stale files
|
||||
# from a previous install.
|
||||
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
|
||||
install(CODE "
|
||||
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
|
||||
" COMPONENT Runtime)
|
||||
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
|
||||
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
|
||||
|
||||
# Install the AOT library on non-Debug builds only.
|
||||
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
endif()
|
||||
88
flutter/linux/flutter/CMakeLists.txt
Normal file
88
flutter/linux/flutter/CMakeLists.txt
Normal file
@@ -0,0 +1,88 @@
|
||||
# This file controls Flutter-level build steps. It should not be edited.
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
|
||||
|
||||
# Configuration provided via flutter tool.
|
||||
include(${EPHEMERAL_DIR}/generated_config.cmake)
|
||||
|
||||
# TODO: Move the rest of this into files in ephemeral. See
|
||||
# https://github.com/flutter/flutter/issues/57146.
|
||||
|
||||
# Serves the same purpose as list(TRANSFORM ... PREPEND ...),
|
||||
# which isn't available in 3.10.
|
||||
function(list_prepend LIST_NAME PREFIX)
|
||||
set(NEW_LIST "")
|
||||
foreach(element ${${LIST_NAME}})
|
||||
list(APPEND NEW_LIST "${PREFIX}${element}")
|
||||
endforeach(element)
|
||||
set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# === Flutter Library ===
|
||||
# System-level dependencies.
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
|
||||
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
|
||||
pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
|
||||
|
||||
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
|
||||
|
||||
# Published to parent scope for install step.
|
||||
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
|
||||
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
|
||||
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
|
||||
set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
|
||||
|
||||
list(APPEND FLUTTER_LIBRARY_HEADERS
|
||||
"fl_basic_message_channel.h"
|
||||
"fl_binary_codec.h"
|
||||
"fl_binary_messenger.h"
|
||||
"fl_dart_project.h"
|
||||
"fl_engine.h"
|
||||
"fl_json_message_codec.h"
|
||||
"fl_json_method_codec.h"
|
||||
"fl_message_codec.h"
|
||||
"fl_method_call.h"
|
||||
"fl_method_channel.h"
|
||||
"fl_method_codec.h"
|
||||
"fl_method_response.h"
|
||||
"fl_plugin_registrar.h"
|
||||
"fl_plugin_registry.h"
|
||||
"fl_standard_message_codec.h"
|
||||
"fl_standard_method_codec.h"
|
||||
"fl_string_codec.h"
|
||||
"fl_value.h"
|
||||
"fl_view.h"
|
||||
"flutter_linux.h"
|
||||
)
|
||||
list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
|
||||
add_library(flutter INTERFACE)
|
||||
target_include_directories(flutter INTERFACE
|
||||
"${EPHEMERAL_DIR}"
|
||||
)
|
||||
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
|
||||
target_link_libraries(flutter INTERFACE
|
||||
PkgConfig::GTK
|
||||
PkgConfig::GLIB
|
||||
PkgConfig::GIO
|
||||
)
|
||||
add_dependencies(flutter flutter_assemble)
|
||||
|
||||
# === Flutter tool backend ===
|
||||
# _phony_ is a non-existent file to force this command to run every time,
|
||||
# since currently there's no way to get a full input/output list from the
|
||||
# flutter tool.
|
||||
add_custom_command(
|
||||
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/_phony_
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
${FLUTTER_TOOL_ENVIRONMENT}
|
||||
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
|
||||
${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(flutter_assemble DEPENDS
|
||||
"${FLUTTER_LIBRARY}"
|
||||
${FLUTTER_LIBRARY_HEADERS}
|
||||
)
|
||||
28
flutter/linux/main.cc
Normal file
28
flutter/linux/main.cc
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <dlfcn.h>
|
||||
#include "my_application.h"
|
||||
|
||||
#define RUSTDESK_LIB_PATH "/usr/lib/rustdesk/librustdesk.so"
|
||||
typedef bool (*RustDeskCoreMain)();
|
||||
|
||||
bool flutter_rustdesk_core_main() {
|
||||
void* librustdesk = dlopen(RUSTDESK_LIB_PATH, RTLD_LAZY);
|
||||
if (!librustdesk) {
|
||||
fprintf(stderr,"load librustdesk.so failed\n");
|
||||
return true;
|
||||
}
|
||||
auto core_main = (RustDeskCoreMain) dlsym(librustdesk,"rustdesk_core_main");
|
||||
char* error;
|
||||
if ((error = dlerror()) != nullptr) {
|
||||
fprintf(stderr, "error finding rustdesk_core_main: %s", error);
|
||||
return true;
|
||||
}
|
||||
return core_main();
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if (!flutter_rustdesk_core_main()) {
|
||||
return 0;
|
||||
}
|
||||
g_autoptr(MyApplication) app = my_application_new();
|
||||
return g_application_run(G_APPLICATION(app), argc, argv);
|
||||
}
|
||||
106
flutter/linux/my_application.cc
Normal file
106
flutter/linux/my_application.cc
Normal file
@@ -0,0 +1,106 @@
|
||||
#include "my_application.h"
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include <gdk/gdkx.h>
|
||||
#endif
|
||||
|
||||
#include "flutter/generated_plugin_registrant.h"
|
||||
|
||||
struct _MyApplication {
|
||||
GtkApplication parent_instance;
|
||||
char** dart_entrypoint_arguments;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
|
||||
|
||||
// Implements GApplication::activate.
|
||||
static void my_application_activate(GApplication* application) {
|
||||
MyApplication* self = MY_APPLICATION(application);
|
||||
GtkWindow* window =
|
||||
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
|
||||
|
||||
// Use a header bar when running in GNOME as this is the common style used
|
||||
// by applications and is the setup most users will be using (e.g. Ubuntu
|
||||
// desktop).
|
||||
// If running on X and not using GNOME then just use a traditional title bar
|
||||
// in case the window manager does more exotic layout, e.g. tiling.
|
||||
// If running on Wayland assume the header bar will work (may need changing
|
||||
// if future cases occur).
|
||||
gboolean use_header_bar = TRUE;
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
GdkScreen* screen = gtk_window_get_screen(window);
|
||||
if (GDK_IS_X11_SCREEN(screen)) {
|
||||
const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
|
||||
if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
|
||||
use_header_bar = FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (use_header_bar) {
|
||||
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
|
||||
gtk_widget_show(GTK_WIDGET(header_bar));
|
||||
gtk_header_bar_set_title(header_bar, "rustdesk");
|
||||
gtk_header_bar_set_show_close_button(header_bar, TRUE);
|
||||
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
|
||||
} else {
|
||||
gtk_window_set_title(window, "rustdesk");
|
||||
}
|
||||
|
||||
// auto bdw = bitsdojo_window_from(window); // <--- add this line
|
||||
// bdw->setCustomFrame(true); // <-- add this line
|
||||
gtk_window_set_default_size(window, 1280, 720); // <-- comment this line
|
||||
gtk_widget_show(GTK_WIDGET(window));
|
||||
|
||||
g_autoptr(FlDartProject) project = fl_dart_project_new();
|
||||
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
|
||||
|
||||
FlView* view = fl_view_new(project);
|
||||
gtk_widget_show(GTK_WIDGET(view));
|
||||
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
|
||||
|
||||
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
|
||||
|
||||
gtk_widget_grab_focus(GTK_WIDGET(view));
|
||||
}
|
||||
|
||||
// Implements GApplication::local_command_line.
|
||||
static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) {
|
||||
MyApplication* self = MY_APPLICATION(application);
|
||||
// Strip out the first argument as it is the binary name.
|
||||
self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
|
||||
|
||||
g_autoptr(GError) error = nullptr;
|
||||
if (!g_application_register(application, nullptr, &error)) {
|
||||
g_warning("Failed to register: %s", error->message);
|
||||
*exit_status = 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_application_activate(application);
|
||||
*exit_status = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Implements GObject::dispose.
|
||||
static void my_application_dispose(GObject* object) {
|
||||
MyApplication* self = MY_APPLICATION(object);
|
||||
g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
|
||||
G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
|
||||
}
|
||||
|
||||
static void my_application_class_init(MyApplicationClass* klass) {
|
||||
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
|
||||
G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
|
||||
G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
|
||||
}
|
||||
|
||||
static void my_application_init(MyApplication* self) {}
|
||||
|
||||
MyApplication* my_application_new() {
|
||||
return MY_APPLICATION(g_object_new(my_application_get_type(),
|
||||
"application-id", APPLICATION_ID,
|
||||
"flags", G_APPLICATION_NON_UNIQUE,
|
||||
nullptr));
|
||||
}
|
||||
18
flutter/linux/my_application.h
Normal file
18
flutter/linux/my_application.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef FLUTTER_MY_APPLICATION_H_
|
||||
#define FLUTTER_MY_APPLICATION_H_
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
|
||||
GtkApplication)
|
||||
|
||||
/**
|
||||
* my_application_new:
|
||||
*
|
||||
* Creates a new Flutter-based application.
|
||||
*
|
||||
* Returns: a new #MyApplication.
|
||||
*/
|
||||
MyApplication* my_application_new();
|
||||
|
||||
#endif // FLUTTER_MY_APPLICATION_H_
|
||||
7
flutter/macos/.gitignore
vendored
Normal file
7
flutter/macos/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# Flutter-related
|
||||
**/Flutter/ephemeral/
|
||||
**/Pods/
|
||||
|
||||
# Xcode-related
|
||||
**/dgph
|
||||
**/xcuserdata/
|
||||
2
flutter/macos/Flutter/Flutter-Debug.xcconfig
Normal file
2
flutter/macos/Flutter/Flutter-Debug.xcconfig
Normal file
@@ -0,0 +1,2 @@
|
||||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
|
||||
#include "ephemeral/Flutter-Generated.xcconfig"
|
||||
2
flutter/macos/Flutter/Flutter-Release.xcconfig
Normal file
2
flutter/macos/Flutter/Flutter-Release.xcconfig
Normal file
@@ -0,0 +1,2 @@
|
||||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
|
||||
#include "ephemeral/Flutter-Generated.xcconfig"
|
||||
40
flutter/macos/Podfile
Normal file
40
flutter/macos/Podfile
Normal file
@@ -0,0 +1,40 @@
|
||||
platform :osx, '10.12'
|
||||
|
||||
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
|
||||
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
|
||||
|
||||
project 'Runner', {
|
||||
'Debug' => :debug,
|
||||
'Profile' => :release,
|
||||
'Release' => :release,
|
||||
}
|
||||
|
||||
def flutter_root
|
||||
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
|
||||
unless File.exist?(generated_xcode_build_settings_path)
|
||||
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
|
||||
end
|
||||
|
||||
File.foreach(generated_xcode_build_settings_path) do |line|
|
||||
matches = line.match(/FLUTTER_ROOT\=(.*)/)
|
||||
return matches[1].strip if matches
|
||||
end
|
||||
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
|
||||
end
|
||||
|
||||
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
|
||||
|
||||
flutter_macos_podfile_setup
|
||||
|
||||
target 'Runner' do
|
||||
use_frameworks!
|
||||
use_modular_headers!
|
||||
|
||||
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
|
||||
end
|
||||
|
||||
post_install do |installer|
|
||||
installer.pods_project.targets.each do |target|
|
||||
flutter_additional_macos_build_settings(target)
|
||||
end
|
||||
end
|
||||
196
flutter/macos/Podfile.lock
Normal file
196
flutter/macos/Podfile.lock
Normal file
@@ -0,0 +1,196 @@
|
||||
PODS:
|
||||
- bitsdojo_window_macos (0.0.1):
|
||||
- FlutterMacOS
|
||||
- desktop_multi_window (0.0.1):
|
||||
- FlutterMacOS
|
||||
- device_info_plus_macos (0.0.1):
|
||||
- FlutterMacOS
|
||||
- Firebase/Analytics (8.15.0):
|
||||
- Firebase/Core
|
||||
- Firebase/Core (8.15.0):
|
||||
- Firebase/CoreOnly
|
||||
- FirebaseAnalytics (~> 8.15.0)
|
||||
- Firebase/CoreOnly (8.15.0):
|
||||
- FirebaseCore (= 8.15.0)
|
||||
- firebase_analytics (9.1.9):
|
||||
- Firebase/Analytics (= 8.15.0)
|
||||
- firebase_core
|
||||
- FlutterMacOS
|
||||
- firebase_core (1.17.1):
|
||||
- Firebase/CoreOnly (~> 8.15.0)
|
||||
- FlutterMacOS
|
||||
- FirebaseAnalytics (8.15.0):
|
||||
- FirebaseAnalytics/AdIdSupport (= 8.15.0)
|
||||
- FirebaseCore (~> 8.0)
|
||||
- FirebaseInstallations (~> 8.0)
|
||||
- GoogleUtilities/AppDelegateSwizzler (~> 7.7)
|
||||
- GoogleUtilities/MethodSwizzler (~> 7.7)
|
||||
- GoogleUtilities/Network (~> 7.7)
|
||||
- "GoogleUtilities/NSData+zlib (~> 7.7)"
|
||||
- nanopb (~> 2.30908.0)
|
||||
- FirebaseAnalytics/AdIdSupport (8.15.0):
|
||||
- FirebaseCore (~> 8.0)
|
||||
- FirebaseInstallations (~> 8.0)
|
||||
- GoogleAppMeasurement (= 8.15.0)
|
||||
- GoogleUtilities/AppDelegateSwizzler (~> 7.7)
|
||||
- GoogleUtilities/MethodSwizzler (~> 7.7)
|
||||
- GoogleUtilities/Network (~> 7.7)
|
||||
- "GoogleUtilities/NSData+zlib (~> 7.7)"
|
||||
- nanopb (~> 2.30908.0)
|
||||
- FirebaseCore (8.15.0):
|
||||
- FirebaseCoreDiagnostics (~> 8.0)
|
||||
- GoogleUtilities/Environment (~> 7.7)
|
||||
- GoogleUtilities/Logger (~> 7.7)
|
||||
- FirebaseCoreDiagnostics (8.15.0):
|
||||
- GoogleDataTransport (~> 9.1)
|
||||
- GoogleUtilities/Environment (~> 7.7)
|
||||
- GoogleUtilities/Logger (~> 7.7)
|
||||
- nanopb (~> 2.30908.0)
|
||||
- FirebaseInstallations (8.15.0):
|
||||
- FirebaseCore (~> 8.0)
|
||||
- GoogleUtilities/Environment (~> 7.7)
|
||||
- GoogleUtilities/UserDefaults (~> 7.7)
|
||||
- PromisesObjC (< 3.0, >= 1.2)
|
||||
- FlutterMacOS (1.0.0)
|
||||
- GoogleAppMeasurement (8.15.0):
|
||||
- GoogleAppMeasurement/AdIdSupport (= 8.15.0)
|
||||
- GoogleUtilities/AppDelegateSwizzler (~> 7.7)
|
||||
- GoogleUtilities/MethodSwizzler (~> 7.7)
|
||||
- GoogleUtilities/Network (~> 7.7)
|
||||
- "GoogleUtilities/NSData+zlib (~> 7.7)"
|
||||
- nanopb (~> 2.30908.0)
|
||||
- GoogleAppMeasurement/AdIdSupport (8.15.0):
|
||||
- GoogleAppMeasurement/WithoutAdIdSupport (= 8.15.0)
|
||||
- GoogleUtilities/AppDelegateSwizzler (~> 7.7)
|
||||
- GoogleUtilities/MethodSwizzler (~> 7.7)
|
||||
- GoogleUtilities/Network (~> 7.7)
|
||||
- "GoogleUtilities/NSData+zlib (~> 7.7)"
|
||||
- nanopb (~> 2.30908.0)
|
||||
- GoogleAppMeasurement/WithoutAdIdSupport (8.15.0):
|
||||
- GoogleUtilities/AppDelegateSwizzler (~> 7.7)
|
||||
- GoogleUtilities/MethodSwizzler (~> 7.7)
|
||||
- GoogleUtilities/Network (~> 7.7)
|
||||
- "GoogleUtilities/NSData+zlib (~> 7.7)"
|
||||
- nanopb (~> 2.30908.0)
|
||||
- GoogleDataTransport (9.1.4):
|
||||
- GoogleUtilities/Environment (~> 7.7)
|
||||
- nanopb (< 2.30910.0, >= 2.30908.0)
|
||||
- PromisesObjC (< 3.0, >= 1.2)
|
||||
- GoogleUtilities/AppDelegateSwizzler (7.7.0):
|
||||
- GoogleUtilities/Environment
|
||||
- GoogleUtilities/Logger
|
||||
- GoogleUtilities/Network
|
||||
- GoogleUtilities/Environment (7.7.0):
|
||||
- PromisesObjC (< 3.0, >= 1.2)
|
||||
- GoogleUtilities/Logger (7.7.0):
|
||||
- GoogleUtilities/Environment
|
||||
- GoogleUtilities/MethodSwizzler (7.7.0):
|
||||
- GoogleUtilities/Logger
|
||||
- GoogleUtilities/Network (7.7.0):
|
||||
- GoogleUtilities/Logger
|
||||
- "GoogleUtilities/NSData+zlib"
|
||||
- GoogleUtilities/Reachability
|
||||
- "GoogleUtilities/NSData+zlib (7.7.0)"
|
||||
- GoogleUtilities/Reachability (7.7.0):
|
||||
- GoogleUtilities/Logger
|
||||
- GoogleUtilities/UserDefaults (7.7.0):
|
||||
- GoogleUtilities/Logger
|
||||
- nanopb (2.30908.0):
|
||||
- nanopb/decode (= 2.30908.0)
|
||||
- nanopb/encode (= 2.30908.0)
|
||||
- nanopb/decode (2.30908.0)
|
||||
- nanopb/encode (2.30908.0)
|
||||
- package_info_plus_macos (0.0.1):
|
||||
- FlutterMacOS
|
||||
- path_provider_macos (0.0.1):
|
||||
- FlutterMacOS
|
||||
- PromisesObjC (2.1.0)
|
||||
- shared_preferences_macos (0.0.1):
|
||||
- FlutterMacOS
|
||||
- url_launcher_macos (0.0.1):
|
||||
- FlutterMacOS
|
||||
- wakelock_macos (0.0.1):
|
||||
- FlutterMacOS
|
||||
- window_manager (0.2.0):
|
||||
- FlutterMacOS
|
||||
|
||||
DEPENDENCIES:
|
||||
- bitsdojo_window_macos (from `Flutter/ephemeral/.symlinks/plugins/bitsdojo_window_macos/macos`)
|
||||
- desktop_multi_window (from `Flutter/ephemeral/.symlinks/plugins/desktop_multi_window/macos`)
|
||||
- device_info_plus_macos (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus_macos/macos`)
|
||||
- firebase_analytics (from `Flutter/ephemeral/.symlinks/plugins/firebase_analytics/macos`)
|
||||
- firebase_core (from `Flutter/ephemeral/.symlinks/plugins/firebase_core/macos`)
|
||||
- FlutterMacOS (from `Flutter/ephemeral`)
|
||||
- package_info_plus_macos (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus_macos/macos`)
|
||||
- path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`)
|
||||
- shared_preferences_macos (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos`)
|
||||
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
|
||||
- wakelock_macos (from `Flutter/ephemeral/.symlinks/plugins/wakelock_macos/macos`)
|
||||
- window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`)
|
||||
|
||||
SPEC REPOS:
|
||||
trunk:
|
||||
- Firebase
|
||||
- FirebaseAnalytics
|
||||
- FirebaseCore
|
||||
- FirebaseCoreDiagnostics
|
||||
- FirebaseInstallations
|
||||
- GoogleAppMeasurement
|
||||
- GoogleDataTransport
|
||||
- GoogleUtilities
|
||||
- nanopb
|
||||
- PromisesObjC
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
bitsdojo_window_macos:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/bitsdojo_window_macos/macos
|
||||
desktop_multi_window:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/desktop_multi_window/macos
|
||||
device_info_plus_macos:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/device_info_plus_macos/macos
|
||||
firebase_analytics:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/firebase_analytics/macos
|
||||
firebase_core:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/firebase_core/macos
|
||||
FlutterMacOS:
|
||||
:path: Flutter/ephemeral
|
||||
package_info_plus_macos:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/package_info_plus_macos/macos
|
||||
path_provider_macos:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos
|
||||
shared_preferences_macos:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos
|
||||
url_launcher_macos:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
|
||||
wakelock_macos:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/wakelock_macos/macos
|
||||
window_manager:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
bitsdojo_window_macos: 44e3b8fe3dd463820e0321f6256c5b1c16bb6a00
|
||||
desktop_multi_window: 566489c048b501134f9d7fb6a2354c60a9126486
|
||||
device_info_plus_macos: 1ad388a1ef433505c4038e7dd9605aadd1e2e9c7
|
||||
Firebase: 5f8193dff4b5b7c5d5ef72ae54bb76c08e2b841d
|
||||
firebase_analytics: d448483150504ed84f25c5437a34af2591a7929e
|
||||
firebase_core: 7b87364e2d1eae70018a60698e89e7d6f5320bad
|
||||
FirebaseAnalytics: 7761cbadb00a717d8d0939363eb46041526474fa
|
||||
FirebaseCore: 5743c5785c074a794d35f2fff7ecc254a91e08b1
|
||||
FirebaseCoreDiagnostics: 92e07a649aeb66352b319d43bdd2ee3942af84cb
|
||||
FirebaseInstallations: 40bd9054049b2eae9a2c38ef1c3dd213df3605cd
|
||||
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
|
||||
GoogleAppMeasurement: 4c19f031220c72464d460c9daa1fb5d1acce958e
|
||||
GoogleDataTransport: 5fffe35792f8b96ec8d6775f5eccd83c998d5a3b
|
||||
GoogleUtilities: e0913149f6b0625b553d70dae12b49fc62914fd1
|
||||
nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96
|
||||
package_info_plus_macos: f010621b07802a241d96d01876d6705f15e77c1c
|
||||
path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19
|
||||
PromisesObjC: 99b6f43f9e1044bd87a95a60beff28c2c44ddb72
|
||||
shared_preferences_macos: a64dc611287ed6cbe28fd1297898db1336975727
|
||||
url_launcher_macos: 597e05b8e514239626bcf4a850fcf9ef5c856ec3
|
||||
wakelock_macos: bc3f2a9bd8d2e6c89fee1e1822e7ddac3bd004a9
|
||||
window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8
|
||||
|
||||
PODFILE CHECKSUM: c7161fcf45d4fd9025dc0f48a76d6e64e52f8176
|
||||
|
||||
COCOAPODS: 1.11.3
|
||||
730
flutter/macos/Runner.xcodeproj/project.pbxproj
Normal file
730
flutter/macos/Runner.xcodeproj/project.pbxproj
Normal file
@@ -0,0 +1,730 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 51;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXAggregateTarget section */
|
||||
33CC111A2044C6BA0003C045 /* Flutter Assemble */ = {
|
||||
isa = PBXAggregateTarget;
|
||||
buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */;
|
||||
buildPhases = (
|
||||
33CC111E2044C6BF0003C045 /* ShellScript */,
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "Flutter Assemble";
|
||||
productName = FLX;
|
||||
};
|
||||
/* End PBXAggregateTarget section */
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; };
|
||||
33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; };
|
||||
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
|
||||
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
|
||||
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
|
||||
C5E54335B73C89F72DB1B606 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26C84465887F29AE938039CB /* Pods_Runner.framework */; };
|
||||
CC13D44B2847D53E00EF8B54 /* librustdesk.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CC13D4362847C8C200EF8B54 /* librustdesk.dylib */; };
|
||||
CC13D4502847D5E800EF8B54 /* librustdesk.dylib in Bundle Framework */ = {isa = PBXBuildFile; fileRef = CC13D4362847C8C200EF8B54 /* librustdesk.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 33CC10E52044A3C60003C045 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 33CC111A2044C6BA0003C045;
|
||||
remoteInfo = FLX;
|
||||
};
|
||||
CC13D4352847C8C200EF8B54 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = CC13D42E2847C8C200EF8B54 /* rustdesk.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = CA6071B5A0F5A7A3EF2297AA;
|
||||
remoteInfo = "librustdesk-cdylib";
|
||||
};
|
||||
CC13D4372847C8C200EF8B54 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = CC13D42E2847C8C200EF8B54 /* rustdesk.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = CA604C7415FB2A3731F5016A;
|
||||
remoteInfo = "librustdesk-staticlib";
|
||||
};
|
||||
CC13D4392847C8C200EF8B54 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = CC13D42E2847C8C200EF8B54 /* rustdesk.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = CA60D3BC5386D3D7DBD96893;
|
||||
remoteInfo = "naming-bin";
|
||||
};
|
||||
CC13D43B2847C8C200EF8B54 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = CC13D42E2847C8C200EF8B54 /* rustdesk.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = CA60D3BC5386B357B2AB834F;
|
||||
remoteInfo = "rustdesk-bin";
|
||||
};
|
||||
CC13D43D2847C8CB00EF8B54 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = CC13D42E2847C8C200EF8B54 /* rustdesk.xcodeproj */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = CA6071B5A0F5D6691E4C3FF1;
|
||||
remoteInfo = "librustdesk-cdylib";
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
33CC110E2044A8840003C045 /* Bundle Framework */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
CC13D4502847D5E800EF8B54 /* librustdesk.dylib in Bundle Framework */,
|
||||
);
|
||||
name = "Bundle Framework";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
26C84465887F29AE938039CB /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
295AD07E63F13855C270A0E0 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
|
||||
333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = "<group>"; };
|
||||
335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = "<group>"; };
|
||||
33CC10ED2044A3C60003C045 /* flutter_hbb.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = flutter_hbb.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = "<group>"; };
|
||||
33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
|
||||
33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = "<group>"; };
|
||||
33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = "<group>"; };
|
||||
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = "<group>"; };
|
||||
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = "<group>"; };
|
||||
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = "<group>"; };
|
||||
33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = "<group>"; };
|
||||
33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; };
|
||||
33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; };
|
||||
7436B85D94E8F7B5A9324869 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
|
||||
C3BB669FF6190AE1B11BCAEA /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
|
||||
CC13D42E2847C8C200EF8B54 /* rustdesk.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = rustdesk.xcodeproj; sourceTree = SOURCE_ROOT; };
|
||||
CCB6FE9A2848A6B800E58D48 /* bridge_generated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = bridge_generated.h; path = Runner/bridge_generated.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
33CC10EA2044A3C60003C045 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CC13D44B2847D53E00EF8B54 /* librustdesk.dylib in Frameworks */,
|
||||
C5E54335B73C89F72DB1B606 /* Pods_Runner.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
33BA886A226E78AF003329D5 /* Configs */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
33E5194F232828860026EE4D /* AppInfo.xcconfig */,
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */,
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
|
||||
333000ED22D3DE5D00554162 /* Warnings.xcconfig */,
|
||||
);
|
||||
path = Configs;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
33CC10E42044A3C60003C045 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CCB6FE9A2848A6B800E58D48 /* bridge_generated.h */,
|
||||
33FAB671232836740065AC1E /* Runner */,
|
||||
33CEB47122A05771004F2AC0 /* Flutter */,
|
||||
33CC10EE2044A3C60003C045 /* Products */,
|
||||
D73912EC22F37F3D000D13A0 /* Frameworks */,
|
||||
A6C450E1C32EC39A23170131 /* Pods */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
33CC10EE2044A3C60003C045 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
33CC10ED2044A3C60003C045 /* flutter_hbb.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
33CC11242044D66E0003C045 /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
33CC10F22044A3C60003C045 /* Assets.xcassets */,
|
||||
33CC10F42044A3C60003C045 /* MainMenu.xib */,
|
||||
33CC10F72044A3C60003C045 /* Info.plist */,
|
||||
);
|
||||
name = Resources;
|
||||
path = ..;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
33CEB47122A05771004F2AC0 /* Flutter */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */,
|
||||
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */,
|
||||
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */,
|
||||
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */,
|
||||
);
|
||||
path = Flutter;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
33FAB671232836740065AC1E /* Runner */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CC13D42E2847C8C200EF8B54 /* rustdesk.xcodeproj */,
|
||||
33CC10F02044A3C60003C045 /* AppDelegate.swift */,
|
||||
33CC11122044BFA00003C045 /* MainFlutterWindow.swift */,
|
||||
33E51913231747F40026EE4D /* DebugProfile.entitlements */,
|
||||
33E51914231749380026EE4D /* Release.entitlements */,
|
||||
33CC11242044D66E0003C045 /* Resources */,
|
||||
33BA886A226E78AF003329D5 /* Configs */,
|
||||
);
|
||||
path = Runner;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A6C450E1C32EC39A23170131 /* Pods */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7436B85D94E8F7B5A9324869 /* Pods-Runner.debug.xcconfig */,
|
||||
295AD07E63F13855C270A0E0 /* Pods-Runner.release.xcconfig */,
|
||||
C3BB669FF6190AE1B11BCAEA /* Pods-Runner.profile.xcconfig */,
|
||||
);
|
||||
path = Pods;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CC13D42F2847C8C200EF8B54 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CC13D4362847C8C200EF8B54 /* librustdesk.dylib */,
|
||||
CC13D4382847C8C200EF8B54 /* liblibrustdesk_static.a */,
|
||||
CC13D43A2847C8C200EF8B54 /* naming */,
|
||||
CC13D43C2847C8C200EF8B54 /* rustdesk */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D73912EC22F37F3D000D13A0 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
26C84465887F29AE938039CB /* Pods_Runner.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
33CC10EC2044A3C60003C045 /* Runner */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */;
|
||||
buildPhases = (
|
||||
610B125EE2B990E4D4B30D05 /* [CP] Check Pods Manifest.lock */,
|
||||
33CC10E92044A3C60003C045 /* Sources */,
|
||||
33CC10EA2044A3C60003C045 /* Frameworks */,
|
||||
33CC10EB2044A3C60003C045 /* Resources */,
|
||||
33CC110E2044A8840003C045 /* Bundle Framework */,
|
||||
3399D490228B24CF009A79C7 /* ShellScript */,
|
||||
4688A20DD8E4F3E900927B2C /* [CP] Embed Pods Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
CC13D43E2847C8CB00EF8B54 /* PBXTargetDependency */,
|
||||
33CC11202044C79F0003C045 /* PBXTargetDependency */,
|
||||
);
|
||||
name = Runner;
|
||||
productName = Runner;
|
||||
productReference = 33CC10ED2044A3C60003C045 /* flutter_hbb.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
33CC10E52044A3C60003C045 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0920;
|
||||
LastUpgradeCheck = 1300;
|
||||
ORGANIZATIONNAME = "";
|
||||
TargetAttributes = {
|
||||
33CC10EC2044A3C60003C045 = {
|
||||
CreatedOnToolsVersion = 9.2;
|
||||
LastSwiftMigration = 1100;
|
||||
ProvisioningStyle = Automatic;
|
||||
SystemCapabilities = {
|
||||
com.apple.Sandbox = {
|
||||
enabled = 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
33CC111A2044C6BA0003C045 = {
|
||||
CreatedOnToolsVersion = 9.2;
|
||||
ProvisioningStyle = Manual;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */;
|
||||
compatibilityVersion = "Xcode 9.3";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 33CC10E42044A3C60003C045;
|
||||
productRefGroup = 33CC10EE2044A3C60003C045 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectReferences = (
|
||||
{
|
||||
ProductGroup = CC13D42F2847C8C200EF8B54 /* Products */;
|
||||
ProjectRef = CC13D42E2847C8C200EF8B54 /* rustdesk.xcodeproj */;
|
||||
},
|
||||
);
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
33CC10EC2044A3C60003C045 /* Runner */,
|
||||
33CC111A2044C6BA0003C045 /* Flutter Assemble */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXReferenceProxy section */
|
||||
CC13D4362847C8C200EF8B54 /* librustdesk.dylib */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = "compiled.mach-o.dylib";
|
||||
path = librustdesk.dylib;
|
||||
remoteRef = CC13D4352847C8C200EF8B54 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
CC13D4382847C8C200EF8B54 /* liblibrustdesk_static.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = liblibrustdesk_static.a;
|
||||
remoteRef = CC13D4372847C8C200EF8B54 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
CC13D43A2847C8C200EF8B54 /* naming */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = "compiled.mach-o.executable";
|
||||
path = naming;
|
||||
remoteRef = CC13D4392847C8C200EF8B54 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
CC13D43C2847C8C200EF8B54 /* rustdesk */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = "compiled.mach-o.executable";
|
||||
path = rustdesk;
|
||||
remoteRef = CC13D43B2847C8C200EF8B54 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
/* End PBXReferenceProxy section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
33CC10EB2044A3C60003C045 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */,
|
||||
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
3399D490228B24CF009A79C7 /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n";
|
||||
};
|
||||
33CC111E2044C6BF0003C045 /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
Flutter/ephemeral/FlutterInputs.xcfilelist,
|
||||
);
|
||||
inputPaths = (
|
||||
Flutter/ephemeral/tripwire,
|
||||
);
|
||||
outputFileListPaths = (
|
||||
Flutter/ephemeral/FlutterOutputs.xcfilelist,
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire";
|
||||
};
|
||||
4688A20DD8E4F3E900927B2C /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
610B125EE2B990E4D4B30D05 /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
|
||||
"${PODS_ROOT}/Manifest.lock",
|
||||
);
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
33CC10E92044A3C60003C045 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */,
|
||||
33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */,
|
||||
335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
33CC11202044C79F0003C045 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */;
|
||||
targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */;
|
||||
};
|
||||
CC13D43E2847C8CB00EF8B54 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
name = "librustdesk-cdylib";
|
||||
targetProxy = CC13D43D2847C8CB00EF8B54 /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
33CC10F42044A3C60003C045 /* MainMenu.xib */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
33CC10F52044A3C60003C045 /* Base */,
|
||||
);
|
||||
name = MainMenu.xib;
|
||||
path = Runner;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
338D0CE9231458BD00FA5F75 /* Profile */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = macosx;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
};
|
||||
name = Profile;
|
||||
};
|
||||
338D0CEA231458BD00FA5F75 /* Profile */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Profile;
|
||||
};
|
||||
338D0CEB231458BD00FA5F75 /* Profile */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Profile;
|
||||
};
|
||||
33CC10F92044A3C60003C045 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
33CC10FA2044A3C60003C045 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = macosx;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
33CC10FC2044A3C60003C045 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
"SWIFT_OBJC_BRIDGING_HEADER[arch=*]" = Runner/bridge_generated.h;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
33CC10FD2044A3C60003C045 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
"SWIFT_OBJC_BRIDGING_HEADER[arch=*]" = Runner/bridge_generated.h;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
33CC111C2044C6BA0003C045 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
33CC111D2044C6BA0003C045 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
33CC10F92044A3C60003C045 /* Debug */,
|
||||
33CC10FA2044A3C60003C045 /* Release */,
|
||||
338D0CE9231458BD00FA5F75 /* Profile */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
33CC10FC2044A3C60003C045 /* Debug */,
|
||||
33CC10FD2044A3C60003C045 /* Release */,
|
||||
338D0CEA231458BD00FA5F75 /* Profile */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
33CC111C2044C6BA0003C045 /* Debug */,
|
||||
33CC111D2044C6BA0003C045 /* Release */,
|
||||
338D0CEB231458BD00FA5F75 /* Profile */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 33CC10E52044A3C60003C045 /* Project object */;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1300"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
||||
BuildableName = "flutter_hbb.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
||||
BuildableName = "flutter_hbb.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
||||
BuildableName = "flutter_hbb.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Profile"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
||||
BuildableName = "flutter_hbb.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
10
flutter/macos/Runner.xcworkspace/contents.xcworkspacedata
generated
Normal file
10
flutter/macos/Runner.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:Runner.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Pods/Pods.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
10
flutter/macos/Runner/AppDelegate.swift
Normal file
10
flutter/macos/Runner/AppDelegate.swift
Normal file
@@ -0,0 +1,10 @@
|
||||
import Cocoa
|
||||
import FlutterMacOS
|
||||
|
||||
@NSApplicationMain
|
||||
class AppDelegate: FlutterAppDelegate {
|
||||
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||
dummy_method_to_enforce_bundling()
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"size" : "16x16",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_16.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "16x16",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_32.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "32x32",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_32.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "32x32",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_64.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "128x128",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_128.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "128x128",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_256.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "256x256",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_256.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "256x256",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_512.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "512x512",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_512.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "512x512",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_1024.png",
|
||||
"scale" : "2x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
343
flutter/macos/Runner/Base.lproj/MainMenu.xib
Normal file
343
flutter/macos/Runner/Base.lproj/MainMenu.xib
Normal file
@@ -0,0 +1,343 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
|
||||
<connections>
|
||||
<outlet property="delegate" destination="Voe-Tx-rLC" id="GzC-gU-4Uq"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="Runner" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="applicationMenu" destination="uQy-DD-JDr" id="XBo-yE-nKs"/>
|
||||
<outlet property="mainFlutterWindow" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
|
||||
<menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
|
||||
<items>
|
||||
<menuItem title="APP_NAME" id="1Xt-HY-uBw">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="APP_NAME" systemMenu="apple" id="uQy-DD-JDr">
|
||||
<items>
|
||||
<menuItem title="About APP_NAME" id="5kV-Vb-QxS">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="orderFrontStandardAboutPanel:" target="-1" id="Exp-CZ-Vem"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
|
||||
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW"/>
|
||||
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
|
||||
<menuItem title="Services" id="NMo-om-nkz">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
|
||||
<menuItem title="Hide APP_NAME" keyEquivalent="h" id="Olw-nP-bQN">
|
||||
<connections>
|
||||
<action selector="hide:" target="-1" id="PnN-Uc-m68"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO">
|
||||
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="hideOtherApplications:" target="-1" id="VT4-aY-XCT"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Show All" id="Kd2-mp-pUS">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="unhideAllApplications:" target="-1" id="Dhg-Le-xox"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
|
||||
<menuItem title="Quit APP_NAME" keyEquivalent="q" id="4sb-4s-VLi">
|
||||
<connections>
|
||||
<action selector="terminate:" target="-1" id="Te7-pn-YzF"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Edit" id="5QF-Oa-p0T">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Edit" id="W48-6f-4Dl">
|
||||
<items>
|
||||
<menuItem title="Undo" keyEquivalent="z" id="dRJ-4n-Yzg">
|
||||
<connections>
|
||||
<action selector="undo:" target="-1" id="M6e-cu-g7V"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Redo" keyEquivalent="Z" id="6dh-zS-Vam">
|
||||
<connections>
|
||||
<action selector="redo:" target="-1" id="oIA-Rs-6OD"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="WRV-NI-Exz"/>
|
||||
<menuItem title="Cut" keyEquivalent="x" id="uRl-iY-unG">
|
||||
<connections>
|
||||
<action selector="cut:" target="-1" id="YJe-68-I9s"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Copy" keyEquivalent="c" id="x3v-GG-iWU">
|
||||
<connections>
|
||||
<action selector="copy:" target="-1" id="G1f-GL-Joy"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Paste" keyEquivalent="v" id="gVA-U4-sdL">
|
||||
<connections>
|
||||
<action selector="paste:" target="-1" id="UvS-8e-Qdg"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Paste and Match Style" keyEquivalent="V" id="WeT-3V-zwk">
|
||||
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="pasteAsPlainText:" target="-1" id="cEh-KX-wJQ"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Delete" id="pa3-QI-u2k">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="delete:" target="-1" id="0Mk-Ml-PaM"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Select All" keyEquivalent="a" id="Ruw-6m-B2m">
|
||||
<connections>
|
||||
<action selector="selectAll:" target="-1" id="VNm-Mi-diN"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="uyl-h8-XO2"/>
|
||||
<menuItem title="Find" id="4EN-yA-p0u">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Find" id="1b7-l0-nxx">
|
||||
<items>
|
||||
<menuItem title="Find…" tag="1" keyEquivalent="f" id="Xz5-n4-O0W">
|
||||
<connections>
|
||||
<action selector="performFindPanelAction:" target="-1" id="cD7-Qs-BN4"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Find and Replace…" tag="12" keyEquivalent="f" id="YEy-JH-Tfz">
|
||||
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="performFindPanelAction:" target="-1" id="WD3-Gg-5AJ"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Find Next" tag="2" keyEquivalent="g" id="q09-fT-Sye">
|
||||
<connections>
|
||||
<action selector="performFindPanelAction:" target="-1" id="NDo-RZ-v9R"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Find Previous" tag="3" keyEquivalent="G" id="OwM-mh-QMV">
|
||||
<connections>
|
||||
<action selector="performFindPanelAction:" target="-1" id="HOh-sY-3ay"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Use Selection for Find" tag="7" keyEquivalent="e" id="buJ-ug-pKt">
|
||||
<connections>
|
||||
<action selector="performFindPanelAction:" target="-1" id="U76-nv-p5D"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Jump to Selection" keyEquivalent="j" id="S0p-oC-mLd">
|
||||
<connections>
|
||||
<action selector="centerSelectionInVisibleArea:" target="-1" id="IOG-6D-g5B"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Spelling and Grammar" id="Dv1-io-Yv7">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Spelling" id="3IN-sU-3Bg">
|
||||
<items>
|
||||
<menuItem title="Show Spelling and Grammar" keyEquivalent=":" id="HFo-cy-zxI">
|
||||
<connections>
|
||||
<action selector="showGuessPanel:" target="-1" id="vFj-Ks-hy3"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Check Document Now" keyEquivalent=";" id="hz2-CU-CR7">
|
||||
<connections>
|
||||
<action selector="checkSpelling:" target="-1" id="fz7-VC-reM"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="bNw-od-mp5"/>
|
||||
<menuItem title="Check Spelling While Typing" id="rbD-Rh-wIN">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleContinuousSpellChecking:" target="-1" id="7w6-Qz-0kB"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Check Grammar With Spelling" id="mK6-2p-4JG">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleGrammarChecking:" target="-1" id="muD-Qn-j4w"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Correct Spelling Automatically" id="78Y-hA-62v">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleAutomaticSpellingCorrection:" target="-1" id="2lM-Qi-WAP"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Substitutions" id="9ic-FL-obx">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Substitutions" id="FeM-D8-WVr">
|
||||
<items>
|
||||
<menuItem title="Show Substitutions" id="z6F-FW-3nz">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="orderFrontSubstitutionsPanel:" target="-1" id="oku-mr-iSq"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="gPx-C9-uUO"/>
|
||||
<menuItem title="Smart Copy/Paste" id="9yt-4B-nSM">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleSmartInsertDelete:" target="-1" id="3IJ-Se-DZD"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Smart Quotes" id="hQb-2v-fYv">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleAutomaticQuoteSubstitution:" target="-1" id="ptq-xd-QOA"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Smart Dashes" id="rgM-f4-ycn">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleAutomaticDashSubstitution:" target="-1" id="oCt-pO-9gS"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Smart Links" id="cwL-P1-jid">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleAutomaticLinkDetection:" target="-1" id="Gip-E3-Fov"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Data Detectors" id="tRr-pd-1PS">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleAutomaticDataDetection:" target="-1" id="R1I-Nq-Kbl"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Text Replacement" id="HFQ-gK-NFA">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleAutomaticTextReplacement:" target="-1" id="DvP-Fe-Py6"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Transformations" id="2oI-Rn-ZJC">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Transformations" id="c8a-y6-VQd">
|
||||
<items>
|
||||
<menuItem title="Make Upper Case" id="vmV-6d-7jI">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="uppercaseWord:" target="-1" id="sPh-Tk-edu"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Make Lower Case" id="d9M-CD-aMd">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="lowercaseWord:" target="-1" id="iUZ-b5-hil"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Capitalize" id="UEZ-Bs-lqG">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="capitalizeWord:" target="-1" id="26H-TL-nsh"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Speech" id="xrE-MZ-jX0">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Speech" id="3rS-ZA-NoH">
|
||||
<items>
|
||||
<menuItem title="Start Speaking" id="Ynk-f8-cLZ">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="startSpeaking:" target="-1" id="654-Ng-kyl"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Stop Speaking" id="Oyz-dy-DGm">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="stopSpeaking:" target="-1" id="dX8-6p-jy9"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="View" id="H8h-7b-M4v">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="View" id="HyV-fh-RgO">
|
||||
<items>
|
||||
<menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa">
|
||||
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="toggleFullScreen:" target="-1" id="dU3-MA-1Rq"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Window" id="aUF-d1-5bR">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo">
|
||||
<items>
|
||||
<menuItem title="Minimize" keyEquivalent="m" id="OY7-WF-poV">
|
||||
<connections>
|
||||
<action selector="performMiniaturize:" target="-1" id="VwT-WD-YPe"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Zoom" id="R4o-n2-Eq4">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="performZoom:" target="-1" id="DIl-cC-cCs"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/>
|
||||
<menuItem title="Bring All to Front" id="LE2-aR-0XJ">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="arrangeInFront:" target="-1" id="DRN-fu-gQh"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Help" id="EPT-qC-fAb">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Help" systemMenu="help" id="rJ0-wn-3NY"/>
|
||||
</menuItem>
|
||||
</items>
|
||||
<point key="canvasLocation" x="142" y="-258"/>
|
||||
</menu>
|
||||
<window title="APP_NAME" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g" customClass="MainFlutterWindow" customModule="Runner" customModuleProvider="target">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<rect key="contentRect" x="335" y="390" width="800" height="600"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1577"/>
|
||||
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="800" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</view>
|
||||
</window>
|
||||
</objects>
|
||||
</document>
|
||||
14
flutter/macos/Runner/Configs/AppInfo.xcconfig
Normal file
14
flutter/macos/Runner/Configs/AppInfo.xcconfig
Normal file
@@ -0,0 +1,14 @@
|
||||
// Application-level settings for the Runner target.
|
||||
//
|
||||
// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
|
||||
// future. If not, the values below would default to using the project name when this becomes a
|
||||
// 'flutter create' template.
|
||||
|
||||
// The application's name. By default this is also the title of the Flutter window.
|
||||
PRODUCT_NAME = flutter_hbb
|
||||
|
||||
// The application's bundle identifier
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.carriez.flutterHbb
|
||||
|
||||
// The copyright displayed in application information
|
||||
PRODUCT_COPYRIGHT = Copyright © 2022 com.carriez. All rights reserved.
|
||||
2
flutter/macos/Runner/Configs/Debug.xcconfig
Normal file
2
flutter/macos/Runner/Configs/Debug.xcconfig
Normal file
@@ -0,0 +1,2 @@
|
||||
#include "../../Flutter/Flutter-Debug.xcconfig"
|
||||
#include "Warnings.xcconfig"
|
||||
2
flutter/macos/Runner/Configs/Release.xcconfig
Normal file
2
flutter/macos/Runner/Configs/Release.xcconfig
Normal file
@@ -0,0 +1,2 @@
|
||||
#include "../../Flutter/Flutter-Release.xcconfig"
|
||||
#include "Warnings.xcconfig"
|
||||
13
flutter/macos/Runner/Configs/Warnings.xcconfig
Normal file
13
flutter/macos/Runner/Configs/Warnings.xcconfig
Normal file
@@ -0,0 +1,13 @@
|
||||
WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES
|
||||
CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
|
||||
CLANG_WARN_PRAGMA_PACK = YES
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES
|
||||
CLANG_WARN_COMMA = YES
|
||||
GCC_WARN_STRICT_SELECTOR_MATCH = YES
|
||||
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
|
||||
GCC_WARN_SHADOW = YES
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES
|
||||
12
flutter/macos/Runner/DebugProfile.entitlements
Normal file
12
flutter/macos/Runner/DebugProfile.entitlements
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.allow-jit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.server</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
32
flutter/macos/Runner/Info.plist
Normal file
32
flutter/macos/Runner/Info.plist
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(FLUTTER_BUILD_NAME)</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>$(PRODUCT_COPYRIGHT)</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
||||
24
flutter/macos/Runner/MainFlutterWindow.swift
Normal file
24
flutter/macos/Runner/MainFlutterWindow.swift
Normal file
@@ -0,0 +1,24 @@
|
||||
import Cocoa
|
||||
import FlutterMacOS
|
||||
// import bitsdojo_window_macos
|
||||
|
||||
class MainFlutterWindow: NSWindow {
|
||||
override func awakeFromNib() {
|
||||
if (!rustdesk_core_main()){
|
||||
print("Rustdesk core returns false, exiting without launching Flutter app")
|
||||
NSApplication.shared.terminate(self)
|
||||
}
|
||||
let flutterViewController = FlutterViewController.init()
|
||||
let windowFrame = self.frame
|
||||
self.contentViewController = flutterViewController
|
||||
self.setFrame(windowFrame, display: true)
|
||||
|
||||
RegisterGeneratedPlugins(registry: flutterViewController)
|
||||
|
||||
super.awakeFromNib()
|
||||
}
|
||||
|
||||
// override func bitsdojo_window_configure() -> UInt {
|
||||
// return BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP
|
||||
// }
|
||||
}
|
||||
8
flutter/macos/Runner/Release.entitlements
Normal file
8
flutter/macos/Runner/Release.entitlements
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
439
flutter/macos/rustdesk.xcodeproj/project.pbxproj
Normal file
439
flutter/macos/rustdesk.xcodeproj/project.pbxproj
Normal file
@@ -0,0 +1,439 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 53;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
CA6061C6409F12977AAB839F /* Cargo.toml in Sources */ = {isa = PBXBuildFile; fileRef = CA603C4309E13EF4668187A5 /* Cargo.toml */; settings = {COMPILER_FLAGS = "--lib"; }; };
|
||||
CA6061C6409FC858B7409EE3 /* Cargo.toml in Sources */ = {isa = PBXBuildFile; fileRef = CA603C4309E13EF4668187A5 /* Cargo.toml */; settings = {COMPILER_FLAGS = "--bin naming"; }; };
|
||||
CA6061C6409FC9FA710A2219 /* Cargo.toml in Sources */ = {isa = PBXBuildFile; fileRef = CA603C4309E13EF4668187A5 /* Cargo.toml */; settings = {COMPILER_FLAGS = "--bin rustdesk"; }; };
|
||||
CA6061C6409FD6691E4C3FF1 /* Cargo.toml in Sources */ = {isa = PBXBuildFile; fileRef = CA603C4309E13EF4668187A5 /* Cargo.toml */; settings = {COMPILER_FLAGS = "--lib"; }; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXBuildRule section */
|
||||
CA603C4309E1AC6C1400ACA8 /* PBXBuildRule */ = {
|
||||
isa = PBXBuildRule;
|
||||
compilerSpec = com.apple.compilers.proxy.script;
|
||||
dependencyFile = "$(DERIVED_FILE_DIR)/$(CARGO_XCODE_TARGET_ARCH)-$(EXECUTABLE_NAME).d";
|
||||
filePatterns = "*/Cargo.toml";
|
||||
fileType = pattern.proxy;
|
||||
inputFiles = (
|
||||
);
|
||||
isEditable = 0;
|
||||
name = "Cargo project build";
|
||||
outputFiles = (
|
||||
"$(OBJECT_FILE_DIR)/$(CARGO_XCODE_TARGET_ARCH)-$(EXECUTABLE_NAME)",
|
||||
);
|
||||
script = "# generated with cargo-xcode 1.4.1\n\nset -eu; export PATH=$PATH:~/.cargo/bin:/usr/local/bin;\nif [ \"${IS_MACCATALYST-NO}\" = YES ]; then\n CARGO_XCODE_TARGET_TRIPLE=\"${CARGO_XCODE_TARGET_ARCH}-apple-ios-macabi\"\nelse\n CARGO_XCODE_TARGET_TRIPLE=\"${CARGO_XCODE_TARGET_ARCH}-apple-${CARGO_XCODE_TARGET_OS}\"\nfi\nif [ \"$CARGO_XCODE_TARGET_OS\" != \"darwin\" ]; then\n PATH=\"${PATH/\\/Contents\\/Developer\\/Toolchains\\/XcodeDefault.xctoolchain\\/usr\\/bin:/xcode-provided-ld-cant-link-lSystem-for-the-host-build-script:}\"\nfi\nPATH=\"$PATH:/opt/homebrew/bin\" # Rust projects often depend on extra tools like nasm, which Xcode lacks\nif [ \"$CARGO_XCODE_BUILD_MODE\" == release ]; then\n OTHER_INPUT_FILE_FLAGS=\"${OTHER_INPUT_FILE_FLAGS} --release\"\nfi\nif command -v rustup &> /dev/null; then\n if ! rustup target list --installed | egrep -q \"${CARGO_XCODE_TARGET_TRIPLE}\"; then\n echo \"warning: this build requires rustup toolchain for $CARGO_XCODE_TARGET_TRIPLE, but it isn't installed\"\n rustup target add \"${CARGO_XCODE_TARGET_TRIPLE}\" || echo >&2 \"warning: can't install $CARGO_XCODE_TARGET_TRIPLE\"\n fi\nfi\nif [ \"$ACTION\" = clean ]; then\n ( set -x; cargo clean --manifest-path=\"$SCRIPT_INPUT_FILE\" ${OTHER_INPUT_FILE_FLAGS} --target=\"${CARGO_XCODE_TARGET_TRIPLE}\"; );\nelse\n ( set -x; cargo build --manifest-path=\"$SCRIPT_INPUT_FILE\" --features=\"${CARGO_XCODE_FEATURES:-}\" ${OTHER_INPUT_FILE_FLAGS} --target=\"${CARGO_XCODE_TARGET_TRIPLE}\"; );\nfi\n# it's too hard to explain Cargo's actual exe path to Xcode build graph, so hardlink to a known-good path instead\nBUILT_SRC=\"${CARGO_TARGET_DIR}/${CARGO_XCODE_TARGET_TRIPLE}/${CARGO_XCODE_BUILD_MODE}/${CARGO_XCODE_CARGO_FILE_NAME}\"\nln -f -- \"$BUILT_SRC\" \"$SCRIPT_OUTPUT_FILE_0\"\n\n# xcode generates dep file, but for its own path, so append our rename to it\nDEP_FILE_SRC=\"${CARGO_TARGET_DIR}/${CARGO_XCODE_TARGET_TRIPLE}/${CARGO_XCODE_BUILD_MODE}/${CARGO_XCODE_CARGO_DEP_FILE_NAME}\"\nif [ -f \"$DEP_FILE_SRC\" ]; then\n DEP_FILE_DST=\"${DERIVED_FILE_DIR}/${CARGO_XCODE_TARGET_ARCH}-${EXECUTABLE_NAME}.d\"\n cp -f \"$DEP_FILE_SRC\" \"$DEP_FILE_DST\"\n echo >> \"$DEP_FILE_DST\" \"$SCRIPT_OUTPUT_FILE_0: $BUILT_SRC\"\nfi\n\n# lipo script needs to know all the platform-specific files that have been built\n# archs is in the file name, so that paths don't stay around after archs change\n# must match input for LipoScript\nFILE_LIST=\"${DERIVED_FILE_DIR}/${ARCHS}-${EXECUTABLE_NAME}.xcfilelist\"\ntouch \"$FILE_LIST\"\nif ! egrep -q \"$SCRIPT_OUTPUT_FILE_0\" \"$FILE_LIST\" ; then\n echo >> \"$FILE_LIST\" \"$SCRIPT_OUTPUT_FILE_0\"\nfi\n";
|
||||
};
|
||||
/* End PBXBuildRule section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
ADDEDBA66A6E1 /* libresolv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libresolv.tbd; path = usr/lib/libresolv.tbd; sourceTree = SDKROOT; };
|
||||
CA603C4309E13EF4668187A5 /* Cargo.toml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Cargo.toml; path = /Users/ruizruiz/Work/Code/Projects/RustDesk/rustdesk/Cargo.toml; sourceTree = "<group>"; };
|
||||
CA604C7415FB2A3731F5016A /* liblibrustdesk_static.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = liblibrustdesk_static.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
CA6071B5A0F5A7A3EF2297AA /* librustdesk.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = librustdesk.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
CA60D3BC5386B357B2AB834F /* rustdesk */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = rustdesk; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
CA60D3BC5386D3D7DBD96893 /* naming */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = naming; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
ADDEDBA66A6E2 /* Required for static linking */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
ADDEDBA66A6E1 /* libresolv.tbd */,
|
||||
);
|
||||
name = "Required for static linking";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CA603C4309E122869D176AE5 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CA6071B5A0F5A7A3EF2297AA /* librustdesk.dylib */,
|
||||
CA604C7415FB2A3731F5016A /* liblibrustdesk_static.a */,
|
||||
CA60D3BC5386D3D7DBD96893 /* naming */,
|
||||
CA60D3BC5386B357B2AB834F /* rustdesk */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CA603C4309E198AF0B5890DB /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
ADDEDBA66A6E2 /* Required for static linking */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CA603C4309E1D65BC3C892A8 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CA603C4309E13EF4668187A5 /* Cargo.toml */,
|
||||
CA603C4309E122869D176AE5 /* Products */,
|
||||
CA603C4309E198AF0B5890DB /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
CA604C7415FB12977AAB839F /* librustdesk-staticlib */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = CA6028B9540B12977AAB839F /* Build configuration list for PBXNativeTarget "librustdesk-staticlib" */;
|
||||
buildPhases = (
|
||||
CA6033723F8212977AAB839F /* Sources */,
|
||||
CA603C4309E1AF6EBB7F357C /* Universal Binary lipo */,
|
||||
);
|
||||
buildRules = (
|
||||
CA603C4309E1AC6C1400ACA8 /* PBXBuildRule */,
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "librustdesk-staticlib";
|
||||
productName = liblibrustdesk_static.a;
|
||||
productReference = CA604C7415FB2A3731F5016A /* liblibrustdesk_static.a */;
|
||||
productType = "com.apple.product-type.library.static";
|
||||
};
|
||||
CA6071B5A0F5D6691E4C3FF1 /* librustdesk-cdylib */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = CA6028B9540BD6691E4C3FF1 /* Build configuration list for PBXNativeTarget "librustdesk-cdylib" */;
|
||||
buildPhases = (
|
||||
CA6033723F82D6691E4C3FF1 /* Sources */,
|
||||
CA603C4309E1AF6EBB7F357C /* Universal Binary lipo */,
|
||||
);
|
||||
buildRules = (
|
||||
CA603C4309E1AC6C1400ACA8 /* PBXBuildRule */,
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "librustdesk-cdylib";
|
||||
productName = librustdesk.dylib;
|
||||
productReference = CA6071B5A0F5A7A3EF2297AA /* librustdesk.dylib */;
|
||||
productType = "com.apple.product-type.library.dynamic";
|
||||
};
|
||||
CA60D3BC5386C858B7409EE3 /* naming-bin */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = CA6028B9540BC858B7409EE3 /* Build configuration list for PBXNativeTarget "naming-bin" */;
|
||||
buildPhases = (
|
||||
CA6033723F82C858B7409EE3 /* Sources */,
|
||||
CA603C4309E1AF6EBB7F357C /* Universal Binary lipo */,
|
||||
);
|
||||
buildRules = (
|
||||
CA603C4309E1AC6C1400ACA8 /* PBXBuildRule */,
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "naming-bin";
|
||||
productName = naming;
|
||||
productReference = CA60D3BC5386D3D7DBD96893 /* naming */;
|
||||
productType = "com.apple.product-type.tool";
|
||||
};
|
||||
CA60D3BC5386C9FA710A2219 /* rustdesk-bin */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = CA6028B9540BC9FA710A2219 /* Build configuration list for PBXNativeTarget "rustdesk-bin" */;
|
||||
buildPhases = (
|
||||
CA6033723F82C9FA710A2219 /* Sources */,
|
||||
CA603C4309E1AF6EBB7F357C /* Universal Binary lipo */,
|
||||
);
|
||||
buildRules = (
|
||||
CA603C4309E1AC6C1400ACA8 /* PBXBuildRule */,
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "rustdesk-bin";
|
||||
productName = rustdesk;
|
||||
productReference = CA60D3BC5386B357B2AB834F /* rustdesk */;
|
||||
productType = "com.apple.product-type.tool";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
CA603C4309E1E04653AD465F /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 1300;
|
||||
TargetAttributes = {
|
||||
CA604C7415FB12977AAB839F = {
|
||||
CreatedOnToolsVersion = 9.2;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
CA6071B5A0F5D6691E4C3FF1 = {
|
||||
CreatedOnToolsVersion = 9.2;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
CA60D3BC5386C858B7409EE3 = {
|
||||
CreatedOnToolsVersion = 9.2;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
CA60D3BC5386C9FA710A2219 = {
|
||||
CreatedOnToolsVersion = 9.2;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = CA603C4309E180E02D6C7F57 /* Build configuration list for PBXProject "rustdesk" */;
|
||||
compatibilityVersion = "Xcode 11.4";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = CA603C4309E1D65BC3C892A8;
|
||||
productRefGroup = CA603C4309E122869D176AE5 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
CA6071B5A0F5D6691E4C3FF1 /* librustdesk-cdylib */,
|
||||
CA604C7415FB12977AAB839F /* librustdesk-staticlib */,
|
||||
CA60D3BC5386C858B7409EE3 /* naming-bin */,
|
||||
CA60D3BC5386C9FA710A2219 /* rustdesk-bin */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
CA603C4309E1AF6EBB7F357C /* Universal Binary lipo */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
"$(DERIVED_FILE_DIR)/$(ARCHS)-$(EXECUTABLE_NAME).xcfilelist",
|
||||
);
|
||||
name = "Universal Binary lipo";
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
"$(TARGET_BUILD_DIR)/$(EXECUTABLE_PATH)",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "# generated with cargo-xcode 1.4.1\nset -eux; cat \"$DERIVED_FILE_DIR/$ARCHS-$EXECUTABLE_NAME.xcfilelist\" | tr '\\n' '\\0' | xargs -0 lipo -create -output \"$TARGET_BUILD_DIR/$EXECUTABLE_PATH\"";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
CA6033723F8212977AAB839F /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CA6061C6409F12977AAB839F /* Cargo.toml in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
CA6033723F82C858B7409EE3 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CA6061C6409FC858B7409EE3 /* Cargo.toml in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
CA6033723F82C9FA710A2219 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CA6061C6409FC9FA710A2219 /* Cargo.toml in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
CA6033723F82D6691E4C3FF1 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CA6061C6409FD6691E4C3FF1 /* Cargo.toml in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
CA604B55B26012977AAB839F /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CARGO_XCODE_CARGO_DEP_FILE_NAME = liblibrustdesk.d;
|
||||
CARGO_XCODE_CARGO_FILE_NAME = liblibrustdesk.a;
|
||||
INSTALL_GROUP = "";
|
||||
INSTALL_MODE_FLAG = "";
|
||||
INSTALL_OWNER = "";
|
||||
PRODUCT_NAME = librustdesk_static;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "macosx iphonesimulator iphoneos appletvsimulator appletvos";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
CA604B55B260C858B7409EE3 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CARGO_XCODE_CARGO_DEP_FILE_NAME = naming.d;
|
||||
CARGO_XCODE_CARGO_FILE_NAME = naming;
|
||||
PRODUCT_NAME = naming;
|
||||
SUPPORTED_PLATFORMS = macosx;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
CA604B55B260C9FA710A2219 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CARGO_XCODE_CARGO_DEP_FILE_NAME = rustdesk.d;
|
||||
CARGO_XCODE_CARGO_FILE_NAME = rustdesk;
|
||||
PRODUCT_NAME = rustdesk;
|
||||
SUPPORTED_PLATFORMS = macosx;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
CA604B55B260D6691E4C3FF1 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CARGO_XCODE_CARGO_DEP_FILE_NAME = liblibrustdesk.d;
|
||||
CARGO_XCODE_CARGO_FILE_NAME = liblibrustdesk.dylib;
|
||||
PRODUCT_NAME = librustdesk;
|
||||
SUPPORTED_PLATFORMS = macosx;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
CA60583BB9CE12977AAB839F /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CARGO_XCODE_CARGO_DEP_FILE_NAME = liblibrustdesk.d;
|
||||
CARGO_XCODE_CARGO_FILE_NAME = liblibrustdesk.a;
|
||||
INSTALL_GROUP = "";
|
||||
INSTALL_MODE_FLAG = "";
|
||||
INSTALL_OWNER = "";
|
||||
PRODUCT_NAME = librustdesk_static;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "macosx iphonesimulator iphoneos appletvsimulator appletvos";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
CA60583BB9CEC858B7409EE3 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CARGO_XCODE_CARGO_DEP_FILE_NAME = naming.d;
|
||||
CARGO_XCODE_CARGO_FILE_NAME = naming;
|
||||
PRODUCT_NAME = naming;
|
||||
SUPPORTED_PLATFORMS = macosx;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
CA60583BB9CEC9FA710A2219 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CARGO_XCODE_CARGO_DEP_FILE_NAME = rustdesk.d;
|
||||
CARGO_XCODE_CARGO_FILE_NAME = rustdesk;
|
||||
PRODUCT_NAME = rustdesk;
|
||||
SUPPORTED_PLATFORMS = macosx;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
CA60583BB9CED6691E4C3FF1 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CARGO_XCODE_CARGO_DEP_FILE_NAME = liblibrustdesk.d;
|
||||
CARGO_XCODE_CARGO_FILE_NAME = liblibrustdesk.dylib;
|
||||
PRODUCT_NAME = librustdesk;
|
||||
SUPPORTED_PLATFORMS = macosx;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
CA608F3F78EE228BE02872F8 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CARGO_TARGET_DIR = "$(PROJECT_TEMP_DIR)/cargo_target";
|
||||
CARGO_XCODE_BUILD_MODE = debug;
|
||||
CARGO_XCODE_FEATURES = "";
|
||||
"CARGO_XCODE_TARGET_ARCH[arch=arm64*]" = aarch64;
|
||||
"CARGO_XCODE_TARGET_ARCH[arch=i386]" = i686;
|
||||
"CARGO_XCODE_TARGET_ARCH[arch=x86_64*]" = x86_64;
|
||||
"CARGO_XCODE_TARGET_OS[sdk=appletvos*]" = tvos;
|
||||
"CARGO_XCODE_TARGET_OS[sdk=appletvsimulator*]" = tvos;
|
||||
"CARGO_XCODE_TARGET_OS[sdk=iphoneos*]" = ios;
|
||||
"CARGO_XCODE_TARGET_OS[sdk=iphonesimulator*]" = "ios-sim";
|
||||
"CARGO_XCODE_TARGET_OS[sdk=macosx*]" = darwin;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_NAME = rustdesk;
|
||||
SDKROOT = macosx;
|
||||
SUPPORTS_MACCATALYST = YES;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
CA608F3F78EE3CC16B37690B /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CARGO_TARGET_DIR = "$(PROJECT_TEMP_DIR)/cargo_target";
|
||||
CARGO_XCODE_BUILD_MODE = release;
|
||||
CARGO_XCODE_FEATURES = "";
|
||||
"CARGO_XCODE_TARGET_ARCH[arch=arm64*]" = aarch64;
|
||||
"CARGO_XCODE_TARGET_ARCH[arch=i386]" = i686;
|
||||
"CARGO_XCODE_TARGET_ARCH[arch=x86_64*]" = x86_64;
|
||||
"CARGO_XCODE_TARGET_OS[sdk=appletvos*]" = tvos;
|
||||
"CARGO_XCODE_TARGET_OS[sdk=appletvsimulator*]" = tvos;
|
||||
"CARGO_XCODE_TARGET_OS[sdk=iphoneos*]" = ios;
|
||||
"CARGO_XCODE_TARGET_OS[sdk=iphonesimulator*]" = "ios-sim";
|
||||
"CARGO_XCODE_TARGET_OS[sdk=macosx*]" = darwin;
|
||||
PRODUCT_NAME = rustdesk;
|
||||
SDKROOT = macosx;
|
||||
SUPPORTS_MACCATALYST = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
CA6028B9540B12977AAB839F /* Build configuration list for PBXNativeTarget "librustdesk-staticlib" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
CA60583BB9CE12977AAB839F /* Release */,
|
||||
CA604B55B26012977AAB839F /* Debug */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
CA6028B9540BC858B7409EE3 /* Build configuration list for PBXNativeTarget "naming-bin" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
CA60583BB9CEC858B7409EE3 /* Release */,
|
||||
CA604B55B260C858B7409EE3 /* Debug */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
CA6028B9540BC9FA710A2219 /* Build configuration list for PBXNativeTarget "rustdesk-bin" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
CA60583BB9CEC9FA710A2219 /* Release */,
|
||||
CA604B55B260C9FA710A2219 /* Debug */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
CA6028B9540BD6691E4C3FF1 /* Build configuration list for PBXNativeTarget "librustdesk-cdylib" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
CA60583BB9CED6691E4C3FF1 /* Release */,
|
||||
CA604B55B260D6691E4C3FF1 /* Debug */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
CA603C4309E180E02D6C7F57 /* Build configuration list for PBXProject "rustdesk" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
CA608F3F78EE3CC16B37690B /* Release */,
|
||||
CA608F3F78EE228BE02872F8 /* Debug */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = CA603C4309E1E04653AD465F /* Project object */;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@ description: Your Remote Desktop Software
|
||||
|
||||
# The following line prevents the package from being accidentally published to
|
||||
# pub.dev using `pub publish`. This is preferred for private packages.
|
||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
||||
|
||||
# The following defines the version and build number for your application.
|
||||
# A version number is three numbers separated by dots, like 1.2.43
|
||||
@@ -19,93 +19,127 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
version: 1.1.10-1+28
|
||||
|
||||
environment:
|
||||
sdk: ">=2.16.1"
|
||||
sdk: ">=2.16.1"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.3
|
||||
ffi: ^1.1.2
|
||||
path_provider: ^2.0.2
|
||||
external_path: ^1.0.1
|
||||
provider: ^6.0.3
|
||||
tuple: ^2.0.0
|
||||
wakelock: ^0.5.2
|
||||
device_info: ^2.0.2
|
||||
firebase_analytics: ^9.1.5
|
||||
package_info: ^2.0.2
|
||||
url_launcher: ^6.0.9
|
||||
shared_preferences: ^2.0.6
|
||||
toggle_switch: ^1.4.0
|
||||
dash_chat_2: ^0.0.12
|
||||
draggable_float_widget: ^0.0.2
|
||||
settings_ui: ^2.0.2
|
||||
flutter_breadcrumb: ^1.0.1
|
||||
http: ^0.13.4
|
||||
qr_code_scanner: ^1.0.0
|
||||
zxing2: ^0.1.0
|
||||
image_picker: ^0.8.5
|
||||
image: ^3.1.3
|
||||
flutter_smart_dialog: ^4.3.1
|
||||
flutter_rust_bridge: ^1.30.0
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.3
|
||||
ffi: ^2.0.1
|
||||
path_provider: ^2.0.2
|
||||
external_path: ^1.0.1
|
||||
provider: ^6.0.3
|
||||
tuple: ^2.0.0
|
||||
wakelock: ^0.5.2
|
||||
device_info_plus: ^4.0.2
|
||||
firebase_analytics: ^9.1.5
|
||||
package_info_plus: ^1.4.2
|
||||
url_launcher: ^6.0.9
|
||||
shared_preferences: ^2.0.6
|
||||
toggle_switch: ^1.4.0
|
||||
dash_chat_2:
|
||||
git:
|
||||
url: https://github.com/fufesou/Dash-Chat-2
|
||||
ref: feat_maxWidth
|
||||
draggable_float_widget: ^0.0.2
|
||||
settings_ui: ^2.0.2
|
||||
flutter_breadcrumb: ^1.0.1
|
||||
http: ^0.13.4
|
||||
qr_code_scanner: ^1.0.0
|
||||
zxing2: ^0.1.0
|
||||
image_picker: ^0.8.5
|
||||
image: ^3.1.3
|
||||
back_button_interceptor: ^6.0.1
|
||||
flutter_rust_bridge:
|
||||
git:
|
||||
url: https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge
|
||||
ref: master
|
||||
path: frb_dart
|
||||
window_manager:
|
||||
git:
|
||||
url: https://github.com/Kingtous/rustdesk_window_manager
|
||||
ref: 799ef079e87938c3f4340591b4330c2598f38bb9
|
||||
desktop_multi_window:
|
||||
git:
|
||||
url: https://github.com/Kingtous/rustdesk_desktop_multi_window
|
||||
ref: e013c81d75320bbf28adddeaadf462264ee6039d
|
||||
freezed_annotation: ^2.0.3
|
||||
tray_manager:
|
||||
git:
|
||||
url: https://github.com/Kingtous/rustdesk_tray_manager
|
||||
ref: 3aa37c86e47ea748e7b5507cbe59f2c54ebdb23a
|
||||
get: ^4.6.5
|
||||
visibility_detector: ^0.3.3
|
||||
contextmenu: ^3.0.0
|
||||
desktop_drop: ^0.3.3
|
||||
scroll_pos: ^0.3.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_launcher_icons: ^0.9.1
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_launcher_icons: ^0.9.1
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
build_runner: ^2.1.11
|
||||
freezed: ^2.0.3
|
||||
flutter_lints: ^2.0.0
|
||||
|
||||
# rerun: flutter pub run flutter_launcher_icons:main
|
||||
flutter_icons:
|
||||
android: "ic_launcher"
|
||||
ios: true
|
||||
image_path: "../1024-rec.png"
|
||||
android: "ic_launcher"
|
||||
ios: true
|
||||
image_path: "../1024-rec.png"
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
# The following section is specific to Flutter.
|
||||
flutter:
|
||||
# The following line ensures that the Material Icons font is
|
||||
# included with your application, so that you can use the icons in
|
||||
# the material Icons class.
|
||||
uses-material-design: true
|
||||
|
||||
# The following line ensures that the Material Icons font is
|
||||
# included with your application, so that you can use the icons in
|
||||
# the material Icons class.
|
||||
uses-material-design: true
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
assets:
|
||||
- assets/
|
||||
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
assets:
|
||||
- assets/
|
||||
fonts:
|
||||
- family: GestureIcons
|
||||
fonts:
|
||||
- asset: assets/gestures.ttf
|
||||
- family: Tabbar
|
||||
fonts:
|
||||
- asset: assets/tabbar.ttf
|
||||
- family: PeerSearchbar
|
||||
fonts:
|
||||
- asset: assets/peer_searchbar.ttf
|
||||
|
||||
fonts:
|
||||
- family: GestureIcons
|
||||
fonts:
|
||||
- asset: assets/gestures.ttf
|
||||
|
||||
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/assets-and-images/#resolution-aware.
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/assets-and-images/#resolution-aware.
|
||||
|
||||
# For details regarding adding assets from package dependencies, see
|
||||
# https://flutter.dev/assets-and-images/#from-packages
|
||||
# For details regarding adding assets from package dependencies, see
|
||||
# https://flutter.dev/assets-and-images/#from-packages
|
||||
|
||||
# To add custom fonts to your application, add a fonts section here,
|
||||
# in this "flutter" section. Each entry in this list should have a
|
||||
# "family" key with the font family name, and a "fonts" key with a
|
||||
# list giving the asset and other descriptors for the font. For
|
||||
# example:
|
||||
# fonts:
|
||||
# - family: Schyler
|
||||
# fonts:
|
||||
# - asset: fonts/Schyler-Regular.ttf
|
||||
# - asset: fonts/Schyler-Italic.ttf
|
||||
# style: italic
|
||||
# - family: Trajan Pro
|
||||
# fonts:
|
||||
# - asset: fonts/TrajanPro.ttf
|
||||
# - asset: fonts/TrajanPro_Bold.ttf
|
||||
# weight: 700
|
||||
#
|
||||
# For details regarding fonts from package dependencies,
|
||||
# see https://flutter.dev/custom-fonts/#from-packages
|
||||
# To add custom fonts to your application, add a fonts section here,
|
||||
# in this "flutter" section. Each entry in this list should have a
|
||||
# "family" key with the font family name, and a "fonts" key with a
|
||||
# list giving the asset and other descriptors for the font. For
|
||||
# example:
|
||||
# fonts:
|
||||
# - family: Schyler
|
||||
# fonts:
|
||||
# - asset: fonts/Schyler-Regular.ttf
|
||||
# - asset: fonts/Schyler-Italic.ttf
|
||||
# style: italic
|
||||
# - family: Trajan Pro
|
||||
# fonts:
|
||||
# - asset: fonts/TrajanPro.ttf
|
||||
# - asset: fonts/TrajanPro_Bold.ttf
|
||||
# weight: 700
|
||||
#
|
||||
# For details regarding fonts from package dependencies,
|
||||
# see https://flutter.dev/custom-fonts/#from-packages
|
||||
|
||||
19
flutter/rustdesk.desktop
Normal file
19
flutter/rustdesk.desktop
Normal file
@@ -0,0 +1,19 @@
|
||||
[Desktop Entry]
|
||||
Version=1.1.10
|
||||
Name=RustDesk
|
||||
GenericName=Remote Desktop
|
||||
Comment=Remote Desktop
|
||||
Exec=/usr/lib/rustdesk/flutter_hbb %u
|
||||
Icon=/usr/share/rustdesk/files/rustdesk.png
|
||||
Terminal=false
|
||||
Type=Application
|
||||
StartupNotify=true
|
||||
Categories=Network;RemoteAccess;GTK;
|
||||
Keywords=internet;
|
||||
Actions=new-window;
|
||||
|
||||
X-Desktop-File-Install-Version=0.23
|
||||
|
||||
[Desktop Action new-window]
|
||||
Name=Open a New Window
|
||||
|
||||
16
flutter/rustdesk.service
Normal file
16
flutter/rustdesk.service
Normal file
@@ -0,0 +1,16 @@
|
||||
[Unit]
|
||||
Description=RustDesk
|
||||
Requires=network.target
|
||||
After=systemd-user-sessions.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/lib/rustdesk/flutter_hbb --service
|
||||
PIDFile=/run/rustdesk.pid
|
||||
KillMode=mixed
|
||||
TimeoutStopSec=30
|
||||
User=root
|
||||
LimitNOFILE=100000
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
17
flutter/windows/.gitignore
vendored
Normal file
17
flutter/windows/.gitignore
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
flutter/ephemeral/
|
||||
|
||||
# Visual Studio user-specific files.
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# Visual Studio build-related files.
|
||||
x64/
|
||||
x86/
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
101
flutter/windows/CMakeLists.txt
Normal file
101
flutter/windows/CMakeLists.txt
Normal file
@@ -0,0 +1,101 @@
|
||||
# Project-level configuration.
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(flutter_hbb LANGUAGES CXX)
|
||||
|
||||
# The name of the executable created for the application. Change this to change
|
||||
# the on-disk name of your application.
|
||||
set(BINARY_NAME "flutter_hbb")
|
||||
|
||||
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
|
||||
# versions of CMake.
|
||||
cmake_policy(SET CMP0063 NEW)
|
||||
|
||||
# Define build configuration option.
|
||||
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
if(IS_MULTICONFIG)
|
||||
set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
|
||||
CACHE STRING "" FORCE)
|
||||
else()
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE "Debug" CACHE
|
||||
STRING "Flutter build mode" FORCE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
"Debug" "Profile" "Release")
|
||||
endif()
|
||||
endif()
|
||||
# Define settings for the Profile build mode.
|
||||
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
|
||||
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
|
||||
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
|
||||
# Use Unicode for all projects.
|
||||
add_definitions(-DUNICODE -D_UNICODE)
|
||||
|
||||
# Compilation settings that should be applied to most targets.
|
||||
#
|
||||
# Be cautious about adding new options here, as plugins use this function by
|
||||
# default. In most cases, you should add new options to specific targets instead
|
||||
# of modifying this function.
|
||||
function(APPLY_STANDARD_SETTINGS TARGET)
|
||||
target_compile_features(${TARGET} PUBLIC cxx_std_17)
|
||||
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
|
||||
target_compile_options(${TARGET} PRIVATE /EHsc)
|
||||
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
|
||||
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
|
||||
endfunction()
|
||||
|
||||
# Flutter library and tool build rules.
|
||||
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
|
||||
add_subdirectory(${FLUTTER_MANAGED_DIR})
|
||||
|
||||
# Application build; see runner/CMakeLists.txt.
|
||||
add_subdirectory("runner")
|
||||
|
||||
# Generated plugin build rules, which manage building the plugins and adding
|
||||
# them to the application.
|
||||
include(flutter/generated_plugins.cmake)
|
||||
|
||||
|
||||
# === Installation ===
|
||||
# Support files are copied into place next to the executable, so that it can
|
||||
# run in place. This is done instead of making a separate bundle (as on Linux)
|
||||
# so that building and running from within Visual Studio will work.
|
||||
set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>")
|
||||
# Make the "install" step default, as it's required to run.
|
||||
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
|
||||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
|
||||
endif()
|
||||
|
||||
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
|
||||
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
if(PLUGIN_BUNDLED_LIBRARIES)
|
||||
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
|
||||
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
endif()
|
||||
|
||||
# Fully re-copy the assets directory on each build to avoid having stale files
|
||||
# from a previous install.
|
||||
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
|
||||
install(CODE "
|
||||
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
|
||||
" COMPONENT Runtime)
|
||||
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
|
||||
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
|
||||
|
||||
# Install the AOT library on non-Debug builds only.
|
||||
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
|
||||
CONFIGURATIONS Profile;Release
|
||||
COMPONENT Runtime)
|
||||
104
flutter/windows/flutter/CMakeLists.txt
Normal file
104
flutter/windows/flutter/CMakeLists.txt
Normal file
@@ -0,0 +1,104 @@
|
||||
# This file controls Flutter-level build steps. It should not be edited.
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
|
||||
|
||||
# Configuration provided via flutter tool.
|
||||
include(${EPHEMERAL_DIR}/generated_config.cmake)
|
||||
|
||||
# TODO: Move the rest of this into files in ephemeral. See
|
||||
# https://github.com/flutter/flutter/issues/57146.
|
||||
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
|
||||
|
||||
# === Flutter Library ===
|
||||
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
|
||||
|
||||
# Published to parent scope for install step.
|
||||
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
|
||||
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
|
||||
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
|
||||
set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
|
||||
|
||||
list(APPEND FLUTTER_LIBRARY_HEADERS
|
||||
"flutter_export.h"
|
||||
"flutter_windows.h"
|
||||
"flutter_messenger.h"
|
||||
"flutter_plugin_registrar.h"
|
||||
"flutter_texture_registrar.h"
|
||||
)
|
||||
list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
|
||||
add_library(flutter INTERFACE)
|
||||
target_include_directories(flutter INTERFACE
|
||||
"${EPHEMERAL_DIR}"
|
||||
)
|
||||
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
|
||||
add_dependencies(flutter flutter_assemble)
|
||||
|
||||
# === Wrapper ===
|
||||
list(APPEND CPP_WRAPPER_SOURCES_CORE
|
||||
"core_implementations.cc"
|
||||
"standard_codec.cc"
|
||||
)
|
||||
list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
|
||||
list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
|
||||
"plugin_registrar.cc"
|
||||
)
|
||||
list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
|
||||
list(APPEND CPP_WRAPPER_SOURCES_APP
|
||||
"flutter_engine.cc"
|
||||
"flutter_view_controller.cc"
|
||||
)
|
||||
list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
|
||||
|
||||
# Wrapper sources needed for a plugin.
|
||||
add_library(flutter_wrapper_plugin STATIC
|
||||
${CPP_WRAPPER_SOURCES_CORE}
|
||||
${CPP_WRAPPER_SOURCES_PLUGIN}
|
||||
)
|
||||
apply_standard_settings(flutter_wrapper_plugin)
|
||||
set_target_properties(flutter_wrapper_plugin PROPERTIES
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
set_target_properties(flutter_wrapper_plugin PROPERTIES
|
||||
CXX_VISIBILITY_PRESET hidden)
|
||||
target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
|
||||
target_include_directories(flutter_wrapper_plugin PUBLIC
|
||||
"${WRAPPER_ROOT}/include"
|
||||
)
|
||||
add_dependencies(flutter_wrapper_plugin flutter_assemble)
|
||||
|
||||
# Wrapper sources needed for the runner.
|
||||
add_library(flutter_wrapper_app STATIC
|
||||
${CPP_WRAPPER_SOURCES_CORE}
|
||||
${CPP_WRAPPER_SOURCES_APP}
|
||||
)
|
||||
apply_standard_settings(flutter_wrapper_app)
|
||||
target_link_libraries(flutter_wrapper_app PUBLIC flutter)
|
||||
target_include_directories(flutter_wrapper_app PUBLIC
|
||||
"${WRAPPER_ROOT}/include"
|
||||
)
|
||||
add_dependencies(flutter_wrapper_app flutter_assemble)
|
||||
|
||||
# === Flutter tool backend ===
|
||||
# _phony_ is a non-existent file to force this command to run every time,
|
||||
# since currently there's no way to get a full input/output list from the
|
||||
# flutter tool.
|
||||
set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
|
||||
set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
|
||||
add_custom_command(
|
||||
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
|
||||
${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
|
||||
${CPP_WRAPPER_SOURCES_APP}
|
||||
${PHONY_OUTPUT}
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
${FLUTTER_TOOL_ENVIRONMENT}
|
||||
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
|
||||
windows-x64 $<CONFIG>
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(flutter_assemble DEPENDS
|
||||
"${FLUTTER_LIBRARY}"
|
||||
${FLUTTER_LIBRARY_HEADERS}
|
||||
${CPP_WRAPPER_SOURCES_CORE}
|
||||
${CPP_WRAPPER_SOURCES_PLUGIN}
|
||||
${CPP_WRAPPER_SOURCES_APP}
|
||||
)
|
||||
51
flutter/windows/runner/CMakeLists.txt
Normal file
51
flutter/windows/runner/CMakeLists.txt
Normal file
@@ -0,0 +1,51 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(runner LANGUAGES CXX)
|
||||
|
||||
# Define the application target. To change its name, change BINARY_NAME in the
|
||||
# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
|
||||
# work.
|
||||
#
|
||||
# Any new source files that you add to the application should be added here.
|
||||
add_executable(${BINARY_NAME} WIN32
|
||||
"flutter_window.cpp"
|
||||
"main.cpp"
|
||||
"utils.cpp"
|
||||
"win32_window.cpp"
|
||||
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
|
||||
"Runner.rc"
|
||||
"runner.exe.manifest"
|
||||
)
|
||||
|
||||
# flutter_rust_bridge with Corrosion
|
||||
find_package(Corrosion REQUIRED)
|
||||
|
||||
corrosion_import_crate(MANIFEST_PATH ../../../Cargo.toml
|
||||
# Equivalent to --all-features passed to cargo build
|
||||
# [ALL_FEATURES]
|
||||
# Equivalent to --no-default-features passed to cargo build
|
||||
# [NO_DEFAULT_FEATURES]
|
||||
# Disable linking of standard libraries (required for no_std crates).
|
||||
# [NO_STD]
|
||||
# Specify cargo build profile (e.g. release or a custom profile)
|
||||
# [PROFILE <cargo-profile>]
|
||||
# Only import the specified crates from a workspace
|
||||
# [CRATES <crate1> ... <crateN>]
|
||||
# Enable the specified features
|
||||
# [FEATURES <feature1> ... <featureN>]
|
||||
)
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE librustdesk)
|
||||
|
||||
# Apply the standard set of build settings. This can be removed for applications
|
||||
# that need different build settings.
|
||||
apply_standard_settings(${BINARY_NAME})
|
||||
|
||||
# Disable Windows macros that collide with C++ standard library functions.
|
||||
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
|
||||
|
||||
# Add dependency libraries and include directories. Add any application-specific
|
||||
# dependencies here.
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
|
||||
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
|
||||
|
||||
# Run the Flutter tool portions of the build. This must not be removed.
|
||||
add_dependencies(${BINARY_NAME} flutter_assemble)
|
||||
121
flutter/windows/runner/Runner.rc
Normal file
121
flutter/windows/runner/Runner.rc
Normal file
@@ -0,0 +1,121 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#pragma code_page(65001)
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United States) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_APP_ICON ICON "resources\\app_icon.ico"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
#ifdef FLUTTER_BUILD_NUMBER
|
||||
#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
|
||||
#else
|
||||
#define VERSION_AS_NUMBER 1,0,0
|
||||
#endif
|
||||
|
||||
#ifdef FLUTTER_BUILD_NAME
|
||||
#define VERSION_AS_STRING #FLUTTER_BUILD_NAME
|
||||
#else
|
||||
#define VERSION_AS_STRING "1.0.0"
|
||||
#endif
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION_AS_NUMBER
|
||||
PRODUCTVERSION VERSION_AS_NUMBER
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS VS_FF_DEBUG
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS VOS__WINDOWS32
|
||||
FILETYPE VFT_APP
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904e4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "com.carriez" "\0"
|
||||
VALUE "FileDescription", "flutter_hbb" "\0"
|
||||
VALUE "FileVersion", VERSION_AS_STRING "\0"
|
||||
VALUE "InternalName", "flutter_hbb" "\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2022 com.carriez. All rights reserved." "\0"
|
||||
VALUE "OriginalFilename", "flutter_hbb.exe" "\0"
|
||||
VALUE "ProductName", "flutter_hbb" "\0"
|
||||
VALUE "ProductVersion", VERSION_AS_STRING "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
||||
#endif // English (United States) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
61
flutter/windows/runner/flutter_window.cpp
Normal file
61
flutter/windows/runner/flutter_window.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
#include "flutter_window.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "flutter/generated_plugin_registrant.h"
|
||||
|
||||
FlutterWindow::FlutterWindow(const flutter::DartProject& project)
|
||||
: project_(project) {}
|
||||
|
||||
FlutterWindow::~FlutterWindow() {}
|
||||
|
||||
bool FlutterWindow::OnCreate() {
|
||||
if (!Win32Window::OnCreate()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RECT frame = GetClientArea();
|
||||
|
||||
// The size here must match the window dimensions to avoid unnecessary surface
|
||||
// creation / destruction in the startup path.
|
||||
flutter_controller_ = std::make_unique<flutter::FlutterViewController>(
|
||||
frame.right - frame.left, frame.bottom - frame.top, project_);
|
||||
// Ensure that basic setup of the controller was successful.
|
||||
if (!flutter_controller_->engine() || !flutter_controller_->view()) {
|
||||
return false;
|
||||
}
|
||||
RegisterPlugins(flutter_controller_->engine());
|
||||
SetChildContent(flutter_controller_->view()->GetNativeWindow());
|
||||
return true;
|
||||
}
|
||||
|
||||
void FlutterWindow::OnDestroy() {
|
||||
if (flutter_controller_) {
|
||||
flutter_controller_ = nullptr;
|
||||
}
|
||||
|
||||
Win32Window::OnDestroy();
|
||||
}
|
||||
|
||||
LRESULT
|
||||
FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
|
||||
WPARAM const wparam,
|
||||
LPARAM const lparam) noexcept {
|
||||
// Give Flutter, including plugins, an opportunity to handle window messages.
|
||||
if (flutter_controller_) {
|
||||
std::optional<LRESULT> result =
|
||||
flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
|
||||
lparam);
|
||||
if (result) {
|
||||
return *result;
|
||||
}
|
||||
}
|
||||
|
||||
switch (message) {
|
||||
case WM_FONTCHANGE:
|
||||
flutter_controller_->engine()->ReloadSystemFonts();
|
||||
break;
|
||||
}
|
||||
|
||||
return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
|
||||
}
|
||||
33
flutter/windows/runner/flutter_window.h
Normal file
33
flutter/windows/runner/flutter_window.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef RUNNER_FLUTTER_WINDOW_H_
|
||||
#define RUNNER_FLUTTER_WINDOW_H_
|
||||
|
||||
#include <flutter/dart_project.h>
|
||||
#include <flutter/flutter_view_controller.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "win32_window.h"
|
||||
|
||||
// A window that does nothing but host a Flutter view.
|
||||
class FlutterWindow : public Win32Window {
|
||||
public:
|
||||
// Creates a new FlutterWindow hosting a Flutter view running |project|.
|
||||
explicit FlutterWindow(const flutter::DartProject& project);
|
||||
virtual ~FlutterWindow();
|
||||
|
||||
protected:
|
||||
// Win32Window:
|
||||
bool OnCreate() override;
|
||||
void OnDestroy() override;
|
||||
LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
|
||||
LPARAM const lparam) noexcept override;
|
||||
|
||||
private:
|
||||
// The project to run.
|
||||
flutter::DartProject project_;
|
||||
|
||||
// The Flutter instance hosted by this window.
|
||||
std::unique_ptr<flutter::FlutterViewController> flutter_controller_;
|
||||
};
|
||||
|
||||
#endif // RUNNER_FLUTTER_WINDOW_H_
|
||||
71
flutter/windows/runner/main.cpp
Normal file
71
flutter/windows/runner/main.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
#include <flutter/dart_project.h>
|
||||
#include <flutter/flutter_view_controller.h>
|
||||
#include <windows.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "flutter_window.h"
|
||||
#include "utils.h"
|
||||
// #include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
|
||||
|
||||
typedef bool (*FUNC_RUSTDESK_CORE_MAIN)(void);
|
||||
|
||||
// auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);
|
||||
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
||||
_In_ wchar_t *command_line, _In_ int show_command)
|
||||
{
|
||||
HINSTANCE hInstance = LoadLibraryA("librustdesk.dll");
|
||||
if (!hInstance)
|
||||
{
|
||||
std::cout << "Failed to load librustdesk.dll" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
FUNC_RUSTDESK_CORE_MAIN rustdesk_core_main =
|
||||
(FUNC_RUSTDESK_CORE_MAIN)GetProcAddress(hInstance, "rustdesk_core_main");
|
||||
if (!rustdesk_core_main)
|
||||
{
|
||||
std::cout << "Failed to get rustdesk_core_main" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (!rustdesk_core_main())
|
||||
{
|
||||
std::cout << "Rustdesk core returns false, exiting without launching Flutter app" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// Attach to console when present (e.g., 'flutter run') or create a
|
||||
// new console when running with a debugger.
|
||||
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent())
|
||||
{
|
||||
CreateAndAttachConsole();
|
||||
}
|
||||
|
||||
// Initialize COM, so that it is available for use in the library and/or
|
||||
// plugins.
|
||||
::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
||||
|
||||
flutter::DartProject project(L"data");
|
||||
|
||||
std::vector<std::string> command_line_arguments =
|
||||
GetCommandLineArguments();
|
||||
|
||||
project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
|
||||
|
||||
FlutterWindow window(project);
|
||||
Win32Window::Point origin(10, 10);
|
||||
Win32Window::Size size(1280, 720);
|
||||
if (!window.CreateAndShow(L"flutter_hbb", origin, size))
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
window.SetQuitOnClose(true);
|
||||
|
||||
::MSG msg;
|
||||
while (::GetMessage(&msg, nullptr, 0, 0))
|
||||
{
|
||||
::TranslateMessage(&msg);
|
||||
::DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
::CoUninitialize();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
16
flutter/windows/runner/resource.h
Normal file
16
flutter/windows/runner/resource.h
Normal file
@@ -0,0 +1,16 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by Runner.rc
|
||||
//
|
||||
#define IDI_APP_ICON 101
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
BIN
flutter/windows/runner/resources/app_icon.ico
Normal file
BIN
flutter/windows/runner/resources/app_icon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
20
flutter/windows/runner/runner.exe.manifest
Normal file
20
flutter/windows/runner/runner.exe.manifest
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||
<!-- Windows 8.1 -->
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||
<!-- Windows 8 -->
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||
<!-- Windows 7 -->
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||
</application>
|
||||
</compatibility>
|
||||
</assembly>
|
||||
64
flutter/windows/runner/utils.cpp
Normal file
64
flutter/windows/runner/utils.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#include "utils.h"
|
||||
|
||||
#include <flutter_windows.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void CreateAndAttachConsole() {
|
||||
if (::AllocConsole()) {
|
||||
FILE *unused;
|
||||
if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
|
||||
_dup2(_fileno(stdout), 1);
|
||||
}
|
||||
if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
|
||||
_dup2(_fileno(stdout), 2);
|
||||
}
|
||||
std::ios::sync_with_stdio();
|
||||
FlutterDesktopResyncOutputStreams();
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> GetCommandLineArguments() {
|
||||
// Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
|
||||
int argc;
|
||||
wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
|
||||
if (argv == nullptr) {
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
std::vector<std::string> command_line_arguments;
|
||||
|
||||
// Skip the first argument as it's the binary name.
|
||||
for (int i = 1; i < argc; i++) {
|
||||
command_line_arguments.push_back(Utf8FromUtf16(argv[i]));
|
||||
}
|
||||
|
||||
::LocalFree(argv);
|
||||
|
||||
return command_line_arguments;
|
||||
}
|
||||
|
||||
std::string Utf8FromUtf16(const wchar_t* utf16_string) {
|
||||
if (utf16_string == nullptr) {
|
||||
return std::string();
|
||||
}
|
||||
int target_length = ::WideCharToMultiByte(
|
||||
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
|
||||
-1, nullptr, 0, nullptr, nullptr);
|
||||
std::string utf8_string;
|
||||
if (target_length == 0 || target_length > utf8_string.max_size()) {
|
||||
return utf8_string;
|
||||
}
|
||||
utf8_string.resize(target_length);
|
||||
int converted_length = ::WideCharToMultiByte(
|
||||
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
|
||||
-1, utf8_string.data(),
|
||||
target_length, nullptr, nullptr);
|
||||
if (converted_length == 0) {
|
||||
return std::string();
|
||||
}
|
||||
return utf8_string;
|
||||
}
|
||||
19
flutter/windows/runner/utils.h
Normal file
19
flutter/windows/runner/utils.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef RUNNER_UTILS_H_
|
||||
#define RUNNER_UTILS_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Creates a console for the process, and redirects stdout and stderr to
|
||||
// it for both the runner and the Flutter library.
|
||||
void CreateAndAttachConsole();
|
||||
|
||||
// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
|
||||
// encoded in UTF-8. Returns an empty std::string on failure.
|
||||
std::string Utf8FromUtf16(const wchar_t* utf16_string);
|
||||
|
||||
// Gets the command line arguments passed in as a std::vector<std::string>,
|
||||
// encoded in UTF-8. Returns an empty std::vector<std::string> on failure.
|
||||
std::vector<std::string> GetCommandLineArguments();
|
||||
|
||||
#endif // RUNNER_UTILS_H_
|
||||
245
flutter/windows/runner/win32_window.cpp
Normal file
245
flutter/windows/runner/win32_window.cpp
Normal file
@@ -0,0 +1,245 @@
|
||||
#include "win32_window.h"
|
||||
|
||||
#include <flutter_windows.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
|
||||
|
||||
// The number of Win32Window objects that currently exist.
|
||||
static int g_active_window_count = 0;
|
||||
|
||||
using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd);
|
||||
|
||||
// Scale helper to convert logical scaler values to physical using passed in
|
||||
// scale factor
|
||||
int Scale(int source, double scale_factor) {
|
||||
return static_cast<int>(source * scale_factor);
|
||||
}
|
||||
|
||||
// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module.
|
||||
// This API is only needed for PerMonitor V1 awareness mode.
|
||||
void EnableFullDpiSupportIfAvailable(HWND hwnd) {
|
||||
HMODULE user32_module = LoadLibraryA("User32.dll");
|
||||
if (!user32_module) {
|
||||
return;
|
||||
}
|
||||
auto enable_non_client_dpi_scaling =
|
||||
reinterpret_cast<EnableNonClientDpiScaling*>(
|
||||
GetProcAddress(user32_module, "EnableNonClientDpiScaling"));
|
||||
if (enable_non_client_dpi_scaling != nullptr) {
|
||||
enable_non_client_dpi_scaling(hwnd);
|
||||
FreeLibrary(user32_module);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Manages the Win32Window's window class registration.
|
||||
class WindowClassRegistrar {
|
||||
public:
|
||||
~WindowClassRegistrar() = default;
|
||||
|
||||
// Returns the singleton registar instance.
|
||||
static WindowClassRegistrar* GetInstance() {
|
||||
if (!instance_) {
|
||||
instance_ = new WindowClassRegistrar();
|
||||
}
|
||||
return instance_;
|
||||
}
|
||||
|
||||
// Returns the name of the window class, registering the class if it hasn't
|
||||
// previously been registered.
|
||||
const wchar_t* GetWindowClass();
|
||||
|
||||
// Unregisters the window class. Should only be called if there are no
|
||||
// instances of the window.
|
||||
void UnregisterWindowClass();
|
||||
|
||||
private:
|
||||
WindowClassRegistrar() = default;
|
||||
|
||||
static WindowClassRegistrar* instance_;
|
||||
|
||||
bool class_registered_ = false;
|
||||
};
|
||||
|
||||
WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr;
|
||||
|
||||
const wchar_t* WindowClassRegistrar::GetWindowClass() {
|
||||
if (!class_registered_) {
|
||||
WNDCLASS window_class{};
|
||||
window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||
window_class.lpszClassName = kWindowClassName;
|
||||
window_class.style = CS_HREDRAW | CS_VREDRAW;
|
||||
window_class.cbClsExtra = 0;
|
||||
window_class.cbWndExtra = 0;
|
||||
window_class.hInstance = GetModuleHandle(nullptr);
|
||||
window_class.hIcon =
|
||||
LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
|
||||
window_class.hbrBackground = 0;
|
||||
window_class.lpszMenuName = nullptr;
|
||||
window_class.lpfnWndProc = Win32Window::WndProc;
|
||||
RegisterClass(&window_class);
|
||||
class_registered_ = true;
|
||||
}
|
||||
return kWindowClassName;
|
||||
}
|
||||
|
||||
void WindowClassRegistrar::UnregisterWindowClass() {
|
||||
UnregisterClass(kWindowClassName, nullptr);
|
||||
class_registered_ = false;
|
||||
}
|
||||
|
||||
Win32Window::Win32Window() {
|
||||
++g_active_window_count;
|
||||
}
|
||||
|
||||
Win32Window::~Win32Window() {
|
||||
--g_active_window_count;
|
||||
Destroy();
|
||||
}
|
||||
|
||||
bool Win32Window::CreateAndShow(const std::wstring& title,
|
||||
const Point& origin,
|
||||
const Size& size) {
|
||||
Destroy();
|
||||
|
||||
const wchar_t* window_class =
|
||||
WindowClassRegistrar::GetInstance()->GetWindowClass();
|
||||
|
||||
const POINT target_point = {static_cast<LONG>(origin.x),
|
||||
static_cast<LONG>(origin.y)};
|
||||
HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
|
||||
UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
|
||||
double scale_factor = dpi / 96.0;
|
||||
|
||||
HWND window = CreateWindow(
|
||||
window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
||||
Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
|
||||
Scale(size.width, scale_factor), Scale(size.height, scale_factor),
|
||||
nullptr, nullptr, GetModuleHandle(nullptr), this);
|
||||
|
||||
if (!window) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return OnCreate();
|
||||
}
|
||||
|
||||
// static
|
||||
LRESULT CALLBACK Win32Window::WndProc(HWND const window,
|
||||
UINT const message,
|
||||
WPARAM const wparam,
|
||||
LPARAM const lparam) noexcept {
|
||||
if (message == WM_NCCREATE) {
|
||||
auto window_struct = reinterpret_cast<CREATESTRUCT*>(lparam);
|
||||
SetWindowLongPtr(window, GWLP_USERDATA,
|
||||
reinterpret_cast<LONG_PTR>(window_struct->lpCreateParams));
|
||||
|
||||
auto that = static_cast<Win32Window*>(window_struct->lpCreateParams);
|
||||
EnableFullDpiSupportIfAvailable(window);
|
||||
that->window_handle_ = window;
|
||||
} else if (Win32Window* that = GetThisFromHandle(window)) {
|
||||
return that->MessageHandler(window, message, wparam, lparam);
|
||||
}
|
||||
|
||||
return DefWindowProc(window, message, wparam, lparam);
|
||||
}
|
||||
|
||||
LRESULT
|
||||
Win32Window::MessageHandler(HWND hwnd,
|
||||
UINT const message,
|
||||
WPARAM const wparam,
|
||||
LPARAM const lparam) noexcept {
|
||||
switch (message) {
|
||||
case WM_DESTROY:
|
||||
window_handle_ = nullptr;
|
||||
Destroy();
|
||||
if (quit_on_close_) {
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_DPICHANGED: {
|
||||
auto newRectSize = reinterpret_cast<RECT*>(lparam);
|
||||
LONG newWidth = newRectSize->right - newRectSize->left;
|
||||
LONG newHeight = newRectSize->bottom - newRectSize->top;
|
||||
|
||||
SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth,
|
||||
newHeight, SWP_NOZORDER | SWP_NOACTIVATE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
case WM_SIZE: {
|
||||
RECT rect = GetClientArea();
|
||||
if (child_content_ != nullptr) {
|
||||
// Size and position the child window.
|
||||
MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left,
|
||||
rect.bottom - rect.top, TRUE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
case WM_ACTIVATE:
|
||||
if (child_content_ != nullptr) {
|
||||
SetFocus(child_content_);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return DefWindowProc(window_handle_, message, wparam, lparam);
|
||||
}
|
||||
|
||||
void Win32Window::Destroy() {
|
||||
OnDestroy();
|
||||
|
||||
if (window_handle_) {
|
||||
DestroyWindow(window_handle_);
|
||||
window_handle_ = nullptr;
|
||||
}
|
||||
if (g_active_window_count == 0) {
|
||||
WindowClassRegistrar::GetInstance()->UnregisterWindowClass();
|
||||
}
|
||||
}
|
||||
|
||||
Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept {
|
||||
return reinterpret_cast<Win32Window*>(
|
||||
GetWindowLongPtr(window, GWLP_USERDATA));
|
||||
}
|
||||
|
||||
void Win32Window::SetChildContent(HWND content) {
|
||||
child_content_ = content;
|
||||
SetParent(content, window_handle_);
|
||||
RECT frame = GetClientArea();
|
||||
|
||||
MoveWindow(content, frame.left, frame.top, frame.right - frame.left,
|
||||
frame.bottom - frame.top, true);
|
||||
|
||||
SetFocus(child_content_);
|
||||
}
|
||||
|
||||
RECT Win32Window::GetClientArea() {
|
||||
RECT frame;
|
||||
GetClientRect(window_handle_, &frame);
|
||||
return frame;
|
||||
}
|
||||
|
||||
HWND Win32Window::GetHandle() {
|
||||
return window_handle_;
|
||||
}
|
||||
|
||||
void Win32Window::SetQuitOnClose(bool quit_on_close) {
|
||||
quit_on_close_ = quit_on_close;
|
||||
}
|
||||
|
||||
bool Win32Window::OnCreate() {
|
||||
// No-op; provided for subclasses.
|
||||
return true;
|
||||
}
|
||||
|
||||
void Win32Window::OnDestroy() {
|
||||
// No-op; provided for subclasses.
|
||||
}
|
||||
98
flutter/windows/runner/win32_window.h
Normal file
98
flutter/windows/runner/win32_window.h
Normal file
@@ -0,0 +1,98 @@
|
||||
#ifndef RUNNER_WIN32_WINDOW_H_
|
||||
#define RUNNER_WIN32_WINDOW_H_
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
// A class abstraction for a high DPI-aware Win32 Window. Intended to be
|
||||
// inherited from by classes that wish to specialize with custom
|
||||
// rendering and input handling
|
||||
class Win32Window {
|
||||
public:
|
||||
struct Point {
|
||||
unsigned int x;
|
||||
unsigned int y;
|
||||
Point(unsigned int x, unsigned int y) : x(x), y(y) {}
|
||||
};
|
||||
|
||||
struct Size {
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
Size(unsigned int width, unsigned int height)
|
||||
: width(width), height(height) {}
|
||||
};
|
||||
|
||||
Win32Window();
|
||||
virtual ~Win32Window();
|
||||
|
||||
// Creates and shows a win32 window with |title| and position and size using
|
||||
// |origin| and |size|. New windows are created on the default monitor. Window
|
||||
// sizes are specified to the OS in physical pixels, hence to ensure a
|
||||
// consistent size to will treat the width height passed in to this function
|
||||
// as logical pixels and scale to appropriate for the default monitor. Returns
|
||||
// true if the window was created successfully.
|
||||
bool CreateAndShow(const std::wstring& title,
|
||||
const Point& origin,
|
||||
const Size& size);
|
||||
|
||||
// Release OS resources associated with window.
|
||||
void Destroy();
|
||||
|
||||
// Inserts |content| into the window tree.
|
||||
void SetChildContent(HWND content);
|
||||
|
||||
// Returns the backing Window handle to enable clients to set icon and other
|
||||
// window properties. Returns nullptr if the window has been destroyed.
|
||||
HWND GetHandle();
|
||||
|
||||
// If true, closing this window will quit the application.
|
||||
void SetQuitOnClose(bool quit_on_close);
|
||||
|
||||
// Return a RECT representing the bounds of the current client area.
|
||||
RECT GetClientArea();
|
||||
|
||||
protected:
|
||||
// Processes and route salient window messages for mouse handling,
|
||||
// size change and DPI. Delegates handling of these to member overloads that
|
||||
// inheriting classes can handle.
|
||||
virtual LRESULT MessageHandler(HWND window,
|
||||
UINT const message,
|
||||
WPARAM const wparam,
|
||||
LPARAM const lparam) noexcept;
|
||||
|
||||
// Called when CreateAndShow is called, allowing subclass window-related
|
||||
// setup. Subclasses should return false if setup fails.
|
||||
virtual bool OnCreate();
|
||||
|
||||
// Called when Destroy is called.
|
||||
virtual void OnDestroy();
|
||||
|
||||
private:
|
||||
friend class WindowClassRegistrar;
|
||||
|
||||
// OS callback called by message pump. Handles the WM_NCCREATE message which
|
||||
// is passed when the non-client area is being created and enables automatic
|
||||
// non-client DPI scaling so that the non-client area automatically
|
||||
// responsponds to changes in DPI. All other messages are handled by
|
||||
// MessageHandler.
|
||||
static LRESULT CALLBACK WndProc(HWND const window,
|
||||
UINT const message,
|
||||
WPARAM const wparam,
|
||||
LPARAM const lparam) noexcept;
|
||||
|
||||
// Retrieves a class instance pointer for |window|
|
||||
static Win32Window* GetThisFromHandle(HWND const window) noexcept;
|
||||
|
||||
bool quit_on_close_ = false;
|
||||
|
||||
// window handle for top level window.
|
||||
HWND window_handle_ = nullptr;
|
||||
|
||||
// window handle for hosted content.
|
||||
HWND child_content_ = nullptr;
|
||||
};
|
||||
|
||||
#endif // RUNNER_WIN32_WINDOW_H_
|
||||
Reference in New Issue
Block a user