From d893137ae26f31f73909cb6727795d97f2c01a08 Mon Sep 17 00:00:00 2001 From: tisfeng Date: Sat, 26 Oct 2024 20:23:01 +0800 Subject: [PATCH] fix: update queryViewHeight when window configuration changes --- .../BaseQueryWindow/EZBaseQueryViewController.m | 13 ++++++------- .../Window/WindowManager/EZLayoutManager.m | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m b/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m index 721ea47c6..fd84d8c63 100644 --- a/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m +++ b/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m @@ -135,7 +135,6 @@ - (void)viewWillAppear { - (void)setupData { self.queryModel = [[EZQueryModel alloc] init]; - self.queryModel.queryViewHeight = [self miniQueryViewHeight]; self.detectManager = [EZDetectManager managerWithModel:self.queryModel]; @@ -224,6 +223,8 @@ - (void)updateWindowConfiguration:(NSNotification *)notification { return; } + self.queryModel.queryViewHeight = [self miniQueryViewHeight]; + self.isInputFieldCellVisible = [Configuration.shared showInputTextFieldWithKey:WindowConfigurationKeyInputFieldCellVisible windowType:self.windowType]; self.isSelectLanguageCellVisible = [Configuration.shared showInputTextFieldWithKey:WindowConfigurationKeySelectLanguageCellVisible @@ -247,9 +248,7 @@ - (void)updateWindowConfiguration:(NSNotification *)notification { } } - [self reloadTableViewData:^{ -// [self updateTableViewHeight]; - }]; + [self reloadTableViewData:nil]; } - (void)modifyLanduage:(NSNotification *)notification { @@ -1589,11 +1588,11 @@ - (void)updateWindowHeightWithLock:(BOOL)lockFlag { CGFloat scrollViewHeight = height + self.scrollView.contentInsets.top + self.scrollView.contentInsets.bottom; scrollViewHeight = MIN(scrollViewHeight, maxWindowSize.height - titleBarHeight); +// MMLogInfo(@"scrollViewHeight: %@", @(scrollViewHeight)); // Diable change window height manually. [self.scrollView mas_updateConstraints:^(MASConstraintMaker *make) { - make.height.mas_greaterThanOrEqualTo(scrollViewHeight); - make.height.mas_lessThanOrEqualTo(scrollViewHeight); + make.height.equalTo(@(scrollViewHeight)).priority(MASLayoutPriorityDefaultHigh); }]; CGFloat showingWindowHeight = scrollViewHeight + titleBarHeight; @@ -1621,7 +1620,7 @@ - (void)updateWindowHeightWithLock:(BOOL)lockFlag { self.lockResizeWindow = NO; }); - // MMLogInfo(@"window frame: %@", @(window.frame)); +// MMLogInfo(@"window frame: %@", @(window.frame)); } - (CGFloat)getRestrainedScrollViewHeight:(CGFloat)scrollViewContentHeight { diff --git a/Easydict/objc/ViewController/Window/WindowManager/EZLayoutManager.m b/Easydict/objc/ViewController/Window/WindowManager/EZLayoutManager.m index 45787f0de..91586d6a5 100644 --- a/Easydict/objc/ViewController/Window/WindowManager/EZLayoutManager.m +++ b/Easydict/objc/ViewController/Window/WindowManager/EZLayoutManager.m @@ -44,8 +44,8 @@ - (instancetype)init { - (void)commonInitialize { self.screen = NSScreen.mainScreen; - self.minimumWindowSize = CGSizeMake(360, 70); - + self.minimumWindowSize = CGSizeMake(360, 40); + Configuration *configuration = [Configuration shared]; self.miniWindowFrame = [configuration windowFrameWithType:EZWindowTypeMini];