Ferrite-backup/Ferrite/Views/SourceSettingsView.swift
kingbri 064a68fbb2 Sources: Add RSS, descriptions, and settings
RSS parsing has been added as a method to parse source since they're
easier on the website's end to parse.

Source settings have been added. The only current setting is the fetch
mode which selects which parser/scraper to use. By default, if an RSS
parser is found, it's selected.

A source now has info shown regarding versioning and authorship. A source
list's repository name and author string are now required.

Signed-off-by: kingbri <bdashore3@gmail.com>
2022-08-31 00:41:38 -04:00

56 lines
1.5 KiB
Swift

//
// SourceSettingsView.swift
// Ferrite
//
// Created by Brian Dashore on 8/4/22.
//
import SwiftUI
struct SourceSettingsView: View {
@Environment(\.dismiss) var dismiss
var body: some View {
NavView {
Form {
SourceSettingsMethodView()
}
.navigationTitle("Source settings")
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button("Done") {
dismiss()
}
}
}
}
}
}
struct SourceSettingsMethodView: View {
@EnvironmentObject var navModel: NavigationViewModel
@State private var selectedTempParser: SourcePreferredParser = .none
var body: some View {
Picker("Fetch method", selection: $selectedTempParser) {
if navModel.selectedSource?.htmlParser != nil {
Text("Web scraping")
.tag(SourcePreferredParser.scraping)
}
if navModel.selectedSource?.rssParser != nil {
Text("RSS")
.tag(SourcePreferredParser.rss)
}
}
.pickerStyle(.inline)
.onAppear {
selectedTempParser = SourcePreferredParser(rawValue: navModel.selectedSource?.preferredParser ?? 0) ?? .none
}
.onChange(of: selectedTempParser) { newMethod in
navModel.selectedSource?.preferredParser = newMethod.rawValue
PersistenceController.shared.save()
}
}
}