From bdf7449a40bf1ae5cd747ab4da32f55a00677ff7 Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichorn@users.noreply.github.com> Date: Thu, 11 Jan 2024 18:03:15 -0600 Subject: [PATCH] Update ColourOptionsController2.m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You may be wondering, why am I adding reset buttons? Well the problem is that if YouTube Reborn isn’t present in uYouEnhanced, I gotta do it like this. --- Source/ColourOptionsController2.m | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Source/ColourOptionsController2.m b/Source/ColourOptionsController2.m index a5f08ba..fcbb156 100644 --- a/Source/ColourOptionsController2.m +++ b/Source/ColourOptionsController2.m @@ -1,5 +1,4 @@ #import "ColourOptionsController2.h" -#import "Localization.h" @interface ColourOptionsController2 () - (void)coloursView; @@ -11,16 +10,19 @@ [super loadView]; [self coloursView]; - self.title = LOC(@"COLOR_OPTIONS_2"); + self.title = LOC(@"Custom Text/Etc. Color"); - UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done)]; - self.navigationItem.leftBarButtonItem = doneButton; + UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStylePlain target:self action:@selector(close)]; + self.navigationItem.rightBarButtonItem = closeButton; UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStylePlain target:self action:@selector(save)]; self.navigationItem.rightBarButtonItem = saveButton; + UIBarButtonItem *resetButton = [[UIBarButtonItem alloc] initWithTitle:@"Reset" style:UIBarButtonItemStylePlain target:self action:@selector(reset)]; + self.navigationItem.leftBarButtonItem = resetButton; + self.supportsAlpha = NO; - NSData *lcmColorData = [[NSUserDefaults standardUserDefaults] objectForKey:@"kYTLcmColourOptionVFive"]; + NSData *lcmColorData = [[NSUserDefaults standardUserDefaults] objectForKey:@"kCustomUIColor"]; NSKeyedUnarchiver *lcmUnarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:lcmColorData error:nil]; [lcmUnarchiver setRequiresSecureCoding:NO]; UIColor *color = [lcmUnarchiver decodeObjectForKey:NSKeyedArchiveRootObjectKey]; @@ -49,16 +51,16 @@ @implementation ColourOptionsController2(Privates) -- (void)done { +- (void)close { [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] setObject:lcmColorData forKey:@"kCustomUIColor"]; [[NSUserDefaults standardUserDefaults] synchronize]; - UIAlertController *alertSaved = [UIAlertController alertControllerWithTitle:@"Colour Saved" message:nil preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *alertSaved = [UIAlertController alertControllerWithTitle:@"Color Saved" message:nil preferredStyle:UIAlertControllerStyleAlert]; [alertSaved addAction:[UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]]; @@ -66,4 +68,9 @@ [self presentViewController:alertSaved animated:YES completion:nil]; } +- (void)reset { + [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"kCustomThemeColor"]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + @end