Ferrite-backup/Ferrite/Views/SettingsViews/SettingsSourceUrlView.swift
kingbri 940f8337a5 Ferrite: Overhaul sources
Sources are now completely changed to use a more flexible API. This
uses a fully native source system, so there will be 0 overhead on
resource usage and performance.

JSON objects specify what is fetched and displayed by Ferrite when
searching torrents.

Sources now include sizes, seeders, and leechers for any site that
specifies them.

The versioning and repo naming framework has been added, but will be
displayed in another update.

API support will be included in another update.

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

58 lines
1.6 KiB
Swift

//
// SettingsSourceUrlView.swift
// Ferrite
//
// Created by Brian Dashore on 7/25/22.
//
import SwiftUI
struct SettingsSourceListView: View {
let backgroundContext = PersistenceController.shared.backgroundContext
@FetchRequest(
entity: SourceList.entity(),
sortDescriptors: []
) var sourceUrls: FetchedResults<SourceList>
@State private var presentSourceSheet = false
var body: some View {
List {
ForEach(sourceUrls, id: \.self) { sourceUrl in
Text(sourceUrl.repoName ?? "Unknown repo")
}
.onDelete { offsets in
for index in offsets {
if let sourceUrl = sourceUrls[safe: index] {
PersistenceController.shared.delete(sourceUrl, context: backgroundContext)
}
}
}
}
.sheet(isPresented: $presentSourceSheet) {
if #available(iOS 16, *) {
SourceListEditorView()
.presentationDetents([.medium])
} else {
SourceListEditorView()
}
}
.navigationTitle("Source lists")
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button {
presentSourceSheet.toggle()
} label: {
Image(systemName: "plus")
}
}
}
}
}
struct SettingsSourceListView_Previews: PreviewProvider {
static var previews: some View {
SettingsSourceListView()
}
}