From cfb8ed01f150323b297dbd3a822a265a9ea348ee Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichornlover@users.noreply.github.com> Date: Mon, 15 Apr 2024 19:32:31 -0500 Subject: [PATCH] Update AppIconOptionsController.m --- Sources/AppIconOptionsController.m | 37 +++++++++++++----------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/Sources/AppIconOptionsController.m b/Sources/AppIconOptionsController.m index 3469cc9..9707202 100644 --- a/Sources/AppIconOptionsController.m +++ b/Sources/AppIconOptionsController.m @@ -46,8 +46,12 @@ } } +- (NSArray *)sortedAppIcons { + return [self.appIcons sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; +} + - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return self.appIcons.count + 1; + return self.appIcons.count; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { @@ -59,28 +63,19 @@ if (!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]; } + NSArray *sortedIcons = [self sortedAppIcons]; + NSString *iconPath = self.appIcons[indexPath.row]; + cell.textLabel.text = [iconPath.lastPathComponent stringByDeletingPathExtension]; - if (indexPath.row == 0) { - cell.textLabel.text = @"Reset"; - if (indexPath.row == self.defaultIconIndex) { - cell.accessoryType = UITableViewCellAccessoryCheckmark; - } else { - cell.accessoryType = UITableViewCellAccessoryNone; - } - } else { - NSString *iconPath = self.appIcons[indexPath.row - 1]; - cell.textLabel.text = [iconPath.lastPathComponent stringByDeletingPathExtension]; - - UIImage *iconImage = [UIImage imageWithContentsOfFile:iconPath]; - cell.imageView.image = [self resizedImageWithImage:iconImage]; - cell.imageView.layer.cornerRadius = 10.0; - cell.imageView.clipsToBounds = YES; + UIImage *iconImage = [UIImage imageWithContentsOfFile:iconPath]; + cell.imageView.image = [self resizedImageWithImage:iconImage]; + cell.imageView.layer.cornerRadius = 10.0; + cell.imageView.clipsToBounds = YES; - if (indexPath.row - 1 == self.selectedIconIndex) { - cell.accessoryType = UITableViewCellAccessoryCheckmark; - } else { - cell.accessoryType = UITableViewCellAccessoryNone; - } + if (indexPath.row == self.selectedIconIndex) { + cell.accessoryType = UITableViewCellAccessoryCheckmark; + } else { + cell.accessoryType = UITableViewCellAccessoryNone; } return cell;