mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Create shared AppDefaults and delete platform-specific AppDefaults.
This commit is contained in:
@@ -25,7 +25,7 @@ final class AddFolderViewController: UITableViewController {
|
||||
|
||||
private var accounts: [Account]! {
|
||||
didSet {
|
||||
if let predefinedAccount = accounts.first(where: { $0.accountID == AppDefaults.shared.addFolderAccountID }) {
|
||||
if let predefinedAccount = accounts.first(where: { $0.accountID == AppDefaults.addFolderAccountID }) {
|
||||
selectedAccount = predefinedAccount
|
||||
} else {
|
||||
selectedAccount = accounts[0]
|
||||
@@ -67,7 +67,7 @@ final class AddFolderViewController: UITableViewController {
|
||||
}
|
||||
|
||||
private func didSelect(_ account: Account) {
|
||||
AppDefaults.shared.addFolderAccountID = account.accountID
|
||||
AppDefaults.addFolderAccountID = account.accountID
|
||||
selectedAccount = account
|
||||
}
|
||||
|
||||
|
||||
@@ -1,293 +0,0 @@
|
||||
//
|
||||
// AppDefaults.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Brent Simmons on 9/22/17.
|
||||
// Copyright © 2017 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
enum UserInterfaceColorPalette: Int, CustomStringConvertible, CaseIterable {
|
||||
case automatic = 0
|
||||
case light = 1
|
||||
case dark = 2
|
||||
|
||||
var description: String {
|
||||
switch self {
|
||||
case .automatic:
|
||||
return NSLocalizedString("Automatic", comment: "Automatic")
|
||||
case .light:
|
||||
return NSLocalizedString("Light", comment: "Light")
|
||||
case .dark:
|
||||
return NSLocalizedString("Dark", comment: "Dark")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final class AppDefaults {
|
||||
|
||||
static let defaultThemeName = "Default"
|
||||
|
||||
static let shared = AppDefaults()
|
||||
private init() {}
|
||||
|
||||
static var store: UserDefaults = {
|
||||
let appIdentifierPrefix = Bundle.main.object(forInfoDictionaryKey: "AppIdentifierPrefix") as! String
|
||||
let suiteName = "\(appIdentifierPrefix)group.\(Bundle.main.bundleIdentifier!)"
|
||||
return UserDefaults.init(suiteName: suiteName)!
|
||||
}()
|
||||
|
||||
let isDeveloperBuild: Bool = {
|
||||
if let dev = Bundle.main.object(forInfoDictionaryKey: "DeveloperEntitlements") as? String, dev == "-dev" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}()
|
||||
|
||||
let isFirstRun: Bool = {
|
||||
if AppDefaults.store.object(forKey: AppDefaultsKey.firstRunDate) as? Date == nil {
|
||||
firstRunDate = Date()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}()
|
||||
|
||||
static var userInterfaceColorPalette: UserInterfaceColorPalette {
|
||||
get {
|
||||
if let result = UserInterfaceColorPalette(rawValue: int(for: AppDefaultsKey.userInterfaceColorPalette)) {
|
||||
return result
|
||||
}
|
||||
return .automatic
|
||||
}
|
||||
set {
|
||||
setInt(for: AppDefaultsKey.userInterfaceColorPalette, newValue.rawValue)
|
||||
}
|
||||
}
|
||||
|
||||
var addFeedAccountID: String? {
|
||||
get {
|
||||
return AppDefaults.string(for: AppDefaultsKey.addFeedAccountID)
|
||||
}
|
||||
set {
|
||||
AppDefaults.setString(for: AppDefaultsKey.addFeedAccountID, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
var addFeedFolderName: String? {
|
||||
get {
|
||||
return AppDefaults.string(for: AppDefaultsKey.addFeedFolderName)
|
||||
}
|
||||
set {
|
||||
AppDefaults.setString(for: AppDefaultsKey.addFeedFolderName, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
var addFolderAccountID: String? {
|
||||
get {
|
||||
return AppDefaults.string(for: AppDefaultsKey.addFolderAccountID)
|
||||
}
|
||||
set {
|
||||
AppDefaults.setString(for: AppDefaultsKey.addFolderAccountID, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
var useSystemBrowser: Bool {
|
||||
get {
|
||||
return UserDefaults.standard.bool(forKey: AppDefaultsKey.useSystemBrowser)
|
||||
}
|
||||
set {
|
||||
UserDefaults.standard.setValue(newValue, forKey: AppDefaultsKey.useSystemBrowser)
|
||||
}
|
||||
}
|
||||
|
||||
var lastImageCacheFlushDate: Date? {
|
||||
get {
|
||||
return AppDefaults.date(for: AppDefaultsKey.lastImageCacheFlushDate)
|
||||
}
|
||||
set {
|
||||
AppDefaults.setDate(for: AppDefaultsKey.lastImageCacheFlushDate, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
var timelineGroupByFeed: Bool {
|
||||
get {
|
||||
return AppDefaults.bool(for: AppDefaultsKey.timelineGroupByFeed)
|
||||
}
|
||||
set {
|
||||
AppDefaults.setBool(for: AppDefaultsKey.timelineGroupByFeed, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
var refreshClearsReadArticles: Bool {
|
||||
get {
|
||||
return AppDefaults.bool(for: AppDefaultsKey.refreshClearsReadArticles)
|
||||
}
|
||||
set {
|
||||
AppDefaults.setBool(for: AppDefaultsKey.refreshClearsReadArticles, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
var timelineSortDirection: ComparisonResult {
|
||||
get {
|
||||
return AppDefaults.sortDirection(for: AppDefaultsKey.timelineSortDirection)
|
||||
}
|
||||
set {
|
||||
AppDefaults.setSortDirection(for: AppDefaultsKey.timelineSortDirection, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
var articleFullscreenAvailable: Bool {
|
||||
get {
|
||||
return AppDefaults.bool(for: AppDefaultsKey.articleFullscreenAvailable)
|
||||
}
|
||||
set {
|
||||
AppDefaults.setBool(for: AppDefaultsKey.articleFullscreenAvailable, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
var articleFullscreenEnabled: Bool {
|
||||
get {
|
||||
return articleFullscreenAvailable && AppDefaults.bool(for: AppDefaultsKey.articleFullscreenEnabled)
|
||||
}
|
||||
set {
|
||||
AppDefaults.setBool(for: AppDefaultsKey.articleFullscreenEnabled, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
var logicalArticleFullscreenEnabled: Bool {
|
||||
articleFullscreenAvailable && articleFullscreenEnabled
|
||||
}
|
||||
|
||||
var confirmMarkAllAsRead: Bool {
|
||||
get {
|
||||
return AppDefaults.bool(for: AppDefaultsKey.confirmMarkAllAsRead)
|
||||
}
|
||||
set {
|
||||
AppDefaults.setBool(for: AppDefaultsKey.confirmMarkAllAsRead, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
var lastRefresh: Date? {
|
||||
get {
|
||||
return AppDefaults.date(for: AppDefaultsKey.lastRefresh)
|
||||
}
|
||||
set {
|
||||
AppDefaults.setDate(for: AppDefaultsKey.lastRefresh, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
var timelineNumberOfLines: Int {
|
||||
get {
|
||||
return AppDefaults.int(for: AppDefaultsKey.timelineNumberOfLines)
|
||||
}
|
||||
set {
|
||||
AppDefaults.setInt(for: AppDefaultsKey.timelineNumberOfLines, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
var timelineIconSize: IconSize {
|
||||
get {
|
||||
let rawValue = AppDefaults.store.integer(forKey: AppDefaultsKey.timelineIconDimension)
|
||||
return IconSize(rawValue: rawValue) ?? IconSize.medium
|
||||
}
|
||||
set {
|
||||
AppDefaults.store.set(newValue.rawValue, forKey: AppDefaultsKey.timelineIconDimension)
|
||||
}
|
||||
}
|
||||
|
||||
var currentThemeName: String? {
|
||||
get {
|
||||
return AppDefaults.string(for: AppDefaultsKey.currentThemeName)
|
||||
}
|
||||
set {
|
||||
AppDefaults.setString(for: AppDefaultsKey.currentThemeName, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
var isArticleContentJavascriptEnabled: Bool {
|
||||
get {
|
||||
UserDefaults.standard.bool(forKey: AppDefaultsKey.articleContentJavascriptEnabled)
|
||||
}
|
||||
set {
|
||||
UserDefaults.standard.set(newValue, forKey: AppDefaultsKey.articleContentJavascriptEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
static func registerDefaults() {
|
||||
let defaults: [String: Any] = [AppDefaultsKey.userInterfaceColorPalette: UserInterfaceColorPalette.automatic.rawValue,
|
||||
AppDefaultsKey.timelineGroupByFeed: false,
|
||||
AppDefaultsKey.refreshClearsReadArticles: false,
|
||||
AppDefaultsKey.timelineNumberOfLines: 2,
|
||||
AppDefaultsKey.timelineIconDimension: IconSize.medium.rawValue,
|
||||
AppDefaultsKey.timelineSortDirection: ComparisonResult.orderedDescending.rawValue,
|
||||
AppDefaultsKey.articleFullscreenAvailable: false,
|
||||
AppDefaultsKey.articleFullscreenEnabled: false,
|
||||
AppDefaultsKey.confirmMarkAllAsRead: true,
|
||||
AppDefaultsKey.currentThemeName: Self.defaultThemeName]
|
||||
AppDefaults.store.register(defaults: defaults)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private extension AppDefaults {
|
||||
|
||||
static var firstRunDate: Date? {
|
||||
get {
|
||||
return date(for: AppDefaultsKey.firstRunDate)
|
||||
}
|
||||
set {
|
||||
setDate(for: AppDefaultsKey.firstRunDate, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static func string(for key: String) -> String? {
|
||||
return UserDefaults.standard.string(forKey: key)
|
||||
}
|
||||
|
||||
static func setString(for key: String, _ value: String?) {
|
||||
UserDefaults.standard.set(value, forKey: key)
|
||||
}
|
||||
|
||||
static func bool(for key: String) -> Bool {
|
||||
return AppDefaults.store.bool(forKey: key)
|
||||
}
|
||||
|
||||
static func setBool(for key: String, _ flag: Bool) {
|
||||
AppDefaults.store.set(flag, forKey: key)
|
||||
}
|
||||
|
||||
static func int(for key: String) -> Int {
|
||||
return AppDefaults.store.integer(forKey: key)
|
||||
}
|
||||
|
||||
static func setInt(for key: String, _ x: Int) {
|
||||
AppDefaults.store.set(x, forKey: key)
|
||||
}
|
||||
|
||||
static func date(for key: String) -> Date? {
|
||||
return AppDefaults.store.object(forKey: key) as? Date
|
||||
}
|
||||
|
||||
static func setDate(for key: String, _ date: Date?) {
|
||||
AppDefaults.store.set(date, forKey: key)
|
||||
}
|
||||
|
||||
static func sortDirection(for key: String) -> ComparisonResult {
|
||||
let rawInt = int(for: key)
|
||||
if rawInt == ComparisonResult.orderedAscending.rawValue {
|
||||
return .orderedAscending
|
||||
}
|
||||
return .orderedDescending
|
||||
}
|
||||
|
||||
static func setSortDirection(for key: String, _ value: ComparisonResult) {
|
||||
if value == .orderedAscending {
|
||||
setInt(for: key, ComparisonResult.orderedAscending.rawValue)
|
||||
} else {
|
||||
setInt(for: key, ComparisonResult.orderedDescending.rawValue)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -76,7 +76,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationC
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
AppDefaults.registerDefaults()
|
||||
|
||||
let isFirstRun = AppDefaults.shared.isFirstRun
|
||||
let isFirstRun = AppDefaults.isFirstRun
|
||||
if isFirstRun {
|
||||
logger.info("Is first run.")
|
||||
}
|
||||
@@ -148,7 +148,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationC
|
||||
}
|
||||
|
||||
@objc func accountRefreshDidFinish(_ note: Notification) {
|
||||
AppDefaults.shared.lastRefresh = Date()
|
||||
AppDefaults.lastRefresh = Date()
|
||||
}
|
||||
|
||||
// MARK: - API
|
||||
@@ -180,7 +180,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationC
|
||||
extensionFeedAddRequestFile.resume()
|
||||
syncTimer?.update()
|
||||
|
||||
if let lastRefresh = AppDefaults.shared.lastRefresh {
|
||||
if let lastRefresh = AppDefaults.lastRefresh {
|
||||
if Date() > lastRefresh.addingTimeInterval(15 * 60) {
|
||||
AccountManager.shared.refreshAll(errorHandler: ErrorHandler.log)
|
||||
} else {
|
||||
|
||||
@@ -149,7 +149,7 @@ final class ArticleViewController: UIViewController {
|
||||
articleExtractorButton.buttonState = controller.articleExtractorButtonState
|
||||
|
||||
self.pageViewController.setViewControllers([controller], direction: .forward, animated: false, completion: nil)
|
||||
if AppDefaults.shared.logicalArticleFullscreenEnabled {
|
||||
if AppDefaults.logicalArticleFullscreenEnabled {
|
||||
controller.hideBars()
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ final class ArticleViewController: UIViewController {
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
let hideToolbars = AppDefaults.shared.logicalArticleFullscreenEnabled
|
||||
let hideToolbars = AppDefaults.logicalArticleFullscreenEnabled
|
||||
if hideToolbars {
|
||||
currentWebViewController?.hideBars()
|
||||
} else {
|
||||
@@ -219,7 +219,7 @@ final class ArticleViewController: UIViewController {
|
||||
starBarButtonItem.isEnabled = true
|
||||
|
||||
let permalinkPresent = article.preferredLink != nil
|
||||
articleExtractorButton.isEnabled = permalinkPresent && !AppDefaults.shared.isDeveloperBuild
|
||||
articleExtractorButton.isEnabled = permalinkPresent && !AppDefaults.isDeveloperBuild
|
||||
actionBarButtonItem.isEnabled = permalinkPresent
|
||||
|
||||
if article.status.read {
|
||||
@@ -265,7 +265,7 @@ final class ArticleViewController: UIViewController {
|
||||
|
||||
@objc func willEnterForeground(_ note: Notification) {
|
||||
// The toolbar will come back on you if you don't hide it again
|
||||
if AppDefaults.shared.logicalArticleFullscreenEnabled {
|
||||
if AppDefaults.logicalArticleFullscreenEnabled {
|
||||
currentWebViewController?.hideBars()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ final class WebViewController: UIViewController {
|
||||
|
||||
private lazy var contextMenuInteraction = UIContextMenuInteraction(delegate: self)
|
||||
private var isFullScreenAvailable: Bool {
|
||||
return AppDefaults.shared.articleFullscreenAvailable && traitCollection.userInterfaceIdiom == .phone && coordinator.isRootSplitCollapsed
|
||||
return AppDefaults.articleFullscreenAvailable && traitCollection.userInterfaceIdiom == .phone && coordinator.isRootSplitCollapsed
|
||||
}
|
||||
private lazy var articleIconSchemeHandler = ArticleIconSchemeHandler(delegate: self)
|
||||
private lazy var transition = ImageTransition(controller: self)
|
||||
@@ -197,7 +197,7 @@ final class WebViewController: UIViewController {
|
||||
}
|
||||
|
||||
func showBars() {
|
||||
AppDefaults.shared.articleFullscreenEnabled = false
|
||||
AppDefaults.articleFullscreenEnabled = false
|
||||
coordinator.showStatusBar()
|
||||
topShowBarsViewConstraint?.constant = 0
|
||||
bottomShowBarsViewConstraint?.constant = 0
|
||||
@@ -208,7 +208,7 @@ final class WebViewController: UIViewController {
|
||||
|
||||
func hideBars() {
|
||||
if isFullScreenAvailable {
|
||||
AppDefaults.shared.articleFullscreenEnabled = true
|
||||
AppDefaults.articleFullscreenEnabled = true
|
||||
coordinator.hideStatusBar()
|
||||
topShowBarsViewConstraint?.constant = -44.0
|
||||
bottomShowBarsViewConstraint?.constant = 44.0
|
||||
@@ -271,7 +271,7 @@ final class WebViewController: UIViewController {
|
||||
|
||||
func openInAppBrowser() {
|
||||
guard let url = article?.preferredURL else { return }
|
||||
if AppDefaults.shared.useSystemBrowser {
|
||||
if AppDefaults.useSystemBrowser {
|
||||
UIApplication.shared.open(url, options: [:])
|
||||
} else {
|
||||
openURLInSafariViewController(url)
|
||||
@@ -381,7 +381,7 @@ extension WebViewController: WKNavigationDelegate {
|
||||
let components = URLComponents(url: url, resolvingAgainstBaseURL: false)
|
||||
if components?.scheme == "http" || components?.scheme == "https" {
|
||||
decisionHandler(.cancel)
|
||||
if AppDefaults.shared.useSystemBrowser {
|
||||
if AppDefaults.useSystemBrowser {
|
||||
UIApplication.shared.open(url, options: [:])
|
||||
} else {
|
||||
UIApplication.shared.open(url, options: [.universalLinksOnly: true]) { didOpen in
|
||||
@@ -674,7 +674,7 @@ private extension WebViewController {
|
||||
topShowBarsView.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(topShowBarsView)
|
||||
|
||||
if AppDefaults.shared.logicalArticleFullscreenEnabled {
|
||||
if AppDefaults.logicalArticleFullscreenEnabled {
|
||||
topShowBarsViewConstraint = view.topAnchor.constraint(equalTo: topShowBarsView.bottomAnchor, constant: -44.0)
|
||||
} else {
|
||||
topShowBarsViewConstraint = view.topAnchor.constraint(equalTo: topShowBarsView.bottomAnchor, constant: 0.0)
|
||||
@@ -694,7 +694,7 @@ private extension WebViewController {
|
||||
topShowBarsView.backgroundColor = .clear
|
||||
bottomShowBarsView.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(bottomShowBarsView)
|
||||
if AppDefaults.shared.logicalArticleFullscreenEnabled {
|
||||
if AppDefaults.logicalArticleFullscreenEnabled {
|
||||
bottomShowBarsViewConstraint = view.bottomAnchor.constraint(equalTo: bottomShowBarsView.topAnchor, constant: 44.0)
|
||||
} else {
|
||||
bottomShowBarsViewConstraint = view.bottomAnchor.constraint(equalTo: bottomShowBarsView.topAnchor, constant: 0.0)
|
||||
|
||||
@@ -30,7 +30,7 @@ struct MarkAsReadAlertController {
|
||||
return
|
||||
}
|
||||
|
||||
if AppDefaults.shared.confirmMarkAllAsRead {
|
||||
if AppDefaults.confirmMarkAllAsRead {
|
||||
let alertController = MarkAsReadAlertController.alert(coordinator: coordinator, confirmTitle: confirmTitle, cancelCompletion: cancelCompletion, sourceType: sourceType) { _ in
|
||||
completion()
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ final class TimelineViewController: UITableViewController, UndoableCommandRunner
|
||||
tableView.dataSource = dataSource
|
||||
tableView.isPrefetchingEnabled = false
|
||||
|
||||
numberOfTextLines = AppDefaults.shared.timelineNumberOfLines
|
||||
iconSize = AppDefaults.shared.timelineIconSize
|
||||
numberOfTextLines = AppDefaults.timelineNumberOfLines
|
||||
iconSize = AppDefaults.timelineIconSize
|
||||
resetEstimatedRowHeight()
|
||||
|
||||
if let titleView = Bundle.main.loadNibNamed("MainTimelineTitleView", owner: self, options: nil)?[0] as? MainTimelineTitleView {
|
||||
@@ -510,9 +510,9 @@ final class TimelineViewController: UITableViewController, UndoableCommandRunner
|
||||
|
||||
@objc func userDefaultsDidChange(_ note: Notification) {
|
||||
DispatchQueue.main.async {
|
||||
if self.numberOfTextLines != AppDefaults.shared.timelineNumberOfLines || self.iconSize != AppDefaults.shared.timelineIconSize {
|
||||
self.numberOfTextLines = AppDefaults.shared.timelineNumberOfLines
|
||||
self.iconSize = AppDefaults.shared.timelineIconSize
|
||||
if self.numberOfTextLines != AppDefaults.timelineNumberOfLines || self.iconSize != AppDefaults.timelineIconSize {
|
||||
self.numberOfTextLines = AppDefaults.timelineNumberOfLines
|
||||
self.iconSize = AppDefaults.timelineIconSize
|
||||
self.resetEstimatedRowHeight()
|
||||
self.reloadAllVisibleCells()
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner {
|
||||
var isTimelineViewControllerPending = false
|
||||
var isArticleViewControllerPending = false
|
||||
|
||||
private(set) var sortDirection = AppDefaults.shared.timelineSortDirection {
|
||||
private(set) var sortDirection = AppDefaults.timelineSortDirection {
|
||||
didSet {
|
||||
if sortDirection != oldValue {
|
||||
sortParametersDidChange()
|
||||
@@ -89,7 +89,7 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner {
|
||||
}
|
||||
}
|
||||
|
||||
private(set) var groupByFeed = AppDefaults.shared.timelineGroupByFeed {
|
||||
private(set) var groupByFeed = AppDefaults.timelineGroupByFeed {
|
||||
didSet {
|
||||
if groupByFeed != oldValue {
|
||||
sortParametersDidChange()
|
||||
@@ -491,8 +491,8 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner {
|
||||
}
|
||||
|
||||
@objc func userDefaultsDidChange(_ note: Notification) {
|
||||
self.sortDirection = AppDefaults.shared.timelineSortDirection
|
||||
self.groupByFeed = AppDefaults.shared.timelineGroupByFeed
|
||||
self.sortDirection = AppDefaults.timelineSortDirection
|
||||
self.groupByFeed = AppDefaults.timelineGroupByFeed
|
||||
}
|
||||
|
||||
@objc func accountDidDownloadArticles(_ note: Notification) {
|
||||
@@ -548,7 +548,7 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner {
|
||||
if isReadFeedsFiltered {
|
||||
rebuildBackingStores()
|
||||
}
|
||||
if isReadArticlesFiltered && (AppDefaults.shared.refreshClearsReadArticles || !conditional) {
|
||||
if isReadArticlesFiltered && (AppDefaults.refreshClearsReadArticles || !conditional) {
|
||||
refreshTimeline(resetScroll: false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
|
||||
Task { @MainActor in
|
||||
// Ensure Feeds view shows on first run on iPad — otherwise the UI is empty.
|
||||
if UIDevice.current.userInterfaceIdiom == .pad && AppDefaults.shared.isFirstRun {
|
||||
if UIDevice.current.userInterfaceIdiom == .pad && AppDefaults.isFirstRun {
|
||||
rootViewController.show(.primary)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ final class AddAccountViewController: UITableViewController, AddAccountDismissDe
|
||||
case AddAccountSections.icloud.rawValue:
|
||||
cell.comboNameLabel?.text = AddAccountSections.icloud.sectionContent[indexPath.row].localizedAccountName()
|
||||
cell.comboImage?.image = AppAssets.image(for: AddAccountSections.icloud.sectionContent[indexPath.row])
|
||||
if AppDefaults.shared.isDeveloperBuild || AccountManager.shared.accounts.contains(where: { $0.type == .cloudKit }) {
|
||||
if AppDefaults.isDeveloperBuild || AccountManager.shared.accounts.contains(where: { $0.type == .cloudKit }) {
|
||||
cell.isUserInteractionEnabled = false
|
||||
cell.comboNameLabel?.isEnabled = false
|
||||
}
|
||||
@@ -139,7 +139,7 @@ final class AddAccountViewController: UITableViewController, AddAccountDismissDe
|
||||
cell.comboNameLabel?.text = AddAccountSections.web.sectionContent[indexPath.row].localizedAccountName()
|
||||
cell.comboImage?.image = AppAssets.image(for: AddAccountSections.web.sectionContent[indexPath.row])
|
||||
let type = AddAccountSections.web.sectionContent[indexPath.row]
|
||||
if (type == .feedly || type == .inoreader) && AppDefaults.shared.isDeveloperBuild {
|
||||
if (type == .feedly || type == .inoreader) && AppDefaults.isDeveloperBuild {
|
||||
cell.isUserInteractionEnabled = false
|
||||
cell.comboNameLabel?.isEnabled = false
|
||||
}
|
||||
|
||||
@@ -49,19 +49,19 @@ final class SettingsViewController: UITableViewController {
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
if AppDefaults.shared.timelineSortDirection == .orderedAscending {
|
||||
if AppDefaults.timelineSortDirection == .orderedAscending {
|
||||
timelineSortOrderSwitch.isOn = true
|
||||
} else {
|
||||
timelineSortOrderSwitch.isOn = false
|
||||
}
|
||||
|
||||
if AppDefaults.shared.timelineGroupByFeed {
|
||||
if AppDefaults.timelineGroupByFeed {
|
||||
groupByFeedSwitch.isOn = true
|
||||
} else {
|
||||
groupByFeedSwitch.isOn = false
|
||||
}
|
||||
|
||||
if AppDefaults.shared.refreshClearsReadArticles {
|
||||
if AppDefaults.refreshClearsReadArticles {
|
||||
refreshClearsReadArticlesSwitch.isOn = true
|
||||
} else {
|
||||
refreshClearsReadArticlesSwitch.isOn = false
|
||||
@@ -69,13 +69,13 @@ final class SettingsViewController: UITableViewController {
|
||||
|
||||
articleThemeDetailLabel.text = ArticleThemesManager.shared.currentTheme.name
|
||||
|
||||
if AppDefaults.shared.confirmMarkAllAsRead {
|
||||
if AppDefaults.confirmMarkAllAsRead {
|
||||
confirmMarkAllAsReadSwitch.isOn = true
|
||||
} else {
|
||||
confirmMarkAllAsReadSwitch.isOn = false
|
||||
}
|
||||
|
||||
if AppDefaults.shared.articleFullscreenAvailable {
|
||||
if AppDefaults.articleFullscreenAvailable {
|
||||
showFullscreenArticlesSwitch.isOn = true
|
||||
} else {
|
||||
showFullscreenArticlesSwitch.isOn = false
|
||||
@@ -83,7 +83,7 @@ final class SettingsViewController: UITableViewController {
|
||||
|
||||
colorPaletteDetailLabel.text = String(describing: AppDefaults.userInterfaceColorPalette)
|
||||
|
||||
openLinksInNetNewsWire.isOn = !AppDefaults.shared.useSystemBrowser
|
||||
openLinksInNetNewsWire.isOn = !AppDefaults.useSystemBrowser
|
||||
|
||||
let buildLabel = NonIntrinsicLabel(frame: CGRect(x: 32.0, y: 0.0, width: 0.0, height: 0.0))
|
||||
buildLabel.font = UIFont.systemFont(ofSize: 11.0)
|
||||
@@ -261,49 +261,49 @@ final class SettingsViewController: UITableViewController {
|
||||
|
||||
@IBAction func switchTimelineOrder(_ sender: Any) {
|
||||
if timelineSortOrderSwitch.isOn {
|
||||
AppDefaults.shared.timelineSortDirection = .orderedAscending
|
||||
AppDefaults.timelineSortDirection = .orderedAscending
|
||||
} else {
|
||||
AppDefaults.shared.timelineSortDirection = .orderedDescending
|
||||
AppDefaults.timelineSortDirection = .orderedDescending
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func switchGroupByFeed(_ sender: Any) {
|
||||
if groupByFeedSwitch.isOn {
|
||||
AppDefaults.shared.timelineGroupByFeed = true
|
||||
AppDefaults.timelineGroupByFeed = true
|
||||
} else {
|
||||
AppDefaults.shared.timelineGroupByFeed = false
|
||||
AppDefaults.timelineGroupByFeed = false
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func switchClearsReadArticles(_ sender: Any) {
|
||||
if refreshClearsReadArticlesSwitch.isOn {
|
||||
AppDefaults.shared.refreshClearsReadArticles = true
|
||||
AppDefaults.refreshClearsReadArticles = true
|
||||
} else {
|
||||
AppDefaults.shared.refreshClearsReadArticles = false
|
||||
AppDefaults.refreshClearsReadArticles = false
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func switchConfirmMarkAllAsRead(_ sender: Any) {
|
||||
if confirmMarkAllAsReadSwitch.isOn {
|
||||
AppDefaults.shared.confirmMarkAllAsRead = true
|
||||
AppDefaults.confirmMarkAllAsRead = true
|
||||
} else {
|
||||
AppDefaults.shared.confirmMarkAllAsRead = false
|
||||
AppDefaults.confirmMarkAllAsRead = false
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func switchFullscreenArticles(_ sender: Any) {
|
||||
if showFullscreenArticlesSwitch.isOn {
|
||||
AppDefaults.shared.articleFullscreenAvailable = true
|
||||
AppDefaults.articleFullscreenAvailable = true
|
||||
} else {
|
||||
AppDefaults.shared.articleFullscreenAvailable = false
|
||||
AppDefaults.articleFullscreenAvailable = false
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func switchBrowserPreference(_ sender: Any) {
|
||||
if openLinksInNetNewsWire.isOn {
|
||||
AppDefaults.shared.useSystemBrowser = false
|
||||
AppDefaults.useSystemBrowser = false
|
||||
} else {
|
||||
AppDefaults.shared.useSystemBrowser = true
|
||||
AppDefaults.useSystemBrowser = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ final class TimelineCustomizerViewController: UIViewController {
|
||||
super.viewDidLoad()
|
||||
|
||||
iconSizeSliderContainerView.layer.cornerRadius = 10
|
||||
iconSizeSlider.value = Float(AppDefaults.shared.timelineIconSize.rawValue)
|
||||
iconSizeSlider.value = Float(AppDefaults.timelineIconSize.rawValue)
|
||||
iconSizeSlider.addTickMarks()
|
||||
|
||||
numberOfLinesSliderContainerView.layer.cornerRadius = 10
|
||||
numberOfLinesSlider.value = Float(AppDefaults.shared.timelineNumberOfLines)
|
||||
numberOfLinesSlider.value = Float(AppDefaults.timelineNumberOfLines)
|
||||
numberOfLinesSlider.addTickMarks()
|
||||
}
|
||||
|
||||
@@ -48,12 +48,12 @@ final class TimelineCustomizerViewController: UIViewController {
|
||||
|
||||
@IBAction func iconSizeChanged(_ sender: Any) {
|
||||
guard let iconSize = IconSize(rawValue: Int(iconSizeSlider.value.rounded())) else { return }
|
||||
AppDefaults.shared.timelineIconSize = iconSize
|
||||
AppDefaults.timelineIconSize = iconSize
|
||||
updatePreview()
|
||||
}
|
||||
|
||||
@IBAction func numberOfLinesChanged(_ sender: Any) {
|
||||
AppDefaults.shared.timelineNumberOfLines = Int(numberOfLinesSlider.value.rounded())
|
||||
AppDefaults.timelineNumberOfLines = Int(numberOfLinesSlider.value.rounded())
|
||||
updatePreview()
|
||||
}
|
||||
|
||||
|
||||
@@ -92,8 +92,8 @@ private extension TimelinePreviewTableViewController {
|
||||
feedName: "Feed Name",
|
||||
byline: nil, iconImage: iconImage,
|
||||
showIcon: true,
|
||||
numberOfLines: AppDefaults.shared.timelineNumberOfLines,
|
||||
iconSize: AppDefaults.shared.timelineIconSize
|
||||
numberOfLines: AppDefaults.timelineNumberOfLines,
|
||||
iconSize: AppDefaults.timelineIconSize
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user