Skip to content

Commit

Permalink
Remove magic numbers in MoreItemsVS
Browse files Browse the repository at this point in the history
  • Loading branch information
wutschel committed Apr 1, 2024
1 parent 7fc3f34 commit e173cc6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 0 additions & 1 deletion XBMC Remote/MoreItemsViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
@interface MoreItemsViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
UITableView *_tableView;
NSArray *mainMenuItems;
int cellLabelOffset;
}

- (id)initWithFrame:(CGRect)frame mainMenu:(NSArray*)menu;
Expand Down
16 changes: 12 additions & 4 deletions XBMC Remote/MoreItemsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ @implementation MoreItemsViewController
@synthesize tableView = _tableView;
#define LABEL_PADDING 8
#define INDICATOR_SIZE 16
#define LABEL_OFFSET 50
#define ICON_WIDTH 34
#define ICON_HEIGHT 30

- (id)initWithFrame:(CGRect)frame mainMenu:(NSArray*)menu {
if (self = [super init]) {
cellLabelOffset = 50;
self.view.frame = frame;
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
// _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
Expand All @@ -28,7 +30,7 @@ - (id)initWithFrame:(CGRect)frame mainMenu:(NSArray*)menu {
mainMenuItems = menu;
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 1)];
_tableView.tableFooterView = footerView;
_tableView.separatorInset = UIEdgeInsetsMake(0, cellLabelOffset, 0, 0);
_tableView.separatorInset = UIEdgeInsetsMake(0, LABEL_OFFSET, 0, 0);
[self.view addSubview:_tableView];
}
return self;
Expand Down Expand Up @@ -64,15 +66,21 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

UILabel *cellLabel = [[UILabel alloc] initWithFrame:CGRectMake(cellLabelOffset, 0, self.view.bounds.size.width - cellLabelOffset - INDICATOR_SIZE - 2 * LABEL_PADDING, cell.frame.size.height)];
UILabel *cellLabel = [[UILabel alloc] initWithFrame:CGRectMake(LABEL_OFFSET,
0,
self.view.bounds.size.width - LABEL_OFFSET - INDICATOR_SIZE - 2 * LABEL_PADDING,
cell.frame.size.height)];
cellLabel.font = [UIFont systemFontOfSize:18];
cellLabel.textColor = [Utilities get1stLabelColor];
cellLabel.highlightedTextColor = [Utilities get1stLabelColor];
NSDictionary *item = mainMenuItems[indexPath.row];
cellLabel.text = item[@"label"];
[cell.contentView addSubview:cellLabel];
if (![item[@"icon"] isEqualToString:@""]) {
CGRect iconImageViewRect = CGRectMake(8, 6, 34, 30);
CGRect iconImageViewRect = CGRectMake((LABEL_OFFSET - ICON_WIDTH) / 2,
(cell.frame.size.height - ICON_HEIGHT) / 2,
ICON_WIDTH,
ICON_HEIGHT);
UIImageView *iconImage = [[UIImageView alloc] initWithFrame:iconImageViewRect];
UIImage *image = [UIImage imageNamed:item[@"icon"]];
image = [Utilities colorizeImage:image withColor:[Utilities get1stLabelColor]];
Expand Down

0 comments on commit e173cc6

Please sign in to comment.