Merge pull request #1969 from fufesou/fix_cm

Fix cm
This commit is contained in:
RustDesk 2022-11-05 11:00:08 +08:00 committed by GitHub
commit 96f2e61ca4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 30 deletions

View File

@ -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

View File

@ -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())
])));

View File

@ -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);
});
}

View File

@ -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;

View File

@ -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)));

View File

@ -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