Merge pull request #1324 from 21pages/style
setting lock && some style change
This commit is contained in:
commit
3028d7c0ff
BIN
flutter/assets/tabbar.ttf
Normal file
BIN
flutter/assets/tabbar.ttf
Normal file
Binary file not shown.
@ -8,7 +8,7 @@ import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
|
||||
import 'package:get/instance_manager.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
@ -38,6 +38,88 @@ final iconAudio = MemoryImage(Uint8List.fromList(base64Decode(
|
||||
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==')));
|
||||
|
||||
class IconFont {
|
||||
static const _family = 'iconfont';
|
||||
IconFont._();
|
||||
|
||||
static const IconData max = IconData(0xe606, fontFamily: _family);
|
||||
static const IconData restore = IconData(0xe607, fontFamily: _family);
|
||||
static const IconData close = IconData(0xe668, fontFamily: _family);
|
||||
static const IconData min = IconData(0xe609, fontFamily: _family);
|
||||
static const IconData add = IconData(0xe664, fontFamily: _family);
|
||||
static const IconData menu = IconData(0xe628, fontFamily: _family);
|
||||
}
|
||||
|
||||
class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
|
||||
const ColorThemeExtension({
|
||||
required this.bg,
|
||||
required this.grayBg,
|
||||
required this.text,
|
||||
required this.lightText,
|
||||
required this.lighterText,
|
||||
required this.border,
|
||||
});
|
||||
|
||||
final Color? bg;
|
||||
final Color? grayBg;
|
||||
final Color? text;
|
||||
final Color? lightText;
|
||||
final Color? lighterText;
|
||||
final Color? border;
|
||||
|
||||
static const light = ColorThemeExtension(
|
||||
bg: Color(0xFFFFFFFF),
|
||||
grayBg: Color(0xFFEEEEEE),
|
||||
text: Color(0xFF222222),
|
||||
lightText: Color(0xFF666666),
|
||||
lighterText: Color(0xFF888888),
|
||||
border: Color(0xFFCCCCCC),
|
||||
);
|
||||
|
||||
static const dark = ColorThemeExtension(
|
||||
bg: Color(0xFF252525),
|
||||
grayBg: Color(0xFF141414),
|
||||
text: Color(0xFFFFFFFF),
|
||||
lightText: Color(0xFF999999),
|
||||
lighterText: Color(0xFF777777),
|
||||
border: Color(0xFF555555),
|
||||
);
|
||||
|
||||
@override
|
||||
ThemeExtension<ColorThemeExtension> copyWith(
|
||||
{Color? bg,
|
||||
Color? grayBg,
|
||||
Color? text,
|
||||
Color? lightText,
|
||||
Color? lighterText,
|
||||
Color? border}) {
|
||||
return ColorThemeExtension(
|
||||
bg: bg ?? this.bg,
|
||||
grayBg: grayBg ?? this.grayBg,
|
||||
text: text ?? this.text,
|
||||
lightText: lightText ?? this.lightText,
|
||||
lighterText: lighterText ?? this.lighterText,
|
||||
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),
|
||||
border: Color.lerp(border, other.border, t),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyTheme {
|
||||
MyTheme._();
|
||||
|
||||
@ -57,13 +139,32 @@ class MyTheme {
|
||||
brightness: Brightness.light,
|
||||
primarySwatch: Colors.blue,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
tabBarTheme: TabBarTheme(labelColor: Colors.black87),
|
||||
tabBarTheme: TabBarTheme(
|
||||
labelColor: Colors.black87,
|
||||
),
|
||||
// backgroundColor: Color(0xFFFFFFFF),
|
||||
).copyWith(
|
||||
extensions: <ThemeExtension<dynamic>>[
|
||||
ColorThemeExtension.light,
|
||||
],
|
||||
);
|
||||
static ThemeData darkTheme = ThemeData(
|
||||
brightness: Brightness.dark,
|
||||
primarySwatch: Colors.blue,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
tabBarTheme: TabBarTheme(labelColor: Colors.white70));
|
||||
tabBarTheme: TabBarTheme(
|
||||
labelColor: Colors.white70,
|
||||
),
|
||||
// backgroundColor: Color(0xFF252525)
|
||||
).copyWith(
|
||||
extensions: <ThemeExtension<dynamic>>[
|
||||
ColorThemeExtension.dark,
|
||||
],
|
||||
);
|
||||
|
||||
static ColorThemeExtension color(BuildContext context) {
|
||||
return Theme.of(context).extension<ColorThemeExtension>()!;
|
||||
}
|
||||
}
|
||||
|
||||
bool isDarkTheme() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
const double kDesktopRemoteTabBarHeight = 48.0;
|
||||
const double kDesktopRemoteTabBarHeight = 28.0;
|
||||
const String kAppTypeMain = "main";
|
||||
const String kAppTypeDesktopRemote = "remote";
|
||||
const String kAppTypeDesktopFileTransfer = "file transfer";
|
||||
|
@ -48,15 +48,16 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: buildServerInfo(context),
|
||||
flex: 1,
|
||||
buildServerInfo(context),
|
||||
VerticalDivider(
|
||||
width: 1,
|
||||
thickness: 1,
|
||||
),
|
||||
Flexible(
|
||||
Expanded(
|
||||
child: buildServerBoard(context),
|
||||
flex: 4,
|
||||
),
|
||||
],
|
||||
);
|
||||
@ -66,6 +67,8 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
return ChangeNotifierProvider.value(
|
||||
value: gFFI.serverModel,
|
||||
child: Container(
|
||||
width: 200,
|
||||
color: MyTheme.color(context).bg,
|
||||
child: Column(
|
||||
children: [
|
||||
buildTip(context),
|
||||
@ -78,44 +81,48 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
}
|
||||
|
||||
buildServerBoard(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(child: ConnectionPage()),
|
||||
],
|
||||
return Container(
|
||||
color: MyTheme.color(context).grayBg,
|
||||
child: ConnectionPage(),
|
||||
);
|
||||
}
|
||||
|
||||
buildIDBoard(BuildContext context) {
|
||||
final model = gFFI.serverModel;
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
|
||||
margin: EdgeInsets.symmetric(horizontal: 16),
|
||||
height: 52,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
children: [
|
||||
Container(
|
||||
width: 3,
|
||||
height: 70,
|
||||
width: 2,
|
||||
decoration: BoxDecoration(color: MyTheme.accent),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
Container(
|
||||
height: 15,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
translate("ID"),
|
||||
style: TextStyle(
|
||||
fontSize: 18, fontWeight: FontWeight.w500),
|
||||
fontSize: 14,
|
||||
color: MyTheme.color(context).lightText),
|
||||
),
|
||||
buildPopupMenu(context)
|
||||
],
|
||||
),
|
||||
GestureDetector(
|
||||
),
|
||||
Flexible(
|
||||
child: GestureDetector(
|
||||
onDoubleTap: () {
|
||||
Clipboard.setData(
|
||||
ClipboardData(text: model.serverId.text));
|
||||
@ -124,7 +131,15 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
child: TextFormField(
|
||||
controller: model.serverId,
|
||||
readOnly: true,
|
||||
)),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
),
|
||||
).marginOnly(bottom: 5),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -136,7 +151,8 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
|
||||
Widget buildPopupMenu(BuildContext context) {
|
||||
var position;
|
||||
return GestureDetector(
|
||||
RxBool hover = false.obs;
|
||||
return InkWell(
|
||||
onTapDown: (detail) {
|
||||
final x = detail.globalPosition.dx;
|
||||
final y = detail.globalPosition.dy;
|
||||
@ -221,31 +237,57 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
onSelectMenu(v);
|
||||
}
|
||||
},
|
||||
child: Icon(Icons.more_vert_outlined));
|
||||
child: Obx(
|
||||
() => Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(90),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: hover.value
|
||||
? MyTheme.color(context).grayBg!
|
||||
: MyTheme.color(context).bg!,
|
||||
spreadRadius: 2)
|
||||
],
|
||||
),
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.more_vert_outlined,
|
||||
size: 20,
|
||||
color: hover.value
|
||||
? MyTheme.color(context).text
|
||||
: MyTheme.color(context).lightText,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
onHover: (value) => hover.value = value,
|
||||
);
|
||||
}
|
||||
|
||||
buildPasswordBoard(BuildContext context) {
|
||||
final model = gFFI.serverModel;
|
||||
RxBool refreshHover = false.obs;
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
|
||||
margin: EdgeInsets.symmetric(vertical: 12, horizontal: 16.0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
children: [
|
||||
Container(
|
||||
width: 3,
|
||||
height: 70,
|
||||
width: 2,
|
||||
height: 52,
|
||||
decoration: BoxDecoration(color: MyTheme.accent),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
translate("Password"),
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
|
||||
style: TextStyle(
|
||||
fontSize: 14, color: MyTheme.color(context).lightText),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
@ -262,12 +304,25 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
child: TextFormField(
|
||||
controller: model.serverPasswd,
|
||||
readOnly: true,
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
),
|
||||
style: TextStyle(fontSize: 15),
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.refresh),
|
||||
onPressed: () => bind.mainUpdateTemporaryPassword(),
|
||||
InkWell(
|
||||
child: Obx(
|
||||
() => Icon(
|
||||
Icons.refresh,
|
||||
color: refreshHover.value
|
||||
? MyTheme.color(context).text
|
||||
: Color(0xFFDDDDDD),
|
||||
size: 22,
|
||||
).marginOnly(right: 5),
|
||||
),
|
||||
onTap: () => bind.mainUpdateTemporaryPassword(),
|
||||
onHover: (value) => refreshHover.value = value,
|
||||
),
|
||||
FutureBuilder<Widget>(
|
||||
future: buildPasswordPopupMenu(context),
|
||||
@ -282,7 +337,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
}
|
||||
})
|
||||
],
|
||||
),
|
||||
).marginOnly(bottom: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -294,7 +349,8 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
|
||||
Future<Widget> buildPasswordPopupMenu(BuildContext context) async {
|
||||
var position;
|
||||
return GestureDetector(
|
||||
RxBool editHover = false.obs;
|
||||
return InkWell(
|
||||
onTapDown: (detail) {
|
||||
final x = detail.globalPosition.dx;
|
||||
final y = detail.globalPosition.dy;
|
||||
@ -365,7 +421,12 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
setPasswordDialog();
|
||||
}
|
||||
},
|
||||
child: Icon(Icons.edit));
|
||||
onHover: (value) => editHover.value = value,
|
||||
child: Obx(() => Icon(Icons.edit,
|
||||
size: 22,
|
||||
color: editHover.value
|
||||
? MyTheme.color(context).text
|
||||
: Color(0xFFDDDDDD))));
|
||||
}
|
||||
|
||||
buildTip(BuildContext context) {
|
||||
@ -377,7 +438,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
children: [
|
||||
Text(
|
||||
translate("Your Desktop"),
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
|
||||
style: TextStyle(fontWeight: FontWeight.normal, fontSize: 19),
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0,
|
||||
@ -385,7 +446,8 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
Text(
|
||||
translate("desk_tip"),
|
||||
overflow: TextOverflow.clip,
|
||||
style: TextStyle(fontSize: 14),
|
||||
style: TextStyle(
|
||||
fontSize: 12, color: MyTheme.color(context).lighterText),
|
||||
)
|
||||
],
|
||||
),
|
||||
@ -394,13 +456,17 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
|
||||
buildControlPanel(BuildContext context) {
|
||||
return Container(
|
||||
width: 320,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10), color: MyTheme.white),
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(translate("Control Remote Desktop")),
|
||||
Text(
|
||||
translate("Control Remote Desktop"),
|
||||
style: TextStyle(fontWeight: FontWeight.normal, fontSize: 19),
|
||||
),
|
||||
Form(
|
||||
child: Column(
|
||||
children: [
|
||||
@ -409,6 +475,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(r"[0-9]"))
|
||||
],
|
||||
style: TextStyle(fontSize: 22, fontWeight: FontWeight.w400),
|
||||
)
|
||||
],
|
||||
))
|
||||
|
@ -71,6 +71,7 @@ class _DesktopSettingPageState extends State<DesktopSettingPage>
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Scaffold(
|
||||
backgroundColor: MyTheme.color(context).bg,
|
||||
body: Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
@ -88,6 +89,8 @@ class _DesktopSettingPageState extends State<DesktopSettingPage>
|
||||
),
|
||||
const VerticalDivider(thickness: 1, width: 1),
|
||||
Expanded(
|
||||
child: Container(
|
||||
color: MyTheme.color(context).grayBg,
|
||||
child: PageView(
|
||||
controller: controller,
|
||||
children: [
|
||||
@ -99,6 +102,7 @@ class _DesktopSettingPageState extends State<DesktopSettingPage>
|
||||
_About(),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
@ -253,32 +257,53 @@ class _Safety extends StatefulWidget {
|
||||
class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
bool locked = true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return ListView(
|
||||
children: [
|
||||
permissions(),
|
||||
password(),
|
||||
Column(
|
||||
children: [
|
||||
_lock(locked, 'Unlock Security Settings', () {
|
||||
locked = false;
|
||||
setState(() => {});
|
||||
}),
|
||||
AbsorbPointer(
|
||||
absorbing: locked,
|
||||
child: Column(children: [
|
||||
permissions(context),
|
||||
password(context),
|
||||
whitelist(),
|
||||
]),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
).marginOnly(bottom: _kListViewBottomMargin);
|
||||
}
|
||||
|
||||
Widget permissions() {
|
||||
Widget permissions(context) {
|
||||
bool enabled = !locked;
|
||||
return _Card(title: 'Permissions', children: [
|
||||
_OptionCheckBox('Enable Keyboard/Mouse', 'enable-keyboard'),
|
||||
_OptionCheckBox('Enable Clipboard', 'enable-clipboard'),
|
||||
_OptionCheckBox('Enable File Transfer', 'enable-file-transfer'),
|
||||
_OptionCheckBox('Enable Audio', 'enable-audio'),
|
||||
_OptionCheckBox('Enable Remote Restart', 'enable-remote-restart'),
|
||||
_OptionCheckBox('Enable remote configuration modification',
|
||||
'allow-remote-config-modification'),
|
||||
_OptionCheckBox(context, 'Enable Keyboard/Mouse', 'enable-keyboard',
|
||||
enabled: enabled),
|
||||
_OptionCheckBox(context, 'Enable Clipboard', 'enable-clipboard',
|
||||
enabled: enabled),
|
||||
_OptionCheckBox(context, 'Enable File Transfer', 'enable-file-transfer',
|
||||
enabled: enabled),
|
||||
_OptionCheckBox(context, 'Enable Audio', 'enable-audio',
|
||||
enabled: enabled),
|
||||
_OptionCheckBox(context, 'Enable Remote Restart', 'enable-remote-restart',
|
||||
enabled: enabled),
|
||||
_OptionCheckBox(context, 'Enable remote configuration modification',
|
||||
'allow-remote-config-modification',
|
||||
enabled: enabled),
|
||||
]);
|
||||
}
|
||||
|
||||
Widget password() {
|
||||
Widget password(BuildContext context) {
|
||||
return ChangeNotifierProvider.value(
|
||||
value: gFFI.serverModel,
|
||||
child: Consumer<ServerModel>(builder: ((context, model, child) {
|
||||
@ -297,15 +322,18 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
|
||||
String currentValue = values[keys.indexOf(model.verificationMethod)];
|
||||
List<Widget> radios = values
|
||||
.map((value) => _Radio<String>(
|
||||
context,
|
||||
value: value,
|
||||
groupValue: currentValue,
|
||||
label: value,
|
||||
onChanged: ((value) {
|
||||
model.verificationMethod = keys[values.indexOf(value)];
|
||||
})))
|
||||
}),
|
||||
enabled: !locked,
|
||||
))
|
||||
.toList();
|
||||
|
||||
var onChanged = tmp_enabled
|
||||
var onChanged = tmp_enabled && !locked
|
||||
? (value) {
|
||||
if (value != null)
|
||||
model.temporaryPasswordLength = value.toString();
|
||||
@ -319,7 +347,12 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
|
||||
value: value,
|
||||
groupValue: model.temporaryPasswordLength,
|
||||
onChanged: onChanged),
|
||||
Text(value),
|
||||
Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
color: _disabledTextColor(
|
||||
context, onChanged != null)),
|
||||
),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 10),
|
||||
onTap: () => onChanged?.call(value),
|
||||
@ -335,10 +368,10 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
|
||||
...lengthRadios,
|
||||
],
|
||||
),
|
||||
enabled: tmp_enabled),
|
||||
enabled: tmp_enabled && !locked),
|
||||
radios[1],
|
||||
_SubButton(
|
||||
'Set permanent password', setPasswordDialog, perm_enabled),
|
||||
_SubButton('Set permanent password', setPasswordDialog,
|
||||
perm_enabled && !locked),
|
||||
radios[2],
|
||||
]);
|
||||
})));
|
||||
@ -346,7 +379,8 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
|
||||
|
||||
Widget whitelist() {
|
||||
return _Card(title: 'IP Whitelisting', children: [
|
||||
_Button('IP Whitelisting', changeWhiteList, tip: 'whitelist_tip')
|
||||
_Button('IP Whitelisting', changeWhiteList,
|
||||
tip: 'whitelist_tip', enabled: !locked)
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -362,40 +396,56 @@ class _ConnectionState extends State<_Connection>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
bool locked = true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return ListView(
|
||||
bool enabled = !locked;
|
||||
return ListView(children: [
|
||||
Column(
|
||||
children: [
|
||||
_lock(locked, 'Unlock Connection Settings', () {
|
||||
locked = false;
|
||||
setState(() => {});
|
||||
}),
|
||||
AbsorbPointer(
|
||||
absorbing: locked,
|
||||
child: Column(children: [
|
||||
_Card(title: 'Server', children: [
|
||||
_Button('ID/Relay Server', changeServer),
|
||||
_Button('ID/Relay Server', changeServer, enabled: enabled),
|
||||
]),
|
||||
_Card(title: 'Service', children: [
|
||||
_OptionCheckBox('Enable Service', 'stop-service', reverse: true),
|
||||
_OptionCheckBox(context, 'Enable Service', 'stop-service',
|
||||
reverse: true, enabled: enabled),
|
||||
// TODO: Not implemented
|
||||
// _option_check('Always connected via relay', 'allow-always-relay'),
|
||||
// _option_check('Always connected via relay', 'allow-always-relay', enabled: enabled),
|
||||
// _option_check('Start ID/relay service', 'stop-rendezvous-service',
|
||||
// reverse: true),
|
||||
// reverse: true, enabled: enabled),
|
||||
]),
|
||||
_Card(title: 'TCP Tunneling', children: [
|
||||
_OptionCheckBox('Enable TCP Tunneling', 'enable-tunnel'),
|
||||
_OptionCheckBox(
|
||||
context, 'Enable TCP Tunneling', 'enable-tunnel',
|
||||
enabled: enabled),
|
||||
]),
|
||||
direct_ip(),
|
||||
direct_ip(context),
|
||||
_Card(title: 'Proxy', children: [
|
||||
_Button('Socks5 Proxy', changeSocks5Proxy),
|
||||
_Button('Socks5 Proxy', changeSocks5Proxy, enabled: enabled),
|
||||
]),
|
||||
]),
|
||||
),
|
||||
],
|
||||
).marginOnly(bottom: _kListViewBottomMargin);
|
||||
)
|
||||
]).marginOnly(bottom: _kListViewBottomMargin);
|
||||
}
|
||||
|
||||
Widget direct_ip() {
|
||||
Widget direct_ip(BuildContext context) {
|
||||
TextEditingController controller = TextEditingController();
|
||||
var update = () => setState(() {});
|
||||
RxBool apply_enabled = false.obs;
|
||||
return _Card(title: 'Direct IP Access', children: [
|
||||
_OptionCheckBox('Enable Direct IP Access', 'direct-server',
|
||||
update: update),
|
||||
_OptionCheckBox(context, 'Enable Direct IP Access', 'direct-server',
|
||||
update: update, enabled: !locked),
|
||||
_futureBuilder(
|
||||
future: () async {
|
||||
String enabled = await bind.mainGetOption(key: 'direct-server');
|
||||
@ -414,7 +464,7 @@ class _ConnectionState extends State<_Connection>
|
||||
width: 80,
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
enabled: enabled,
|
||||
enabled: enabled && !locked,
|
||||
onChanged: (_) => apply_enabled.value = true,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(
|
||||
@ -429,10 +479,10 @@ class _ConnectionState extends State<_Connection>
|
||||
),
|
||||
),
|
||||
),
|
||||
enabled: enabled,
|
||||
),
|
||||
enabled: enabled && !locked,
|
||||
).marginOnly(left: 5),
|
||||
Obx(() => ElevatedButton(
|
||||
onPressed: apply_enabled.value && enabled
|
||||
onPressed: apply_enabled.value && enabled && !locked
|
||||
? () async {
|
||||
apply_enabled.value = false;
|
||||
await bind.mainSetOption(
|
||||
@ -440,7 +490,9 @@ class _ConnectionState extends State<_Connection>
|
||||
value: controller.text);
|
||||
}
|
||||
: null,
|
||||
child: Text(translate('Apply')),
|
||||
child: Text(
|
||||
translate('Apply'),
|
||||
),
|
||||
).marginOnly(left: 20))
|
||||
]);
|
||||
},
|
||||
@ -466,7 +518,7 @@ class _DisplayState extends State<_Display> with AutomaticKeepAliveClientMixin {
|
||||
return ListView(
|
||||
children: [
|
||||
_Card(title: 'Adaptive Bitrate', children: [
|
||||
_OptionCheckBox('Adaptive Bitrate', 'enable-abr'),
|
||||
_OptionCheckBox(context, 'Adaptive Bitrate', 'enable-abr'),
|
||||
]),
|
||||
hwcodec(),
|
||||
],
|
||||
@ -480,7 +532,8 @@ class _DisplayState extends State<_Display> with AutomaticKeepAliveClientMixin {
|
||||
return Offstage(
|
||||
offstage: !(data as bool),
|
||||
child: _Card(title: 'Hardware Codec', children: [
|
||||
_OptionCheckBox('Enable hardware codec', 'enable-hwcodec'),
|
||||
_OptionCheckBox(
|
||||
context, 'Enable hardware codec', 'enable-hwcodec'),
|
||||
]),
|
||||
);
|
||||
});
|
||||
@ -549,6 +602,7 @@ class _AudioState extends State<_Audio> with AutomaticKeepAliveClientMixin {
|
||||
);
|
||||
deviceWidget.addAll([
|
||||
_Radio<_AudioInputType>(
|
||||
context,
|
||||
value: _AudioInputType.Specify,
|
||||
groupValue: groupValue,
|
||||
label: 'Specify device',
|
||||
@ -563,6 +617,7 @@ class _AudioState extends State<_Audio> with AutomaticKeepAliveClientMixin {
|
||||
}
|
||||
return Column(children: [
|
||||
_Radio<_AudioInputType>(
|
||||
context,
|
||||
value: _AudioInputType.Mute,
|
||||
groupValue: groupValue,
|
||||
label: 'Mute',
|
||||
@ -572,6 +627,7 @@ class _AudioState extends State<_Audio> with AutomaticKeepAliveClientMixin {
|
||||
},
|
||||
),
|
||||
_Radio(
|
||||
context,
|
||||
value: _AudioInputType.Standard,
|
||||
groupValue: groupValue,
|
||||
label: 'Use standard device',
|
||||
@ -700,8 +756,12 @@ Widget _Card({required String title, required List<Widget> children}) {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _OptionCheckBox(String label, String key,
|
||||
{Function()? update = null, bool reverse = false}) {
|
||||
Color? _disabledTextColor(BuildContext context, bool enabled) {
|
||||
return enabled ? null : MyTheme.color(context).lighterText;
|
||||
}
|
||||
|
||||
Widget _OptionCheckBox(BuildContext context, String label, String key,
|
||||
{Function()? update = null, bool reverse = false, bool enabled = true}) {
|
||||
return _futureBuilder(
|
||||
future: bind.mainGetOption(key: key),
|
||||
hasData: (data) {
|
||||
@ -721,9 +781,14 @@ Widget _OptionCheckBox(String label, String key,
|
||||
child: Obx(
|
||||
() => Row(
|
||||
children: [
|
||||
Checkbox(value: ref.value, onChanged: onChanged)
|
||||
Checkbox(
|
||||
value: ref.value, onChanged: enabled ? onChanged : null)
|
||||
.marginOnly(right: 10),
|
||||
Expanded(child: Text(translate(label)))
|
||||
Expanded(
|
||||
child: Text(
|
||||
translate(label),
|
||||
style: TextStyle(color: _disabledTextColor(context, enabled)),
|
||||
))
|
||||
],
|
||||
),
|
||||
).marginOnly(left: _kCheckBoxLeftMargin),
|
||||
@ -734,29 +799,33 @@ Widget _OptionCheckBox(String label, String key,
|
||||
});
|
||||
}
|
||||
|
||||
Widget _Radio<T>({
|
||||
required T value,
|
||||
Widget _Radio<T>(BuildContext context,
|
||||
{required T value,
|
||||
required T groupValue,
|
||||
required String label,
|
||||
required Function(T value) onChanged,
|
||||
}) {
|
||||
var on_change = (T? value) {
|
||||
bool enabled = true}) {
|
||||
var on_change = enabled
|
||||
? (T? value) {
|
||||
if (value != null) {
|
||||
onChanged(value);
|
||||
}
|
||||
};
|
||||
}
|
||||
: null;
|
||||
return GestureDetector(
|
||||
child: Row(
|
||||
children: [
|
||||
Radio<T>(value: value, groupValue: groupValue, onChanged: on_change),
|
||||
Expanded(
|
||||
child: Text(translate(label),
|
||||
style: TextStyle(fontSize: _kContentFontSize))
|
||||
style: TextStyle(
|
||||
fontSize: _kContentFontSize,
|
||||
color: _disabledTextColor(context, enabled)))
|
||||
.marginOnly(left: 5),
|
||||
),
|
||||
],
|
||||
).marginOnly(left: _kRadioLeftMargin),
|
||||
onTap: () => on_change(value),
|
||||
onTap: () => on_change?.call(value),
|
||||
);
|
||||
}
|
||||
|
||||
@ -808,19 +877,19 @@ Widget _SubLabeledWidget(String label, Widget child, {bool enabled = true}) {
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: hover.value && enabled
|
||||
? Colors.grey.withOpacity(0.8)
|
||||
: Colors.grey.withOpacity(0.5),
|
||||
? Color(0xFFD7D7D7)
|
||||
: Color(0xFFCBCBCB),
|
||||
width: hover.value && enabled ? 2 : 1)),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
height: 28,
|
||||
color: (hover.value && enabled)
|
||||
? Colors.grey.withOpacity(0.8)
|
||||
: Colors.grey.withOpacity(0.5),
|
||||
? Color(0xFFD7D7D7)
|
||||
: Color(0xFFCBCBCB),
|
||||
child: Text(
|
||||
label + ': ',
|
||||
style: TextStyle(),
|
||||
style: TextStyle(fontWeight: FontWeight.w300),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
padding:
|
||||
@ -851,6 +920,43 @@ Widget _futureBuilder(
|
||||
});
|
||||
}
|
||||
|
||||
Widget _lock(
|
||||
bool locked,
|
||||
String label,
|
||||
Function() onUnlock,
|
||||
) {
|
||||
return Offstage(
|
||||
offstage: !locked,
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: _kCardFixedWidth,
|
||||
child: Card(
|
||||
child: ElevatedButton(
|
||||
child: Container(
|
||||
height: 25,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.security_sharp,
|
||||
size: 20,
|
||||
),
|
||||
Text(translate(label)).marginOnly(left: 5),
|
||||
]).marginSymmetric(vertical: 2)),
|
||||
onPressed: () async {
|
||||
bool checked = await bind.mainCheckSuperUserPermission();
|
||||
if (checked) {
|
||||
onUnlock();
|
||||
}
|
||||
},
|
||||
).marginSymmetric(horizontal: 2, vertical: 4),
|
||||
).marginOnly(left: _kCardLeftMargin),
|
||||
).marginOnly(top: 10),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class _ComboBox extends StatelessWidget {
|
||||
late final List<String> keys;
|
||||
|
@ -30,7 +30,11 @@ class _DesktopTabPageState extends State<DesktopTabPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: MyTheme.color(context).border!)),
|
||||
child: Scaffold(
|
||||
backgroundColor: MyTheme.color(context).bg,
|
||||
body: Column(
|
||||
children: [
|
||||
DesktopTabBar(
|
||||
@ -55,6 +59,7 @@ class _DesktopTabPageState extends State<DesktopTabPage> {
|
||||
))),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -98,6 +98,7 @@ class _FileManagerPageState extends State<FileManagerPage>
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: MyTheme.color(context).bg,
|
||||
body: Row(
|
||||
children: [
|
||||
Flexible(flex: 3, child: body(isLocal: true)),
|
||||
|
@ -181,10 +181,11 @@ class _RemotePageState extends State<RemotePage>
|
||||
_ffi.inputKey(label, down: down, press: press ?? false);
|
||||
}
|
||||
|
||||
Widget buildBody(FfiModel ffiModel) {
|
||||
Widget buildBody(BuildContext context, FfiModel ffiModel) {
|
||||
final hasDisplays = ffiModel.pi.displays.length > 0;
|
||||
final keyboard = ffiModel.permissions['keyboard'] != false;
|
||||
return Scaffold(
|
||||
backgroundColor: MyTheme.color(context).bg,
|
||||
// resizeToAvoidBottomInset: true,
|
||||
floatingActionButton: _showBar
|
||||
? null
|
||||
@ -229,7 +230,8 @@ class _RemotePageState extends State<RemotePage>
|
||||
ChangeNotifierProvider.value(value: _ffi.canvasModel),
|
||||
],
|
||||
child: Consumer<FfiModel>(
|
||||
builder: (context, ffiModel, _child) => buildBody(ffiModel))));
|
||||
builder: (context, ffiModel, _child) =>
|
||||
buildBody(context, ffiModel))));
|
||||
}
|
||||
|
||||
Widget getRawPointerAndKeyBody(Widget child) {
|
||||
|
@ -13,7 +13,7 @@ import 'package:scroll_pos/scroll_pos.dart';
|
||||
const double _kTabBarHeight = kDesktopRemoteTabBarHeight;
|
||||
const double _kIconSize = 18;
|
||||
const double _kDividerIndent = 10;
|
||||
const double _kAddIconSize = _kTabBarHeight - 15;
|
||||
const double _kActionIconSize = 12;
|
||||
final _tabBarKey = GlobalKey();
|
||||
|
||||
void closeTab(String? id) {
|
||||
@ -70,7 +70,6 @@ class DesktopTabBar extends StatelessWidget {
|
||||
super(key: key) {
|
||||
scrollController.itemCount = tabs.length;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
debugPrint("callback");
|
||||
scrollController.scrollToItem(selected.value,
|
||||
center: true, animate: true);
|
||||
});
|
||||
@ -80,6 +79,10 @@ class DesktopTabBar extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: _kTabBarHeight,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: _kTabBarHeight - 1,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@ -88,9 +91,19 @@ class DesktopTabBar extends StatelessWidget {
|
||||
Offstage(
|
||||
offstage: !mainTab,
|
||||
child: Row(children: [
|
||||
Image.asset('assets/logo.ico'),
|
||||
Text("RustDesk").paddingOnly(left: 5),
|
||||
]).paddingSymmetric(horizontal: 12, vertical: 5),
|
||||
Image.asset(
|
||||
'assets/logo.ico',
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
Text(
|
||||
"RustDesk",
|
||||
style: TextStyle(fontSize: 13),
|
||||
).marginOnly(left: 2),
|
||||
]).marginOnly(
|
||||
left: 5,
|
||||
right: 10,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
@ -122,23 +135,27 @@ class DesktopTabBar extends StatelessWidget {
|
||||
),
|
||||
Offstage(
|
||||
offstage: onAddSetting == null,
|
||||
child: Tooltip(
|
||||
message: translate("Settings"),
|
||||
child: InkWell(
|
||||
child: Icon(
|
||||
Icons.menu,
|
||||
color: _theme.unSelectedIconColor,
|
||||
),
|
||||
child: _ActionIcon(
|
||||
message: 'Settings',
|
||||
icon: IconFont.menu,
|
||||
theme: _theme,
|
||||
onTap: () => onAddSetting?.call(),
|
||||
).paddingOnly(right: 10),
|
||||
is_close: false,
|
||||
),
|
||||
),
|
||||
WindowActionPanel(
|
||||
mainTab: mainTab,
|
||||
color: _theme.unSelectedIconColor,
|
||||
theme: _theme,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
height: 1,
|
||||
thickness: 1,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -157,23 +174,20 @@ class DesktopTabBar extends StatelessWidget {
|
||||
|
||||
class WindowActionPanel extends StatelessWidget {
|
||||
final bool mainTab;
|
||||
final Color color;
|
||||
final _Theme theme;
|
||||
|
||||
const WindowActionPanel(
|
||||
{Key? key, required this.mainTab, required this.color})
|
||||
{Key? key, required this.mainTab, required this.theme})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Tooltip(
|
||||
message: translate("Minimize"),
|
||||
child: InkWell(
|
||||
child: Icon(
|
||||
Icons.minimize,
|
||||
color: color,
|
||||
).paddingSymmetric(horizontal: 5),
|
||||
_ActionIcon(
|
||||
message: 'Minimize',
|
||||
icon: IconFont.min,
|
||||
theme: theme,
|
||||
onTap: () {
|
||||
if (mainTab) {
|
||||
windowManager.minimize();
|
||||
@ -181,45 +195,50 @@ class WindowActionPanel extends StatelessWidget {
|
||||
WindowController.fromWindowId(windowId!).minimize();
|
||||
}
|
||||
},
|
||||
is_close: false,
|
||||
),
|
||||
),
|
||||
Tooltip(
|
||||
message: translate("Maximize"),
|
||||
child: InkWell(
|
||||
child: Icon(
|
||||
Icons.rectangle_outlined,
|
||||
color: color,
|
||||
size: 20,
|
||||
).paddingSymmetric(horizontal: 5),
|
||||
onTap: () {
|
||||
FutureBuilder(builder: (context, snapshot) {
|
||||
RxBool is_maximized = false.obs;
|
||||
if (mainTab) {
|
||||
windowManager.isMaximized().then((maximized) {
|
||||
if (maximized) {
|
||||
windowManager.unmaximize();
|
||||
} else {
|
||||
windowManager.maximize();
|
||||
}
|
||||
is_maximized.value = maximized;
|
||||
});
|
||||
} else {
|
||||
final wc = WindowController.fromWindowId(windowId!);
|
||||
wc.isMaximized().then((maximized) {
|
||||
if (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 {
|
||||
final wc = WindowController.fromWindowId(windowId!);
|
||||
if (is_maximized.value) {
|
||||
wc.unmaximize();
|
||||
} else {
|
||||
wc.maximize();
|
||||
}
|
||||
});
|
||||
}
|
||||
is_maximized.value = !is_maximized.value;
|
||||
},
|
||||
is_close: false,
|
||||
),
|
||||
),
|
||||
Tooltip(
|
||||
message: translate("Close"),
|
||||
child: InkWell(
|
||||
child: Icon(
|
||||
Icons.close,
|
||||
color: color,
|
||||
).paddingSymmetric(horizontal: 5),
|
||||
);
|
||||
}),
|
||||
_ActionIcon(
|
||||
message: 'Close',
|
||||
icon: IconFont.close,
|
||||
theme: theme,
|
||||
onTap: () {
|
||||
if (mainTab) {
|
||||
windowManager.close();
|
||||
@ -227,15 +246,16 @@ class WindowActionPanel extends StatelessWidget {
|
||||
WindowController.fromWindowId(windowId!).close();
|
||||
}
|
||||
},
|
||||
is_close: true,
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class _ListView extends StatelessWidget {
|
||||
late Rx<PageController> controller;
|
||||
final Rx<PageController> controller;
|
||||
final ScrollPosController scrollController;
|
||||
final RxList<TabInfo> tabInfos;
|
||||
final Rx<int> selected;
|
||||
@ -328,9 +348,7 @@ class _Tab extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
bool is_selected = index == selected;
|
||||
bool show_divider = index != selected - 1 && index != selected;
|
||||
return Stack(
|
||||
children: [
|
||||
Ink(
|
||||
return Ink(
|
||||
child: InkWell(
|
||||
onHover: (hover) => _hover.value = hover,
|
||||
onTap: () => onSelected(),
|
||||
@ -384,18 +402,6 @@ class _Tab extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
height: 2,
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: Center(
|
||||
child: Container(
|
||||
color:
|
||||
is_selected ? theme.indicatorColor : Colors.transparent),
|
||||
))
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -410,19 +416,13 @@ class _AddButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Ink(
|
||||
height: _kTabBarHeight,
|
||||
child: InkWell(
|
||||
customBorder: const CircleBorder(),
|
||||
return _ActionIcon(
|
||||
message: 'New Connection',
|
||||
icon: IconFont.add,
|
||||
theme: theme,
|
||||
onTap: () =>
|
||||
rustDeskWinManager.call(WindowType.Main, "main_window_on_top", ""),
|
||||
child: Icon(
|
||||
Icons.add_sharp,
|
||||
size: _kAddIconSize,
|
||||
color: theme.unSelectedIconColor,
|
||||
),
|
||||
),
|
||||
);
|
||||
is_close: false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -461,6 +461,46 @@ class _CloseButton extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class _ActionIcon extends StatelessWidget {
|
||||
final String message;
|
||||
final IconData icon;
|
||||
final _Theme 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),
|
||||
child: InkWell(
|
||||
hoverColor: is_close ? Colors.red : 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 _Theme {
|
||||
late Color unSelectedtabIconColor;
|
||||
late Color selectedtabIconColor;
|
||||
@ -469,7 +509,7 @@ class _Theme {
|
||||
late Color selectedIconColor;
|
||||
late Color unSelectedIconColor;
|
||||
late Color dividerColor;
|
||||
late Color indicatorColor;
|
||||
late Color hoverColor;
|
||||
|
||||
_Theme.light() {
|
||||
unSelectedtabIconColor = Color.fromARGB(255, 162, 203, 241);
|
||||
@ -479,7 +519,7 @@ class _Theme {
|
||||
selectedIconColor = Color.fromARGB(255, 26, 26, 26);
|
||||
unSelectedIconColor = Color.fromARGB(255, 96, 96, 96);
|
||||
dividerColor = Color.fromARGB(255, 238, 238, 238);
|
||||
indicatorColor = MyTheme.accent;
|
||||
hoverColor = Colors.grey.withOpacity(0.2);
|
||||
}
|
||||
|
||||
_Theme.dark() {
|
||||
@ -490,6 +530,6 @@ class _Theme {
|
||||
selectedIconColor = Color.fromARGB(255, 215, 215, 215);
|
||||
unSelectedIconColor = Color.fromARGB(255, 255, 255, 255);
|
||||
dividerColor = Color.fromARGB(255, 64, 64, 64);
|
||||
indicatorColor = MyTheme.accent;
|
||||
hoverColor = Colors.black26;
|
||||
}
|
||||
}
|
||||
|
@ -108,6 +108,9 @@ flutter:
|
||||
- family: GestureIcons
|
||||
fonts:
|
||||
- asset: assets/gestures.ttf
|
||||
- family: IconFont
|
||||
fonts:
|
||||
- asset: assets/tabbar.ttf
|
||||
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/assets-and-images/#resolution-aware.
|
||||
|
@ -22,12 +22,12 @@ use crate::ui_interface;
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use crate::ui_interface::{change_id, check_connect_status, is_ok_change_id};
|
||||
use crate::ui_interface::{
|
||||
discover, forget_password, get_api_server, get_app_name, get_async_job_status,
|
||||
get_connect_status, get_fav, get_id, get_lan_peers, get_langs, get_license, get_local_option,
|
||||
get_option, get_options, get_peer, get_peer_option, get_socks, get_sound_inputs, get_uuid,
|
||||
get_version, has_hwcodec, has_rendezvous_service, post_request, set_local_option, set_option,
|
||||
set_options, set_peer_option, set_permanent_password, set_socks, store_fav,
|
||||
test_if_valid_server, update_temporary_password, using_public_server,
|
||||
check_super_user_permission, discover, forget_password, get_api_server, get_app_name,
|
||||
get_async_job_status, get_connect_status, get_fav, get_id, get_lan_peers, get_langs,
|
||||
get_license, get_local_option, get_option, get_options, get_peer, get_peer_option, get_socks,
|
||||
get_sound_inputs, get_uuid, get_version, has_hwcodec, has_rendezvous_service, post_request,
|
||||
set_local_option, set_option, set_options, set_peer_option, set_permanent_password, set_socks,
|
||||
store_fav, test_if_valid_server, update_temporary_password, using_public_server,
|
||||
};
|
||||
|
||||
fn initialize(app_dir: &str) {
|
||||
@ -735,6 +735,10 @@ pub fn main_set_permanent_password(password: String) {
|
||||
set_permanent_password(password);
|
||||
}
|
||||
|
||||
pub fn main_check_super_user_permission() -> bool {
|
||||
check_super_user_permission()
|
||||
}
|
||||
|
||||
pub fn cm_send_chat(conn_id: i32, msg: String) {
|
||||
connection_manager::send_chat(conn_id, msg);
|
||||
}
|
||||
|
@ -629,3 +629,9 @@ extern "C" {
|
||||
pub fn quit_gui() {
|
||||
unsafe { gtk_main_quit() };
|
||||
}
|
||||
|
||||
pub fn check_super_user_permission() -> ResultType<bool> {
|
||||
// TODO: replace echo with a rustdesk's program, which is location-fixed and non-gui.
|
||||
let status = std::process::Command::new("pkexec").arg("echo").status()?;
|
||||
Ok(status.success() && status.code() == Some(0))
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use hbb_common::{
|
||||
};
|
||||
use std::io::prelude::*;
|
||||
use std::{
|
||||
ffi::OsString,
|
||||
ffi::{CString, OsString},
|
||||
fs, io, mem,
|
||||
sync::{Arc, Mutex},
|
||||
time::{Duration, Instant},
|
||||
@ -17,7 +17,8 @@ use winapi::{
|
||||
shared::{minwindef::*, ntdef::NULL, windef::*},
|
||||
um::{
|
||||
errhandlingapi::GetLastError, handleapi::CloseHandle, minwinbase::STILL_ACTIVE,
|
||||
processthreadsapi::GetExitCodeProcess, winbase::*, wingdi::*, winnt::HANDLE, winuser::*,
|
||||
processthreadsapi::GetExitCodeProcess, shellapi::ShellExecuteA, winbase::*, wingdi::*,
|
||||
winnt::HANDLE, winuser::*,
|
||||
},
|
||||
};
|
||||
use windows_service::{
|
||||
@ -1418,3 +1419,17 @@ pub fn get_user_token(session_id: u32, as_user: bool) -> HANDLE {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_super_user_permission() -> ResultType<bool> {
|
||||
unsafe {
|
||||
let ret = ShellExecuteA(
|
||||
NULL as _,
|
||||
CString::new("runas")?.as_ptr() as _,
|
||||
CString::new("cmd")?.as_ptr() as _,
|
||||
CString::new("/c /q")?.as_ptr() as _,
|
||||
NULL as _,
|
||||
SW_SHOWNORMAL,
|
||||
);
|
||||
return Ok(ret as i32 > 32);
|
||||
}
|
||||
}
|
||||
|
@ -676,6 +676,13 @@ pub fn has_hwcodec() -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
pub fn check_super_user_permission() -> bool {
|
||||
#[cfg(any(windows, target_os = "linux"))]
|
||||
return crate::platform::check_super_user_permission().unwrap_or(false);
|
||||
#[cfg(not(any(windows, target_os = "linux")))]
|
||||
true
|
||||
}
|
||||
|
||||
pub fn check_zombie(childs: Childs) {
|
||||
let mut deads = Vec::new();
|
||||
loop {
|
||||
|
Loading…
x
Reference in New Issue
Block a user