From 5da51c01f9da48a069b320d9b95f98268acbfda3 Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichornlover@users.noreply.github.com> Date: Wed, 24 Apr 2024 23:00:55 -0500 Subject: [PATCH] Shrink and reduce AppIconOptionsController UI --- Sources/AppIconOptionsController.m | 39 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/Sources/AppIconOptionsController.m b/Sources/AppIconOptionsController.m index 3657641..16eb244 100644 --- a/Sources/AppIconOptionsController.m +++ b/Sources/AppIconOptionsController.m @@ -23,7 +23,7 @@ self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; self.tableView.dataSource = self; self.tableView.delegate = self; - self.tableView.backgroundColor = [UIColor blackColor]; + self.tableView.backgroundColor = (self.pageStyle == UIUserInterfaceStyleLight) ? [UIColor whiteColor] : [UIColor blackColor]; [self.view addSubview:self.tableView]; UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:@selector(back)]; @@ -33,17 +33,16 @@ } else { backButton.image = backImage; } - [backButton setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor], NSFontAttributeName: [UIFont fontWithName:@"YTSans-Medium" size:20]} forState:UIControlStateNormal]; + [backButton setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor blackColor], NSFontAttributeName: [UIFont fontWithName:@"YTSans-Medium" size:20]} forState:UIControlStateNormal]; self.navigationItem.leftBarButtonItem = backButton; - UIBarButtonItem *resetButton = [[UIBarButtonItem alloc] initWithTitle:@"Reset" style:UIBarButtonItemStylePlain target:self action:@selector(resetIcon)]; - [resetButton setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor colorWithRed:203.0/255.0 green:22.0/255.0 blue:51.0/255.0 alpha:1.0], NSFontAttributeName: [UIFont fontWithName:@"YTSans-Medium" size:20]} forState:UIControlStateNormal]; - + UIBarButtonItem *resetButton = [[UIBarButtonItem alloc] initWithImage:[UIImage systemImageNamed:@"arrow.clockwise.circle.fill"] style:UIBarButtonItemStylePlain target:self action:@selector(resetIcon)]; + UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStylePlain target:self action:@selector(saveIcon)]; [saveButton setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor colorWithRed:203.0/255.0 green:22.0/255.0 blue:51.0/255.0 alpha:1.0], NSFontAttributeName: [UIFont fontWithName:@"YTSans-Medium" size:20]} forState:UIControlStateNormal]; - + self.navigationItem.rightBarButtonItems = @[saveButton, resetButton]; - + NSString *path = [[NSBundle mainBundle] pathForResource:@"uYouPlus" ofType:@"bundle"]; NSBundle *bundle = [NSBundle bundleWithPath:path]; self.appIcons = [bundle pathsForResourcesOfType:@"png" inDirectory:@"AppIcons"]; @@ -57,10 +56,6 @@ return self.appIcons.count; } -- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - return 80.0; -} - - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; if (!cell) { @@ -68,14 +63,20 @@ } NSString *iconPath = self.appIcons[indexPath.row]; - cell.textLabel.text = [iconPath.lastPathComponent stringByDeletingPathExtension]; - UIImage *iconImage = [UIImage imageWithContentsOfFile:iconPath]; - cell.imageView.image = iconImage; - cell.imageView.layer.cornerRadius = 20.0; - cell.imageView.clipsToBounds = YES; - cell.imageView.frame = CGRectMake(20, 20, 60, 60); - cell.textLabel.frame = CGRectMake(90, 20, self.view.frame.size.width - 100, 40); + + cell.backgroundColor = [UIColor whiteColor]; + cell.selectionStyle = UITableViewCellSelectionStyleNone; + + UIImageView *iconImageView = [[UIImageView alloc] initWithImage:iconImage]; + iconImageView.frame = CGRectMake(16, 8, 24, 24); + [cell.contentView addSubview:iconImageView]; + + UILabel *iconNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(56, 0, self.view.frame.size.width - 56, 40)]; + iconNameLabel.text = [iconPath.lastPathComponent stringByDeletingPathExtension]; + iconNameLabel.textColor = [UIColor blackColor]; + iconNameLabel.font = [UIFont systemFontOfSize:18.0 weight:UIFontWeightMedium]; + [cell.contentView addSubview:iconNameLabel]; if (indexPath.row == self.selectedIconIndex) { cell.accessoryType = UITableViewCellAccessoryCheckmark; @@ -125,7 +126,7 @@ [dict setObject:iconURL forKey:@"iconURL"]; NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"]; [dict writeToFile:filePath atomically:YES]; - + [self showAlertWithTitle:@"Alternate Icon" message:@"Please restart the app to apply the alternate icon"]; } }