From 35e600b73cca052bc05a94abf6160cac9601c511 Mon Sep 17 00:00:00 2001 From: phlpsong <103433299+phlpsong@users.noreply.github.com> Date: Sat, 3 Feb 2024 21:48:41 +0800 Subject: [PATCH] fix: not show beta feature for macOS 13 below (#384) --- .../EZSettingViewController.m | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/Easydict/Feature/PerferenceWindow/EZSettingViewController.m b/Easydict/Feature/PerferenceWindow/EZSettingViewController.m index 415295202..8715ec11e 100644 --- a/Easydict/Feature/PerferenceWindow/EZSettingViewController.m +++ b/Easydict/Feature/PerferenceWindow/EZSettingViewController.m @@ -495,14 +495,16 @@ - (void)setupUI { self.hideMenuBarIconButton = [NSButton checkboxWithTitle:hideMenuBarIcon target:self action:@selector(hideMenuBarIconButtonClicked:)]; [self.contentView addSubview:self.hideMenuBarIconButton]; - NSTextField *betaNewAppLabel = [NSTextField labelWithString:NSLocalizedString(@"beta_new_app", nil)]; - betaNewAppLabel.font = font; - [self.contentView addSubview:betaNewAppLabel]; - self.betaNewAppLabel = betaNewAppLabel; - - NSString *enableBetaNewApp = NSLocalizedString(@"enable_beta_new_app", nil); - self.enableBetaNewAppButton = [NSButton checkboxWithTitle:enableBetaNewApp target:self action:@selector(enableBetaNewAppButtonClicked:)]; - [self.contentView addSubview:self.enableBetaNewAppButton]; + if (@available(macOS 13.0, *)) { + NSTextField *betaNewAppLabel = [NSTextField labelWithString:NSLocalizedString(@"beta_new_app", nil)]; + betaNewAppLabel.font = font; + [self.contentView addSubview:betaNewAppLabel]; + self.betaNewAppLabel = betaNewAppLabel; + + NSString *enableBetaNewApp = NSLocalizedString(@"enable_beta_new_app", nil); + self.enableBetaNewAppButton = [NSButton checkboxWithTitle:enableBetaNewApp target:self action:@selector(enableBetaNewAppButtonClicked:)]; + [self.contentView addSubview:self.enableBetaNewAppButton]; + } NSTextField *fontSizeLabel = [NSTextField labelWithString:NSLocalizedString(@"font_size", nil)]; fontSizeLabel.font = font; @@ -556,7 +558,9 @@ - (void)setupUI { self.showEudicQuickLinkButton.mm_isOn = self.config.showEudicQuickLink; self.showAppleDictionaryQuickLinkButton.mm_isOn = self.config.showAppleDictionaryQuickLink; self.hideMenuBarIconButton.mm_isOn = self.config.hideMenuBarIcon; - self.enableBetaNewAppButton.mm_isOn = self.config.enableBetaNewApp; + if (@available(macOS 13.0, *)) { + self.enableBetaNewAppButton.mm_isOn = self.config.enableBetaNewApp; + } } - (void)updateViewConstraints { @@ -863,18 +867,22 @@ - (void)updateViewConstraints { make.left.equalTo(self.menuBarIconLabel.mas_right).offset(self.horizontalPadding); make.centerY.equalTo(self.menuBarIconLabel); }]; - - [self.betaNewAppLabel mas_remakeConstraints:^(MASConstraintMaker *make) { - make.right.equalTo(self.autoGetSelectedTextLabel); - make.top.equalTo(self.hideMenuBarIconButton.mas_bottom).offset(self.verticalPadding); - }]; - [self.enableBetaNewAppButton mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.equalTo(self.betaNewAppLabel.mas_right).offset(self.horizontalPadding); - make.centerY.equalTo(self.betaNewAppLabel); - }]; + if (@available(macOS 13.0, *)) { + [self.betaNewAppLabel mas_remakeConstraints:^(MASConstraintMaker *make) { + make.right.equalTo(self.autoGetSelectedTextLabel); + make.top.equalTo(self.hideMenuBarIconButton.mas_bottom).offset(self.verticalPadding); + }]; + [self.enableBetaNewAppButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.equalTo(self.betaNewAppLabel.mas_right).offset(self.horizontalPadding); + make.centerY.equalTo(self.betaNewAppLabel); + }]; + self.bottommostView = self.enableBetaNewAppButton; + } else { + self.bottommostView = self.hideMenuBarIconButton; + } + self.topmostView = self.inputLabel; - self.bottommostView = self.enableBetaNewAppButton; if ([EZLanguageManager.shared isSystemChineseFirstLanguage]) { self.leftmostView = self.adjustQueryIconPostionLabel;