77 lines
2.2 KiB
Swift
77 lines
2.2 KiB
Swift
import SwiftUI
|
|
import SFSafeSymbols
|
|
|
|
|
|
enum ContentDisplayType {
|
|
case markdown
|
|
case html
|
|
case rendered
|
|
}
|
|
|
|
@main
|
|
struct CHDataManagementApp: App {
|
|
|
|
var navigationTitle: String {
|
|
""
|
|
}
|
|
|
|
@ObservedObject
|
|
var content: Content = .init()
|
|
|
|
@State
|
|
var selectedLanguage: ContentLanguage = .english
|
|
|
|
@State
|
|
var contentDisplayType: ContentDisplayType = .markdown
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
TabView {
|
|
Tab("Posts", systemImage: SFSymbol.rectangleAndPencilAndEllipsis.rawValue) {
|
|
PostList(posts: $content.posts)
|
|
.environment(\.language, selectedLanguage)
|
|
.background(Color(r: 2, g: 15, b: 26))
|
|
}
|
|
Tab("Pages", systemImage: SFSymbol.textBelowPhoto.rawValue) {
|
|
Text("TODO")
|
|
}
|
|
Tab("Tags", systemImage: SFSymbol.tag.rawValue) {
|
|
Text("TODO")
|
|
}
|
|
Tab("Images", systemImage: SFSymbol.photo.rawValue) {
|
|
ImagesView()
|
|
.environmentObject(content)
|
|
}
|
|
Tab("Files", systemImage: SFSymbol.doc.rawValue) {
|
|
FilesView()
|
|
.environmentObject(content)
|
|
}
|
|
Tab("Settings", systemImage: SFSymbol.gear.rawValue) {
|
|
SettingsView()
|
|
.environmentObject(content)
|
|
}
|
|
}
|
|
.toolbar {
|
|
ToolbarItem(placement: .primaryAction) {
|
|
Picker("", selection: $selectedLanguage) {
|
|
Text("English")
|
|
.tag(ContentLanguage.english)
|
|
Text("German")
|
|
.tag(ContentLanguage.german)
|
|
}.pickerStyle(.segmented)
|
|
}
|
|
}
|
|
.onAppear(perform: importOldContent)
|
|
}
|
|
}
|
|
|
|
private func importOldContent() {
|
|
do {
|
|
try content.loadFromDisk()
|
|
//content.importOldContent()
|
|
} catch {
|
|
print("Failed to load content: \(error.localizedDescription)")
|
|
}
|
|
}
|
|
}
|