Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
yanmao committed Apr 29, 2020
1 parent dd140b3 commit 0607e62
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 38 deletions.
19 changes: 8 additions & 11 deletions WeChatExtension/WeChatExtension.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@
188A66372272ACBA0096663E /* MMChatsTableCellView+hook.h in Headers */ = {isa = PBXBuildFile; fileRef = 188A65E52272ACBA0096663E /* MMChatsTableCellView+hook.h */; };
188A66382272ACBA0096663E /* WeChat+hook.h in Headers */ = {isa = PBXBuildFile; fileRef = 188A65E62272ACBA0096663E /* WeChat+hook.h */; };
188A663B2272ACBA0096663E /* MMStickerMessageCellView+hook.h in Headers */ = {isa = PBXBuildFile; fileRef = 188A65E92272ACBA0096663E /* MMStickerMessageCellView+hook.h */; };
188A663C2272ACBA0096663E /* YMMessageHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 188A65EA2272ACBA0096663E /* YMMessageHelper.m */; };
188A663D2272ACBA0096663E /* YMMessageHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 188A65EB2272ACBA0096663E /* YMMessageHelper.h */; };
188A663E2272ACBA0096663E /* MMStickerMessageCellView+hook.m in Sources */ = {isa = PBXBuildFile; fileRef = 188A65EC2272ACBA0096663E /* MMStickerMessageCellView+hook.m */; };
188A66412272ACBA0096663E /* WeChat+hook.m in Sources */ = {isa = PBXBuildFile; fileRef = 188A65EF2272ACBA0096663E /* WeChat+hook.m */; };
188A66422272ACBA0096663E /* MMChatsTableCellView+hook.m in Sources */ = {isa = PBXBuildFile; fileRef = 188A65F02272ACBA0096663E /* MMChatsTableCellView+hook.m */; };
188A66432272ACBA0096663E /* fishhook.c in Sources */ = {isa = PBXBuildFile; fileRef = 188A65F22272ACBA0096663E /* fishhook.c */; };
188A66442272ACBA0096663E /* fishhook.h in Headers */ = {isa = PBXBuildFile; fileRef = 188A65F32272ACBA0096663E /* fishhook.h */; };
1898CF4A2459231100B557E9 /* YMMessageHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 1898CF482459231100B557E9 /* YMMessageHelper.m */; };
1898CF4B2459231100B557E9 /* YMMessageHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 1898CF492459231100B557E9 /* YMMessageHelper.h */; };
18A7A12E2272ACE300361A98 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 18A7A12D2272ACE300361A98 /* main.mm */; };
18A7A1302272ACE900361A98 /* WeChatPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 18A7A12F2272ACE900361A98 /* WeChatPlugin.h */; };
18A7A1342272AF5300361A98 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18A7A1332272AF5300361A98 /* SystemConfiguration.framework */; };
Expand Down Expand Up @@ -252,13 +252,13 @@
188A65E52272ACBA0096663E /* MMChatsTableCellView+hook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MMChatsTableCellView+hook.h"; sourceTree = "<group>"; };
188A65E62272ACBA0096663E /* WeChat+hook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WeChat+hook.h"; sourceTree = "<group>"; };
188A65E92272ACBA0096663E /* MMStickerMessageCellView+hook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MMStickerMessageCellView+hook.h"; sourceTree = "<group>"; };
188A65EA2272ACBA0096663E /* YMMessageHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YMMessageHelper.m; sourceTree = "<group>"; };
188A65EB2272ACBA0096663E /* YMMessageHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YMMessageHelper.h; sourceTree = "<group>"; };
188A65EC2272ACBA0096663E /* MMStickerMessageCellView+hook.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MMStickerMessageCellView+hook.m"; sourceTree = "<group>"; };
188A65EF2272ACBA0096663E /* WeChat+hook.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "WeChat+hook.m"; sourceTree = "<group>"; };
188A65F02272ACBA0096663E /* MMChatsTableCellView+hook.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MMChatsTableCellView+hook.m"; sourceTree = "<group>"; };
188A65F22272ACBA0096663E /* fishhook.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fishhook.c; sourceTree = "<group>"; };
188A65F32272ACBA0096663E /* fishhook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fishhook.h; sourceTree = "<group>"; };
1898CF482459231100B557E9 /* YMMessageHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YMMessageHelper.m; sourceTree = "<group>"; };
1898CF492459231100B557E9 /* YMMessageHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YMMessageHelper.h; sourceTree = "<group>"; };
18A7A12D2272ACE300361A98 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = "<group>"; };
18A7A12F2272ACE900361A98 /* WeChatPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeChatPlugin.h; sourceTree = "<group>"; };
18A7A1312272AF0000361A98 /* libGCDWebServer.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libGCDWebServer.a; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -521,6 +521,8 @@
188A65B62272ACBA0096663E /* Helper */ = {
isa = PBXGroup;
children = (
1898CF492459231100B557E9 /* YMMessageHelper.h */,
1898CF482459231100B557E9 /* YMMessageHelper.m */,
D79D23572449EF5C00C391E4 /* GVUserDefaults.h */,
D79D23582449EF5C00C391E4 /* GVUserDefaults.m */,
188A65B72272ACBA0096663E /* YMSwizzledHelper.h */,
Expand All @@ -531,8 +533,6 @@
36AC9D89228A81C200EA9F97 /* XMLReader.m */,
18D298502394EE60009EE6B0 /* YMNetWorkHelper.h */,
18D298512394EE60009EE6B0 /* YMNetWorkHelper.m */,
188A65EB2272ACBA0096663E /* YMMessageHelper.h */,
188A65EA2272ACBA0096663E /* YMMessageHelper.m */,
);
path = Helper;
sourceTree = "<group>";
Expand Down Expand Up @@ -640,9 +640,6 @@
18D4C34A24236180006A20E2 /* NSObject+ThemeHook.m */,
18B37AB7245536ED00037B58 /* NSObject+Safe.h */,
18B37AB8245536ED00037B58 /* NSObject+Safe.m */,
188A65EB2272ACBA0096663E /* YMMessageTool.h */,
188A65EA2272ACBA0096663E /* YMMessageTool.m */,

);
path = Hook;
sourceTree = "<group>";
Expand Down Expand Up @@ -759,6 +756,7 @@
188A662F2272ACBA0096663E /* NotifyConstant.h in Headers */,
18A7A15B2272AFE600361A98 /* GCDWebServerHTTPStatusCodes.h in Headers */,
18A7A1602272AFE600361A98 /* GCDWebServerRequest.h in Headers */,
1898CF4B2459231100B557E9 /* YMMessageHelper.h in Headers */,
18A7A1642272AFE600361A98 /* GCDWebServerDataResponse.h in Headers */,
18A7A15C2272AFE600361A98 /* GCDWebServerResponse.h in Headers */,
188A662B2272ACBA0096663E /* NSString+Action.h in Headers */,
Expand Down Expand Up @@ -811,7 +809,6 @@
18A7A1612272AFE600361A98 /* GCDWebServerFileResponse.h in Headers */,
188A66372272ACBA0096663E /* MMChatsTableCellView+hook.h in Headers */,
18A7A1622272AFE600361A98 /* GCDWebServerStreamedResponse.h in Headers */,
188A663D2272ACBA0096663E /* YMMessageHelper.h in Headers */,
188A662A2272ACBA0096663E /* NSDate+Action.h in Headers */,
188A661B2272ACBA0096663E /* YMAutoReplyModel.h in Headers */,
188A65F82272ACBA0096663E /* TKDownloadWindowController.h in Headers */,
Expand Down Expand Up @@ -998,6 +995,7 @@
188A661D2272ACBA0096663E /* NSButton+Action.m in Sources */,
36AC9D8B228A81C200EA9F97 /* XMLReader.m in Sources */,
188A66412272ACBA0096663E /* WeChat+hook.m in Sources */,
1898CF4A2459231100B557E9 /* YMMessageHelper.m in Sources */,
188A66282272ACBA0096663E /* NSTextField+Action.m in Sources */,
3644BDF92285545500EDE358 /* TCBlobDownloadManager.m in Sources */,
18A7A16C2272AFE600361A98 /* GCDWebServerURLEncodedFormRequest.m in Sources */,
Expand All @@ -1024,7 +1022,6 @@
18A7A1682272AFE600361A98 /* GCDWebServerStreamedResponse.m in Sources */,
188A66092272ACBA0096663E /* YMAssistantMenuManager.m in Sources */,
3644BE012285549100EDE358 /* YMUpdateManager.m in Sources */,
188A663C2272ACBA0096663E /* YMMessageHelper.m in Sources */,
188A66072272ACBA0096663E /* YMHTTPManager.m in Sources */,
18A7A1572272AFE600361A98 /* GCDWebServerResponse.m in Sources */,
188A66102272ACBA0096663E /* YMWebServerManager.m in Sources */,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#import <Foundation/Foundation.h>
#import "GVUserDefaults.h"
#import <AppKit/AppKit.h>

typedef NS_ENUM(NSInteger, PluginLanguageType) {
PluginLanguageTypeZH,
Expand Down Expand Up @@ -38,7 +39,7 @@ typedef NS_ENUM(NSInteger, PluginLanguageType) {
@property (nonatomic, copy) NSString *currentUserName; /**< 当前用户的id */
@property (nonatomic) BOOL isAllowMoreOpenBaby; /**< 子WeChat多开 */
@property (nonatomic) BOOL darkMode; /**< 黑暗模式 */
@property (nonatomic) BOOL blackMode; /**< 深邃模式 */
@property (nonatomic) BOOL blackMode; /**< 深邃模式 */
@property (nonatomic) BOOL pinkMode; /**< 少女模式 */
@property (nonatomic) BOOL groupMultiColorMode; /**< 群成员彩色 */
@property (nonatomic) BOOL isThemeLoaded; /**< 是否有使用过皮肤 */
Expand Down Expand Up @@ -68,12 +69,13 @@ typedef NS_ENUM(NSInteger, PluginLanguageType) {
- (BOOL)usingTheme;
- (BOOL)usingDarkTheme;

- (id)mainBackgroundColor;
- (id)mainTextColor;
- (id)mainIgnoredBackgroundColor;
- (id)mainIgnoredTextColor;
- (id)mainSeperatorColor;
- (id)mainScrollerColor;
- (id)mainDividerColor;
- (NSColor *)mainBackgroundColor;
- (NSColor *)mainTextColor;
- (NSColor *)mainIgnoredBackgroundColor;
- (NSColor *)mainIgnoredTextColor;
- (NSColor *)mainSeperatorColor;
- (NSColor *)mainScrollerColor;
- (NSColor *)mainDividerColor;
- (NSColor *)mainChatCellBackgroundColor;
@end

Original file line number Diff line number Diff line change
Expand Up @@ -348,43 +348,48 @@ - (BOOL)usingDarkTheme {
return self.darkMode || self.blackMode;
}

- (id)mainTextColor {
- (NSColor *)mainTextColor {
if (![self usingTheme]) {
return kDefaultTextColor;
}
return self.darkMode ? kDarkModeTextColor : (self.blackMode ? kBlackModeTextColor : kPinkModeTextColor);
}

- (id)mainBackgroundColor {
- (NSColor *)mainBackgroundColor {
if (![self usingTheme]) {
return NSColor.clearColor;
}
return self.darkMode ? kDarkBacgroundColor : (self.blackMode ? kBlackBackgroundColor : kPinkBacgroundColor);
}

- (id)mainIgnoredTextColor {
- (NSColor *)mainIgnoredTextColor {
if (![self usingTheme]) {
return kDefaultIgnoredTextColor;
}
return self.darkMode ? kDarkModeIgnoredTextColor : (self.blackMode ? kBlackModeIgnoredTextColor : kPinkModeIgnoredTextColor);
}

- (id)mainIgnoredBackgroundColor {
- (NSColor *)mainIgnoredBackgroundColor {
if (![self usingTheme]) {
return kDefaultIgnoredBackgroundColor;
}
return self.darkMode ? kDarkModeIgnoredBackgroundColor : (self.blackMode ? kBlackModeIgnoredBackgroundColor : kPinkModeIgnoredBackgroundColor);
}

- (id)mainSeperatorColor {
- (NSColor *)mainSeperatorColor {
return self.darkMode ? kRGBColor(147, 148, 248, 0.2) : (self.blackMode ? kRGBColor(128,128,128, 0.5) : kRGBColor(147, 148, 248, 0.2));
}

- (id)mainScrollerColor {
- (NSColor *)mainScrollerColor {
return self.darkMode ? kRGBColor(33, 48, 64, 1.0) : (self.blackMode ? kRGBColor(128,128,128, 0.5) : NSColor.clearColor);
}

- (id)mainDividerColor {
- (NSColor *)mainDividerColor {
return self.darkMode ? kRGBColor(71, 69, 112, 0.5) : (self.blackMode ? kRGBColor(128,128,128, 0.7) : kRGBColor(71, 69, 112, 0.5));
}

- (NSColor *)mainChatCellBackgroundColor {
return self.darkMode ? kRGBColor(33, 48, 64, 1.0) : (self.blackMode ? kRGBColor(38, 38, 38, 1.0) : nil);
}

@end
15 changes: 4 additions & 11 deletions WeChatExtension/WeChatExtension/Sources/Hook/NSObject+ThemeHook.m
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ - (void)hook_updateGroupChatNickName
if (originalText.length > 0) {
NSColor *radomColor = nil;
if ([TKWeChatPluginConfig sharedConfig].usingDarkTheme && [TKWeChatPluginConfig sharedConfig].groupMultiColorMode) {
radomColor = [[YMThemeMgr shareInstance] randomColor:originalText.string.md5String];
radomColor = [[YMThemeManager shareInstance] randomColor:originalText.string.md5String];
} else {
radomColor = kMainTextColor;
}
Expand Down Expand Up @@ -233,7 +233,7 @@ - (void)hook_setMessageText:(id)arg1

- (void)hook_setSeperator:(NSView *)arg1
{
[[YMThemeMgr shareInstance] changeTheme:arg1 color:kMainSeperatorColor];
[[YMThemeManager shareInstance] changeTheme:arg1 color:kMainSeperatorColor];
[self hook_setSeperator:arg1];
}

Expand Down Expand Up @@ -359,8 +359,7 @@ - (void)hook_updateNickName
cell.nickName.attributedStringValue = returnValue;

if ([TKWeChatPluginConfig sharedConfig].usingDarkTheme) {
// MARK: - 点击对框列表之后,无法显示该对话框处于选择状态,故注释掉
// [[YMThemeMgr shareInstance] changeTheme:cell.containerView color:kRGBColor(56, 70, 92, 1.0)];
[[YMThemeManager shareInstance] changeTheme:cell color:[TKWeChatPluginConfig sharedConfig].mainChatCellBackgroundColor];
cell.muteIndicator.normalColor = [NSColor redColor];
}
}
Expand All @@ -376,14 +375,11 @@ - (void)hook_mouseDown:(id)arg1
NSColor *original = [NSColor colorWithCGColor:cell.layer.backgroundColor];
cell.layer.backgroundColor = (TKWeChatPluginConfig.sharedConfig.blackMode ? kRGBColor(128,128,128, 0.5) : kRGBColor(147, 148, 248, 0.5)).CGColor;
[cell setNeedsDisplay:YES];
// MARK: - 点击对框列表之后,恢复之前状态
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
cell.layer.backgroundColor = original.CGColor;
[cell setNeedsDisplay:YES];
});
}


}

- (void)hook_setAttributedStringValue:(NSAttributedString *)arg1
Expand Down Expand Up @@ -441,9 +437,6 @@ - (void)hook_setTextColor:(NSColor *)arg1
{
arg1 = kMainTextColor;
[self hook_setTextColor:arg1];

MMTextField *textField = (MMTextField *)self;
// textField.backgroundColor = kMainBackgroundColor;
}

- (instancetype)hook_scrollViewInitWithFrame:(NSRect)frameRect
Expand Down
2 changes: 1 addition & 1 deletion WeChatExtension/WeChatExtension/Sources/Hook/WeChat+hook.m
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ - (void)hook_viewWillAppear {
return;
} else {
if (TKWeChatPluginConfig.sharedConfig.usingTheme) {
[[YMThemeMgr shareInstance] changeTheme:loginVC.view];
[[YMThemeManager shareInstance] changeTheme:loginVC.view];
}
}

Expand Down

0 comments on commit 0607e62

Please sign in to comment.