mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-11 17:41:28 +03:00
opt & fix:
- main window ui: adapt pc logic - fix: platform infomation using device info plus Signed-off-by: Kingtous <kingtous@qq.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:async';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
|
||||
import 'models/model.dart';
|
||||
@@ -35,6 +36,7 @@ class MyTheme {
|
||||
static const Color border = Color(0xFFCCCCCC);
|
||||
static const Color idColor = Color(0xFF00B6F0);
|
||||
static const Color darkGray = Color(0xFFB9BABC);
|
||||
static const Color dark = Colors.black87;
|
||||
}
|
||||
|
||||
final ButtonStyle flatButtonStyle = TextButton.styleFrom(
|
||||
@@ -97,9 +99,9 @@ class DialogManager {
|
||||
|
||||
static Future<T?> show<T>(DialogBuilder builder,
|
||||
{bool clickMaskDismiss = false,
|
||||
bool backDismiss = false,
|
||||
String? tag,
|
||||
bool useAnimation = true}) async {
|
||||
bool backDismiss = false,
|
||||
String? tag,
|
||||
bool useAnimation = true}) async {
|
||||
final t;
|
||||
if (tag != null) {
|
||||
t = tag;
|
||||
@@ -124,11 +126,10 @@ class DialogManager {
|
||||
}
|
||||
|
||||
class CustomAlertDialog extends StatelessWidget {
|
||||
CustomAlertDialog(
|
||||
{required this.title,
|
||||
required this.content,
|
||||
required this.actions,
|
||||
this.contentPadding});
|
||||
CustomAlertDialog({required this.title,
|
||||
required this.content,
|
||||
required this.actions,
|
||||
this.contentPadding});
|
||||
|
||||
final Widget title;
|
||||
final Widget content;
|
||||
@@ -141,7 +142,7 @@ class CustomAlertDialog extends StatelessWidget {
|
||||
scrollable: true,
|
||||
title: title,
|
||||
contentPadding:
|
||||
EdgeInsets.symmetric(horizontal: contentPadding ?? 25, vertical: 10),
|
||||
EdgeInsets.symmetric(horizontal: contentPadding ?? 25, vertical: 10),
|
||||
content: content,
|
||||
actions: actions,
|
||||
);
|
||||
|
||||
@@ -52,7 +52,11 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
getUpdateUI(),
|
||||
getSearchBarUI(),
|
||||
Row(
|
||||
children: [
|
||||
getSearchBarUI(),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 12),
|
||||
getPeers(),
|
||||
]),
|
||||
@@ -61,9 +65,9 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
|
||||
/// Callback for the connect button.
|
||||
/// Connects to the selected peer.
|
||||
void onConnect() {
|
||||
void onConnect({bool isFileTransfer = false}) {
|
||||
var id = _idController.text.trim();
|
||||
connect(id);
|
||||
connect(id, isFileTransfer: isFileTransfer);
|
||||
}
|
||||
|
||||
/// Connect to a peer with [id].
|
||||
@@ -72,9 +76,11 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
if (id == '') return;
|
||||
id = id.replaceAll(' ', '');
|
||||
if (isFileTransfer) {
|
||||
if (!await PermissionManager.check("file")) {
|
||||
if (!await PermissionManager.request("file")) {
|
||||
return;
|
||||
if (!isDesktop) {
|
||||
if (!await PermissionManager.check("file")) {
|
||||
if (!await PermissionManager.request("file")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Navigator.push(
|
||||
@@ -126,61 +132,100 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
/// 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),
|
||||
padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 16.0),
|
||||
child: Container(
|
||||
height: 84,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 8, bottom: 8),
|
||||
padding: const EdgeInsets.only(top: 16, bottom: 16),
|
||||
child: Ink(
|
||||
decoration: BoxDecoration(
|
||||
color: MyTheme.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(13)),
|
||||
),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(left: 16, right: 16),
|
||||
child: TextField(
|
||||
autocorrect: false,
|
||||
enableSuggestions: false,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
// keyboardType: TextInputType.number,
|
||||
style: TextStyle(
|
||||
fontFamily: 'WorkSans',
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 30,
|
||||
color: MyTheme.idColor,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
labelText: translate('Remote ID'),
|
||||
// hintText: 'Enter your remote ID',
|
||||
border: InputBorder.none,
|
||||
helperStyle: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
color: MyTheme.darkGray,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16,
|
||||
letterSpacing: 0.2,
|
||||
color: MyTheme.darkGray,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(left: 16, right: 16),
|
||||
child: TextField(
|
||||
autocorrect: false,
|
||||
enableSuggestions: false,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
// keyboardType: TextInputType.number,
|
||||
style: TextStyle(
|
||||
fontFamily: 'WorkSans',
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 30,
|
||||
// color: MyTheme.idColor,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
labelText: translate('Control Remote Desktop'),
|
||||
// hintText: 'Enter your remote ID',
|
||||
// border: InputBorder.,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.zero),
|
||||
helperStyle: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
color: MyTheme.dark,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 26,
|
||||
letterSpacing: 0.2,
|
||||
color: MyTheme.dark,
|
||||
),
|
||||
),
|
||||
controller: _idController,
|
||||
),
|
||||
),
|
||||
controller: _idController,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: 60,
|
||||
height: 60,
|
||||
child: IconButton(
|
||||
icon: Icon(Icons.arrow_forward,
|
||||
color: MyTheme.darkGray, size: 45),
|
||||
onPressed: onConnect,
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 16.0, horizontal: 16.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
OutlinedButton(
|
||||
onPressed: () {
|
||||
onConnect(isFileTransfer: true);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8.0, horizontal: 8.0),
|
||||
child: Text(
|
||||
translate(
|
||||
"File Transfer",
|
||||
),
|
||||
style: TextStyle(color: MyTheme.dark),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 30,
|
||||
),
|
||||
OutlinedButton(
|
||||
onPressed: onConnect,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8.0, horizontal: 16.0),
|
||||
child: Text(
|
||||
translate(
|
||||
"Connection",
|
||||
),
|
||||
style: TextStyle(color: MyTheme.white),
|
||||
),
|
||||
),
|
||||
style: OutlinedButton.styleFrom(
|
||||
backgroundColor: Colors.blueAccent,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -78,10 +78,11 @@ class _DesktopHomePageState extends State<DesktopHomePage> {
|
||||
buildServerBoard(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
// buildControlPanel(context),
|
||||
// buildRecentSession(context),
|
||||
ConnectionPage()
|
||||
Expanded(child: ConnectionPage())
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ import 'package:bitsdojo_window/bitsdojo_window.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
const sidebarColor = Color(0xFF0C6AF6);
|
||||
const backgroundStartColor = Color(0xFF7BBCF5);
|
||||
const backgroundEndColor = Color(0xFF0CCBF6);
|
||||
const backgroundStartColor = Color(0xFF0583EA);
|
||||
const backgroundEndColor = Color(0xFF0697EA);
|
||||
|
||||
class DesktopTitleBar extends StatelessWidget {
|
||||
final Widget? child;
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:device_info/device_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/services.dart';
|
||||
@@ -101,11 +101,23 @@ class PlatformFFI {
|
||||
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
|
||||
name = '${androidInfo.brand}-${androidInfo.model}';
|
||||
id = androidInfo.id.hashCode.toString();
|
||||
androidVersion = androidInfo.version.sdkInt;
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user