mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Merge branch 'master' of https://github.com/rustdesk/rustdesk
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
import '../../common/formatter/id_formatter.dart';
|
||||
import '../../models/model.dart';
|
||||
import '../../models/peer_model.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
@@ -15,7 +16,7 @@ class _PopupMenuTheme {
|
||||
static const Color commonColor = MyTheme.accent;
|
||||
// kMinInteractiveDimension
|
||||
static const double height = 25.0;
|
||||
static const double dividerHeight = 12.0;
|
||||
static const double dividerHeight = 3.0;
|
||||
}
|
||||
|
||||
typedef PopupMenuEntryBuilder = Future<List<mod_menu.PopupMenuEntry<String>>>
|
||||
@@ -46,7 +47,8 @@ class _PeerCard extends StatefulWidget {
|
||||
/// State for the connection page.
|
||||
class _PeerCardState extends State<_PeerCard>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
final double _cardRadis = 20;
|
||||
var _menuPos = RelativeRect.fill;
|
||||
final double _cardRadis = 16;
|
||||
final double _borderWidth = 2;
|
||||
final RxBool _iconMoreHover = false.obs;
|
||||
|
||||
@@ -118,7 +120,7 @@ class _PeerCardState extends State<_PeerCard>
|
||||
? Colors.green
|
||||
: Colors.yellow)),
|
||||
Text(
|
||||
'${peer.id}',
|
||||
formatID('${peer.id}'),
|
||||
style: TextStyle(fontWeight: FontWeight.w400),
|
||||
),
|
||||
]),
|
||||
@@ -239,7 +241,7 @@ class _PeerCardState extends State<_PeerCard>
|
||||
backgroundColor: peer.online
|
||||
? Colors.green
|
||||
: Colors.yellow)),
|
||||
Text(peer.id)
|
||||
Text(formatID(peer.id))
|
||||
]).paddingSymmetric(vertical: 8),
|
||||
_actionMore(peer),
|
||||
],
|
||||
@@ -253,36 +255,36 @@ class _PeerCardState extends State<_PeerCard>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _actionMore(Peer peer) {
|
||||
return FutureBuilder(
|
||||
future: widget.popupMenuEntryBuilder(context),
|
||||
initialData: const <mod_menu.PopupMenuEntry<String>>[],
|
||||
builder: (BuildContext context,
|
||||
AsyncSnapshot<List<mod_menu.PopupMenuEntry<String>>> snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return Listener(
|
||||
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: mod_menu.PopupMenuButton(
|
||||
padding: EdgeInsets.zero,
|
||||
icon: Icon(Icons.more_vert,
|
||||
size: 18,
|
||||
color: _iconMoreHover.value
|
||||
? MyTheme.color(context).text
|
||||
: MyTheme.color(context).lightText),
|
||||
position: mod_menu.PopupMenuPosition.under,
|
||||
itemBuilder: (BuildContext context) => snapshot.data!,
|
||||
))));
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
});
|
||||
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))));
|
||||
|
||||
/// 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 {
|
||||
await mod_menu.showMenu(
|
||||
context: context,
|
||||
position: _menuPos,
|
||||
items: await super.widget.popupMenuEntryBuilder(context),
|
||||
elevation: 8,
|
||||
);
|
||||
}
|
||||
|
||||
/// Get the image for the current [platform].
|
||||
@@ -411,19 +413,26 @@ abstract class BasePeerCard extends StatelessWidget {
|
||||
@protected
|
||||
MenuEntryBase<String> _rdpAction(BuildContext context, String id) {
|
||||
return MenuEntryButton<String>(
|
||||
childBuilder: (TextStyle? style) => Row(
|
||||
children: [
|
||||
Text(
|
||||
translate('RDP'),
|
||||
style: style,
|
||||
),
|
||||
SizedBox(width: 20),
|
||||
IconButton(
|
||||
icon: Icon(Icons.edit),
|
||||
onPressed: () => _rdpDialog(id),
|
||||
)
|
||||
],
|
||||
),
|
||||
childBuilder: (TextStyle? style) => Container(
|
||||
alignment: AlignmentDirectional.center,
|
||||
height: _PopupMenuTheme.height,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
translate('RDP'),
|
||||
style: style,
|
||||
),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: IconButton(
|
||||
padding: EdgeInsets.zero,
|
||||
icon: Icon(Icons.edit),
|
||||
onPressed: () => _rdpDialog(id),
|
||||
),
|
||||
))
|
||||
],
|
||||
)),
|
||||
proc: () {
|
||||
_connect(context, id, isRDP: true);
|
||||
},
|
||||
@@ -554,47 +563,47 @@ abstract class BasePeerCard extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
gFFI.dialogManager.show((setState, close) {
|
||||
submit() async {
|
||||
isInProgress.value = true;
|
||||
name = controller.text;
|
||||
await bind.mainSetPeerOption(id: id, key: 'alias', value: name);
|
||||
if (isAddressBook) {
|
||||
gFFI.abModel.setPeerOption(id, 'alias', name);
|
||||
await gFFI.abModel.updateAb();
|
||||
}
|
||||
alias.value = await bind.mainGetPeerOption(id: peer.id, key: 'alias');
|
||||
close();
|
||||
isInProgress.value = false;
|
||||
}
|
||||
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate('Rename')),
|
||||
content: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
child: Form(
|
||||
child: TextFormField(
|
||||
controller: controller,
|
||||
decoration: InputDecoration(border: OutlineInputBorder()),
|
||||
focusNode: FocusNode()..requestFocus(),
|
||||
decoration:
|
||||
const InputDecoration(border: OutlineInputBorder()),
|
||||
),
|
||||
),
|
||||
),
|
||||
Obx(() => Offstage(
|
||||
offstage: isInProgress.isFalse,
|
||||
child: LinearProgressIndicator())),
|
||||
child: const LinearProgressIndicator())),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
close();
|
||||
},
|
||||
child: Text(translate("Cancel"))),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
isInProgress.value = true;
|
||||
name = controller.text;
|
||||
await bind.mainSetPeerOption(id: id, key: 'alias', value: name);
|
||||
if (isAddressBook) {
|
||||
gFFI.abModel.setPeerOption(id, 'alias', name);
|
||||
await gFFI.abModel.updateAb();
|
||||
}
|
||||
alias.value =
|
||||
await bind.mainGetPeerOption(id: peer.id, key: 'alias');
|
||||
close();
|
||||
isInProgress.value = false;
|
||||
},
|
||||
child: Text(translate("OK"))),
|
||||
TextButton(onPressed: close, child: Text(translate("Cancel"))),
|
||||
TextButton(onPressed: submit, child: Text(translate("OK"))),
|
||||
],
|
||||
onSubmit: submit,
|
||||
onCancel: close,
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -614,6 +623,7 @@ class RecentPeerCard extends BasePeerCard {
|
||||
if (peer.platform == 'Windows') {
|
||||
menuItems.add(_rdpAction(context, peer.id));
|
||||
}
|
||||
menuItems.add(MenuEntryDivider());
|
||||
menuItems.add(await _forceAlwaysRelayAction(peer.id));
|
||||
menuItems.add(_renameAction(peer.id, false));
|
||||
menuItems.add(_removeAction(peer.id, () async {
|
||||
@@ -740,13 +750,23 @@ class AddressBookPeerCard extends BasePeerCard {
|
||||
var selectedTag = gFFI.abModel.getPeerTags(id).obs;
|
||||
|
||||
gFFI.dialogManager.show((setState, close) {
|
||||
submit() async {
|
||||
setState(() {
|
||||
isInProgress = true;
|
||||
});
|
||||
gFFI.abModel.changeTagForPeer(id, selectedTag);
|
||||
await gFFI.abModel.updateAb();
|
||||
close();
|
||||
}
|
||||
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate("Edit Tag")),
|
||||
content: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
child: Wrap(
|
||||
children: tags
|
||||
.map((e) => _buildTag(e, selectedTag, onTap: () {
|
||||
@@ -759,26 +779,16 @@ class AddressBookPeerCard extends BasePeerCard {
|
||||
.toList(growable: false),
|
||||
),
|
||||
),
|
||||
Offstage(offstage: !isInProgress, child: LinearProgressIndicator())
|
||||
Offstage(
|
||||
offstage: !isInProgress, child: const 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"))),
|
||||
TextButton(onPressed: close, child: Text(translate("Cancel"))),
|
||||
TextButton(onPressed: submit, child: Text(translate("OK"))),
|
||||
],
|
||||
onSubmit: submit,
|
||||
onCancel: close,
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -861,25 +871,35 @@ void _rdpDialog(String id) async {
|
||||
RxBool secure = true.obs;
|
||||
|
||||
gFFI.dialogManager.show((setState, close) {
|
||||
submit() async {
|
||||
await bind.mainSetPeerOption(
|
||||
id: id, key: 'rdp_port', value: portController.text.trim());
|
||||
await bind.mainSetPeerOption(
|
||||
id: id, key: 'rdp_username', value: userController.text);
|
||||
await bind.mainSetPeerOption(
|
||||
id: id, key: 'rdp_password', value: passwordContorller.text);
|
||||
close();
|
||||
}
|
||||
|
||||
return CustomAlertDialog(
|
||||
title: Text('RDP ' + translate('Settings')),
|
||||
title: Text('RDP ${translate('Settings')}'),
|
||||
content: ConstrainedBox(
|
||||
constraints: BoxConstraints(minWidth: 500),
|
||||
constraints: const BoxConstraints(minWidth: 500),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(minWidth: 100),
|
||||
constraints: const BoxConstraints(minWidth: 100),
|
||||
child: Text(
|
||||
"${translate('Port')}:",
|
||||
textAlign: TextAlign.start,
|
||||
).marginOnly(bottom: 16.0)),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
width: 24.0,
|
||||
),
|
||||
Expanded(
|
||||
@@ -888,52 +908,54 @@ void _rdpDialog(String id) async {
|
||||
FilteringTextInputFormatter.allow(RegExp(
|
||||
r'^([0-9]|[1-9]\d|[1-9]\d{2}|[1-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$'))
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(), hintText: '3389'),
|
||||
controller: portController,
|
||||
focusNode: FocusNode()..requestFocus(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(minWidth: 100),
|
||||
constraints: const BoxConstraints(minWidth: 100),
|
||||
child: Text(
|
||||
"${translate('Username')}:",
|
||||
textAlign: TextAlign.start,
|
||||
).marginOnly(bottom: 16.0)),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
width: 24.0,
|
||||
),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
decoration: InputDecoration(border: OutlineInputBorder()),
|
||||
decoration:
|
||||
const InputDecoration(border: OutlineInputBorder()),
|
||||
controller: userController,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(minWidth: 100),
|
||||
constraints: const BoxConstraints(minWidth: 100),
|
||||
child: Text("${translate('Password')}:")
|
||||
.marginOnly(bottom: 16.0)),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
width: 24.0,
|
||||
),
|
||||
Expanded(
|
||||
child: Obx(() => TextField(
|
||||
obscureText: secure.value,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
suffixIcon: IconButton(
|
||||
onPressed: () => secure.value = !secure.value,
|
||||
icon: Icon(secure.value
|
||||
@@ -948,23 +970,11 @@ void _rdpDialog(String id) async {
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
close();
|
||||
},
|
||||
child: Text(translate("Cancel"))),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await bind.mainSetPeerOption(
|
||||
id: id, key: 'rdp_port', value: portController.text.trim());
|
||||
await bind.mainSetPeerOption(
|
||||
id: id, key: 'rdp_username', value: userController.text);
|
||||
await bind.mainSetPeerOption(
|
||||
id: id, key: 'rdp_password', value: passwordContorller.text);
|
||||
close();
|
||||
},
|
||||
child: Text(translate("OK"))),
|
||||
TextButton(onPressed: close, child: Text(translate("Cancel"))),
|
||||
TextButton(onPressed: submit, child: Text(translate("OK"))),
|
||||
],
|
||||
onSubmit: submit,
|
||||
onCancel: close,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:core';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import './material_mod_popup_menu.dart' as mod_menu;
|
||||
@@ -174,8 +175,8 @@ class MenuEntryRadios<T> extends MenuEntryBase<T> {
|
||||
children: [
|
||||
Text(
|
||||
opt.text,
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
style: TextStyle(
|
||||
color: MyTheme.color(context).text,
|
||||
fontSize: MenuConfig.fontSize,
|
||||
fontWeight: FontWeight.normal),
|
||||
),
|
||||
@@ -256,8 +257,8 @@ class MenuEntrySubRadios<T> extends MenuEntryBase<T> {
|
||||
children: [
|
||||
Text(
|
||||
opt.text,
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
style: TextStyle(
|
||||
color: MyTheme.color(context).text,
|
||||
fontSize: MenuConfig.fontSize,
|
||||
fontWeight: FontWeight.normal),
|
||||
),
|
||||
@@ -300,8 +301,8 @@ class MenuEntrySubRadios<T> extends MenuEntryBase<T> {
|
||||
const SizedBox(width: MenuConfig.midPadding),
|
||||
Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
style: TextStyle(
|
||||
color: MyTheme.color(context).text,
|
||||
fontSize: MenuConfig.fontSize,
|
||||
fontWeight: FontWeight.normal),
|
||||
),
|
||||
@@ -346,8 +347,8 @@ abstract class MenuEntrySwitchBase<T> extends MenuEntryBase<T> {
|
||||
// const SizedBox(width: MenuConfig.midPadding),
|
||||
Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
style: TextStyle(
|
||||
color: MyTheme.color(context).text,
|
||||
fontSize: MenuConfig.fontSize,
|
||||
fontWeight: FontWeight.normal),
|
||||
),
|
||||
@@ -450,8 +451,8 @@ class MenuEntrySubMenu<T> extends MenuEntryBase<T> {
|
||||
const SizedBox(width: MenuConfig.midPadding),
|
||||
Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
style: TextStyle(
|
||||
color: MyTheme.color(context).text,
|
||||
fontSize: MenuConfig.fontSize,
|
||||
fontWeight: FontWeight.normal),
|
||||
),
|
||||
@@ -491,8 +492,8 @@ class MenuEntryButton<T> extends MenuEntryBase<T> {
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
constraints: BoxConstraints(minHeight: conf.height),
|
||||
child: childBuilder(
|
||||
const TextStyle(
|
||||
color: Colors.black,
|
||||
TextStyle(
|
||||
color: MyTheme.color(context).text,
|
||||
fontSize: MenuConfig.fontSize,
|
||||
fontWeight: FontWeight.normal),
|
||||
)),
|
||||
|
||||
@@ -496,9 +496,17 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
|
||||
});
|
||||
final quality =
|
||||
await bind.sessionGetCustomImageQuality(id: widget.id);
|
||||
final double initValue = quality != null && quality.isNotEmpty
|
||||
double initValue = quality != null && quality.isNotEmpty
|
||||
? quality[0].toDouble()
|
||||
: 50.0;
|
||||
const minValue = 10.0;
|
||||
const maxValue = 100.0;
|
||||
if (initValue < minValue) {
|
||||
initValue = minValue;
|
||||
}
|
||||
if (initValue > maxValue) {
|
||||
initValue = maxValue;
|
||||
}
|
||||
final RxDouble sliderValue = RxDouble(initValue);
|
||||
final rxReplay = rxdart.ReplaySubject<double>();
|
||||
rxReplay
|
||||
@@ -513,30 +521,44 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
|
||||
final slider = Obx(() {
|
||||
return Slider(
|
||||
value: sliderValue.value,
|
||||
max: 100,
|
||||
divisions: 100,
|
||||
label: sliderValue.value.round().toString(),
|
||||
min: minValue,
|
||||
max: maxValue,
|
||||
divisions: 90,
|
||||
onChanged: (double value) {
|
||||
sliderValue.value = value;
|
||||
rxReplay.add(value);
|
||||
},
|
||||
);
|
||||
});
|
||||
final content = Row(
|
||||
children: [
|
||||
slider,
|
||||
SizedBox(
|
||||
width: 90,
|
||||
child: Obx(() => Text(
|
||||
'${sliderValue.value.round()}% Bitrate',
|
||||
style: const TextStyle(fontSize: 15),
|
||||
)))
|
||||
],
|
||||
);
|
||||
msgBoxCommon(widget.ffi.dialogManager, 'Custom Image Quality',
|
||||
slider, [btnCancel]);
|
||||
content, [btnCancel]);
|
||||
}
|
||||
}),
|
||||
MenuEntryDivider<String>(),
|
||||
MenuEntrySwitch<String>(
|
||||
text: translate('Show remote cursor'),
|
||||
getter: () async {
|
||||
return bind.sessionGetToggleOptionSync(
|
||||
id: widget.id, arg: 'show-remote-cursor');
|
||||
},
|
||||
setter: (bool v) async {
|
||||
await bind.sessionToggleOption(
|
||||
id: widget.id, value: 'show-remote-cursor');
|
||||
}),
|
||||
() {
|
||||
final state = ShowRemoteCursorState.find(widget.id);
|
||||
return MenuEntrySwitch2<String>(
|
||||
text: translate('Show remote cursor'),
|
||||
getter: () {
|
||||
return state;
|
||||
},
|
||||
setter: (bool v) async {
|
||||
state.value = v;
|
||||
await bind.sessionToggleOption(
|
||||
id: widget.id, value: 'show-remote-cursor');
|
||||
});
|
||||
}(),
|
||||
MenuEntrySwitch<String>(
|
||||
text: translate('Show quality monitor'),
|
||||
getter: () async {
|
||||
@@ -565,12 +587,12 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
|
||||
'Lock after session end', 'lock-after-session-end'));
|
||||
if (pi.platform == 'Windows') {
|
||||
displayMenu.add(MenuEntrySwitch2<String>(
|
||||
dismissOnClicked: true,
|
||||
text: translate('Privacy mode'),
|
||||
getter: () {
|
||||
return PrivacyModeState.find(widget.id);
|
||||
},
|
||||
setter: (bool v) async {
|
||||
Navigator.pop(context);
|
||||
await bind.sessionToggleOption(
|
||||
id: widget.id, value: 'privacy-mode');
|
||||
}));
|
||||
@@ -620,46 +642,49 @@ void showSetOSPassword(
|
||||
var autoLogin = await bind.sessionGetOption(id: id, arg: "auto-login") != "";
|
||||
controller.text = password;
|
||||
dialogManager.show((setState, close) {
|
||||
submit() {
|
||||
var text = controller.text.trim();
|
||||
bind.sessionPeerOption(id: id, name: "os-password", value: text);
|
||||
bind.sessionPeerOption(
|
||||
id: id, name: "auto-login", value: autoLogin ? 'Y' : '');
|
||||
if (text != "" && login) {
|
||||
bind.sessionInputOsPassword(id: id, value: text);
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate('OS Password')),
|
||||
content: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
PasswordWidget(controller: controller),
|
||||
CheckboxListTile(
|
||||
contentPadding: const EdgeInsets.all(0),
|
||||
dense: true,
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
title: Text(
|
||||
translate('Auto Login'),
|
||||
),
|
||||
value: autoLogin,
|
||||
onChanged: (v) {
|
||||
if (v == null) return;
|
||||
setState(() => autoLogin = v);
|
||||
},
|
||||
title: Text(translate('OS Password')),
|
||||
content: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
PasswordWidget(controller: controller),
|
||||
CheckboxListTile(
|
||||
contentPadding: const EdgeInsets.all(0),
|
||||
dense: true,
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
title: Text(
|
||||
translate('Auto Login'),
|
||||
),
|
||||
]),
|
||||
actions: [
|
||||
TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
close();
|
||||
},
|
||||
child: Text(translate('Cancel')),
|
||||
),
|
||||
TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
var text = controller.text.trim();
|
||||
bind.sessionPeerOption(id: id, name: "os-password", value: text);
|
||||
bind.sessionPeerOption(
|
||||
id: id, name: "auto-login", value: autoLogin ? 'Y' : '');
|
||||
if (text != "" && login) {
|
||||
bind.sessionInputOsPassword(id: id, value: text);
|
||||
}
|
||||
close();
|
||||
},
|
||||
child: Text(translate('OK')),
|
||||
),
|
||||
]);
|
||||
value: autoLogin,
|
||||
onChanged: (v) {
|
||||
if (v == null) return;
|
||||
setState(() => autoLogin = v);
|
||||
},
|
||||
),
|
||||
]),
|
||||
actions: [
|
||||
TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: close,
|
||||
child: Text(translate('Cancel')),
|
||||
),
|
||||
TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: submit,
|
||||
child: Text(translate('OK')),
|
||||
),
|
||||
],
|
||||
onSubmit: submit,
|
||||
onCancel: close,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/material.dart' hide TabBarTheme;
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/consts.dart';
|
||||
import 'package:flutter_hbb/main.dart';
|
||||
@@ -59,13 +59,15 @@ class DesktopTabState {
|
||||
|
||||
class DesktopTabController {
|
||||
final state = DesktopTabState().obs;
|
||||
final DesktopTabType tabType;
|
||||
|
||||
/// index, key
|
||||
Function(int, String)? onRemove;
|
||||
|
||||
Function(int)? onSelected;
|
||||
|
||||
void add(TabInfo tab) {
|
||||
DesktopTabController({required this.tabType});
|
||||
|
||||
void add(TabInfo tab, {bool authorized = false}) {
|
||||
if (!isDesktop) return;
|
||||
final index = state.value.tabs.indexWhere((e) => e.key == tab.key);
|
||||
int toIndex;
|
||||
@@ -79,6 +81,16 @@ class DesktopTabController {
|
||||
toIndex = state.value.tabs.length - 1;
|
||||
assert(toIndex >= 0);
|
||||
}
|
||||
if (tabType == DesktopTabType.cm) {
|
||||
Future.delayed(Duration.zero, () async {
|
||||
window_on_top(null);
|
||||
});
|
||||
if (authorized) {
|
||||
Future.delayed(const Duration(seconds: 3), () {
|
||||
windowManager.minimize();
|
||||
});
|
||||
}
|
||||
}
|
||||
try {
|
||||
jumpTo(toIndex);
|
||||
} catch (e) {
|
||||
@@ -106,6 +118,7 @@ class DesktopTabController {
|
||||
}
|
||||
|
||||
void jumpTo(int index) {
|
||||
if (!isDesktop || index < 0) return;
|
||||
state.update((val) {
|
||||
val!.selected = index;
|
||||
Future.delayed(Duration.zero, (() {
|
||||
@@ -114,12 +127,14 @@ class DesktopTabController {
|
||||
}
|
||||
if (val.scrollController.hasClients &&
|
||||
val.scrollController.canScroll &&
|
||||
val.scrollController.itemCount >= index) {
|
||||
val.scrollController.itemCount > index) {
|
||||
val.scrollController.scrollToItem(index, center: true, animate: true);
|
||||
}
|
||||
}));
|
||||
});
|
||||
onSelected?.call(index);
|
||||
if (state.value.tabs.length > index) {
|
||||
onSelected?.call(index);
|
||||
}
|
||||
}
|
||||
|
||||
void closeBy(String? key) {
|
||||
@@ -143,8 +158,7 @@ class DesktopTabController {
|
||||
|
||||
class TabThemeConf {
|
||||
double iconSize;
|
||||
TarBarTheme theme;
|
||||
TabThemeConf({required this.iconSize, required this.theme});
|
||||
TabThemeConf({required this.iconSize});
|
||||
}
|
||||
|
||||
typedef TabBuilder = Widget Function(
|
||||
@@ -153,9 +167,6 @@ typedef LabelGetter = Rx<String> Function(String key);
|
||||
|
||||
class DesktopTab extends StatelessWidget {
|
||||
final Function(String)? onTabClose;
|
||||
final TarBarTheme theme;
|
||||
final DesktopTabType tabType;
|
||||
final bool isMainWindow;
|
||||
final bool showTabBar;
|
||||
final bool showLogo;
|
||||
final bool showTitle;
|
||||
@@ -170,11 +181,12 @@ class DesktopTab extends StatelessWidget {
|
||||
|
||||
final DesktopTabController controller;
|
||||
Rx<DesktopTabState> get state => controller.state;
|
||||
late final DesktopTabType tabType;
|
||||
late final bool isMainWindow;
|
||||
|
||||
const DesktopTab({
|
||||
DesktopTab({
|
||||
Key? key,
|
||||
required this.controller,
|
||||
required this.tabType,
|
||||
this.theme = const TarBarTheme.light(),
|
||||
this.onTabClose,
|
||||
this.showTabBar = true,
|
||||
this.showLogo = true,
|
||||
@@ -187,23 +199,26 @@ class DesktopTab extends StatelessWidget {
|
||||
this.onClose,
|
||||
this.tabBuilder,
|
||||
this.labelGetter,
|
||||
}) : isMainWindow =
|
||||
tabType == DesktopTabType.main || tabType == DesktopTabType.cm;
|
||||
}) : super(key: key) {
|
||||
tabType = controller.tabType;
|
||||
isMainWindow =
|
||||
tabType == DesktopTabType.main || tabType == DesktopTabType.cm;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(children: [
|
||||
Offstage(
|
||||
offstage: !showTabBar,
|
||||
child: Container(
|
||||
child: SizedBox(
|
||||
height: _kTabBarHeight,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
SizedBox(
|
||||
height: _kTabBarHeight - 1,
|
||||
child: _buildBar(),
|
||||
),
|
||||
Divider(
|
||||
const Divider(
|
||||
height: 1,
|
||||
thickness: 1,
|
||||
),
|
||||
@@ -282,7 +297,7 @@ class DesktopTab extends StatelessWidget {
|
||||
)),
|
||||
Offstage(
|
||||
offstage: !showTitle,
|
||||
child: Text(
|
||||
child: const Text(
|
||||
"RustDesk",
|
||||
style: TextStyle(fontSize: 13),
|
||||
).marginOnly(left: 2))
|
||||
@@ -303,7 +318,6 @@ class DesktopTab extends StatelessWidget {
|
||||
child: _ListView(
|
||||
controller: controller,
|
||||
onTabClose: onTabClose,
|
||||
theme: theme,
|
||||
tabBuilder: tabBuilder,
|
||||
labelGetter: labelGetter,
|
||||
)),
|
||||
@@ -314,7 +328,8 @@ class DesktopTab extends StatelessWidget {
|
||||
Offstage(offstage: tail == null, child: tail),
|
||||
WindowActionPanel(
|
||||
mainTab: isMainWindow,
|
||||
theme: theme,
|
||||
tabType: tabType,
|
||||
state: state,
|
||||
showMinimize: showMinimize,
|
||||
showMaximize: showMaximize,
|
||||
showClose: showClose,
|
||||
@@ -327,7 +342,8 @@ class DesktopTab extends StatelessWidget {
|
||||
|
||||
class WindowActionPanel extends StatelessWidget {
|
||||
final bool mainTab;
|
||||
final TarBarTheme theme;
|
||||
final DesktopTabType tabType;
|
||||
final Rx<DesktopTabState> state;
|
||||
|
||||
final bool showMinimize;
|
||||
final bool showMaximize;
|
||||
@@ -337,7 +353,8 @@ class WindowActionPanel extends StatelessWidget {
|
||||
const WindowActionPanel(
|
||||
{Key? key,
|
||||
required this.mainTab,
|
||||
required this.theme,
|
||||
required this.tabType,
|
||||
required this.state,
|
||||
this.showMinimize = true,
|
||||
this.showMaximize = true,
|
||||
this.showClose = true,
|
||||
@@ -353,7 +370,6 @@ class WindowActionPanel extends StatelessWidget {
|
||||
child: ActionIcon(
|
||||
message: 'Minimize',
|
||||
icon: IconFont.min,
|
||||
theme: theme,
|
||||
onTap: () {
|
||||
if (mainTab) {
|
||||
windowManager.minimize();
|
||||
@@ -361,31 +377,30 @@ class WindowActionPanel extends StatelessWidget {
|
||||
WindowController.fromWindowId(windowId!).minimize();
|
||||
}
|
||||
},
|
||||
is_close: false,
|
||||
isClose: false,
|
||||
)),
|
||||
// TODO: drag makes window restore
|
||||
Offstage(
|
||||
offstage: !showMaximize,
|
||||
child: FutureBuilder(builder: (context, snapshot) {
|
||||
RxBool is_maximized = false.obs;
|
||||
RxBool isMaximized = false.obs;
|
||||
if (mainTab) {
|
||||
windowManager.isMaximized().then((maximized) {
|
||||
is_maximized.value = maximized;
|
||||
isMaximized.value = maximized;
|
||||
});
|
||||
} else {
|
||||
final wc = WindowController.fromWindowId(windowId!);
|
||||
wc.isMaximized().then((maximized) {
|
||||
is_maximized.value = maximized;
|
||||
isMaximized.value = maximized;
|
||||
});
|
||||
}
|
||||
return Obx(
|
||||
() => ActionIcon(
|
||||
message: is_maximized.value ? "Restore" : "Maximize",
|
||||
icon: is_maximized.value ? IconFont.restore : IconFont.max,
|
||||
theme: theme,
|
||||
message: isMaximized.value ? "Restore" : "Maximize",
|
||||
icon: isMaximized.value ? IconFont.restore : IconFont.max,
|
||||
onTap: () {
|
||||
if (mainTab) {
|
||||
if (is_maximized.value) {
|
||||
if (isMaximized.value) {
|
||||
windowManager.unmaximize();
|
||||
} else {
|
||||
windowManager.maximize();
|
||||
@@ -393,15 +408,15 @@ class WindowActionPanel extends StatelessWidget {
|
||||
} else {
|
||||
// TODO: subwindow is maximized but first query result is not maximized.
|
||||
final wc = WindowController.fromWindowId(windowId!);
|
||||
if (is_maximized.value) {
|
||||
if (isMaximized.value) {
|
||||
wc.unmaximize();
|
||||
} else {
|
||||
wc.maximize();
|
||||
}
|
||||
}
|
||||
is_maximized.value = !is_maximized.value;
|
||||
isMaximized.value = !isMaximized.value;
|
||||
},
|
||||
is_close: false,
|
||||
isClose: false,
|
||||
),
|
||||
);
|
||||
})),
|
||||
@@ -410,40 +425,70 @@ class WindowActionPanel extends StatelessWidget {
|
||||
child: ActionIcon(
|
||||
message: 'Close',
|
||||
icon: IconFont.close,
|
||||
theme: theme,
|
||||
onTap: () {
|
||||
if (mainTab) {
|
||||
windowManager.close();
|
||||
} else {
|
||||
// only hide for multi window, not close
|
||||
Future.delayed(Duration.zero, () {
|
||||
WindowController.fromWindowId(windowId!).hide();
|
||||
});
|
||||
onTap: () async {
|
||||
action() {
|
||||
if (mainTab) {
|
||||
windowManager.close();
|
||||
} else {
|
||||
// only hide for multi window, not close
|
||||
Future.delayed(Duration.zero, () {
|
||||
WindowController.fromWindowId(windowId!).hide();
|
||||
});
|
||||
}
|
||||
onClose?.call();
|
||||
}
|
||||
|
||||
if (tabType != DesktopTabType.main &&
|
||||
state.value.tabs.length > 1) {
|
||||
closeConfirmDialog(action);
|
||||
} else {
|
||||
action();
|
||||
}
|
||||
onClose?.call();
|
||||
},
|
||||
is_close: true,
|
||||
isClose: true,
|
||||
)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
closeConfirmDialog(Function() callback) async {
|
||||
final res = await gFFI.dialogManager.show<bool>((setState, close) {
|
||||
submit() => close(true);
|
||||
return CustomAlertDialog(
|
||||
title: Row(children: [
|
||||
const Icon(Icons.warning_amber_sharp,
|
||||
color: Colors.redAccent, size: 28),
|
||||
const SizedBox(width: 10),
|
||||
Text(translate("Warning")),
|
||||
]),
|
||||
content: Text(translate("Disconnect all devices?")),
|
||||
actions: [
|
||||
TextButton(onPressed: close, child: Text(translate("Cancel"))),
|
||||
ElevatedButton(onPressed: submit, child: Text(translate("OK"))),
|
||||
],
|
||||
onSubmit: submit,
|
||||
onCancel: close,
|
||||
);
|
||||
});
|
||||
if (res == true) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class _ListView extends StatelessWidget {
|
||||
final DesktopTabController controller;
|
||||
final Function(String key)? onTabClose;
|
||||
final TarBarTheme theme;
|
||||
|
||||
final TabBuilder? tabBuilder;
|
||||
final LabelGetter? labelGetter;
|
||||
|
||||
Rx<DesktopTabState> get state => controller.state;
|
||||
|
||||
_ListView(
|
||||
const _ListView(
|
||||
{required this.controller,
|
||||
required this.onTabClose,
|
||||
required this.theme,
|
||||
this.tabBuilder,
|
||||
this.labelGetter});
|
||||
|
||||
@@ -453,7 +498,7 @@ class _ListView extends StatelessWidget {
|
||||
controller: state.value.scrollController,
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
physics: BouncingScrollPhysics(),
|
||||
physics: const BouncingScrollPhysics(),
|
||||
children: state.value.tabs.asMap().entries.map((e) {
|
||||
final index = e.key;
|
||||
final tab = e.value;
|
||||
@@ -468,7 +513,6 @@ class _ListView extends StatelessWidget {
|
||||
selected: state.value.selected,
|
||||
onClose: () => controller.remove(index),
|
||||
onSelected: () => controller.jumpTo(index),
|
||||
theme: theme,
|
||||
tabBuilder: tabBuilder == null
|
||||
? null
|
||||
: (Widget icon, Widget labelWidget, TabThemeConf themeConf) {
|
||||
@@ -485,31 +529,29 @@ class _ListView extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _Tab extends StatefulWidget {
|
||||
late final int index;
|
||||
late final Rx<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;
|
||||
late final TarBarTheme theme;
|
||||
final int index;
|
||||
final Rx<String> label;
|
||||
final IconData? selectedIcon;
|
||||
final IconData? unselectedIcon;
|
||||
final bool closable;
|
||||
final int selected;
|
||||
final Function() onClose;
|
||||
final Function() onSelected;
|
||||
final Widget Function(Widget icon, Widget label, TabThemeConf themeConf)?
|
||||
tabBuilder;
|
||||
|
||||
_Tab(
|
||||
{Key? key,
|
||||
required this.index,
|
||||
required this.label,
|
||||
this.selectedIcon,
|
||||
this.unselectedIcon,
|
||||
this.tabBuilder,
|
||||
required this.closable,
|
||||
required this.selected,
|
||||
required this.onClose,
|
||||
required this.onSelected,
|
||||
required this.theme})
|
||||
: super(key: key);
|
||||
const _Tab({
|
||||
Key? key,
|
||||
required this.index,
|
||||
required this.label,
|
||||
this.selectedIcon,
|
||||
this.unselectedIcon,
|
||||
this.tabBuilder,
|
||||
required this.closable,
|
||||
required this.selected,
|
||||
required this.onClose,
|
||||
required this.onSelected,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<_Tab> createState() => _TabState();
|
||||
@@ -529,8 +571,8 @@ class _TabState extends State<_Tab> with RestorationMixin {
|
||||
isSelected ? widget.selectedIcon : widget.unselectedIcon,
|
||||
size: _kIconSize,
|
||||
color: isSelected
|
||||
? widget.theme.selectedtabIconColor
|
||||
: widget.theme.unSelectedtabIconColor,
|
||||
? MyTheme.tabbar(context).selectedTabIconColor
|
||||
: MyTheme.tabbar(context).unSelectedTabIconColor,
|
||||
).paddingOnly(right: 5));
|
||||
final labelWidget = Obx(() {
|
||||
return Text(
|
||||
@@ -538,8 +580,8 @@ class _TabState extends State<_Tab> with RestorationMixin {
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: isSelected
|
||||
? widget.theme.selectedTextColor
|
||||
: widget.theme.unSelectedTextColor),
|
||||
? MyTheme.tabbar(context).selectedTextColor
|
||||
: MyTheme.tabbar(context).unSelectedTextColor),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -552,8 +594,8 @@ class _TabState extends State<_Tab> with RestorationMixin {
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return widget.tabBuilder!(icon, labelWidget,
|
||||
TabThemeConf(iconSize: _kIconSize, theme: widget.theme));
|
||||
return widget.tabBuilder!(
|
||||
icon, labelWidget, TabThemeConf(iconSize: _kIconSize));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -582,7 +624,6 @@ class _TabState extends State<_Tab> with RestorationMixin {
|
||||
visiable: hover.value && widget.closable,
|
||||
tabSelected: isSelected,
|
||||
onClose: () => widget.onClose(),
|
||||
theme: widget.theme,
|
||||
)))
|
||||
])).paddingSymmetric(horizontal: 10),
|
||||
Offstage(
|
||||
@@ -591,7 +632,7 @@ class _TabState extends State<_Tab> with RestorationMixin {
|
||||
width: 1,
|
||||
indent: _kDividerIndent,
|
||||
endIndent: _kDividerIndent,
|
||||
color: widget.theme.dividerColor,
|
||||
color: MyTheme.tabbar(context).dividerColor,
|
||||
thickness: 1,
|
||||
),
|
||||
)
|
||||
@@ -614,14 +655,12 @@ class _CloseButton extends StatelessWidget {
|
||||
final bool visiable;
|
||||
final bool tabSelected;
|
||||
final Function onClose;
|
||||
late final TarBarTheme theme;
|
||||
|
||||
_CloseButton({
|
||||
const _CloseButton({
|
||||
Key? key,
|
||||
required this.visiable,
|
||||
required this.tabSelected,
|
||||
required this.onClose,
|
||||
required this.theme,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@@ -637,8 +676,8 @@ class _CloseButton extends StatelessWidget {
|
||||
Icons.close,
|
||||
size: _kIconSize,
|
||||
color: tabSelected
|
||||
? theme.selectedIconColor
|
||||
: theme.unSelectedIconColor,
|
||||
? MyTheme.tabbar(context).selectedIconColor
|
||||
: MyTheme.tabbar(context).unSelectedIconColor,
|
||||
),
|
||||
),
|
||||
)).paddingOnly(left: 5);
|
||||
@@ -648,16 +687,14 @@ class _CloseButton extends StatelessWidget {
|
||||
class ActionIcon extends StatelessWidget {
|
||||
final String message;
|
||||
final IconData icon;
|
||||
final TarBarTheme theme;
|
||||
final Function() onTap;
|
||||
final bool is_close;
|
||||
final bool isClose;
|
||||
const ActionIcon({
|
||||
Key? key,
|
||||
required this.message,
|
||||
required this.icon,
|
||||
required this.theme,
|
||||
required this.onTap,
|
||||
required this.is_close,
|
||||
required this.isClose,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@@ -665,34 +702,32 @@ class ActionIcon extends StatelessWidget {
|
||||
RxBool hover = false.obs;
|
||||
return Obx(() => Tooltip(
|
||||
message: translate(message),
|
||||
waitDuration: Duration(seconds: 1),
|
||||
waitDuration: const Duration(seconds: 1),
|
||||
child: InkWell(
|
||||
hoverColor:
|
||||
is_close ? Color.fromARGB(255, 196, 43, 28) : theme.hoverColor,
|
||||
hoverColor: isClose
|
||||
? const Color.fromARGB(255, 196, 43, 28)
|
||||
: MyTheme.tabbar(context).hoverColor,
|
||||
onHover: (value) => hover.value = value,
|
||||
child: Container(
|
||||
onTap: onTap,
|
||||
child: SizedBox(
|
||||
height: _kTabBarHeight - 1,
|
||||
width: _kTabBarHeight - 1,
|
||||
child: Icon(
|
||||
icon,
|
||||
color: hover.value && is_close
|
||||
color: hover.value && isClose
|
||||
? Colors.white
|
||||
: theme.unSelectedIconColor,
|
||||
: MyTheme.tabbar(context).unSelectedIconColor,
|
||||
size: _kActionIconSize,
|
||||
),
|
||||
),
|
||||
onTap: onTap,
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class AddButton extends StatelessWidget {
|
||||
late final TarBarTheme theme;
|
||||
|
||||
AddButton({
|
||||
const AddButton({
|
||||
Key? key,
|
||||
required this.theme,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@@ -700,41 +735,101 @@ class AddButton extends StatelessWidget {
|
||||
return ActionIcon(
|
||||
message: 'New Connection',
|
||||
icon: IconFont.add,
|
||||
theme: theme,
|
||||
onTap: () =>
|
||||
rustDeskWinManager.call(WindowType.Main, "main_window_on_top", ""),
|
||||
is_close: false);
|
||||
isClose: 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;
|
||||
class TabbarTheme extends ThemeExtension<TabbarTheme> {
|
||||
final Color? selectedTabIconColor;
|
||||
final Color? unSelectedTabIconColor;
|
||||
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 TabbarTheme(
|
||||
{required this.selectedTabIconColor,
|
||||
required this.unSelectedTabIconColor,
|
||||
required this.selectedTextColor,
|
||||
required this.unSelectedTextColor,
|
||||
required this.selectedIconColor,
|
||||
required this.unSelectedIconColor,
|
||||
required this.dividerColor,
|
||||
required this.hoverColor});
|
||||
|
||||
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;
|
||||
static const light = TabbarTheme(
|
||||
selectedTabIconColor: MyTheme.accent,
|
||||
unSelectedTabIconColor: Color.fromARGB(255, 162, 203, 241),
|
||||
selectedTextColor: Color.fromARGB(255, 26, 26, 26),
|
||||
unSelectedTextColor: Color.fromARGB(255, 96, 96, 96),
|
||||
selectedIconColor: Color.fromARGB(255, 26, 26, 26),
|
||||
unSelectedIconColor: Color.fromARGB(255, 96, 96, 96),
|
||||
dividerColor: Color.fromARGB(255, 238, 238, 238),
|
||||
hoverColor: Color.fromARGB(51, 158, 158, 158));
|
||||
|
||||
static const dark = TabbarTheme(
|
||||
selectedTabIconColor: MyTheme.accent,
|
||||
unSelectedTabIconColor: Color.fromARGB(255, 30, 65, 98),
|
||||
selectedTextColor: Color.fromARGB(255, 255, 255, 255),
|
||||
unSelectedTextColor: Color.fromARGB(255, 207, 207, 207),
|
||||
selectedIconColor: Color.fromARGB(255, 215, 215, 215),
|
||||
unSelectedIconColor: Color.fromARGB(255, 255, 255, 255),
|
||||
dividerColor: Color.fromARGB(255, 64, 64, 64),
|
||||
hoverColor: Colors.black26);
|
||||
|
||||
@override
|
||||
ThemeExtension<TabbarTheme> copyWith({
|
||||
Color? selectedTabIconColor,
|
||||
Color? unSelectedTabIconColor,
|
||||
Color? selectedTextColor,
|
||||
Color? unSelectedTextColor,
|
||||
Color? selectedIconColor,
|
||||
Color? unSelectedIconColor,
|
||||
Color? dividerColor,
|
||||
Color? hoverColor,
|
||||
}) {
|
||||
return TabbarTheme(
|
||||
selectedTabIconColor: selectedTabIconColor ?? this.selectedTabIconColor,
|
||||
unSelectedTabIconColor:
|
||||
unSelectedTabIconColor ?? this.unSelectedTabIconColor,
|
||||
selectedTextColor: selectedTextColor ?? this.selectedTextColor,
|
||||
unSelectedTextColor: unSelectedTextColor ?? this.unSelectedTextColor,
|
||||
selectedIconColor: selectedIconColor ?? this.selectedIconColor,
|
||||
unSelectedIconColor: unSelectedIconColor ?? this.unSelectedIconColor,
|
||||
dividerColor: dividerColor ?? this.dividerColor,
|
||||
hoverColor: hoverColor ?? this.hoverColor,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
ThemeExtension<TabbarTheme> lerp(
|
||||
ThemeExtension<TabbarTheme>? other, double t) {
|
||||
if (other is! TabbarTheme) {
|
||||
return this;
|
||||
}
|
||||
return TabbarTheme(
|
||||
selectedTabIconColor:
|
||||
Color.lerp(selectedTabIconColor, other.selectedTabIconColor, t),
|
||||
unSelectedTabIconColor:
|
||||
Color.lerp(unSelectedTabIconColor, other.unSelectedTabIconColor, t),
|
||||
selectedTextColor:
|
||||
Color.lerp(selectedTextColor, other.selectedTextColor, t),
|
||||
unSelectedTextColor:
|
||||
Color.lerp(unSelectedTextColor, other.unSelectedTextColor, t),
|
||||
selectedIconColor:
|
||||
Color.lerp(selectedIconColor, other.selectedIconColor, t),
|
||||
unSelectedIconColor:
|
||||
Color.lerp(unSelectedIconColor, other.unSelectedIconColor, t),
|
||||
dividerColor: Color.lerp(dividerColor, other.dividerColor, t),
|
||||
hoverColor: Color.lerp(hoverColor, other.hoverColor, t),
|
||||
);
|
||||
}
|
||||
|
||||
static color(BuildContext context) {
|
||||
return Theme.of(context).extension<ColorThemeExtension>()!;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user