This repository has been archived by the owner on Jan 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
257 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
Theos/packages/ | ||
Theos/.theos | ||
.theos | ||
.cache/ | ||
compile_commands.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
#include <Foundation/NSUserDefaults.h> | ||
#import <UIKit/UIKit.h> | ||
|
||
@interface UIImage (Scale) | ||
+ (UIImage *)resizeImageFromImage:(UIImage *)image withSize:(CGSize)size; | ||
@end | ||
|
||
@interface NSUserDefaults (Colors) | ||
- (void)setColor:(UIColor*)color forKey:(NSString*)key; | ||
- (UIColor*)colorForKey:(NSString*)key; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#import <UIKit/UIKit.h> | ||
|
||
@interface JDEButtons : NSObject | ||
- (UIButton*)boldButton; | ||
- (UIButton*)buttonWithImageNamed:(NSString*)image; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#import <UIKit/UIKit.h> | ||
#import "Exts.h" | ||
@interface ThemingViewController : UIViewController | ||
@end | ||
|
||
@interface ColorCell : UITableViewCell | ||
@property (nonatomic, strong) UIButton *colorButton; | ||
@end | ||
|
||
|
||
#define main "mainColor" | ||
#define secondary "customLightGrayColor" | ||
#define user "meColor" | ||
#define userDot "channelNotification" | ||
#define channel "channelColor" | ||
#define channelDot "declineColor" // channel and notification Dots | ||
#define notification "notificationColor" | ||
#define pollCell "pollBgColor" | ||
|
||
|
||
typedef NS_ENUM(NSUInteger, ThemeOption){ | ||
ThemeOptionMainColor, | ||
ThemeOptionSecondaryColor, | ||
ThemeOptionUserSectionColor, | ||
ThemeOptionChannelsSectionColor, | ||
ThemeOptionNotificationsSectionColor, | ||
ThemeOptionPollCellsBackgroundColor | ||
|
||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
#import "ThemingViewController.h" | ||
#include "Classes/JDESettingsManager.h" | ||
|
||
|
||
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) // https://stackoverflow.com/a/5337804 | ||
|
||
|
||
|
||
static NSDictionary<NSNumber*, NSString*> *_ThemeOptionKeysDict(){ | ||
return @{ | ||
@(ThemeOptionMainColor): @"mainColor", | ||
@(ThemeOptionSecondaryColor): @"customLightGrayColor", | ||
@(ThemeOptionUserSectionColor): @"meColor", | ||
@(ThemeOptionChannelsSectionColor): @"channelColor", | ||
@(ThemeOptionNotificationsSectionColor): @"notificationColor", | ||
@(ThemeOptionPollCellsBackgroundColor): @"pollBgColor" | ||
}; | ||
} | ||
|
||
UIColor *colorForKey(NSString *key){ | ||
UIColor *color = [[JDESettingsManager sharedInstance].tweakSettings colorForKey:key]; | ||
if (!color){ | ||
return [UIColor colorNamed:key]; | ||
} | ||
return color; | ||
} | ||
|
||
|
||
@interface ColorCell() | ||
@end | ||
|
||
@implementation ColorCell | ||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { | ||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; | ||
if(self){ | ||
self.colorButton = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
self.accessoryView = self.colorButton; | ||
self.colorButton.frame = CGRectMake(0, 0, 30, 30); | ||
self.colorButton.layer.cornerRadius = .5 * self.colorButton.frame.size.width; | ||
self.colorButton.clipsToBounds = YES; | ||
self.colorButton.layer.borderWidth = 3; | ||
self.colorButton.layer.borderColor = UIColor.systemGrayColor.CGColor; | ||
} | ||
return self; | ||
} | ||
|
||
@end | ||
|
||
@interface ThemingViewController()<UITableViewDelegate, UITableViewDataSource, UIColorPickerViewControllerDelegate> | ||
@property (strong, nonatomic) UITableView *tableView; | ||
@property (strong, nonatomic) NSIndexPath *indexPathForColorPicker; | ||
@end | ||
|
||
@implementation ThemingViewController | ||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
self.view.backgroundColor = UIColor.systemBackgroundColor; | ||
self.title = @"Theming"; | ||
|
||
self.tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStyleInsetGrouped]; | ||
self.tableView.delegate = self; | ||
self.tableView.dataSource = self; | ||
|
||
[self.view addSubview:self.tableView]; | ||
} | ||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { | ||
return 33; | ||
} | ||
|
||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { | ||
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]; | ||
label.text = @"Unavailable for below iOS 13 :)"; | ||
label.textColor = UIColor.secondaryLabelColor; | ||
return label; | ||
} | ||
|
||
|
||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ | ||
return _ThemeOptionKeysDict().allKeys.count +1; | ||
} | ||
|
||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ | ||
|
||
if(indexPath.row == [tableView numberOfRowsInSection:0] -1){ | ||
UITableViewCell *resetCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]; | ||
|
||
resetCell.textLabel.text = @"Reset"; | ||
resetCell.textLabel.textColor = UIColor.systemRedColor; | ||
resetCell.textLabel.textAlignment = NSTextAlignmentCenter; | ||
|
||
return resetCell; | ||
} | ||
|
||
ColorCell *cell = [tableView dequeueReusableCellWithIdentifier:@"colorCell"]; | ||
if (!cell){ | ||
cell = [[ColorCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"colorCell"]; | ||
} | ||
|
||
cell.selectionStyle = UITableViewCellSelectionStyleNone; | ||
NSString *key = _ThemeOptionKeysDict()[@(indexPath.row)]; | ||
cell.textLabel.text = key; | ||
cell.colorButton.backgroundColor = colorForKey(key); | ||
[cell.colorButton addTarget:self action:@selector(tappedColor:) forControlEvents:UIControlEventTouchUpInside]; | ||
|
||
|
||
|
||
return cell; | ||
} | ||
|
||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { | ||
if(indexPath.row == [tableView numberOfRowsInSection:0] -1){ | ||
for(NSString *color in _ThemeOptionKeysDict().allValues){ | ||
[[JDESettingsManager sharedInstance].tweakSettings removeObjectForKey:color]; | ||
} | ||
[tableView reloadData]; | ||
} | ||
[tableView deselectRowAtIndexPath:indexPath animated:YES]; | ||
} | ||
|
||
- (void)tappedColor:(UIButton*)sender{ | ||
CGPoint buttonPos = [sender convertPoint:CGPointZero toView:self.tableView]; | ||
self.indexPathForColorPicker = [self.tableView indexPathForRowAtPoint:buttonPos]; | ||
|
||
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"14")){ | ||
UIColorPickerViewController *colorPicker = [UIColorPickerViewController new]; | ||
colorPicker.delegate = self; | ||
[self presentViewController:colorPicker animated:YES completion:nil]; | ||
} | ||
} | ||
|
||
- (void)colorPickerViewControllerDidSelectColor:(UIColorPickerViewController *)viewController{ | ||
ColorCell *cell = [self.tableView cellForRowAtIndexPath:self.indexPathForColorPicker]; | ||
cell.colorButton.backgroundColor = viewController.selectedColor; | ||
[[JDESettingsManager sharedInstance].tweakSettings setColor:viewController.selectedColor | ||
forKey:_ThemeOptionKeysDict()[@(self.indexPathForColorPicker.row)]]; | ||
} | ||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
6b1b456
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@https://shared.jodel.com/GmYueHl0kDb