mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Continue progress on modern look.
This commit is contained in:
@@ -35,7 +35,7 @@ extension AppColor {
|
||||
extension AppColor {
|
||||
|
||||
#if os(iOS)
|
||||
static var barColor = UIColor(hex: "#708090")
|
||||
static var barColor = UIColor(hex: "#7080A0")
|
||||
static var controlBackground = color("controlBackgroundColor")
|
||||
static var fullScreenBackground = color("fullScreenBackgroundColor")
|
||||
static var iconBackground = color("iconBackgroundColor")
|
||||
|
||||
@@ -15,7 +15,7 @@ final class MainWindowController {
|
||||
|
||||
let rootSplitViewController: RootSplitViewController
|
||||
let sidebarViewController = SidebarViewController()
|
||||
let timelineViewController = TimelineViewController()
|
||||
let timelineViewController = TimelineCollectionViewController()
|
||||
let articleViewController = ArticleViewController()
|
||||
|
||||
let coordinator: SceneCoordinator
|
||||
@@ -35,11 +35,12 @@ final class MainWindowController {
|
||||
rootSplitViewController.delegate = coordinator
|
||||
self.rootSplitViewController = rootSplitViewController
|
||||
|
||||
sidebarViewController.delegate = self
|
||||
|
||||
window.rootViewController = rootSplitViewController
|
||||
|
||||
window.tintColor = AppColor.accent
|
||||
updateUserInterfaceStyle()
|
||||
UINavigationBar.appearance().scrollEdgeAppearance = UINavigationBarAppearance()
|
||||
|
||||
window.makeKeyAndVisible()
|
||||
|
||||
@@ -74,6 +75,21 @@ final class MainWindowController {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - SidebarViewControllerDelegate
|
||||
|
||||
extension MainWindowController: SidebarViewControllerDelegate {
|
||||
|
||||
func sidebarViewController(_: SidebarViewController, didSelect items: [any Item]) {
|
||||
timelineViewController.items = items
|
||||
rootSplitViewController.show(.supplementary)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - UISplitViewControllerDelegate
|
||||
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private extension MainWindowController {
|
||||
|
||||
func updateUserInterfaceStyle() {
|
||||
|
||||
@@ -14,17 +14,17 @@ final class RootSplitViewController: UISplitViewController {
|
||||
var coordinator: SceneCoordinator! {
|
||||
didSet {
|
||||
// sidebarViewController.coordinator = coordinator
|
||||
timelineViewController.coordinator = coordinator
|
||||
// timelineViewController.coordinator = coordinator
|
||||
articleViewController.coordinator = coordinator
|
||||
}
|
||||
}
|
||||
|
||||
private let sidebarViewController: SidebarViewController
|
||||
private let timelineViewController: TimelineViewController
|
||||
private let timelineViewController: TimelineCollectionViewController
|
||||
private let articleViewController: ArticleViewController
|
||||
|
||||
init(sidebarViewController: SidebarViewController,
|
||||
timelineViewController: TimelineViewController,
|
||||
timelineViewController: TimelineCollectionViewController,
|
||||
articleViewController: ArticleViewController) {
|
||||
|
||||
self.sidebarViewController = sidebarViewController
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -26,7 +24,7 @@
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7mJ-VZ-zqU">
|
||||
<rect key="frame" x="214" y="34" width="33" height="22"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
|
||||
<color key="textColor" systemColor="secondaryLabelColor"/>
|
||||
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
@@ -53,9 +51,4 @@
|
||||
<point key="canvasLocation" x="-75" y="-117"/>
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<systemColor name="secondaryLabelColor">
|
||||
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
</resources>
|
||||
</document>
|
||||
|
||||
@@ -10,8 +10,15 @@ import Foundation
|
||||
import UIKit
|
||||
import Account
|
||||
|
||||
protocol SidebarViewControllerDelegate: AnyObject {
|
||||
|
||||
func sidebarViewController(_: SidebarViewController, didSelect: [any Item])
|
||||
}
|
||||
|
||||
final class SidebarViewController: UICollectionViewController {
|
||||
|
||||
weak var delegate: SidebarViewControllerDelegate?
|
||||
|
||||
private let tree = SidebarTree()
|
||||
|
||||
typealias DataSource = UICollectionViewDiffableDataSource<SectionID, ItemID>
|
||||
@@ -63,20 +70,7 @@ final class SidebarViewController: UICollectionViewController {
|
||||
|
||||
title = "Feeds"
|
||||
navigationController?.navigationBar.prefersLargeTitles = true
|
||||
|
||||
let appearance = UINavigationBarAppearance()
|
||||
appearance.configureWithOpaqueBackground() // Ensures solid background
|
||||
appearance.backgroundColor = AppColor.navigationBarBackground // Set your desired color
|
||||
appearance.titleTextAttributes = [.foregroundColor: UIColor.white] // Regular title text
|
||||
appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white] // Large title text
|
||||
appearance.shadowColor = .clear
|
||||
|
||||
// Apply the appearance settings
|
||||
navigationController?.navigationBar.standardAppearance = appearance
|
||||
navigationController?.navigationBar.scrollEdgeAppearance = appearance
|
||||
navigationController?.navigationBar.compactAppearance = appearance // Optional
|
||||
navigationController?.navigationBar.compactScrollEdgeAppearance = appearance
|
||||
|
||||
navigationController?.navigationBar.tintColor = .white
|
||||
navigationController?.navigationBar.isTranslucent = false
|
||||
|
||||
if let subviews = navigationController?.navigationBar.subviews {
|
||||
@@ -88,8 +82,10 @@ final class SidebarViewController: UICollectionViewController {
|
||||
}
|
||||
|
||||
navigationItem.rightBarButtonItem = filterButton
|
||||
|
||||
navigationItem.largeTitleDisplayMode = .always
|
||||
|
||||
toolbar.barTintColor = AppColor.toolbarBackground
|
||||
toolbar.tintColor = .white
|
||||
toolbar.isTranslucent = false
|
||||
toolbar.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
@@ -124,24 +120,37 @@ final class SidebarViewController: UICollectionViewController {
|
||||
collectionView.verticalScrollIndicatorInsets.bottom = toolbarHeight
|
||||
}
|
||||
|
||||
func updateVisibleRows() {
|
||||
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
|
||||
var itemIDsToReload = [ItemID]()
|
||||
|
||||
for indexPath in collectionView.indexPathsForVisibleItems {
|
||||
if let itemID = dataSource.itemIdentifier(for: indexPath) {
|
||||
itemIDsToReload.append(itemID)
|
||||
}
|
||||
guard let itemID = dataSource.itemIdentifier(for: indexPath) else {
|
||||
assertionFailure("Expected itemID for indexPath \(indexPath).")
|
||||
return
|
||||
}
|
||||
guard let item = tree.item(with: itemID) else {
|
||||
assertionFailure("Expected item for itemID \(itemID).")
|
||||
return
|
||||
}
|
||||
|
||||
if !itemIDsToReload.isEmpty {
|
||||
var snapshot = dataSource.snapshot()
|
||||
snapshot.reloadItems(itemIDsToReload)
|
||||
dataSource.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
delegate?.sidebarViewController(self, didSelect: [item])
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
// TODO: Implement actions
|
||||
|
||||
extension SidebarViewController {
|
||||
|
||||
@objc func toggleFilter(_ sender: Any) {
|
||||
}
|
||||
|
||||
// MARK: - Notifications
|
||||
@objc func showSettings(_ sender: Any?) {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Notifications
|
||||
|
||||
private extension SidebarViewController {
|
||||
|
||||
@objc func faviconDidBecomeAvailable(_ note: Notification) {
|
||||
updateVisibleRows()
|
||||
@@ -160,18 +169,7 @@ final class SidebarViewController: UICollectionViewController {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
// TODO: Implement actions
|
||||
|
||||
extension SidebarViewController {
|
||||
|
||||
@objc func toggleFilter(_ sender: Any) {
|
||||
}
|
||||
|
||||
@objc func showSettings(_ sender: Any?) {
|
||||
}
|
||||
}
|
||||
// MARK: - Private
|
||||
|
||||
private extension SidebarViewController {
|
||||
|
||||
@@ -252,4 +250,21 @@ private extension SidebarViewController {
|
||||
|
||||
dataSource.apply(snapshot, animatingDifferences: true)
|
||||
}
|
||||
|
||||
func updateVisibleRows() {
|
||||
|
||||
var itemIDsToReload = [ItemID]()
|
||||
|
||||
for indexPath in collectionView.indexPathsForVisibleItems {
|
||||
if let itemID = dataSource.itemIdentifier(for: indexPath) {
|
||||
itemIDsToReload.append(itemID)
|
||||
}
|
||||
}
|
||||
|
||||
if !itemIDsToReload.isEmpty {
|
||||
var snapshot = dataSource.snapshot()
|
||||
snapshot.reloadItems(itemIDsToReload)
|
||||
dataSource.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,14 @@ final class TimelineArticlesManager {
|
||||
|
||||
final class TimelineCollectionViewController: UICollectionViewController {
|
||||
|
||||
var items = [any Item]() {
|
||||
didSet {
|
||||
updateTitle()
|
||||
}
|
||||
}
|
||||
|
||||
private static var defaultTitle = "Articles" // ToDo: localize
|
||||
|
||||
private let timelineArticlesManager = TimelineArticlesManager()
|
||||
|
||||
typealias DataSource = UICollectionViewDiffableDataSource<TimelineSectionID, TimelineArticleID>
|
||||
@@ -90,7 +98,8 @@ final class TimelineCollectionViewController: UICollectionViewController {
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
title = "Articles"
|
||||
navigationItem.largeTitleDisplayMode = .never
|
||||
updateTitle()
|
||||
|
||||
collectionView.register(TimelineCell.self, forCellWithReuseIdentifier: TimelineCell.reuseIdentifier)
|
||||
|
||||
@@ -122,4 +131,8 @@ private extension TimelineCollectionViewController {
|
||||
|
||||
dataSource.apply(snapshot, animatingDifferences: true)
|
||||
}
|
||||
|
||||
func updateTitle() {
|
||||
title = items.first?.title ?? Self.defaultTitle
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user