render cm side page after window size change, calculate real window

width

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2023-09-29 15:09:58 +08:00
parent 563cd828ad
commit d8e51c6b14
2 changed files with 46 additions and 30 deletions

View File

@ -175,11 +175,31 @@ class ConnectionManagerState extends State<ConnectionManager> {
], ],
); );
}, },
pageViewBuilder: (pageView) => Row( pageViewBuilder: (pageView) => LayoutBuilder(
children: [ builder: (context, constrains) {
var borderWidth = 0.0;
if (constrains.maxWidth >
kConnectionManagerWindowSizeClosedChat.width) {
borderWidth = kConnectionManagerWindowSizeOpenChat.width -
constrains.maxWidth;
} else {
borderWidth = kConnectionManagerWindowSizeClosedChat.width -
constrains.maxWidth;
}
if (borderWidth < 0 || borderWidth > 50) {
borderWidth = 0;
}
final realClosedWidth =
kConnectionManagerWindowSizeClosedChat.width -
borderWidth;
final realChatPageWidth =
constrains.maxWidth - realClosedWidth;
return Row(children: [
if (constrains.maxWidth >
kConnectionManagerWindowSizeClosedChat.width)
Consumer<ChatModel>( Consumer<ChatModel>(
builder: (_, model, child) => model.isShowCMSidePage builder: (_, model, child) => SizedBox(
? Expanded( width: realChatPageWidth,
child: buildRemoteBlock( child: buildRemoteBlock(
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
@ -189,20 +209,13 @@ class ConnectionManagerState extends State<ConnectionManager> {
.dividerColor))), .dividerColor))),
child: buildSidePage()), child: buildSidePage()),
), ),
flex: (kConnectionManagerWindowSizeOpenChat.width - )),
kConnectionManagerWindowSizeClosedChat SizedBox(
.width) width: realClosedWidth,
.toInt(), child:
) SizedBox(width: realClosedWidth, child: pageView)),
: Offstage(), ]);
), },
Expanded(
child: pageView,
flex: kConnectionManagerWindowSizeClosedChat.width
.toInt() -
4 // prevent stretch of the page view when chat is open,
),
],
), ),
), ),
); );
@ -966,8 +979,7 @@ class __FileTransferLogPageState extends State<_FileTransferLogPage> {
return PreferredSize( return PreferredSize(
preferredSize: const Size(200, double.infinity), preferredSize: const Size(200, double.infinity),
child: Container( child: Container(
margin: const EdgeInsets.only(top: 16.0, bottom: 16.0, right: 16.0), padding: const EdgeInsets.all(12.0),
padding: const EdgeInsets.all(8.0),
child: Obx( child: Obx(
() { () {
final jobTable = gFFI.cmFileModel.currentJobTable; final jobTable = gFFI.cmFileModel.currentJobTable;

View File

@ -285,7 +285,10 @@ class ChatModel with ChangeNotifier {
await toggleCMSidePage(); await toggleCMSidePage();
} }
var _togglingCMSidePage = false; // protect order for await
toggleCMSidePage() async { toggleCMSidePage() async {
if (_togglingCMSidePage) return false;
_togglingCMSidePage = true;
if (_isShowCMSidePage) { if (_isShowCMSidePage) {
_isShowCMSidePage = !_isShowCMSidePage; _isShowCMSidePage = !_isShowCMSidePage;
notifyListeners(); notifyListeners();
@ -300,6 +303,7 @@ class ChatModel with ChangeNotifier {
_isShowCMSidePage = !_isShowCMSidePage; _isShowCMSidePage = !_isShowCMSidePage;
notifyListeners(); notifyListeners();
} }
_togglingCMSidePage = false;
} }
changeCurrentKey(MessageKey key) { changeCurrentKey(MessageKey key) {