Improve settings, sidebars

This commit is contained in:
Christoph Hagen
2024-12-04 22:54:05 +01:00
parent b3cc4a57db
commit c3309197c0
36 changed files with 968 additions and 426 deletions

View File

@ -0,0 +1,19 @@
import Foundation
final class LocalizedPostSettings: ObservableObject {
@Published
var title: String
@Published
var description: String
@Published
var feedUrlPrefix: String
init(title: String, description: String, feedUrlPrefix: String) {
self.title = title
self.description = description
self.feedUrlPrefix = feedUrlPrefix
}
}

View File

@ -0,0 +1,15 @@
import Foundation
final class LocalizedSettings: ObservableObject {
@Published
var navigationBarIconDescription: String
@Published
var posts: LocalizedPostSettings
init(navigationBarIconDescription: String, posts: LocalizedPostSettings) {
self.navigationBarIconDescription = navigationBarIconDescription
self.posts = posts
}
}

View File

@ -0,0 +1,17 @@
import Foundation
final class NavigationBarSettings: ObservableObject {
/// The path to the main icon in the navigation bar
@Published
var iconPath: String
/// The tags to show in the navigation bar
@Published
var tags: [Tag]
init(iconPath: String, tags: [Tag]) {
self.iconPath = iconPath
self.tags = tags
}
}

View File

@ -0,0 +1,17 @@
import Foundation
final class PostSettings: ObservableObject {
/// The number of posts to show in a single page of the news feed
@Published
var postsPerPage: Int
/// The maximum width of the main content
@Published
var contentWidth: CGFloat
init(postsPerPage: Int, contentWidth: CGFloat) {
self.postsPerPage = postsPerPage
self.contentWidth = contentWidth
}
}

View File

@ -0,0 +1,34 @@
import Foundation
final class Settings: ObservableObject {
@Published
var outputDirectoryPath: String
@Published
var navigationBar: NavigationBarSettings
@Published
var posts: PostSettings
@Published
var german: LocalizedSettings
@Published
var english: LocalizedSettings
init(outputDirectoryPath: String, navigationBar: NavigationBarSettings, posts: PostSettings, german: LocalizedSettings, english: LocalizedSettings) {
self.outputDirectoryPath = outputDirectoryPath
self.navigationBar = navigationBar
self.posts = posts
self.german = german
self.english = english
}
func localized(in language: ContentLanguage) -> LocalizedSettings {
switch language {
case .english: return english
case .german: return german
}
}
}