Same treatment - ColourOptionsController2.m

This commit is contained in:
aricloverEXTRA 2026-06-30 18:46:01 -05:00 committed by GitHub
parent d443c4a13b
commit 4c75804420
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,10 +7,10 @@
@implementation ColourOptionsController2
- (void)loadView {
[super loadView];
[super loadView];
self.title = @"Custom Tint Color";
UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStylePlain target:self action:@selector(close)];
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStylePlain target:self action:@selector(save)];
self.navigationItem.rightBarButtonItems = @[closeButton, saveButton];
@ -20,26 +20,27 @@
self.supportsAlpha = NO;
NSData *lcmColorData = [[NSUserDefaults standardUserDefaults] objectForKey:@"kCustomUIColor"];
NSKeyedUnarchiver *lcmUnarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:lcmColorData error:nil];
[lcmUnarchiver setRequiresSecureCoding:NO];
UIColor *color = [lcmUnarchiver decodeObjectForKey:NSKeyedArchiveRootObjectKey];
self.selectedColor = color;
if (lcmColorData) {
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:lcmColorData error:nil];
[unarchiver setRequiresSecureCoding:NO];
self.selectedColor = [unarchiver decodeObjectForKey:NSKeyedArchiveRootObjectKey];
}
// Better iPad scaling
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
CGFloat scale = MIN(self.view.bounds.size.width / 768, self.view.bounds.size.height / 1024);
CGFloat scale = MIN(self.view.bounds.size.width / 768.0, self.view.bounds.size.height / 1024.0);
self.view.transform = CGAffineTransformMakeScale(scale, scale);
}
}
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) {
CGFloat scale = MIN(size.width / 768, size.height / 1024);
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
CGFloat scale = MIN(size.width / 768.0, size.height / 1024.0);
self.view.transform = CGAffineTransformMakeScale(scale, scale);
} completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
}];
} completion:nil];
}
}
@ -52,16 +53,13 @@
}
- (void)save {
NSData *lcmColorData = [NSKeyedArchiver archivedDataWithRootObject:self.selectedColor requiringSecureCoding:nil error:nil];
NSData *lcmColorData = [NSKeyedArchiver archivedDataWithRootObject:self.selectedColor requiringSecureCoding:NO error:nil];
[[NSUserDefaults standardUserDefaults] setObject:lcmColorData forKey:@"kCustomUIColor"];
[[NSUserDefaults standardUserDefaults] synchronize];
UIAlertController *alertSaved = [UIAlertController alertControllerWithTitle:@"Color Saved" message:nil preferredStyle:UIAlertControllerStyleAlert];
[alertSaved addAction:[UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}]];
[self presentViewController:alertSaved animated:YES completion:nil];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Color Saved" message:nil preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alert animated:YES completion:nil];
}
- (void)reset {