mirror of
https://github.com/arichornlover/uYouEnhanced.git
synced 2026-04-20 02:32:10 +00:00
Add Color Picker Controllers (For Themes & LCM)
I have added 2 color picker controllers! in uYouEnhanced Settings, the themes will get an update to help you give it more personalization. However I do need help making this a reality in uYouEnhanced Settings.
This commit is contained in:
parent
df3a7ddad8
commit
dea08c68ba
4 changed files with 150 additions and 0 deletions
6
Source/ColourOptionsController.h
Normal file
6
Source/ColourOptionsController.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#import <UIKit/UIKit.h>
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
@interface ColourOptionsController : UIColorPickerViewController <UIColorPickerViewControllerDelegate>
|
||||
|
||||
@end
|
||||
69
Source/ColourOptionsController.m
Normal file
69
Source/ColourOptionsController.m
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
#import "ColourOptionsController.h"
|
||||
#import "Localization.h"
|
||||
|
||||
@interface ColourOptionsController ()
|
||||
- (void)coloursView;
|
||||
@end
|
||||
|
||||
@implementation ColourOptionsController
|
||||
|
||||
- (void)loadView {
|
||||
[super loadView];
|
||||
[self coloursView];
|
||||
|
||||
self.title = LOC(@"COLOR_OPTIONS");
|
||||
|
||||
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done)];
|
||||
self.navigationItem.leftBarButtonItem = doneButton;
|
||||
|
||||
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStylePlain target:self action:@selector(save)];
|
||||
self.navigationItem.rightBarButtonItem = saveButton;
|
||||
|
||||
self.supportsAlpha = NO;
|
||||
NSData *colorData = [[NSUserDefaults standardUserDefaults] objectForKey:@"kYTRebornColourOptionsVFour"];
|
||||
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:colorData error:nil];
|
||||
[unarchiver setRequiresSecureCoding:NO];
|
||||
UIColor *color = [unarchiver decodeObjectForKey:NSKeyedArchiveRootObjectKey];
|
||||
self.selectedColor = color;
|
||||
}
|
||||
|
||||
- (void)coloursView {
|
||||
if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) {
|
||||
self.view.backgroundColor = [UIColor colorWithRed:0.949 green:0.949 blue:0.969 alpha:1.0];
|
||||
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]}];
|
||||
self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
|
||||
}
|
||||
else {
|
||||
self.view.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
|
||||
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
|
||||
[super traitCollectionDidChange:previousTraitCollection];
|
||||
[self coloursView];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation ColourOptionsController(Privates)
|
||||
|
||||
- (void)done {
|
||||
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)save {
|
||||
NSData *colorData = [NSKeyedArchiver archivedDataWithRootObject:self.selectedColor requiringSecureCoding:nil error:nil];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:colorData forKey:@"kYTRebornColourOptionsVFour"];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
|
||||
UIAlertController *alertSaved = [UIAlertController alertControllerWithTitle:@"Colour Saved" message:nil preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
[alertSaved addAction:[UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
||||
}]];
|
||||
|
||||
[self presentViewController:alertSaved animated:YES completion:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
6
Source/ColourOptionsController2.h
Normal file
6
Source/ColourOptionsController2.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#import <UIKit/UIKit.h>
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
@interface ColourOptionsController2 : UIColorPickerViewController <UIColorPickerViewControllerDelegate>
|
||||
|
||||
@end
|
||||
69
Source/ColourOptionsController2.m
Normal file
69
Source/ColourOptionsController2.m
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
#import "ColourOptionsController2.h"
|
||||
#import "Localization.h"
|
||||
|
||||
@interface ColourOptionsController2 ()
|
||||
- (void)coloursView;
|
||||
@end
|
||||
|
||||
@implementation ColourOptionsController2
|
||||
|
||||
- (void)loadView {
|
||||
[super loadView];
|
||||
[self coloursView];
|
||||
|
||||
self.title = LOC(@"COLOR_OPTIONS_2");
|
||||
|
||||
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done)];
|
||||
self.navigationItem.leftBarButtonItem = doneButton;
|
||||
|
||||
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStylePlain target:self action:@selector(save)];
|
||||
self.navigationItem.rightBarButtonItem = saveButton;
|
||||
|
||||
self.supportsAlpha = NO;
|
||||
NSData *lcmColorData = [[NSUserDefaults standardUserDefaults] objectForKey:@"kYTLcmColourOptionVFive"];
|
||||
NSKeyedUnarchiver *lcmUnarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:lcmColorData error:nil];
|
||||
[lcmUnarchiver setRequiresSecureCoding:NO];
|
||||
UIColor *color = [lcmUnarchiver decodeObjectForKey:NSKeyedArchiveRootObjectKey];
|
||||
self.selectedColor = color;
|
||||
}
|
||||
|
||||
- (void)coloursView {
|
||||
if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) {
|
||||
self.view.backgroundColor = [UIColor colorWithRed:0.949 green:0.949 blue:0.969 alpha:1.0];
|
||||
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]}];
|
||||
self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
|
||||
}
|
||||
else {
|
||||
self.view.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
|
||||
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
|
||||
[super traitCollectionDidChange:previousTraitCollection];
|
||||
[self coloursView];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation ColourOptionsController2(Privates)
|
||||
|
||||
- (void)done {
|
||||
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)save {
|
||||
NSData *lcmColorData = [NSKeyedArchiver archivedDataWithRootObject:self.selectedColor requiringSecureCoding:nil error:nil];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:lcmColorData forKey:@"kYTLcmColourOptionVFive"];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
|
||||
UIAlertController *alertSaved = [UIAlertController alertControllerWithTitle:@"Colour Saved" message:nil preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
[alertSaved addAction:[UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
||||
}]];
|
||||
|
||||
[self presentViewController:alertSaved animated:YES completion:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
Loading…
Reference in a new issue