mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Article themes moved to SwiftUI
This commit is contained in:
@@ -34,6 +34,7 @@ final class ArticleThemesManager: NSObject, NSFilePresenter, Logging, Observable
|
||||
do {
|
||||
currentTheme = try articleThemeWithThemeName(newValue)
|
||||
AppDefaults.shared.currentThemeName = newValue
|
||||
objectWillChange.send()
|
||||
} catch {
|
||||
logger.error("Unable to set new theme: \(error.localizedDescription, privacy: .public)")
|
||||
}
|
||||
@@ -51,12 +52,14 @@ final class ArticleThemesManager: NSObject, NSFilePresenter, Logging, Observable
|
||||
}() {
|
||||
didSet {
|
||||
NotificationCenter.default.post(name: .CurrentArticleThemeDidChangeNotification, object: self)
|
||||
objectWillChange.send()
|
||||
}
|
||||
}
|
||||
|
||||
lazy var themeNames = { buildThemeNames() }() {
|
||||
didSet {
|
||||
NotificationCenter.default.post(name: .ArticleThemeNamesDidChangeNotification, object: self)
|
||||
objectWillChange.send()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +105,7 @@ final class ArticleThemesManager: NSObject, NSFilePresenter, Logging, Observable
|
||||
}
|
||||
|
||||
try FileManager.default.copyItem(atPath: filename, toPath: toFilename)
|
||||
objectWillChange.send()
|
||||
}
|
||||
|
||||
func articleThemeWithThemeName(_ themeName: String) throws -> ArticleTheme {
|
||||
@@ -127,6 +131,7 @@ final class ArticleThemesManager: NSObject, NSFilePresenter, Logging, Observable
|
||||
func deleteTheme(themeName: String) {
|
||||
if let filename = pathForThemeName(themeName, folder: folderPath) {
|
||||
try? FileManager.default.removeItem(atPath: filename)
|
||||
objectWillChange.send()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
33
Shared/Importers/NNWThemeDocument.swift
Normal file
33
Shared/Importers/NNWThemeDocument.swift
Normal file
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// NNWThemeDocument.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Stuart Breckenridge on 20/12/2022.
|
||||
// Copyright © 2022 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Account
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
public struct NNWThemeDocument: FileDocument {
|
||||
|
||||
public static var readableContentTypes: [UTType] {
|
||||
UTType.types(tag: "nnwtheme", tagClass: .filenameExtension, conformingTo: nil)
|
||||
}
|
||||
|
||||
public static var writableContentTypes: [UTType] {
|
||||
UTType.types(tag: "nnwtheme", tagClass: .filenameExtension, conformingTo: nil)
|
||||
}
|
||||
|
||||
public init(configuration: ReadConfiguration) throws {
|
||||
|
||||
}
|
||||
|
||||
public func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
|
||||
let wrapper = try FileWrapper(url: URL(string: "")!)
|
||||
return wrapper
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,3 +17,5 @@
|
||||
"ENABLE_EXTENSION_BUTTON_TITLE" = "Enable Extension";
|
||||
"UPDATE_CREDENTIALS_BUTTON_TITLE" = "Update Credentials";
|
||||
"USE_CLOUDKIT_BUTTON_TITLE" = "Use iCloud";
|
||||
"DELETE_THEME_BUTTON_TITLE" = "Delete Theme";
|
||||
"IMPORT_THEME_BUTTON_TITLE" = "Import Theme";
|
||||
|
||||
@@ -43,7 +43,15 @@
|
||||
"TIMELINE_LAYOUT" = "Timeline Layout";
|
||||
"ICON_SIZE" = "Icon Size";
|
||||
"NUMBER_OF_LINES" = "Number of Lines";
|
||||
"INSTALLED_THEMES" = "Installed Themes";
|
||||
"ARTICLE_THEMES_TITLE" = "Article Themes";
|
||||
"ARTICLE_THEME" = "Article Theme";
|
||||
"IMPORT_THEME_CONFIRMATION_TITLE" = "Import Theme";
|
||||
"IMPORT_THEME_CONFIRMATION_MESSAGE_%@_%@" = "Are you sure you want to import “%@” by %@?";
|
||||
"IMPORT_THEME_SUCCESS_TITLE" = "Import Successful";
|
||||
"IMPORT_THEME_SUCCESS_MESSAGE_%@" = "“%@” has been imported successfully.";
|
||||
"DELETE_THEME_ALERT_TITLE_%@" = "Are you sure you want to delete “%@”?";
|
||||
"DELETE_THEME_ALERT_MESSAGE" = "Are you sure you want to delete this theme? This action is not reversible.";
|
||||
"CONFIRM_MARK_ALL_AS_READ" = "Confirm Mark All as Read";
|
||||
"OPEN_LINKS_IN_APP" = "Open Links in NetNewsWire";
|
||||
"SMALL_ICON_SIZE" = "Small";
|
||||
|
||||
Reference in New Issue
Block a user