ソースを参照

Adapt to iOS 13 API changes

Carola Nitz 6 年 前
コミット
ea91de9f7e

+ 11 - 2
Sources/AppearanceManager.swift

@@ -27,12 +27,12 @@ class AppearanceManager: NSObject {
         UINavigationBar.appearance().barTintColor = theme.colors.navigationbarColor
         UINavigationBar.appearance(whenContainedInInstancesOf: [VLCPlaybackNavigationController.self]).barTintColor = nil
         UINavigationBar.appearance().tintColor = theme.colors.orangeUI
-        UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: theme.colors.navigationbarTextColor]
+        UINavigationBar.appearance().titleTextAttributes = [.foregroundColor: theme.colors.navigationbarTextColor]
 
         if #available(iOS 11.0, *) {
             UINavigationBar.appearance().prefersLargeTitles = true
             UINavigationBar.appearance(whenContainedInInstancesOf: [VLCPlaybackNavigationController.self]).prefersLargeTitles = false
-            UINavigationBar.appearance().largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor: theme.colors.navigationbarTextColor]
+            UINavigationBar.appearance().largeTitleTextAttributes = [.foregroundColor: theme.colors.navigationbarTextColor]
         }
 
         let selectedBackgroundView = UIView()
@@ -54,6 +54,15 @@ class AppearanceManager: NSObject {
         UIPageControl.appearance().pageIndicatorTintColor = .lightGray
         UIPageControl.appearance().currentPageIndicatorTintColor = theme.colors.orangeUI
     }
+
+    @available(iOS 13.0, *)
+    @objc class func navigationbarAppearance() -> UINavigationBarAppearance {
+        let navBarAppearance = UINavigationBarAppearance()
+        navBarAppearance.backgroundColor = PresentationTheme.current.colors.navigationbarColor
+        navBarAppearance.titleTextAttributes = [.foregroundColor: PresentationTheme.current.colors.navigationbarTextColor]
+        navBarAppearance.largeTitleTextAttributes = [.foregroundColor: PresentationTheme.current.colors.navigationbarTextColor]
+        return navBarAppearance
+    }
 }
 
 //extensions so that preferredStatusBarStyle is called on all childViewControllers otherwise this is not forwarded

+ 4 - 0
Sources/LocalNetworkConnectivity/VLCNetworkLoginViewController.m

@@ -68,6 +68,10 @@
     self.dataSource = dataSource;
 
     self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BUTTON_CONNECT", nil) style:UIBarButtonItemStyleDone target:self action:@selector(connectLoginDataSource)];
+    if (@available(iOS 13.0, *)) {
+        self.navigationController.navigationBar.standardAppearance = [VLCApperanceManager navigationbarAppearance];
+        self.navigationController.navigationBar.scrollEdgeAppearance = [VLCApperanceManager navigationbarAppearance];
+    }
 }
 
 - (UIStatusBarStyle)preferredStatusBarStyle

+ 5 - 1
Sources/LocalNetworkConnectivity/VLCServerListViewController.m

@@ -169,7 +169,7 @@
 
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(themeDidChange) name:kVLCThemeDidChangeNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contentSizeDidChange) name:UIContentSizeCategoryDidChangeNotification object:nil];
-
+    [self themeDidChange];
     NSArray *browserClasses = @[
                                 [VLCLocalNetworkServiceBrowserUPnP class],
                                 [VLCLocalNetworkServiceBrowserPlex class],
@@ -337,6 +337,10 @@
     _localNetworkTableView.separatorColor = PresentationTheme.current.colors.background;
     _refreshControl.backgroundColor = PresentationTheme.current.colors.background;
     self.navigationController.view.backgroundColor = PresentationTheme.current.colors.background;
+    if (@available(iOS 13.0, *)) {
+        self.navigationController.navigationBar.standardAppearance = [VLCApperanceManager navigationbarAppearance];
+        self.navigationController.navigationBar.scrollEdgeAppearance = [VLCApperanceManager navigationbarAppearance];
+    }
     [self setNeedsStatusBarAppearanceUpdate];
 }
 

+ 1 - 1
Sources/MediaCategories/MediaCategoryViewController.swift

@@ -365,7 +365,7 @@ extension MediaCategoryViewController {
         searchDataSource.shouldReloadFor(searchString: searchText)
         reloadData()
         if searchText.isEmpty {
-            self.searchBar.resignFirstResponder
+            self.searchBar.resignFirstResponder()
         }
     }
 }

+ 4 - 0
Sources/VLCFirstStepsViewController.m

@@ -69,6 +69,10 @@
 - (void)updateTheme
 {
     self.view.backgroundColor = PresentationTheme.current.colors.background;
+    if (@available(iOS 13.0, *)) {
+        self.navigationController.navigationBar.standardAppearance = [VLCApperanceManager navigationbarAppearance];
+        self.navigationController.navigationBar.scrollEdgeAppearance = [VLCApperanceManager navigationbarAppearance];
+    }
 }
 
 - (UIStatusBarStyle)preferredStatusBarStyle

+ 4 - 1
Sources/VLCTabBarCoordinator.swift

@@ -37,12 +37,15 @@ class VLCTabBarCoordinator: NSObject {
             if let navController = $0 as? UINavigationController, navController.topViewController is VLCSettingsController {
                 navController.navigationBar.barTintColor = PresentationTheme.current.colors.navigationbarColor
                 navController.navigationBar.tintColor = PresentationTheme.current.colors.orangeUI
-                navController.navigationBar.isTranslucent = false
                 navController.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:  PresentationTheme.current.colors.navigationbarTextColor]
 
                 if #available(iOS 11.0, *) {
                     navController.navigationBar.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor:  PresentationTheme.current.colors.navigationbarTextColor]
                 }
+                if #available(iOS 13.0, *) {
+                    navController.navigationBar.standardAppearance = AppearanceManager.navigationbarAppearance()
+                    navController.navigationBar.scrollEdgeAppearance = AppearanceManager.navigationbarAppearance()
+                }
             }
         }
     }