Skip to content

Instantly share code, notes, and snippets.

@BandarHL
Created January 17, 2020 16:47
Show Gist options
  • Save BandarHL/b363c8ac1b0bdb1fe6fb97775373511d to your computer and use it in GitHub Desktop.
Save BandarHL/b363c8ac1b0bdb1fe6fb97775373511d to your computer and use it in GitHub Desktop.
ios 13 dark mode for whatsapp
#import <UIKit/UIKit.h>
%config(generator=internal)
@interface WAMessage: NSObject
@property (nonatomic, retain) NSAttributedString *attributedText;
@property (nonatomic, retain) NSString *text;
@end
@interface WAMessageReplyContext : NSObject
@property(copy, nonatomic) NSAttributedString *snippet;
@property (nonatomic, retain) NSString *senderName;
@end
@interface WAMessageReplyContextSlice : NSObject
@property(nonatomic, retain) WAMessageReplyContext *replyContext;
@end
%hook UIViewController
- (void)setOverrideUserInterfaceStyle:(long long)arg1 {
if (@available(iOS 13.0, *)) {
arg1 = UIUserInterfaceStyleDark;
return %orig(arg1);
} else {
return %orig;
}
}
%end
%hook UIView
- (void)_setOverrideUserInterfaceStyle:(long long)arg1 {
if (@available(iOS 13.0, *)) {
arg1 = UIUserInterfaceStyleDark;
return %orig(arg1);
} else {
return %orig;
}
}
- (void)setOverrideUserInterfaceStyle:(long long)arg1 {
if (@available(iOS 13.0, *)) {
arg1 = UIUserInterfaceStyleDark;
return %orig(arg1);
} else {
return %orig;
}
}
%end
// from WADarkMode: https://github.com/AhmedBafkir/WADarkMode
%hook WAMessage
- (NSAttributedString *)attributedText {
NSAttributedString *ah = %orig;
NSMutableAttributedString *copy = [ah mutableCopy];
[copy addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0, [copy length])];
ah = copy;
return ah;
}
%end
%hook WAMessageReplyContextSlice
- (NSAttributedString *)attributedTextWithMessage:(id)arg1 textAlignment:(NSInteger)arg2 {
NSAttributedString *ah = %orig;
NSMutableAttributedString *copy = [ah mutableCopy];
[copy addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0, [copy length])];
ah = copy;
return ah;
}
%end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment