commit
96f2e61ca4
@ -54,6 +54,7 @@ class ChatPage extends StatelessWidget implements PageShape {
|
||||
return DashChat(
|
||||
onSend: (chatMsg) {
|
||||
chatModel.send(chatMsg);
|
||||
chatModel.inputNode.requestFocus();
|
||||
},
|
||||
currentUser: chatModel.me,
|
||||
messages: chatModel
|
||||
|
@ -101,6 +101,7 @@ class ConnectionManagerState extends State<ConnectionManager> {
|
||||
gFFI.serverModel.updateClientState();
|
||||
gFFI.serverModel.tabController.onSelected = (index, _) =>
|
||||
gFFI.chatModel.changeCurrentID(gFFI.serverModel.clients[index].id);
|
||||
gFFI.chatModel.isConnManager = true;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@ -159,7 +160,7 @@ class ConnectionManagerState extends State<ConnectionManager> {
|
||||
pageViewBuilder: (pageView) => Row(children: [
|
||||
Expanded(child: pageView),
|
||||
Consumer<ChatModel>(
|
||||
builder: (_, model, child) => model.isShowChatPage
|
||||
builder: (_, model, child) => model.isShowCMChatPage
|
||||
? Expanded(child: Scaffold(body: ChatPage()))
|
||||
: Offstage())
|
||||
])));
|
||||
|
@ -160,15 +160,10 @@ void runConnectionManagerScreen() async {
|
||||
);
|
||||
windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||
await windowManager.show();
|
||||
await Future.wait([windowManager.focus(), windowManager.setOpacity(1)]);
|
||||
// ensure initial window size to be changed
|
||||
await windowManager.setSize(kConnectionManagerWindowSize);
|
||||
await Future.wait([
|
||||
windowManager.setAlignment(Alignment.topRight),
|
||||
windowManager.focus(),
|
||||
windowManager.setOpacity(1)
|
||||
]);
|
||||
// ensure
|
||||
windowManager.setAlignment(Alignment.topRight);
|
||||
await windowManager.setSizeAlignment(
|
||||
kConnectionManagerWindowSize, Alignment.topRight);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ class ChatModel with ChangeNotifier {
|
||||
OverlayState? _overlayState;
|
||||
OverlayEntry? chatIconOverlayEntry;
|
||||
OverlayEntry? chatWindowOverlayEntry;
|
||||
bool isConnManager = false;
|
||||
|
||||
final ChatUser me = ChatUser(
|
||||
id: "",
|
||||
@ -42,13 +43,13 @@ class ChatModel with ChangeNotifier {
|
||||
MessageBody(me, []);
|
||||
|
||||
var _currentID = clientModeID;
|
||||
late bool _isShowChatPage = false;
|
||||
late bool _isShowCMChatPage = false;
|
||||
|
||||
Map<int, MessageBody> get messages => _messages;
|
||||
|
||||
int get currentID => _currentID;
|
||||
|
||||
bool get isShowChatPage => _isShowChatPage;
|
||||
bool get isShowCMChatPage => _isShowCMChatPage;
|
||||
|
||||
final WeakReference<FFI> parent;
|
||||
|
||||
@ -147,9 +148,11 @@ class ChatModel with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
_isChatOverlayHide() => ((!isDesktop && chatIconOverlayEntry == null) ||
|
||||
chatWindowOverlayEntry == null);
|
||||
|
||||
toggleChatOverlay() {
|
||||
if ((!isDesktop && chatIconOverlayEntry == null) ||
|
||||
chatWindowOverlayEntry == null) {
|
||||
if (_isChatOverlayHide()) {
|
||||
gFFI.invokeMethod("enable_soft_keyboard", true);
|
||||
if (!isDesktop) {
|
||||
showChatIconOverlay();
|
||||
@ -161,20 +164,29 @@ class ChatModel with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
showChatPage(int id) async {
|
||||
if (isConnManager) {
|
||||
if (!_isShowCMChatPage) {
|
||||
await toggleCMChatPage(id);
|
||||
}
|
||||
} else {
|
||||
if (_isChatOverlayHide()) {
|
||||
await toggleChatOverlay();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
toggleCMChatPage(int id) async {
|
||||
if (gFFI.chatModel.currentID != id) {
|
||||
gFFI.chatModel.changeCurrentID(id);
|
||||
}
|
||||
if (_isShowChatPage) {
|
||||
_isShowChatPage = !_isShowChatPage;
|
||||
if (_isShowCMChatPage) {
|
||||
_isShowCMChatPage = !_isShowCMChatPage;
|
||||
notifyListeners();
|
||||
await windowManager.setSize(Size(300, 400));
|
||||
await windowManager.setAlignment(Alignment.topRight);
|
||||
await windowManager.setSizeAlignment(Size(300, 400), Alignment.topRight);
|
||||
} else {
|
||||
await windowManager.setSize(Size(600, 400));
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
await windowManager.setAlignment(Alignment.topRight);
|
||||
_isShowChatPage = !_isShowChatPage;
|
||||
await windowManager.setSizeAlignment(Size(600, 400), Alignment.topRight);
|
||||
_isShowCMChatPage = !_isShowCMChatPage;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@ -208,13 +220,11 @@ class ChatModel with ChangeNotifier {
|
||||
}
|
||||
if (text.isEmpty) return;
|
||||
// mobile: first message show overlay icon
|
||||
if (chatIconOverlayEntry == null) {
|
||||
if (!isDesktop && chatIconOverlayEntry == null) {
|
||||
showChatIconOverlay();
|
||||
}
|
||||
// desktop: show chat page
|
||||
if (!_isShowChatPage) {
|
||||
toggleCMChatPage(id);
|
||||
}
|
||||
// show chat page
|
||||
await showChatPage(id);
|
||||
|
||||
int toId = currentID;
|
||||
|
||||
|
@ -407,9 +407,7 @@ class ServerModel with ChangeNotifier {
|
||||
if (client.hasUnreadChatMessage.value) {
|
||||
client.hasUnreadChatMessage.value = false;
|
||||
final chatModel = parent.target!.chatModel;
|
||||
if (!chatModel.isShowChatPage) {
|
||||
chatModel.toggleCMChatPage(client.id);
|
||||
}
|
||||
chatModel.showChatPage(client.id);
|
||||
}
|
||||
},
|
||||
page: desktop.buildConnectionCard(client)));
|
||||
|
@ -60,7 +60,7 @@ dependencies:
|
||||
window_manager:
|
||||
git:
|
||||
url: https://github.com/Kingtous/rustdesk_window_manager
|
||||
ref: 88487257cbafc501599ab4f82ec343b46acec020
|
||||
ref: d1e4b40f4a1ffeb8630696be6883dd31bf307998
|
||||
desktop_multi_window:
|
||||
git:
|
||||
url: https://github.com/Kingtous/rustdesk_desktop_multi_window
|
||||
|
Loading…
x
Reference in New Issue
Block a user