diff --git a/Easydict/Feature/Configuration/EZConfiguration.h b/Easydict/Feature/Configuration/EZConfiguration.h index eabee5f8b..bc07911ee 100644 --- a/Easydict/Feature/Configuration/EZConfiguration.h +++ b/Easydict/Feature/Configuration/EZConfiguration.h @@ -9,7 +9,6 @@ #import #import "EZLanguageManager.h" #import "EZLayoutManager.h" -#import "Easydict-Swift.h" NS_ASSUME_NONNULL_BEGIN @@ -30,6 +29,12 @@ typedef NS_ENUM(NSUInteger, EZLanguageDetectOptimize) { EZLanguageDetectOptimizeGoogle = 2, }; +typedef NS_ENUM(NSUInteger, EZAppearenceType) { + EZAppearenceTypeSystem = 0, + EZAppearenceTypeLight = 1, + EZAppearenceTypeDark = 2, +}; + @interface EZConfiguration : NSObject @property (nonatomic, copy) EZLanguage firstLanguage; @@ -76,7 +81,7 @@ typedef NS_ENUM(NSUInteger, EZLanguageDetectOptimize) { @property (nonatomic, assign, readonly) CGFloat fontSizeRatio; @property (nonatomic, assign) NSInteger fontSizeIndex; -@property (nonatomic, assign) AppearenceType appearance; +@property (nonatomic, assign) EZAppearenceType appearance; + (instancetype)shared; + (void)destroySharedInstance; diff --git a/Easydict/Feature/Configuration/EZConfiguration.m b/Easydict/Feature/Configuration/EZConfiguration.m index 2331900a6..939744f59 100644 --- a/Easydict/Feature/Configuration/EZConfiguration.m +++ b/Easydict/Feature/Configuration/EZConfiguration.m @@ -450,13 +450,12 @@ - (CGFloat)fontSizeRatio { return _fontSizes[_fontSizeIndex].floatValue; } -- (void)setAppearance:(AppearenceType)appearance { +- (void)setAppearance:(EZAppearenceType)appearance { _appearance = appearance; [NSUserDefaults mm_write:@(appearance) forKey:kApperanceKey]; [[DarkModeManager manager] updateDarkMode]; - } #pragma mark - Window Frame diff --git a/Easydict/Feature/DarkMode/DarkModeManager.m b/Easydict/Feature/DarkMode/DarkModeManager.m index 16d267140..af749d661 100644 --- a/Easydict/Feature/DarkMode/DarkModeManager.m +++ b/Easydict/Feature/DarkMode/DarkModeManager.m @@ -8,6 +8,7 @@ #import "DarkModeManager.h" #import "EZConfiguration.h" +#import "Easydict-Swift.h" @interface DarkModeManager () @@ -48,7 +49,8 @@ - (void)updateDarkMode { BOOL isDarkMode = [self isDarkMode]; NSLog(@"%@", isDarkMode ? @"深色模式" : @"浅色模式"); - switch (EZConfiguration.shared.appearance) { + AppearenceType type = (AppearenceType)EZConfiguration.shared.appearance; + switch (type) { case AppearenceTypeDark: self.systemDarkMode = true; break; @@ -61,8 +63,8 @@ - (void)updateDarkMode { default: break; } - [AppearenceHelper.shared updateAppApperance:EZConfiguration.shared.appearance]; - + + [AppearenceHelper.shared updateAppApperance:type]; } - (BOOL)isDarkMode { diff --git a/Easydict/NewApp/NewAppManager.swift b/Easydict/NewApp/NewAppManager.swift index d334290b0..5b54187f0 100644 --- a/Easydict/NewApp/NewAppManager.swift +++ b/Easydict/NewApp/NewAppManager.swift @@ -22,13 +22,13 @@ public final class NewAppManager: NSObject { public var enable: Bool { UserDefaults.standard.bool(forKey: Self.enableKey) } - + @objc public var showEnableToggleUI: Bool { #if DEBUG - true + true #else - false + false #endif } }