mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-02 12:06:58 +01:00
Register AppDefaults. Issue #2190
This commit is contained in:
parent
782ae1c5cd
commit
88d03586ae
@ -55,11 +55,11 @@ final class AppDefaults: ObservableObject {
|
||||
static let addWebFeedAccountID = "addWebFeedAccountID"
|
||||
static let addWebFeedFolderName = "addWebFeedFolderName"
|
||||
static let addFolderAccountID = "addFolderAccountID"
|
||||
static let timelineSortDirection = "timelineSortDirection"
|
||||
|
||||
|
||||
static let userInterfaceColorPalette = "userInterfaceColorPalette"
|
||||
static let timelineSortDirection = "timelineSortDirection"
|
||||
static let timelineGroupByFeed = "timelineGroupByFeed"
|
||||
static let timelineIconSize = "timelineIconSize"
|
||||
static let timelineIconDimensions = "timelineIconDimensions"
|
||||
static let timelineNumberOfLines = "timelineNumberOfLines"
|
||||
|
||||
// iOS Defaults
|
||||
@ -178,7 +178,7 @@ final class AppDefaults: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
@AppStorage(wrappedValue: 40.0, Key.timelineIconSize, store: store) var timelineIconSize: Double {
|
||||
@AppStorage(wrappedValue: 40.0, Key.timelineIconDimensions, store: store) var timelineIconDimensions: Double {
|
||||
didSet {
|
||||
objectWillChange.send()
|
||||
}
|
||||
@ -266,6 +266,21 @@ final class AppDefaults: ObservableObject {
|
||||
objectWillChange.send()
|
||||
}
|
||||
}
|
||||
|
||||
static func registerDefaults() {
|
||||
let defaults: [String : Any] = [Key.userInterfaceColorPalette: UserInterfaceColorPalette.automatic.rawValue,
|
||||
Key.timelineGroupByFeed: false,
|
||||
Key.refreshClearsReadArticles: false,
|
||||
Key.timelineNumberOfLines: 2,
|
||||
Key.timelineIconDimensions: 40,
|
||||
Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue,
|
||||
Key.articleFullscreenAvailable: false,
|
||||
Key.articleFullscreenEnabled: false,
|
||||
Key.confirmMarkAllAsRead: true,
|
||||
"NSScrollViewShouldScrollUnderTitlebar": false,
|
||||
Key.refreshInterval: RefreshInterval.everyHour.rawValue]
|
||||
AppDefaults.store.register(defaults: defaults)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ struct TimelineItemView: View {
|
||||
TimelineItemStatusView(status: timelineItem.status)
|
||||
if let image = articleIconImageLoader.image {
|
||||
IconImageView(iconImage: image)
|
||||
.frame(width: CGFloat(defaults.timelineIconSize), height: CGFloat(defaults.timelineIconSize), alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
|
||||
.frame(width: CGFloat(defaults.timelineIconDimensions), height: CGFloat(defaults.timelineIconDimensions), alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
VStack {
|
||||
Text(verbatim: timelineItem.article.title ?? "N/A")
|
||||
|
@ -71,7 +71,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
//AppDefaults.registerDefaults()
|
||||
AppDefaults.registerDefaults()
|
||||
|
||||
let isFirstRun = AppDefaults.shared.isFirstRun()
|
||||
if isFirstRun {
|
||||
|
@ -33,8 +33,8 @@ struct TimelineLayoutView: View {
|
||||
}
|
||||
|
||||
var iconSize: some View {
|
||||
Slider(value: $appSettings.timelineIconSize, in: 20...60, step: 10, minimumValueLabel: Text("Small"), maximumValueLabel: Text("Large"), label: {
|
||||
Text(String(appSettings.timelineIconSize))
|
||||
Slider(value: $appSettings.timelineIconDimensions, in: 20...60, step: 10, minimumValueLabel: Text("Small"), maximumValueLabel: Text("Large"), label: {
|
||||
Text(String(appSettings.timelineIconDimensions))
|
||||
})
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ struct TimelineLayoutView: View {
|
||||
|
||||
Image(systemName: "paperplane.circle")
|
||||
.resizable()
|
||||
.frame(width: CGFloat(appSettings.timelineIconSize), height: CGFloat(appSettings.timelineIconSize), alignment: .top)
|
||||
.frame(width: CGFloat(appSettings.timelineIconDimensions), height: CGFloat(appSettings.timelineIconDimensions), alignment: .top)
|
||||
.foregroundColor(.accentColor)
|
||||
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
|
@ -133,7 +133,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
||||
}
|
||||
#endif
|
||||
|
||||
//AppDefaults.registerDefaults()
|
||||
AppDefaults.registerDefaults()
|
||||
let isFirstRun = AppDefaults.shared.isFirstRun()
|
||||
if isFirstRun {
|
||||
os_log(.debug, log: log, "Is first run.")
|
||||
|
@ -45,7 +45,7 @@ final class AppDefaults {
|
||||
static let timelineGroupByFeed = "timelineGroupByFeed"
|
||||
static let refreshClearsReadArticles = "refreshClearsReadArticles"
|
||||
static let timelineNumberOfLines = "timelineNumberOfLines"
|
||||
static let timelineIconSize = "timelineIconSize"
|
||||
static let timelineIconDimension = "timelineIconSize"
|
||||
static let timelineSortDirection = "timelineSortDirection"
|
||||
static let articleFullscreenAvailable = "articleFullscreenAvailable"
|
||||
static let articleFullscreenEnabled = "articleFullscreenEnabled"
|
||||
@ -202,11 +202,11 @@ final class AppDefaults {
|
||||
|
||||
var timelineIconSize: IconSize {
|
||||
get {
|
||||
let rawValue = AppDefaults.store.integer(forKey: Key.timelineIconSize)
|
||||
let rawValue = AppDefaults.store.integer(forKey: Key.timelineIconDimension)
|
||||
return IconSize(rawValue: rawValue) ?? IconSize.medium
|
||||
}
|
||||
set {
|
||||
AppDefaults.store.set(newValue.rawValue, forKey: Key.timelineIconSize)
|
||||
AppDefaults.store.set(newValue.rawValue, forKey: Key.timelineIconDimension)
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,7 +215,7 @@ final class AppDefaults {
|
||||
Key.timelineGroupByFeed: false,
|
||||
Key.refreshClearsReadArticles: false,
|
||||
Key.timelineNumberOfLines: 2,
|
||||
Key.timelineIconSize: IconSize.medium.rawValue,
|
||||
Key.timelineIconDimension: IconSize.medium.rawValue,
|
||||
Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue,
|
||||
Key.articleFullscreenAvailable: false,
|
||||
Key.articleFullscreenEnabled: false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user