desktop cm chat page

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2022-11-04 21:43:51 +08:00
parent 4272f0194e
commit e7ac6eb0d2
3 changed files with 29 additions and 22 deletions

View File

@@ -34,6 +34,7 @@ class ChatModel with ChangeNotifier {
OverlayEntry? chatWindowOverlayEntry;
bool _showOnWindowRestore = false;
bool _isWindowMinimized = false;
bool isConnManager = false;
final ChatUser me = ChatUser(
id: "",
@@ -44,13 +45,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;
@@ -71,7 +72,6 @@ class ChatModel with ChangeNotifier {
setWindowMinimized(bool v) {
_isWindowMinimized = v;
if (!_isWindowMinimized && _showOnWindowRestore) {
showChatIconOverlay();
_showOnWindowRestore = false;
}
}
@@ -158,9 +158,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();
@@ -172,12 +174,24 @@ 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);
@@ -185,7 +199,7 @@ class ChatModel with ChangeNotifier {
await windowManager.setSize(Size(600, 400));
await Future.delayed(Duration(milliseconds: 100));
await windowManager.setAlignment(Alignment.topRight);
_isShowChatPage = !_isShowChatPage;
_isShowCMChatPage = !_isShowCMChatPage;
notifyListeners();
}
}
@@ -219,17 +233,11 @@ class ChatModel with ChangeNotifier {
}
if (text.isEmpty) return;
// mobile: first message show overlay icon
if (chatIconOverlayEntry == null) {
if (_isWindowMinimized) {
showChatIconOverlay();
} else {
_showOnWindowRestore = true;
}
}
// desktop: show chat page
if (!_isShowChatPage) {
toggleCMChatPage(id);
if (!isDesktop && chatIconOverlayEntry == null) {
showChatIconOverlay();
}
// show chat page
await showChatPage(id);
int toId = currentID;