From 48b27df35f4e9c4d4ebf7888c3bebfca4bed8026 Mon Sep 17 00:00:00 2001 From: tisfeng Date: Thu, 24 Oct 2024 00:34:38 +0800 Subject: [PATCH] fix: remove unused code --- .../View/WordResultView/EZWordResultView.m | 55 +++++++++---------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/Easydict/objc/ViewController/View/WordResultView/EZWordResultView.m b/Easydict/objc/ViewController/View/WordResultView/EZWordResultView.m index 05024c904..8d687d273 100644 --- a/Easydict/objc/ViewController/View/WordResultView/EZWordResultView.m +++ b/Easydict/objc/ViewController/View/WordResultView/EZWordResultView.m @@ -111,8 +111,6 @@ - (void)refreshWithResult:(EZQueryResult *)result { } else { BOOL isShortWordLength = result.queryText.length && [EZLanguageManager.shared isShortWordLength:result.queryText language:result.queryFromLanguage]; - __block CGFloat ezLabelTopOffset = 0; - BOOL showBigWord = result.wordResult || result.showBigWord; if (isShortWordLength && showBigWord) { EZLabel *bigWordLabel = [[EZLabel alloc] init]; @@ -191,14 +189,9 @@ - (void)refreshWithResult:(EZQueryResult *)result { CGSize labelSize = [self labelSize:resultLabel exceptedWidth:exceptedWidth]; make.size.mas_equalTo(labelSize).priorityHigh(); - // ???: This means the label text has more than 2 lines, so we need to adjust the top offset. - if (labelSize.height > explainLabel.height * 2) { - // ezLabelTopOffset = -1; - } - if (explainLabel) { if (lastView) { - make.top.equalTo(lastView.mas_bottom).offset(topOffset + ezLabelTopOffset); + make.top.equalTo(lastView.mas_bottom).offset(topOffset); } else { make.top.equalTo(self).offset(topOffset); } @@ -549,17 +542,32 @@ - (void)refreshWithResult:(EZQueryResult *)result { // 同义词 if (result.wordResult.synonyms.count) { - lastView = [self buildSynonymsAndAntonymsView:NSLocalizedString(@"synonyms", nil) parts:result.wordResult.synonyms textColor:typeTextColor typeTextFont:typeTextFont height:&height lastView:lastView]; + lastView = [self buildSynonymsAndAntonymsView:NSLocalizedString(@"synonyms", nil) + parts:result.wordResult.synonyms + textColor:typeTextColor + typeTextFont:typeTextFont + height:&height + lastView:lastView]; } // 反义词 if (result.wordResult.antonyms.count) { - lastView = [self buildSynonymsAndAntonymsView:NSLocalizedString(@"antonyms", nil) parts:result.wordResult.antonyms textColor:typeTextColor typeTextFont:typeTextFont height:&height lastView:lastView]; + lastView = [self buildSynonymsAndAntonymsView:NSLocalizedString(@"antonyms", nil) + parts:result.wordResult.antonyms + textColor:typeTextColor + typeTextFont:typeTextFont + height:&height + lastView:lastView]; } // 搭配 if (result.wordResult.collocation.count) { - lastView = [self buildSynonymsAndAntonymsView:NSLocalizedString(@"collocation", nil) parts:result.wordResult.collocation textColor:typeTextColor typeTextFont:typeTextFont height:&height lastView:lastView]; + lastView = [self buildSynonymsAndAntonymsView:NSLocalizedString(@"collocation", nil) + parts:result.wordResult.collocation + textColor:typeTextColor + typeTextFont:typeTextFont + height:&height + lastView:lastView]; } __block NSString *lastSimpleWordPart = nil; @@ -882,7 +890,12 @@ - (void)setupBottomToolBarButtons:(EZQueryResult *)result lastView:(NSView *)las } } -- (NSView *)buildSynonymsAndAntonymsView:(NSString *)title parts:(NSArray *)parts textColor:(NSColor *)typeTextColor typeTextFont:(NSFont *)typeTextFont height:(CGFloat *)height lastView:(NSView *)lastView { +- (NSView *)buildSynonymsAndAntonymsView:(NSString *)title + parts:(NSArray *)parts + textColor:(NSColor *)typeTextColor + typeTextFont:(NSFont *)typeTextFont + height:(CGFloat *)height + lastView:(NSView *)lastView { __block NSView *rtnView = lastView; EZLabel *synonymsTitle = [[EZLabel alloc] init]; [self addSubview:synonymsTitle]; @@ -1274,24 +1287,6 @@ - (void)getTextWithHref:(NSString *)href completionHandler:(void (^_Nullable)(NS }]; } -- (void)updateWebViewAllIframeFontSize { - CGFloat fontSize = Configuration.shared.fontSizeRatio * 100; - - NSString *jsCode = [NSString stringWithFormat: - @"var iframes = document.querySelectorAll('iframe');" - @"for (var i = 0; i < iframes.length; i++) {" - @" var iframe = iframes[i];" - @" var frameDoc = iframe.contentDocument || iframe.contentWindow.document;" - @" frameDoc.body.style.fontSize = '%f%%';" - @"};", - fontSize]; - - [self evaluateJavaScript:jsCode completionHandler:^(id _Nullable result, NSError *_Nullable error) { - if (!error) { - } - }]; -} - #pragma mark - // Convert text to multiple lines, such as "Hello world" to "Hello\nworld"