Skip to content

Commit

Permalink
屏蔽消息图标颜色, TouchBar修复
Browse files Browse the repository at this point in the history
  • Loading branch information
yanmao committed Mar 25, 2020
1 parent eb26260 commit 4e86e92
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,19 @@ - (void)hook_setSessionInfo:(MMSessionInfo *)sessionInfo {
}];

NSMutableArray *selectSessions = [[TKWeChatPluginConfig sharedConfig] selectSessions];
NSColor *changeColor = [TKWeChatPluginConfig sharedConfig].darkMode ? kRGBColor(255, 255, 255, 1.0) : [NSColor blackColor];
if (isIgnore) {
cellView.layer.backgroundColor = kBG3.CGColor;
changeColor = kRGBColor(25, 185, 77, 1.0);
} else if ([selectSessions containsObject:sessionInfo]){
cellView.layer.backgroundColor = kBG4.CGColor;
} else {
cellView.layer.backgroundColor = [NSColor clearColor].CGColor;
changeColor = [NSColor redColor];
}

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NSAttributedString *str = cellView.nickName.attributedStringValue;
NSMutableAttributedString *returnValue = [[NSMutableAttributedString alloc] initWithString:str.string attributes:@{NSForegroundColorAttributeName :changeColor, NSFontAttributeName : [NSFont systemFontOfSize:14]}];
cellView.nickName.attributedStringValue = returnValue;
});

[cellView.layer setNeedsDisplay];
}

Expand Down
23 changes: 21 additions & 2 deletions WeChatExtension/WeChatExtension/Sources/Hook/NSObject+ThemeHook.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ + (void)hookTheme
}
}


- (void)hook_textFieldSetTextColor:(NSAttributedString *)arg1
{
if ([TKWeChatPluginConfig sharedConfig].darkMode) {
Expand Down Expand Up @@ -241,7 +240,7 @@ - (void)hook_mouseDown:(id)arg1
{
[self hook_mouseDown:arg1];
MMChatsTableCellView *cell = (MMChatsTableCellView *)self;

NSColor *highColor = nil;
if (cell.selected) {
highColor = kRGBColor(147, 148, 248, 0.5);
Expand Down Expand Up @@ -339,7 +338,9 @@ - (void)hook_ComposeInputViewControllerViewDidLoad {
for (NSView *sub in controller.view.subviews) {
if ([sub isKindOfClass:objc_getClass("SVGButton")]) {
NSButton *button = (NSButton *)sub;
NSImage *tempImage = button.image;
button.image = button.alternateImage;
button.alternateImage = tempImage;
button.alphaValue = 0.5;
}
}
Expand All @@ -349,6 +350,10 @@ - (void)hook_ComposeInputViewControllerViewDidLoad {
- (void)hook_initWithFrame:(NSView *)view {
[self hook_initWithFrame:view];

if ([view isKindOfClass:[objc_getClass("NSTouchBarView") class]]) {
return;
}

if ([view isKindOfClass:[objc_getClass("NSButtonImageView") class]]) {
return;
}
Expand Down Expand Up @@ -387,6 +392,11 @@ - (void)hook_initWithFrame:(NSView *)view {
[[YMThemeMgr shareInstance] changeTheme:view];
}

//MMSidebarColorIconView
if ([view isKindOfClass:[objc_getClass("MMSidebarColorIconView") class]]) {
MMSidebarColorIconView *sidebar = (MMSidebarColorIconView *)view;
sidebar.normalColor = [NSColor whiteColor];
}
#pragma mark - view
if ([view isKindOfClass:[objc_getClass("MMSessionPickerListGroupRowView") class]]) {
for (NSView *sub in view.subviews) {
Expand Down Expand Up @@ -503,6 +513,15 @@ - (void)hook_themeViewDidLoad
return;
}

//Fix: TouchBar在粉色模式下会变色
if ([self isKindOfClass:objc_getClass("NSCandidateListViewController")]) {
return;
}

if ([self isKindOfClass:objc_getClass("NSTouchBarViewController")]) {
return;
}

NSViewController *viewController = (NSViewController *)self;
[[YMThemeMgr shareInstance] changeTheme:viewController.view];

Expand Down
6 changes: 6 additions & 0 deletions WeChatExtension/WeChatExtension/WeChatPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -777,3 +777,9 @@ forHTTPHeaderField:(NSString *)field;
@interface MMMessageCellView : NSView
@property(retain, nonatomic) NSTextField *groupChatNickNameLabel;
@end

@interface MMSidebarColorIconView : MMView
@property(retain, nonatomic) NSImage *image; // @synthesize image=_image;
@property(retain, nonatomic) NSColor *selectedColor; // @synthesize selectedColor=_selectedColor;
@property(retain, nonatomic) NSColor *normalColor; // @synthesize normalColor=_normalColor;
@end

0 comments on commit 4e86e92

Please sign in to comment.