Merge pull request #4889 from 21pages/fix_remote_chat

opt remote chat page
This commit is contained in:
RustDesk
2023-07-06 14:37:35 +08:00
committed by GitHub
7 changed files with 78 additions and 22 deletions

View File

@@ -56,15 +56,14 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
if (peerId != null) {
ConnectionTypeState.init(peerId);
tabController.onSelected = (id) {
final remotePage = tabController.state.value.tabs
.firstWhereOrNull((tab) => tab.key == id)
?.page;
final remotePage = tabController.widget(id);
if (remotePage is RemotePage) {
final ffi = remotePage.ffi;
bind.setCurSessionId(sessionId: ffi.sessionId);
}
WindowController.fromWindowId(windowId())
.setTitle(getWindowNameWithId(id));
UnreadChatCountState.find(id).value = 0;
};
tabController.add(TabInfo(
key: peerId,
@@ -206,6 +205,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
).paddingOnly(right: 5),
),
label,
unreadMessageCountBuilder(UnreadChatCountState.find(key)),
],
);

View File

@@ -158,24 +158,7 @@ class ConnectionManagerState extends State<ConnectionManager> {
message: key,
waitDuration: Duration(seconds: 1),
child: label),
Obx(() => Offstage(
offstage:
!((client?.unreadChatMessageCount.value ?? 0) > 0),
child: Container(
width: 16,
height: 16,
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
),
child: Center(
child: Text(
"${client?.unreadChatMessageCount.value ?? 0}",
maxLines: 1,
style: TextStyle(
color: Colors.white, fontSize: 10)),
),
).marginOnly(left: 4)))
unreadMessageCountBuilder(client?.unreadChatMessageCount),
],
);
},

View File

@@ -187,6 +187,10 @@ class DesktopTabController {
state.value.tabs.clear();
state.refresh();
}
Widget? widget(String key) {
return state.value.tabs.firstWhereOrNull((tab) => tab.key == key)?.page;
}
}
class TabThemeConf {