List IDs are used to link a source list with an actual source. Each list entry has a unique ID that a user can compare with a source to see if it's legitimate. Source IDs are just identifiers for sources. Not sure what to do with these yet but they may be useful for the future. Signed-off-by: kingbri <bdashore3@gmail.com>
83 lines
2.6 KiB
Swift
83 lines
2.6 KiB
Swift
//
|
|
// SourceSettingsView.swift
|
|
// Ferrite
|
|
//
|
|
// Created by Brian Dashore on 8/4/22.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct SourceSettingsView: View {
|
|
@Environment(\.dismiss) var dismiss
|
|
|
|
@EnvironmentObject var navModel: NavigationViewModel
|
|
|
|
var body: some View {
|
|
NavView {
|
|
Form {
|
|
if let selectedSource = navModel.selectedSource {
|
|
Section("Info") {
|
|
VStack(alignment: .leading, spacing: 5) {
|
|
HStack {
|
|
Text(selectedSource.name)
|
|
|
|
Text("v\(selectedSource.version)")
|
|
}
|
|
|
|
Text("by \(selectedSource.author)")
|
|
.foregroundColor(.secondary)
|
|
|
|
if let listId = selectedSource.listId {
|
|
Text("List ID: \(listId)")
|
|
.font(.caption)
|
|
.foregroundColor(.secondary)
|
|
} else {
|
|
Text("No list ID found. This source should be removed.")
|
|
.font(.caption)
|
|
.foregroundColor(.secondary)
|
|
}
|
|
}
|
|
}
|
|
|
|
SourceSettingsMethodView(selectedSource: selectedSource)
|
|
}
|
|
}
|
|
.navigationTitle("Source settings")
|
|
.toolbar {
|
|
ToolbarItem(placement: .navigationBarTrailing) {
|
|
Button("Done") {
|
|
dismiss()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct SourceSettingsMethodView: View {
|
|
@ObservedObject var selectedSource: Source
|
|
|
|
@State private var selectedTempParser: SourcePreferredParser = .none
|
|
|
|
var body: some View {
|
|
Picker("Fetch method", selection: $selectedTempParser) {
|
|
if selectedSource.htmlParser != nil {
|
|
Text("Web scraping")
|
|
.tag(SourcePreferredParser.scraping)
|
|
}
|
|
|
|
if selectedSource.rssParser != nil {
|
|
Text("RSS")
|
|
.tag(SourcePreferredParser.rss)
|
|
}
|
|
}
|
|
.pickerStyle(.inline)
|
|
.onAppear {
|
|
selectedTempParser = SourcePreferredParser(rawValue: selectedSource.preferredParser) ?? .none
|
|
}
|
|
.onChange(of: selectedTempParser) { newMethod in
|
|
selectedSource.preferredParser = selectedTempParser.rawValue
|
|
PersistenceController.shared.save()
|
|
}
|
|
}
|
|
}
|