Skip to content

Commit

Permalink
fix: remove unused animateFlag
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed Oct 26, 2024
1 parent 4812001 commit 9b32571
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ - (void)setupData {
- (void)setupUI {
[self tableView];

[self updateWindowViewHeight];
[self updateWindowHeight];

mm_weakify(self);
[self setResizeWindowBlock:^{
Expand All @@ -174,7 +174,7 @@ - (void)setupUI {
}
}

[self updateWindowViewHeight];
[self updateWindowHeight];
}];
}];

Expand Down Expand Up @@ -247,7 +247,9 @@ - (void)updateWindowConfiguration:(NSNotification *)notification {
}
}

[self reloadTableViewData:nil];
[self reloadTableViewData:^{
// [self updateTableViewHeight];
}];
}

- (void)modifyLanduage:(NSNotification *)notification {
Expand Down Expand Up @@ -909,7 +911,7 @@ - (nullable NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(null
self.selectLanguageCell = selectLanguageCell;

mm_weakify(self);
[selectLanguageCell setEnterActionBlock:^(EZLanguage _Nonnull from, EZLanguage _Nonnull to) {
[selectLanguageCell setEnterActionBlock:^(EZLanguage from, EZLanguage to) {
mm_strongify(self);
self.queryModel.userSourceLanguage = from;
self.queryModel.userTargetLanguage = to;
Expand Down Expand Up @@ -996,7 +998,7 @@ - (void)reloadTableViewData:(nullable void (^)(void))completion {
- (void)reloadTableViewDataWithLock:(BOOL)lockFlag completion:(nullable void (^)(void))completion {
[CATransaction begin];
[CATransaction setCompletionBlock:^{
[self updateWindowViewHeightWithLock:lockFlag animate:NO display:YES];
[self updateWindowHeightWithLock:lockFlag];
if (completion) {
completion();
}
Expand Down Expand Up @@ -1081,7 +1083,7 @@ - (void)updateTableViewRowIndexes:(NSIndexSet *)rowIndexes
// !!!: Must first notify the update tableView cell height, and then calculate the tableView height.
// MMLogInfo(@"noteHeightOfRowsWithIndexesChanged: %@", rowIndexes);
[self.tableView noteHeightOfRowsWithIndexesChanged:rowIndexes];
[self updateWindowViewHeight];
[self updateWindowHeight];
} completionHandler:^{
// MMLogInfo(@"completionHandler, updateTableViewRowIndexes: %@", rowIndexes);
if (completionHandler) {
Expand Down Expand Up @@ -1566,17 +1568,11 @@ - (CGRect)tableViewContentBounds {

#pragma mark - Update Window Height

- (void)updateWindowViewHeight {
[self updateWindowViewHeightWithAnimation:NO display:YES];
}

- (void)updateWindowViewHeightWithAnimation:(BOOL)animateFlag display:(BOOL)displayFlag {
[self updateWindowViewHeightWithLock:YES animate:animateFlag display:displayFlag];
- (void)updateWindowHeight {
[self updateWindowHeightWithLock:YES];
}

- (void)updateWindowViewHeightWithLock:(BOOL)lockFlag
animate:(BOOL)animateFlag
display:(BOOL)displayFlag {
- (void)updateWindowHeightWithLock:(BOOL)lockFlag {
if (lockFlag) {
self.lockResizeWindow = YES;
}
Expand Down Expand Up @@ -1615,19 +1611,15 @@ - (void)updateWindowViewHeightWithLock:(BOOL)lockFlag
// ???: why set window frame will change tableView height?
// ???: why this window animation will block cell rendering?
// [self.window setFrame:safeFrame display:NO animate:animateFlag];
[self.baseQueryWindow setFrame:safeFrame display:NO];
[self.baseQueryWindow setFrame:safeFrame display:YES];

// Restore tableView height.
self.tableView.height = tableViewHeight;

if (animateFlag) {
// Animation cost time.
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(EZUpdateTableViewRowHeightAnimationDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.lockResizeWindow = NO;
});
} else {
// Animation cost time.
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(EZUpdateTableViewRowHeightAnimationDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.lockResizeWindow = NO;
}
});

// MMLogInfo(@"window frame: %@", @(window.frame));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ - (CGSize)maximumWindowSize:(EZWindowType)type {


- (CGFloat)inputViewMinHeight:(EZWindowType)type {
if (![self showInputTextField:type]) {
return 0;
}

switch (type) {
case EZWindowTypeMain:
return 75; // three line
Expand All @@ -120,6 +124,10 @@ - (CGFloat)inputViewMinHeight:(EZWindowType)type {
}

- (CGFloat)inputViewMaxHeight:(EZWindowType)type {
if (![self showInputTextField:type]) {
return 0;
}

switch (type) {
case EZWindowTypeMain:
return NSScreen.mainScreen.frame.size.height * 0.3;
Expand Down Expand Up @@ -210,4 +218,8 @@ - (void)updateWindowFrame:(EZBaseQueryWindow *)window {
[Configuration.shared setWindowFrame:window.frame windowType:windowType];
}

- (BOOL)showInputTextField:(EZWindowType)windowType {
return [Configuration.shared showInputTextFieldWithKey:WindowConfigurationKeyInputFieldCellVisible windowType:windowType];
}

@end

0 comments on commit 9b32571

Please sign in to comment.