fix_cm: miminize window, mid commit

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2022-11-04 17:01:49 +08:00
parent 884a223449
commit 4272f0194e
2 changed files with 33 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import 'package:flutter/services.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:wakelock/wakelock.dart'; import 'package:wakelock/wakelock.dart';
import 'package:window_manager/window_manager.dart';
import 'package:flutter_custom_cursor/flutter_custom_cursor.dart'; import 'package:flutter_custom_cursor/flutter_custom_cursor.dart';
import 'package:flutter_improved_scrolling/flutter_improved_scrolling.dart'; import 'package:flutter_improved_scrolling/flutter_improved_scrolling.dart';
@ -46,7 +47,7 @@ class RemotePage extends StatefulWidget {
} }
class _RemotePageState extends State<RemotePage> class _RemotePageState extends State<RemotePage>
with AutomaticKeepAliveClientMixin { with AutomaticKeepAliveClientMixin, WindowListener {
Timer? _timer; Timer? _timer;
String keyboardMode = "legacy"; String keyboardMode = "legacy";
final _cursorOverImage = false.obs; final _cursorOverImage = false.obs;
@ -248,6 +249,21 @@ class _RemotePageState extends State<RemotePage>
); );
} }
@override
void onWindowMinimize() {
_ffi.chatModel.setWindowMinimized(true);
}
@override
void onWindowMaximize() {
_ffi.chatModel.setWindowMinimized(false);
}
@override
void onWindowRestore() {
_ffi.chatModel.setWindowMinimized(false);
}
@override @override
bool get wantKeepAlive => true; bool get wantKeepAlive => true;
} }

View File

@ -32,6 +32,8 @@ class ChatModel with ChangeNotifier {
OverlayState? _overlayState; OverlayState? _overlayState;
OverlayEntry? chatIconOverlayEntry; OverlayEntry? chatIconOverlayEntry;
OverlayEntry? chatWindowOverlayEntry; OverlayEntry? chatWindowOverlayEntry;
bool _showOnWindowRestore = false;
bool _isWindowMinimized = false;
final ChatUser me = ChatUser( final ChatUser me = ChatUser(
id: "", id: "",
@ -66,6 +68,14 @@ class ChatModel with ChangeNotifier {
} }
} }
setWindowMinimized(bool v) {
_isWindowMinimized = v;
if (!_isWindowMinimized && _showOnWindowRestore) {
showChatIconOverlay();
_showOnWindowRestore = false;
}
}
setOverlayState(OverlayState? os) { setOverlayState(OverlayState? os) {
_overlayState = os; _overlayState = os;
} }
@ -101,6 +111,7 @@ class ChatModel with ChangeNotifier {
initPositionYInTop: false, initPositionYInTop: false,
initPositionYMarginBorder: 100, initPositionYMarginBorder: 100,
borderTopContainTopBar: true, borderTopContainTopBar: true,
appBarHeight: 0,
), ),
child: FloatingActionButton( child: FloatingActionButton(
onPressed: () { onPressed: () {
@ -209,7 +220,11 @@ class ChatModel with ChangeNotifier {
if (text.isEmpty) return; if (text.isEmpty) return;
// mobile: first message show overlay icon // mobile: first message show overlay icon
if (chatIconOverlayEntry == null) { if (chatIconOverlayEntry == null) {
showChatIconOverlay(); if (_isWindowMinimized) {
showChatIconOverlay();
} else {
_showOnWindowRestore = true;
}
} }
// desktop: show chat page // desktop: show chat page
if (!_isShowChatPage) { if (!_isShowChatPage) {