2019-11-19 02:12:24 +01:00
|
|
|
//
|
|
|
|
// InteractiveNavigationController.swift
|
|
|
|
// NetNewsWire
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 8/22/19.
|
|
|
|
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
class InteractiveNavigationController: UINavigationController {
|
|
|
|
|
|
|
|
private let poppableDelegate = PoppableGestureRecognizerDelegate()
|
|
|
|
|
|
|
|
static func template() -> UINavigationController {
|
|
|
|
let navController = InteractiveNavigationController()
|
|
|
|
navController.configure()
|
|
|
|
return navController
|
|
|
|
}
|
|
|
|
|
|
|
|
static func template(rootViewController: UIViewController) -> UINavigationController {
|
|
|
|
let navController = InteractiveNavigationController(rootViewController: rootViewController)
|
|
|
|
navController.configure()
|
|
|
|
return navController
|
|
|
|
}
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
|
|
|
poppableDelegate.navigationController = self
|
|
|
|
interactivePopGestureRecognizer?.delegate = poppableDelegate
|
2024-11-05 05:23:26 +01:00
|
|
|
|
|
|
|
registerForTraitChanges([UITraitUserInterfaceStyle.self], target: self, action: #selector(userInterfaceStyleDidChange))
|
2019-11-19 02:12:24 +01:00
|
|
|
}
|
2024-11-05 05:23:26 +01:00
|
|
|
|
|
|
|
@objc func userInterfaceStyleDidChange() {
|
|
|
|
configure()
|
2019-11-19 02:12:24 +01:00
|
|
|
}
|
2020-04-06 15:47:01 +02:00
|
|
|
}
|
2019-11-19 02:12:24 +01:00
|
|
|
|
|
|
|
// MARK: Private
|
|
|
|
|
|
|
|
private extension InteractiveNavigationController {
|
|
|
|
|
|
|
|
func configure() {
|
|
|
|
isToolbarHidden = false
|
|
|
|
|
2020-01-20 19:43:26 +01:00
|
|
|
let navigationStandardAppearance = UINavigationBarAppearance()
|
|
|
|
navigationStandardAppearance.titleTextAttributes = [.foregroundColor: UIColor.label]
|
|
|
|
navigationStandardAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor.label]
|
|
|
|
navigationBar.standardAppearance = navigationStandardAppearance
|
|
|
|
|
|
|
|
let scrollEdgeStandardAppearance = UINavigationBarAppearance()
|
|
|
|
scrollEdgeStandardAppearance.backgroundColor = .systemBackground
|
|
|
|
navigationBar.scrollEdgeAppearance = scrollEdgeStandardAppearance
|
|
|
|
|
2019-11-19 02:12:24 +01:00
|
|
|
navigationBar.tintColor = AppAssets.primaryAccentColor
|
|
|
|
|
|
|
|
let toolbarAppearance = UIToolbarAppearance()
|
|
|
|
toolbar.standardAppearance = toolbarAppearance
|
|
|
|
toolbar.compactAppearance = toolbarAppearance
|
|
|
|
toolbar.tintColor = AppAssets.primaryAccentColor
|
|
|
|
}
|
|
|
|
}
|