mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
flutter_desktop: connection type icon, tested windows
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -45,12 +45,17 @@ class ConnectionType {
|
||||
Rx<String> get secure => _secure;
|
||||
Rx<String> get direct => _direct;
|
||||
|
||||
static String get strSecure => 'secure';
|
||||
static String get strInsecure => 'insecure';
|
||||
static String get strDirect => '';
|
||||
static String get strIndirect => '_relay';
|
||||
|
||||
void setSecure(bool v) {
|
||||
_secure.value = v ? 'secure' : 'insecure';
|
||||
_secure.value = v ? strSecure : strInsecure;
|
||||
}
|
||||
|
||||
void setDirect(bool v) {
|
||||
_direct.value = v ? '' : '_relay';
|
||||
_direct.value = v ? strDirect : strIndirect;
|
||||
}
|
||||
|
||||
bool isValid() {
|
||||
@@ -63,11 +68,20 @@ class ConnectionTypeState {
|
||||
static String tag(String id) => 'connection_type_$id';
|
||||
|
||||
static void init(String id) {
|
||||
final ConnectionType collectionType = ConnectionType();
|
||||
Get.put(collectionType, tag: tag(id));
|
||||
final key = tag(id);
|
||||
if (!Get.isRegistered(tag: key)) {
|
||||
final ConnectionType collectionType = ConnectionType();
|
||||
Get.put(collectionType, tag: key);
|
||||
}
|
||||
}
|
||||
|
||||
static void delete(String id) {
|
||||
final key = tag(id);
|
||||
if (Get.isRegistered(tag: key)) {
|
||||
Get.delete(tag: key);
|
||||
}
|
||||
}
|
||||
|
||||
static void delete(String id) => Get.delete(tag: tag(id));
|
||||
static ConnectionType find(String id) =>
|
||||
Get.find<ConnectionType>(tag: tag(id));
|
||||
}
|
||||
|
||||
@@ -28,15 +28,17 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
|
||||
_ConnectionTabPageState(Map<String, dynamic> params) {
|
||||
final RxBool fullscreen = Get.find(tag: 'fullscreen');
|
||||
if (params['id'] != null) {
|
||||
final peerId = params['id'];
|
||||
if (peerId != null) {
|
||||
ConnectionTypeState.init(peerId);
|
||||
tabController.add(TabInfo(
|
||||
key: params['id'],
|
||||
label: params['id'],
|
||||
key: peerId,
|
||||
label: peerId,
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
page: Obx(() => RemotePage(
|
||||
key: ValueKey(params['id']),
|
||||
id: params['id'],
|
||||
key: ValueKey(peerId),
|
||||
id: peerId,
|
||||
tabBarHeight:
|
||||
fullscreen.isTrue ? 0 : kDesktopRemoteTabBarHeight,
|
||||
))));
|
||||
@@ -89,10 +91,10 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
child: Scaffold(
|
||||
backgroundColor: MyTheme.color(context).bg,
|
||||
body: Obx(() => DesktopTab(
|
||||
controller: tabController,
|
||||
theme: theme,
|
||||
isMainWindow: false,
|
||||
showTabBar: fullscreen.isFalse,
|
||||
controller: tabController,
|
||||
theme: theme,
|
||||
isMainWindow: false,
|
||||
showTabBar: fullscreen.isFalse,
|
||||
onClose: () {
|
||||
tabController.clear();
|
||||
},
|
||||
@@ -104,36 +106,45 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
.setFullscreen(fullscreen.isTrue);
|
||||
return pageView;
|
||||
},
|
||||
tabBuilder: (key, icon, label, themeConf) {
|
||||
final connectionType = ConnectionTypeState.find(key);
|
||||
if (!connectionType.isValid()) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
icon,
|
||||
label,
|
||||
],
|
||||
);
|
||||
} else {
|
||||
final iconName =
|
||||
'${connectionType.secure.value}${connectionType.direct.value}';
|
||||
final connectionIcon = Image.asset(
|
||||
'assets/$iconName.png',
|
||||
width: themeConf.iconSize,
|
||||
height: themeConf.iconSize,
|
||||
color: theme.selectedtabIconColor,
|
||||
);
|
||||
//.paddingOnly(right: 5);
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
icon,
|
||||
connectionIcon,
|
||||
label,
|
||||
],
|
||||
);
|
||||
}
|
||||
}))),
|
||||
tabBuilder: (key, icon, label, themeConf) => Obx(() {
|
||||
final connectionType = ConnectionTypeState.find(key);
|
||||
if (!ConnectionTypeState.find(key).isValid()) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
icon,
|
||||
label,
|
||||
],
|
||||
);
|
||||
} else {
|
||||
final msgDirect = translate(
|
||||
connectionType.direct.value ==
|
||||
ConnectionType.strDirect
|
||||
? 'Direct Connection'
|
||||
: 'Relay Connection');
|
||||
final msgSecure = translate(
|
||||
connectionType.secure.value ==
|
||||
ConnectionType.strSecure
|
||||
? 'Secure Connection'
|
||||
: 'Insecure Connection');
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
icon,
|
||||
Tooltip(
|
||||
message: '$msgDirect\n$msgSecure',
|
||||
child: Image.asset(
|
||||
'assets/${connectionType.secure.value}${connectionType.direct.value}.png',
|
||||
width: themeConf.iconSize,
|
||||
height: themeConf.iconSize,
|
||||
).paddingOnly(right: 5),
|
||||
),
|
||||
label,
|
||||
],
|
||||
);
|
||||
}
|
||||
}),
|
||||
))),
|
||||
),
|
||||
));
|
||||
}
|
||||
@@ -142,6 +153,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
if (tabController.state.value.tabs.isEmpty) {
|
||||
WindowController.fromWindowId(windowId()).hide();
|
||||
}
|
||||
ConnectionTypeState.delete(id);
|
||||
}
|
||||
|
||||
int windowId() {
|
||||
|
||||
@@ -58,14 +58,12 @@ class _RemotePageState extends State<RemotePage>
|
||||
PrivacyModeState.init(id);
|
||||
BlockInputState.init(id);
|
||||
CurrentDisplayState.init(id);
|
||||
ConnectionTypeState.init(id);
|
||||
}
|
||||
|
||||
void _removeStates(String id) {
|
||||
PrivacyModeState.delete(id);
|
||||
BlockInputState.delete(id);
|
||||
CurrentDisplayState.delete(id);
|
||||
ConnectionTypeState.delete(id);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user