Skip to content

Commit

Permalink
Merge pull request #942 from wutschel/fix_menu
Browse files Browse the repository at this point in the history
Bugfix: Not all menu cells updated on connect/disconnect
  • Loading branch information
kambala-decapitator committed Oct 21, 2023
2 parents 8fea335 + 3aa9da1 commit f7b6f31
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
12 changes: 4 additions & 8 deletions XBMC Remote/MasterViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ - (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)
return self.mainMenu.count;
}

- (void)tableView:(UITableView*)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath {
[Utilities setStyleOfMenuItemCell:cell active:AppDelegate.instance.serverOnLine || indexPath.row == 0];
}

- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mainMenuCellIdentifier"];
if (cell == nil) {
Expand Down Expand Up @@ -140,14 +144,6 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI
icon.image = [Utilities colorizeImage:icon.highlightedImage withColor:UIColor.grayColor];
cell.backgroundColor = [Utilities getGrayColor:36 alpha:1];
}
if (AppDelegate.instance.serverOnLine || indexPath.row == 0) {
icon.alpha = 1.0;
title.alpha = 1.0;
}
else {
icon.alpha = 0.3;
title.alpha = 0.3;
}
return cell;
}

Expand Down
1 change: 1 addition & 0 deletions XBMC Remote/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ typedef enum {
+ (NSString*)getConnectionStatusIconName;
+ (NSString*)getConnectionStatusServerName;
+ (void)addShadowsToView:(UIView*)view viewFrame:(CGRect)frame;
+ (void)setStyleOfMenuItemCell:(UITableViewCell*)cell active:(BOOL)active;
+ (void)setStyleOfMenuItems:(UITableView*)tableView active:(BOOL)active;
+ (void)enableDefaultController:(id<UITableViewDelegate>)viewController tableView:(UITableView*)tableView menuItems:(NSArray*)menuItems;
+ (id)unarchivePath:(NSString*)path file:(NSString*)filename;
Expand Down
13 changes: 9 additions & 4 deletions XBMC Remote/Utilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,15 @@ + (void)addShadowsToView:(UIView*)view viewFrame:(CGRect)frame {
}
}

+ (void)setStyleOfMenuItems:(UITableView*)tableView active:(BOOL)active {
+ (void)setStyleOfMenuItemCell:(UITableViewCell*)cell active:(BOOL)active {
CGFloat alpha = active ? 1.0 : 0.3;
UIImageView *icon = (UIImageView*)[cell viewWithTag:1];
UILabel *title = (UILabel*)[cell viewWithTag:3];
icon.alpha = alpha;
title.alpha = alpha;
}

+ (void)setStyleOfMenuItems:(UITableView*)tableView active:(BOOL)active {
for (NSIndexPath *indexPath in tableView.indexPathsForVisibleRows) {
// The iPhone uses the top most cell as connection status. This should not be faded/unfaded.
if (IS_IPHONE && indexPath.row == 0 && indexPath.section == 0) {
Expand All @@ -1029,9 +1036,7 @@ + (void)setStyleOfMenuItems:(UITableView*)tableView active:(BOOL)active {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
[UIView animateWithDuration:0.3
animations:^{
((UIImageView*)[cell viewWithTag:1]).alpha = alpha;
((UIImageView*)[cell viewWithTag:2]).alpha = alpha;
((UIImageView*)[cell viewWithTag:3]).alpha = alpha;
[Utilities setStyleOfMenuItemCell:cell active:active];
}];
}
}
Expand Down
9 changes: 1 addition & 8 deletions XBMC Remote/iPad/MenuViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ - (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)
}

- (void)tableView:(UITableView*)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath {
[Utilities setStyleOfMenuItemCell:cell active:AppDelegate.instance.serverOnLine];
cell.backgroundColor = UIColor.clearColor;
}

Expand All @@ -159,14 +160,6 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI
title.text = item.mainLabel;
icon.highlightedImage = [UIImage imageNamed:iconName];
icon.image = [Utilities colorizeImage:icon.highlightedImage withColor:UIColor.grayColor];
if (AppDelegate.instance.serverOnLine) {
icon.alpha = 1.0;
title.alpha = 1.0;
}
else {
icon.alpha = 0.3;
title.alpha = 0.3;
}
return cell;
}

Expand Down

0 comments on commit f7b6f31

Please sign in to comment.