Merge pull request #4889 from 21pages/fix_remote_chat
opt remote chat page
This commit is contained in:
commit
d6709e069c
@ -2140,3 +2140,20 @@ Widget buildRemoteBlock({required Widget child, WhetherUseRemoteBlock? use}) {
|
|||||||
]),
|
]),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget unreadMessageCountBuilder(RxInt? count) {
|
||||||
|
return Obx(() => Offstage(
|
||||||
|
offstage: !((count?.value ?? 0) > 0),
|
||||||
|
child: Container(
|
||||||
|
width: 16,
|
||||||
|
height: 16,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.red,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Text("${count?.value ?? 0}",
|
||||||
|
maxLines: 1, style: TextStyle(color: Colors.white, fontSize: 10)),
|
||||||
|
),
|
||||||
|
).marginOnly(left: 4)));
|
||||||
|
}
|
||||||
|
@ -285,6 +285,29 @@ class PeerStringOption {
|
|||||||
Get.find<RxString>(tag: tag(id, opt));
|
Get.find<RxString>(tag: tag(id, opt));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class UnreadChatCountState {
|
||||||
|
static String tag(id) => 'unread_chat_count_$id';
|
||||||
|
|
||||||
|
static void init(String id) {
|
||||||
|
final key = tag(id);
|
||||||
|
if (!Get.isRegistered(tag: key)) {
|
||||||
|
final RxInt state = RxInt(0);
|
||||||
|
Get.put(state, tag: key);
|
||||||
|
} else {
|
||||||
|
Get.find<RxInt>(tag: key).value = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void delete(String id) {
|
||||||
|
final key = tag(id);
|
||||||
|
if (Get.isRegistered(tag: key)) {
|
||||||
|
Get.delete(tag: key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static RxInt find(String id) => Get.find<RxInt>(tag: tag(id));
|
||||||
|
}
|
||||||
|
|
||||||
initSharedStates(String id) {
|
initSharedStates(String id) {
|
||||||
PrivacyModeState.init(id);
|
PrivacyModeState.init(id);
|
||||||
BlockInputState.init(id);
|
BlockInputState.init(id);
|
||||||
@ -294,6 +317,7 @@ initSharedStates(String id) {
|
|||||||
RemoteCursorMovedState.init(id);
|
RemoteCursorMovedState.init(id);
|
||||||
FingerprintState.init(id);
|
FingerprintState.init(id);
|
||||||
PeerBoolOption.init(id, 'zoom-cursor', () => false);
|
PeerBoolOption.init(id, 'zoom-cursor', () => false);
|
||||||
|
UnreadChatCountState.init(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeSharedStates(String id) {
|
removeSharedStates(String id) {
|
||||||
@ -305,4 +329,5 @@ removeSharedStates(String id) {
|
|||||||
RemoteCursorMovedState.delete(id);
|
RemoteCursorMovedState.delete(id);
|
||||||
FingerprintState.delete(id);
|
FingerprintState.delete(id);
|
||||||
PeerBoolOption.delete(id, 'zoom-cursor');
|
PeerBoolOption.delete(id, 'zoom-cursor');
|
||||||
|
UnreadChatCountState.delete(id);
|
||||||
}
|
}
|
||||||
|
@ -56,15 +56,14 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
|||||||
if (peerId != null) {
|
if (peerId != null) {
|
||||||
ConnectionTypeState.init(peerId);
|
ConnectionTypeState.init(peerId);
|
||||||
tabController.onSelected = (id) {
|
tabController.onSelected = (id) {
|
||||||
final remotePage = tabController.state.value.tabs
|
final remotePage = tabController.widget(id);
|
||||||
.firstWhereOrNull((tab) => tab.key == id)
|
|
||||||
?.page;
|
|
||||||
if (remotePage is RemotePage) {
|
if (remotePage is RemotePage) {
|
||||||
final ffi = remotePage.ffi;
|
final ffi = remotePage.ffi;
|
||||||
bind.setCurSessionId(sessionId: ffi.sessionId);
|
bind.setCurSessionId(sessionId: ffi.sessionId);
|
||||||
}
|
}
|
||||||
WindowController.fromWindowId(windowId())
|
WindowController.fromWindowId(windowId())
|
||||||
.setTitle(getWindowNameWithId(id));
|
.setTitle(getWindowNameWithId(id));
|
||||||
|
UnreadChatCountState.find(id).value = 0;
|
||||||
};
|
};
|
||||||
tabController.add(TabInfo(
|
tabController.add(TabInfo(
|
||||||
key: peerId,
|
key: peerId,
|
||||||
@ -206,6 +205,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
|||||||
).paddingOnly(right: 5),
|
).paddingOnly(right: 5),
|
||||||
),
|
),
|
||||||
label,
|
label,
|
||||||
|
unreadMessageCountBuilder(UnreadChatCountState.find(key)),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -158,24 +158,7 @@ class ConnectionManagerState extends State<ConnectionManager> {
|
|||||||
message: key,
|
message: key,
|
||||||
waitDuration: Duration(seconds: 1),
|
waitDuration: Duration(seconds: 1),
|
||||||
child: label),
|
child: label),
|
||||||
Obx(() => Offstage(
|
unreadMessageCountBuilder(client?.unreadChatMessageCount),
|
||||||
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)))
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -187,6 +187,10 @@ class DesktopTabController {
|
|||||||
state.value.tabs.clear();
|
state.value.tabs.clear();
|
||||||
state.refresh();
|
state.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget? widget(String key) {
|
||||||
|
return state.value.tabs.firstWhereOrNull((tab) => tab.key == key)?.page;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TabThemeConf {
|
class TabThemeConf {
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:dash_chat_2/dash_chat_2.dart';
|
import 'package:dash_chat_2/dash_chat_2.dart';
|
||||||
|
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||||
import 'package:draggable_float_widget/draggable_float_widget.dart';
|
import 'package:draggable_float_widget/draggable_float_widget.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_hbb/common/shared_state.dart';
|
||||||
|
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
|
||||||
import 'package:flutter_hbb/models/platform_model.dart';
|
import 'package:flutter_hbb/models/platform_model.dart';
|
||||||
|
import 'package:flutter_hbb/models/state_model.dart';
|
||||||
import 'package:get/get_rx/src/rx_types/rx_types.dart';
|
import 'package:get/get_rx/src/rx_types/rx_types.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
@ -309,6 +313,29 @@ class ChatModel with ChangeNotifier {
|
|||||||
id: session.id,
|
id: session.id,
|
||||||
);
|
);
|
||||||
toId = id;
|
toId = id;
|
||||||
|
|
||||||
|
if (isDesktop) {
|
||||||
|
if (Get.isRegistered<DesktopTabController>()) {
|
||||||
|
DesktopTabController tabController = Get.find<DesktopTabController>();
|
||||||
|
var index = tabController.state.value.tabs
|
||||||
|
.indexWhere((e) => e.key == session.id);
|
||||||
|
final notSelected =
|
||||||
|
index >= 0 && tabController.state.value.selected != index;
|
||||||
|
// minisized: top and switch tab
|
||||||
|
// not minisized: add count
|
||||||
|
if (await WindowController.fromWindowId(stateGlobal.windowId)
|
||||||
|
.isMinimized()) {
|
||||||
|
window_on_top(stateGlobal.windowId);
|
||||||
|
if (notSelected) {
|
||||||
|
tabController.jumpTo(index);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (notSelected) {
|
||||||
|
UnreadChatCountState.find(session.id).value += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final client =
|
final client =
|
||||||
session.serverModel.clients.firstWhere((client) => client.id == id);
|
session.serverModel.clients.firstWhere((client) => client.id == id);
|
||||||
|
@ -319,7 +319,7 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: HEAD
|
ref: HEAD
|
||||||
resolved-ref: "30518303e28702bf6b8110465293c05d21bc4cd2"
|
resolved-ref: aee670819f5fe7e8b0f05e0239dafb5c62f7a84b
|
||||||
url: "https://github.com/rustdesk-org/rustdesk_desktop_multi_window"
|
url: "https://github.com/rustdesk-org/rustdesk_desktop_multi_window"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.0"
|
version: "0.1.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user