Settings Additions

- Timeline Layout
- Programmatic navigation to Mark All as Read
This commit is contained in:
Stuart Breckenridge
2022-12-04 21:01:32 +08:00
parent f2cda7fcad
commit d6284f6b6c
9 changed files with 34 additions and 29 deletions

View File

@@ -243,7 +243,6 @@ final class AppDefaults: ObservableObject {
}
set {
AppDefaults.setInt(for: Key.timelineNumberOfLines, newValue)
AppDefaults.shared.objectWillChange.send()
}
}
@@ -254,7 +253,6 @@ final class AppDefaults: ObservableObject {
}
set {
AppDefaults.store.set(newValue.rawValue, forKey: Key.timelineIconDimension)
AppDefaults.shared.objectWillChange.send()
}
}

View File

@@ -1130,13 +1130,8 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, Logging {
}
func showSettings(scrollToArticlesSection: Bool = false) {
// let settingsNavController = UIStoryboard.settings.instantiateInitialViewController() as! UINavigationController
// let settingsViewController = settingsNavController.topViewController as! SettingsViewController
// settingsViewController.scrollToArticlesSection = scrollToArticlesSection
// settingsNavController.modalPresentationStyle = .formSheet
// settingsViewController.presentingParentController = rootSplitViewController
// rootSplitViewController.present(settingsNavController, animated: true)
let hostedSettings = UIHostingController(rootView: SettingsView())
var s = scrollToArticlesSection
let hostedSettings = UIHostingController(rootView: SettingsView(isConfigureAppearanceShown: Binding(get: { s }, set: { s = $0 })))
rootSplitViewController.present(hostedSettings, animated: true)
}

View File

@@ -12,7 +12,7 @@ import RSCore
import UIKit
import SwiftUI
struct ArticleThemesViewControllerRepresentable: UIViewControllerRepresentable {
struct ArticleThemesWrapper: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> ArticleThemesTableViewController {
let storyboard = UIStoryboard(name: "Settings", bundle: .main)
let controller = storyboard.instantiateViewController(withIdentifier: "ArticleThemesTableViewController") as! ArticleThemesTableViewController

View File

@@ -933,7 +933,7 @@
<!--Timeline Preview Table View Controller-->
<scene sceneID="k4U-0u-Fgv">
<objects>
<viewController id="vZY-Cd-RuD" customClass="TimelinePreviewTableViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="TimelinePreviewTableViewController" id="vZY-Cd-RuD" customClass="TimelinePreviewTableViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="xMG-o1-VfV">
<rect key="frame" x="0.0" y="0.0" width="300" height="128"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -1079,10 +1079,10 @@
<color key="backgroundColor" systemColor="systemGroupedBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="NotificationsCell" id="guK-h7-1U7" customClass="NotificationsTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="20" y="55.5" width="374" height="44"/>
<rect key="frame" x="20" y="55.5" width="374" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="guK-h7-1U7" id="7Rd-Ur-EwD">
<rect key="frame" x="0.0" y="0.0" width="374" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="374" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ggq-dZ-hv7">
@@ -1093,7 +1093,7 @@
<color key="onTintColor" name="AccentColor"/>
</switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="78k-PU-gKA">
<rect key="frame" x="58" y="11" width="241" height="21.5"/>
<rect key="frame" x="58" y="11" width="241" height="21"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@@ -1124,7 +1124,7 @@
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="OpenSettingsCell" textLabel="5OE-bg-gWy" style="IBUITableViewCellStyleDefault" id="LXf-Fb-We7" customClass="VibrantBasicTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="20" y="99.5" width="374" height="43.5"/>
<rect key="frame" x="20" y="99" width="374" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="LXf-Fb-We7" id="k2T-id-bci">
<rect key="frame" x="0.0" y="0.0" width="374" height="43.5"/>

View File

@@ -7,6 +7,22 @@
//
import UIKit
import SwiftUI
import RSCore
struct TimelineCustomizerWrapper: UIViewControllerRepresentable {
public func makeUIViewController(context: Context) -> TimelineCustomizerViewController {
let controller = UIStoryboard.settings.instantiateController(ofType: TimelineCustomizerViewController.self)
return controller
}
public func updateUIViewController(_ uiViewController: TimelineCustomizerViewController, context: Context) {
//
}
public typealias UIViewControllerType = TimelineCustomizerViewController
}
class TimelineCustomizerViewController: UIViewController {

View File

@@ -23,6 +23,7 @@ struct DisplayAndBehaviorsView: View {
SettingsViewRows.SortOldestToNewest($appDefaults.timelineSortDirectionBool)
SettingsViewRows.GroupByFeed($appDefaults.timelineGroupByFeed)
SettingsViewRows.RefreshToClearReadArticles($appDefaults.refreshClearsReadArticles)
SettingsViewRows.TimelineLayout
}
Section("Article") {

View File

@@ -144,22 +144,15 @@ struct SettingsViewRows {
/// This row, when tapped, will push the the Timeline Layout screen
/// in to view.
static var TimelineLayout: some View {
NavigationLink(destination: NotificationsViewControllerRepresentable()) {
Label {
Text("Timeline Layout")
} icon: {
Image(systemName: "slider.vertical.3")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 25.0, height: 25.0)
}
NavigationLink(destination: TimelineCustomizerWrapper().edgesIgnoringSafeArea(.all).navigationTitle(Text("Timeline Layout"))) {
Text("Timeline Layout")
}
}
/// This row, when tapped, will push the the Theme Selector screen
/// in to view.
static var ThemeSelection: some View {
NavigationLink(destination: ArticleThemesViewControllerRepresentable().edgesIgnoringSafeArea(.all)) {
NavigationLink(destination: ArticleThemesWrapper().edgesIgnoringSafeArea(.all)) {
HStack {
Text("Article Theme")
Spacer()
@@ -192,8 +185,8 @@ struct SettingsViewRows {
/// This row, when tapped, will push the New Article Notifications
/// screen in to view.
static var ConfigureAppearance: some View {
NavigationLink(destination: DisplayAndBehaviorsView()) {
static func ConfigureAppearance(_ isShown: Binding<Bool>) -> some View {
NavigationLink(destination: DisplayAndBehaviorsView(), isActive: isShown) {
Label {
Text("Display & Behaviors")
} icon: {

View File

@@ -15,6 +15,8 @@ struct SettingsView: View {
@StateObject private var appDefaults = AppDefaults.shared
@StateObject private var viewModel = SettingsViewModel()
@Binding var isConfigureAppearanceShown: Bool
var body: some View {
NavigationView {
@@ -34,7 +36,7 @@ struct SettingsView: View {
// Appearance
Section(header: Text("Appearance"), footer: Text("Manage the look, feel, and behavior of NetNewsWire.")) {
SettingsViewRows.ConfigureAppearance
SettingsViewRows.ConfigureAppearance($isConfigureAppearanceShown)
if viewModel.notificationPermissions == .authorized {
SettingsViewRows.ConfigureNewArticleNotifications
}
@@ -49,6 +51,7 @@ struct SettingsView: View {
}
}
.tint(Color(uiColor: AppAssets.primaryAccentColor))
.navigationViewStyle(.stack)
.listStyle(.insetGrouped)
.navigationTitle(Text("Settings"))
.navigationBarTitleDisplayMode(.inline)

View File

@@ -50,7 +50,6 @@ struct NewArticleNotificationsView: View {
get: { webfeed.isNotifyAboutNewArticles ?? false },
set: { webfeed.isNotifyAboutNewArticles = $0 }))
}
}
}