mirror of
https://github.com/lint/TFDidThatSay
synced 2025-07-06 01:06:45 +00:00
Create function to get current text color
This commit is contained in:
@ -58,6 +58,7 @@
|
|||||||
@interface CommentTreeHeaderNode
|
@interface CommentTreeHeaderNode
|
||||||
@property(strong, nonatomic) id commentTreeNode;
|
@property(strong, nonatomic) id commentTreeNode;
|
||||||
- (void)updateContentViewsForData:(id)arg1;
|
- (void)updateContentViewsForData:(id)arg1;
|
||||||
|
- (void)configureNodes;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface CommentTreeCommandBarNode
|
@interface CommentTreeCommandBarNode
|
||||||
@ -156,7 +157,7 @@
|
|||||||
- (id)initWithConfig:(id)arg1;
|
- (id)initWithConfig:(id)arg1;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface ThemeManager
|
@interface ThemeManager : NSObject
|
||||||
|
|
||||||
+ (id)sharedManager;
|
+ (id)sharedManager;
|
||||||
|
|
||||||
|
231
tweak/Reddit.xm
231
tweak/Reddit.xm
@ -12,6 +12,87 @@ int secondVersionPart = 0;
|
|||||||
|
|
||||||
%group Reddit_v4_current
|
%group Reddit_v4_current
|
||||||
|
|
||||||
|
UIColor * getCurrentTextColor() {
|
||||||
|
|
||||||
|
ThemeManager *themeManager;
|
||||||
|
id isNightMode;
|
||||||
|
UIColor *textColor;
|
||||||
|
|
||||||
|
if (firstVersionPart == 2020) {
|
||||||
|
if (secondVersionPart <= 40) {
|
||||||
|
|
||||||
|
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
|
||||||
|
AppSettings *appSettings = [%c(AppSettings) sharedSettings];
|
||||||
|
AccountManager *accountManager = secondVersionPart >= 29 ? [appDelegate accountManager] : [%c(AccountManager) sharedManager];
|
||||||
|
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:appSettings];
|
||||||
|
isNightMode = [[accountManager defaults] objectForKey:@"kUseNightKey"];
|
||||||
|
|
||||||
|
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"13.0") && [appSettings isAutoDarkModeEnabled]) {
|
||||||
|
|
||||||
|
NSInteger sysInterfaceStyle = [[UITraitCollection _currentTraitCollection] userInterfaceStyle];
|
||||||
|
|
||||||
|
if (sysInterfaceStyle == UIUserInterfaceStyleDark){
|
||||||
|
textColor = [[themeManager darkTheme] bodyTextColor];
|
||||||
|
} else {
|
||||||
|
textColor = [[themeManager lightTheme] bodyTextColor];
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (isNightMode) {
|
||||||
|
textColor = [[themeManager darkTheme] bodyTextColor];
|
||||||
|
} else {
|
||||||
|
textColor = [[themeManager lightTheme] bodyTextColor];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[themeManager release];
|
||||||
|
} else {
|
||||||
|
RUIThemeGuidance *themeGuidance = [%c(RUIThemeGuidance) sharedGuidance];
|
||||||
|
textColor = [[themeGuidance currentTheme] bodyTextColor];
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (secondVersionPart >= 45) {
|
||||||
|
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
|
||||||
|
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
||||||
|
|
||||||
|
if (isNightMode) {
|
||||||
|
textColor = [[themeManager darkTheme] bodyTextColor];
|
||||||
|
} else {
|
||||||
|
textColor = [[themeManager lightTheme] bodyTextColor];
|
||||||
|
}
|
||||||
|
|
||||||
|
[themeManager release];
|
||||||
|
|
||||||
|
} else if (secondVersionPart >= 37) {
|
||||||
|
themeManager = [[%c(ThemeManager) alloc] initWithTraitCollection:nil appSettings:[%c(AppSettings) sharedSettings]];
|
||||||
|
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
||||||
|
|
||||||
|
if (isNightMode) {
|
||||||
|
textColor = [[themeManager nightTheme] bodyTextColor];
|
||||||
|
} else {
|
||||||
|
textColor = [[themeManager dayTheme] bodyTextColor];
|
||||||
|
}
|
||||||
|
|
||||||
|
[themeManager release];
|
||||||
|
|
||||||
|
} else {
|
||||||
|
themeManager = [%c(ThemeManager) sharedManager];
|
||||||
|
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
||||||
|
|
||||||
|
if (isNightMode) {
|
||||||
|
textColor = [[themeManager nightTheme] bodyTextColor];
|
||||||
|
} else {
|
||||||
|
textColor = [[themeManager dayTheme] bodyTextColor];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return textColor;
|
||||||
|
}
|
||||||
|
|
||||||
%hook CommentTreeNode
|
%hook CommentTreeNode
|
||||||
%property(assign,nonatomic)id commentTreeHeaderNode;
|
%property(assign,nonatomic)id commentTreeHeaderNode;
|
||||||
%property(assign,nonatomic)id commentTreeCommandBarNode;
|
%property(assign,nonatomic)id commentTreeCommandBarNode;
|
||||||
@ -95,83 +176,9 @@ int secondVersionPart = 0;
|
|||||||
NSString *author = data[@"author"];
|
NSString *author = data[@"author"];
|
||||||
NSString *body = data[@"body"];
|
NSString *body = data[@"body"];
|
||||||
|
|
||||||
|
UIColor *textColor = getCurrentTextColor();
|
||||||
NSMutableAttributedString *bodyMutableAttributedText;
|
NSMutableAttributedString *bodyMutableAttributedText;
|
||||||
|
|
||||||
id themeManager;
|
|
||||||
id isNightMode;
|
|
||||||
id textColor;
|
|
||||||
|
|
||||||
if (firstVersionPart == 2020) {
|
|
||||||
if (secondVersionPart <= 40) {
|
|
||||||
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
|
|
||||||
AppSettings *appSettings = [%c(AppSettings) sharedSettings];
|
|
||||||
AccountManager *accountManager = secondVersionPart >= 29 ? [appDelegate accountManager] : [%c(AccountManager) sharedManager];
|
|
||||||
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:appSettings];
|
|
||||||
isNightMode = [[accountManager defaults] objectForKey:@"kUseNightKey"];
|
|
||||||
|
|
||||||
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"13.0") && [appSettings isAutoDarkModeEnabled]) {
|
|
||||||
|
|
||||||
NSInteger sysInterfaceStyle = [[UITraitCollection _currentTraitCollection] userInterfaceStyle];
|
|
||||||
|
|
||||||
if (sysInterfaceStyle == UIUserInterfaceStyleDark){
|
|
||||||
textColor = [[themeManager darkTheme] bodyTextColor];
|
|
||||||
} else {
|
|
||||||
textColor = [[themeManager lightTheme] bodyTextColor];
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (isNightMode) {
|
|
||||||
textColor = [[themeManager darkTheme] bodyTextColor];
|
|
||||||
} else {
|
|
||||||
textColor = [[themeManager lightTheme] bodyTextColor];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[themeManager release];
|
|
||||||
} else {
|
|
||||||
RUIThemeGuidance *themeGuidance = [%c(RUIThemeGuidance) sharedGuidance];
|
|
||||||
textColor = [[themeGuidance currentTheme] bodyTextColor];
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (secondVersionPart >= 45) {
|
|
||||||
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
|
|
||||||
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
|
||||||
|
|
||||||
if (isNightMode) {
|
|
||||||
textColor = [[themeManager darkTheme] bodyTextColor];
|
|
||||||
} else {
|
|
||||||
textColor = [[themeManager lightTheme] bodyTextColor];
|
|
||||||
}
|
|
||||||
|
|
||||||
[themeManager release];
|
|
||||||
|
|
||||||
} else if (secondVersionPart >= 37) {
|
|
||||||
themeManager = [[%c(ThemeManager) alloc] initWithTraitCollection:nil appSettings:[%c(AppSettings) sharedSettings]];
|
|
||||||
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
|
||||||
|
|
||||||
if (isNightMode) {
|
|
||||||
textColor = [[themeManager nightTheme] bodyTextColor];
|
|
||||||
} else {
|
|
||||||
textColor = [[themeManager dayTheme] bodyTextColor];
|
|
||||||
}
|
|
||||||
|
|
||||||
[themeManager release];
|
|
||||||
|
|
||||||
} else {
|
|
||||||
themeManager = [%c(ThemeManager) sharedManager];
|
|
||||||
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
|
||||||
|
|
||||||
if (isNightMode) {
|
|
||||||
textColor = [[themeManager nightTheme] bodyTextColor];
|
|
||||||
} else {
|
|
||||||
textColor = [[themeManager dayTheme] bodyTextColor];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
|
bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
|
||||||
|
|
||||||
[bodyMutableAttributedText beginEditing];
|
[bodyMutableAttributedText beginEditing];
|
||||||
@ -292,79 +299,7 @@ int secondVersionPart = 0;
|
|||||||
NSString *author = data[@"author"];
|
NSString *author = data[@"author"];
|
||||||
NSString *body = data[@"body"];
|
NSString *body = data[@"body"];
|
||||||
|
|
||||||
id themeManager;
|
UIColor *textColor = getCurrentTextColor();
|
||||||
id isNightMode;
|
|
||||||
id textColor;
|
|
||||||
|
|
||||||
if (firstVersionPart == 2020) {
|
|
||||||
|
|
||||||
if (secondVersionPart <= 40) {
|
|
||||||
|
|
||||||
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
|
|
||||||
AccountManager *accountManager = secondVersionPart >= 29 ? [appDelegate accountManager] : [%c(AccountManager) sharedManager];
|
|
||||||
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
|
|
||||||
isNightMode = [[accountManager defaults] objectForKey:@"kUseNightKey"];
|
|
||||||
|
|
||||||
if (isNightMode) {
|
|
||||||
textColor = [[themeManager darkTheme] bodyTextColor];
|
|
||||||
} else {
|
|
||||||
textColor = [[themeManager lightTheme] bodyTextColor];
|
|
||||||
}
|
|
||||||
|
|
||||||
[themeManager release];
|
|
||||||
} else {
|
|
||||||
RUIThemeGuidance *themeGuidance = [%c(RUIThemeGuidance) sharedGuidance];
|
|
||||||
textColor = [[themeGuidance currentTheme] bodyTextColor];
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (secondVersionPart >= 45) {
|
|
||||||
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
|
|
||||||
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
|
||||||
|
|
||||||
if (isNightMode) {
|
|
||||||
textColor = [[themeManager darkTheme] bodyTextColor];
|
|
||||||
} else {
|
|
||||||
textColor = [[themeManager lightTheme] bodyTextColor];
|
|
||||||
}
|
|
||||||
|
|
||||||
[themeManager release];
|
|
||||||
|
|
||||||
} else if (secondVersionPart >= 37) {
|
|
||||||
themeManager = [[%c(ThemeManager) alloc] initWithTraitCollection:nil appSettings:[%c(AppSettings) sharedSettings]];
|
|
||||||
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
|
||||||
|
|
||||||
if (isNightMode) {
|
|
||||||
textColor = [[themeManager nightTheme] bodyTextColor];
|
|
||||||
} else {
|
|
||||||
textColor = [[themeManager dayTheme] bodyTextColor];
|
|
||||||
}
|
|
||||||
|
|
||||||
[themeManager release];
|
|
||||||
|
|
||||||
} else {
|
|
||||||
themeManager = [%c(ThemeManager) sharedManager];
|
|
||||||
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
|
||||||
|
|
||||||
if (isNightMode) {
|
|
||||||
textColor = [[themeManager nightTheme] bodyTextColor];
|
|
||||||
} else {
|
|
||||||
textColor = [[themeManager dayTheme] bodyTextColor];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
NSMutableAttributedString *bodyMutableAttributedText;
|
|
||||||
|
|
||||||
if ((firstVersionPart == 2020 && secondVersionPart <= 41) || firstVersionPart != 2020) {
|
|
||||||
bodyMutableAttributedText = [[post previewFeedPostTextString] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
|
|
||||||
} else {
|
|
||||||
bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
NSMutableAttributedString *bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
|
NSMutableAttributedString *bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
|
||||||
|
|
||||||
[bodyMutableAttributedText beginEditing];
|
[bodyMutableAttributedText beginEditing];
|
||||||
|
Reference in New Issue
Block a user