|
@@ -38,6 +38,8 @@ class NCSplitViewController: UISplitViewController {
|
|
|
if let tabBarController = navigationController?.topViewController as? UITabBarController {
|
|
|
appDelegate.createTabBarController(tabBarController)
|
|
|
}
|
|
|
+
|
|
|
+ setPrimaryColumn()
|
|
|
}
|
|
|
|
|
|
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
|
@@ -57,10 +59,16 @@ class NCSplitViewController: UISplitViewController {
|
|
|
}
|
|
|
|
|
|
override func viewDidLayoutSubviews() {
|
|
|
+ setPrimaryColumn()
|
|
|
+ }
|
|
|
+
|
|
|
+ @discardableResult
|
|
|
+ private func setPrimaryColumn() {
|
|
|
|
|
|
var fraction: CGFloat = 0.4
|
|
|
let gap = 1.0 / self.traitCollection.displayScale
|
|
|
let device = UIDevice.current.userInterfaceIdiom
|
|
|
+ var collectionView: UICollectionView?
|
|
|
|
|
|
if device == .pad {
|
|
|
if let detailNavigationController = self.viewControllers.last as? NCDetailNavigationController {
|
|
@@ -86,14 +94,23 @@ class NCSplitViewController: UISplitViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- self.preferredPrimaryColumnWidthFraction = fraction
|
|
|
-
|
|
|
- DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
|
|
- self.appDelegate.activeMedia?.collectionView?.collectionViewLayout.invalidateLayout()
|
|
|
- self.appDelegate.activeFavorite?.collectionView?.collectionViewLayout.invalidateLayout()
|
|
|
- self.appDelegate.activeOffline?.collectionView?.collectionViewLayout.invalidateLayout()
|
|
|
+ if appDelegate.activeMedia?.view?.window != nil {
|
|
|
+ collectionView = self.appDelegate.activeMedia?.collectionView
|
|
|
+ } else if appDelegate.activeFavorite?.view?.window != nil {
|
|
|
+ collectionView = self.appDelegate.activeFavorite?.collectionView
|
|
|
+ } else if appDelegate.activeOffline?.view?.window != nil {
|
|
|
+ collectionView = self.appDelegate.activeOffline?.collectionView
|
|
|
+ } else if appDelegate.activeTrash?.view?.window != nil {
|
|
|
self.appDelegate.activeTrash?.collectionView?.collectionViewLayout.invalidateLayout()
|
|
|
+ } else {
|
|
|
+ self.preferredPrimaryColumnWidthFraction = fraction
|
|
|
}
|
|
|
+
|
|
|
+ collectionView?.performBatchUpdates({
|
|
|
+ collectionView?.collectionViewLayout.invalidateLayout()
|
|
|
+ }, completion: { (_) in
|
|
|
+ self.preferredPrimaryColumnWidthFraction = fraction
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
@objc func timerHandlerChangeTheming(_ timer: Timer) {
|