mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
90 lines
2.9 KiB
Swift
90 lines
2.9 KiB
Swift
//
|
|
// 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
|
|
}
|
|
|
|
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
|
super.traitCollectionDidChange(previousTraitCollection)
|
|
if traitCollection.userInterfaceStyle != previousTraitCollection?.userInterfaceStyle {
|
|
configure()
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: Private
|
|
|
|
private extension InteractiveNavigationController {
|
|
|
|
func configure() {
|
|
isToolbarHidden = false
|
|
|
|
// Standard appearance with system background
|
|
let standardAppearance = UINavigationBarAppearance()
|
|
standardAppearance.backgroundColor = .clear
|
|
standardAppearance.shadowColor = nil
|
|
standardAppearance.titleTextAttributes = [
|
|
.foregroundColor: UIColor.label,
|
|
.font: UIFont.systemFont(ofSize: UIFont.preferredFont(forTextStyle: .body).pointSize, weight: .heavy)
|
|
]
|
|
standardAppearance.largeTitleTextAttributes = [
|
|
.foregroundColor: UIColor.label,
|
|
.font: UIFont.systemFont(ofSize: UIFont.preferredFont(forTextStyle: .largeTitle).pointSize - 3, weight: .black)
|
|
]
|
|
|
|
let scrollEdgeAppearance = UINavigationBarAppearance()
|
|
scrollEdgeAppearance.backgroundColor = .systemBackground
|
|
scrollEdgeAppearance.shadowColor = nil
|
|
scrollEdgeAppearance.titleTextAttributes = [
|
|
.foregroundColor: UIColor.label,
|
|
.font: UIFont.systemFont(ofSize: UIFont.preferredFont(forTextStyle: .body).pointSize, weight: .heavy)
|
|
]
|
|
scrollEdgeAppearance.largeTitleTextAttributes = [
|
|
.foregroundColor: UIColor.label,
|
|
.font: UIFont.systemFont(ofSize: UIFont.preferredFont(forTextStyle: .largeTitle).pointSize - 3, weight: .black)
|
|
]
|
|
|
|
|
|
navigationBar.standardAppearance = standardAppearance
|
|
navigationBar.scrollEdgeAppearance = scrollEdgeAppearance
|
|
navigationBar.compactAppearance = standardAppearance
|
|
navigationBar.compactScrollEdgeAppearance = scrollEdgeAppearance
|
|
|
|
|
|
let toolbarAppearance = UIToolbarAppearance()
|
|
toolbarAppearance.shadowColor = nil
|
|
toolbar.standardAppearance = toolbarAppearance
|
|
toolbar.compactAppearance = nil
|
|
toolbar.scrollEdgeAppearance = nil
|
|
toolbar.tintColor = AppAssets.primaryAccentColor
|
|
}
|
|
|
|
}
|