Browse Source

VLCNetworkListCell: Fix highlighted cell labels background color

With the changes in iOS 13, if a tableViewCell is highlighted,
one needs to manualy set backgroundColor and opaque properties.
See 13955336 on https://developer.apple.com/documentation/ios_ipados_release_notes/ios_13_release_notes.

Closes #660
Edgar Fouillet 5 years ago
parent
commit
74183f2b0c

+ 17 - 3
Sources/LocalNetworkConnectivity/VLCNetworkListCell.m

@@ -37,16 +37,30 @@
     self.downloadButton.hidden = YES;
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(themeDidChange)
                                                  name:kVLCThemeDidChangeNotification object:nil];
+    // If a tableViewCell is highlighted, one needs to manualy set the opaque property
+    if (@available(iOS 13.0, *)) {
+        self.opaque = NO;
+    }
+    [self themeDidChange];
     [super awakeFromNib];
 }
 
 - (void)themeDidChange
 {
     self.titleLabel.textColor = PresentationTheme.current.colors.cellTextColor;
-    self.titleLabel.backgroundColor = PresentationTheme.current.colors.background;
     self.subtitleLabel.textColor = PresentationTheme.current.colors.cellDetailTextColor;
-    self.subtitleLabel.backgroundColor = PresentationTheme.current.colors.background;
-    self.backgroundColor = PresentationTheme.current.colors.background;
+    self.folderTitleLabel.textColor = PresentationTheme.current.colors.cellDetailTextColor;
+
+    UIColor *backgroundColor = PresentationTheme.current.colors.background;
+
+    if (@available(iOS 13.0, *)) {
+        backgroundColor = UIColor.clearColor;
+    }
+
+    self.backgroundColor = backgroundColor;
+    self.titleLabel.backgroundColor = backgroundColor;
+    self.folderTitleLabel.backgroundColor = backgroundColor;
+    self.subtitleLabel.backgroundColor = backgroundColor;
 }
 
 - (void)setTitleLabelCentered:(BOOL)titleLabelCentered

+ 0 - 3
Sources/LocalNetworkConnectivity/VLCNetworkListViewController.m

@@ -156,9 +156,6 @@ NSString *VLCNetworkListCellIdentifier = @"VLCNetworkListCellIdentifier";
 
 - (void)tableView:(UITableView *)tableView willDisplayCell:(VLCNetworkListCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
 {
-    UIColor *color = (indexPath.row % 2 == 0)? [UIColor blackColor]: [UIColor VLCDarkBackgroundColor];
-    cell.backgroundColor = cell.titleLabel.backgroundColor = cell.folderTitleLabel.backgroundColor = cell.subtitleLabel.backgroundColor =  color;
-
     if ([indexPath row] == ((NSIndexPath *)[[tableView indexPathsForVisibleRows] lastObject]).row)
         [_activityIndicator stopAnimating];
 }

+ 0 - 1
Sources/LocalNetworkConnectivity/VLCNetworkServerBrowserViewController.m

@@ -184,7 +184,6 @@
     if([indexPath row] == ((NSIndexPath*)[[tableView indexPathsForVisibleRows] lastObject]).row)
         [[VLCActivityManager defaultManager] networkActivityStopped];
 
-    cell.backgroundColor = cell.titleLabel.backgroundColor = cell.folderTitleLabel.backgroundColor = cell.subtitleLabel.backgroundColor = PresentationTheme.current.colors.cellBackgroundA;
     cell.titleLabel.textColor = cell.folderTitleLabel.textColor = cell.subtitleLabel.textColor = cell.thumbnailView.tintColor = PresentationTheme.current.colors.cellTextColor;
 }
 

+ 0 - 2
Sources/LocalNetworkConnectivity/VLCServerListViewController.m

@@ -248,8 +248,6 @@
 
 - (void)tableView:(UITableView *)tableView willDisplayCell:(VLCNetworkListCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
 {
-    UIColor *color = PresentationTheme.current.colors.cellBackgroundA;
-    cell.backgroundColor = cell.titleLabel.backgroundColor = cell.folderTitleLabel.backgroundColor = cell.subtitleLabel.backgroundColor = color;
     cell.titleLabel.textColor = cell.folderTitleLabel.textColor = cell.thumbnailView.tintColor = PresentationTheme.current.colors.cellTextColor;
     cell.subtitleLabel.textColor = PresentationTheme.current.colors.cellDetailTextColor;
 }