Skip to content

Commit

Permalink
fix: AppearenceType type error
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed Dec 29, 2023
1 parent eb95886 commit ff8baea
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
9 changes: 7 additions & 2 deletions Easydict/Feature/Configuration/EZConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#import <Foundation/Foundation.h>
#import "EZLanguageManager.h"
#import "EZLayoutManager.h"
#import "Easydict-Swift.h"

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions Easydict/Feature/Configuration/EZConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions Easydict/Feature/DarkMode/DarkModeManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "DarkModeManager.h"
#import "EZConfiguration.h"
#import "Easydict-Swift.h"

@interface DarkModeManager ()

Expand Down Expand Up @@ -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;
Expand All @@ -61,8 +63,8 @@ - (void)updateDarkMode {
default:
break;
}
[AppearenceHelper.shared updateAppApperance:EZConfiguration.shared.appearance];


[AppearenceHelper.shared updateAppApperance:type];
}

- (BOOL)isDarkMode {
Expand Down
6 changes: 3 additions & 3 deletions Easydict/NewApp/NewAppManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit ff8baea

Please sign in to comment.