flutter_desktop: connection type icon, tested windows

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2022-08-29 22:46:19 +08:00
parent 01e96a1134
commit f42c6ffeaf
24 changed files with 154 additions and 46 deletions

View File

@ -45,12 +45,17 @@ class ConnectionType {
Rx<String> get secure => _secure; Rx<String> get secure => _secure;
Rx<String> get direct => _direct; 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) { void setSecure(bool v) {
_secure.value = v ? 'secure' : 'insecure'; _secure.value = v ? strSecure : strInsecure;
} }
void setDirect(bool v) { void setDirect(bool v) {
_direct.value = v ? '' : '_relay'; _direct.value = v ? strDirect : strIndirect;
} }
bool isValid() { bool isValid() {
@ -63,11 +68,20 @@ class ConnectionTypeState {
static String tag(String id) => 'connection_type_$id'; static String tag(String id) => 'connection_type_$id';
static void init(String id) { static void init(String id) {
final ConnectionType collectionType = ConnectionType(); final key = tag(id);
Get.put(collectionType, tag: 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) => static ConnectionType find(String id) =>
Get.find<ConnectionType>(tag: tag(id)); Get.find<ConnectionType>(tag: tag(id));
} }

View File

@ -28,15 +28,17 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
_ConnectionTabPageState(Map<String, dynamic> params) { _ConnectionTabPageState(Map<String, dynamic> params) {
final RxBool fullscreen = Get.find(tag: 'fullscreen'); final RxBool fullscreen = Get.find(tag: 'fullscreen');
if (params['id'] != null) { final peerId = params['id'];
if (peerId != null) {
ConnectionTypeState.init(peerId);
tabController.add(TabInfo( tabController.add(TabInfo(
key: params['id'], key: peerId,
label: params['id'], label: peerId,
selectedIcon: selectedIcon, selectedIcon: selectedIcon,
unselectedIcon: unselectedIcon, unselectedIcon: unselectedIcon,
page: Obx(() => RemotePage( page: Obx(() => RemotePage(
key: ValueKey(params['id']), key: ValueKey(peerId),
id: params['id'], id: peerId,
tabBarHeight: tabBarHeight:
fullscreen.isTrue ? 0 : kDesktopRemoteTabBarHeight, fullscreen.isTrue ? 0 : kDesktopRemoteTabBarHeight,
)))); ))));
@ -89,10 +91,10 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
child: Scaffold( child: Scaffold(
backgroundColor: MyTheme.color(context).bg, backgroundColor: MyTheme.color(context).bg,
body: Obx(() => DesktopTab( body: Obx(() => DesktopTab(
controller: tabController, controller: tabController,
theme: theme, theme: theme,
isMainWindow: false, isMainWindow: false,
showTabBar: fullscreen.isFalse, showTabBar: fullscreen.isFalse,
onClose: () { onClose: () {
tabController.clear(); tabController.clear();
}, },
@ -104,36 +106,45 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
.setFullscreen(fullscreen.isTrue); .setFullscreen(fullscreen.isTrue);
return pageView; return pageView;
}, },
tabBuilder: (key, icon, label, themeConf) { tabBuilder: (key, icon, label, themeConf) => Obx(() {
final connectionType = ConnectionTypeState.find(key); final connectionType = ConnectionTypeState.find(key);
if (!connectionType.isValid()) { if (!ConnectionTypeState.find(key).isValid()) {
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
icon, icon,
label, label,
], ],
); );
} else { } else {
final iconName = final msgDirect = translate(
'${connectionType.secure.value}${connectionType.direct.value}'; connectionType.direct.value ==
final connectionIcon = Image.asset( ConnectionType.strDirect
'assets/$iconName.png', ? 'Direct Connection'
width: themeConf.iconSize, : 'Relay Connection');
height: themeConf.iconSize, final msgSecure = translate(
color: theme.selectedtabIconColor, connectionType.secure.value ==
); ConnectionType.strSecure
//.paddingOnly(right: 5); ? 'Secure Connection'
return Row( : 'Insecure Connection');
mainAxisAlignment: MainAxisAlignment.center, return Row(
children: [ mainAxisAlignment: MainAxisAlignment.center,
icon, children: [
connectionIcon, icon,
label, 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) { if (tabController.state.value.tabs.isEmpty) {
WindowController.fromWindowId(windowId()).hide(); WindowController.fromWindowId(windowId()).hide();
} }
ConnectionTypeState.delete(id);
} }
int windowId() { int windowId() {

View File

@ -58,14 +58,12 @@ class _RemotePageState extends State<RemotePage>
PrivacyModeState.init(id); PrivacyModeState.init(id);
BlockInputState.init(id); BlockInputState.init(id);
CurrentDisplayState.init(id); CurrentDisplayState.init(id);
ConnectionTypeState.init(id);
} }
void _removeStates(String id) { void _removeStates(String id) {
PrivacyModeState.delete(id); PrivacyModeState.delete(id);
BlockInputState.delete(id); BlockInputState.delete(id);
CurrentDisplayState.delete(id); CurrentDisplayState.delete(id);
ConnectionTypeState.delete(id);
} }
@override @override

View File

@ -313,5 +313,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "滚屏方式"), ("Scroll Style", "滚屏方式"),
("Show Menubar", "显示菜单栏"), ("Show Menubar", "显示菜单栏"),
("Hide Menubar", "隐藏菜单栏"), ("Hide Menubar", "隐藏菜单栏"),
("Direct Connection", "直接连接"),
("Relay Connection", "中继连接"),
("Secure Connection", "安全连接"),
("Insecure Connection", "非安全连接"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -313,5 +313,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "Štýl posúvania"), ("Scroll Style", "Štýl posúvania"),
("Show Menubar", "Zobrazit panel nabídek"), ("Show Menubar", "Zobrazit panel nabídek"),
("Hide Menubar", "skrýt panel nabídek"), ("Hide Menubar", "skrýt panel nabídek"),
("Direct Connection", "Přímé spojení"),
("Relay Connection", "Připojení relé"),
("Secure Connection", "Zabezpečené připojení"),
("Insecure Connection", "Nezabezpečené připojení"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -313,5 +313,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "Rulstil"), ("Scroll Style", "Rulstil"),
("Show Menubar", "Vis menulinje"), ("Show Menubar", "Vis menulinje"),
("Hide Menubar", "skjul menulinjen"), ("Hide Menubar", "skjul menulinjen"),
("Direct Connection", "Direkte forbindelse"),
("Relay Connection", "Relæforbindelse"),
("Secure Connection", "Sikker forbindelse"),
("Insecure Connection", "Usikker forbindelse"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -313,5 +313,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "Scroll-Stil"), ("Scroll Style", "Scroll-Stil"),
("Show Menubar", "Menüleiste anzeigen"), ("Show Menubar", "Menüleiste anzeigen"),
("Hide Menubar", "Menüleiste ausblenden"), ("Hide Menubar", "Menüleiste ausblenden"),
("Direct Connection", "Direkte Verbindung"),
("Relay Connection", "Relaisverbindung"),
("Secure Connection", "Sichere Verbindung"),
("Insecure Connection", "Unsichere Verbindung"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -313,5 +313,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "Ruluma Stilo"), ("Scroll Style", "Ruluma Stilo"),
("Show Menubar", "Montru menubreton"), ("Show Menubar", "Montru menubreton"),
("Hide Menubar", "kaŝi menubreton"), ("Hide Menubar", "kaŝi menubreton"),
("Direct Connection", "Rekta Konekto"),
("Relay Connection", "Relajsa Konekto"),
("Secure Connection", "Sekura Konekto"),
("Insecure Connection", "Nesekura Konekto"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -313,5 +313,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "Estilo de desplazamiento"), ("Scroll Style", "Estilo de desplazamiento"),
("Show Menubar", "ajustes de pantalla"), ("Show Menubar", "ajustes de pantalla"),
("Hide Menubar", "ocultar barra de menú"), ("Hide Menubar", "ocultar barra de menú"),
("Direct Connection", "Conexión directa"),
("Relay Connection", "Conexión de relé"),
("Secure Connection", "Conexión segura"),
("Insecure Connection", "Conexión insegura"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -313,5 +313,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "Style de défilement"), ("Scroll Style", "Style de défilement"),
("Show Menubar", "Afficher la barre de menus"), ("Show Menubar", "Afficher la barre de menus"),
("Hide Menubar", "masquer la barre de menus"), ("Hide Menubar", "masquer la barre de menus"),
("Direct Connection", "Connexion directe"),
("Relay Connection", "Connexion relais"),
("Secure Connection", "Connexion sécurisée"),
("Insecure Connection", "Connexion non sécurisée"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -313,5 +313,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "Görgetési stílus"), ("Scroll Style", "Görgetési stílus"),
("Show Menubar", "Menüsor megjelenítése"), ("Show Menubar", "Menüsor megjelenítése"),
("Hide Menubar", "menüsor elrejtése"), ("Hide Menubar", "menüsor elrejtése"),
("Direct Connection", "Közvetlen kapcsolat"),
("Relay Connection", "Relé csatlakozás"),
("Secure Connection", "Biztonságos kapcsolat"),
("Insecure Connection", "Nem biztonságos kapcsolat"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -313,5 +313,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "Gaya Gulir"), ("Scroll Style", "Gaya Gulir"),
("Show Menubar", "Tampilkan bilah menu"), ("Show Menubar", "Tampilkan bilah menu"),
("Hide Menubar", "sembunyikan bilah menu"), ("Hide Menubar", "sembunyikan bilah menu"),
("Direct Connection", "Koneksi langsung"),
("Relay Connection", "Koneksi Relay"),
("Secure Connection", "Koneksi aman"),
("Insecure Connection", "Koneksi Tidak Aman"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -312,5 +312,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "Stile di scorrimento"), ("Scroll Style", "Stile di scorrimento"),
("Show Menubar", "Mostra la barra dei menu"), ("Show Menubar", "Mostra la barra dei menu"),
("Hide Menubar", "nascondi la barra dei menu"), ("Hide Menubar", "nascondi la barra dei menu"),
("Direct Connection", "Connessione diretta"),
("Relay Connection", "Collegamento a relè"),
("Secure Connection", "Connessione sicura"),
("Insecure Connection", "Connessione insicura"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -310,5 +310,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "スクロール スタイル"), ("Scroll Style", "スクロール スタイル"),
("Show Menubar", "メニューバーを表示"), ("Show Menubar", "メニューバーを表示"),
("Hide Menubar", "メニューバーを隠す"), ("Hide Menubar", "メニューバーを隠す"),
("Direct Connection", "直接接続"),
("Relay Connection", "リレー接続"),
("Secure Connection", "安全な接続"),
("Insecure Connection", "安全でない接続"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -310,5 +310,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "스크롤 스타일"), ("Scroll Style", "스크롤 스타일"),
("Show Menubar", "메뉴 표시줄 표시"), ("Show Menubar", "메뉴 표시줄 표시"),
("Hide Menubar", "메뉴 표시줄 숨기기"), ("Hide Menubar", "메뉴 표시줄 숨기기"),
("Direct Connection", "직접 연결"),
("Relay Connection", "릴레이 연결"),
("Secure Connection", "보안 연결"),
("Insecure Connection", "안전하지 않은 연결"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -314,5 +314,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "Styl przewijania"), ("Scroll Style", "Styl przewijania"),
("Show Menubar", "Pokaż pasek menu"), ("Show Menubar", "Pokaż pasek menu"),
("Hide Menubar", "ukryj pasek menu"), ("Hide Menubar", "ukryj pasek menu"),
("Direct Connection", "Bezpośrednie połączenie"),
("Relay Connection", "Połączenie przekaźnika"),
("Secure Connection", "Bezpieczne połączenie"),
("Insecure Connection", "Niepewne połączenie"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -310,5 +310,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "Estilo de rolagem"), ("Scroll Style", "Estilo de rolagem"),
("Show Menubar", "Mostrar barra de menus"), ("Show Menubar", "Mostrar barra de menus"),
("Hide Menubar", "ocultar barra de menu"), ("Hide Menubar", "ocultar barra de menu"),
("Direct Connection", "Conexão direta"),
("Relay Connection", "Conexão de relé"),
("Secure Connection", "Conexão segura"),
("Insecure Connection", "Conexão insegura"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -313,5 +313,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", ""), ("Scroll Style", ""),
("Show Menubar", ""), ("Show Menubar", ""),
("Hide Menubar", ""), ("Hide Menubar", ""),
("Direct Connection", ""),
("Relay Connection", ""),
("Secure Connection", ""),
("Insecure Connection", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -313,5 +313,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "Стиль прокрутки"), ("Scroll Style", "Стиль прокрутки"),
("Show Menubar", "Показать строку меню"), ("Show Menubar", "Показать строку меню"),
("Hide Menubar", "скрыть строку меню"), ("Hide Menubar", "скрыть строку меню"),
("Direct Connection", "Прямая связь"),
("Relay Connection", "Релейное соединение"),
("Secure Connection", "Безопасное соединение"),
("Insecure Connection", "Небезопасное соединение"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -313,5 +313,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "Štýl posúvania"), ("Scroll Style", "Štýl posúvania"),
("Show Menubar", "Zobraziť panel s ponukami"), ("Show Menubar", "Zobraziť panel s ponukami"),
("Hide Menubar", "skryť panel s ponukami"), ("Hide Menubar", "skryť panel s ponukami"),
("Direct Connection", "Priame pripojenie"),
("Relay Connection", "Reléové pripojenie"),
("Secure Connection", "Zabezpečené pripojenie"),
("Insecure Connection", "Nezabezpečené pripojenie"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -313,5 +313,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", ""), ("Scroll Style", ""),
("Show Menubar", ""), ("Show Menubar", ""),
("Hide Menubar", ""), ("Hide Menubar", ""),
("Direct Connection", ""),
("Relay Connection", ""),
("Secure Connection", ""),
("Insecure Connection", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -313,5 +313,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "Kaydırma Stili"), ("Scroll Style", "Kaydırma Stili"),
("Show Menubar", "Menü çubuğunu göster"), ("Show Menubar", "Menü çubuğunu göster"),
("Hide Menubar", "menü çubuğunu gizle"), ("Hide Menubar", "menü çubuğunu gizle"),
("Direct Connection", "Doğrudan Bağlantı"),
("Relay Connection", "Röle Bağlantısı"),
("Secure Connection", "Güvenli bağlantı"),
("Insecure Connection", "Güvenli Bağlantı"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -313,5 +313,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "滾動樣式"), ("Scroll Style", "滾動樣式"),
("Show Menubar", "顯示菜單欄"), ("Show Menubar", "顯示菜單欄"),
("Hide Menubar", "隱藏菜單欄"), ("Hide Menubar", "隱藏菜單欄"),
("Direct Connection", "直接連接"),
("Relay Connection", "中繼連接"),
("Secure Connection", "安全連接"),
("Insecure Connection", "非安全連接"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -313,5 +313,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scroll Style", "Kiểu cuộn"), ("Scroll Style", "Kiểu cuộn"),
("Show Menubar", "Hiển thị thanh menu"), ("Show Menubar", "Hiển thị thanh menu"),
("Hide Menubar", "ẩn thanh menu"), ("Hide Menubar", "ẩn thanh menu"),
("Direct Connection", "Kết nối trực tiếp"),
("Relay Connection", "Kết nối chuyển tiếp"),
("Secure Connection", "Kết nối an toàn"),
("Insecure Connection", "Kết nối không an toàn"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }