Ferrite-backup/Ferrite/Views/SettingsViews/SettingsSourceListView.swift
kingbri 664c57b751 Ferrite: Add updater
Updates are sent via an alert on starting the app. This can be
disabled in the settings menu.

A full version struct has been completed for flexible comparisons.

Version history can also be viewed in settings in case a user wants
to download an earlier version of the app.

Updates track Github releases.

Signed-off-by: kingbri <bdashore3@gmail.com>
2022-08-31 18:47:02 -04:00

83 lines
2.5 KiB
Swift

//
// SettingsSourceListView.swift
// Ferrite
//
// Created by Brian Dashore on 7/25/22.
//
import SwiftUI
struct SettingsSourceListView: View {
let backgroundContext = PersistenceController.shared.backgroundContext
@EnvironmentObject var navModel: NavigationViewModel
@FetchRequest(
entity: SourceList.entity(),
sortDescriptors: []
) var sourceLists: FetchedResults<SourceList>
@State private var presentSourceSheet = false
@State private var selectedSourceList: SourceList?
var body: some View {
List {
Section(header: Text("List information")) {
ForEach(sourceLists, id: \.self) { sourceList in
VStack(alignment: .leading, spacing: 5) {
Text(sourceList.name)
Text(sourceList.author)
.foregroundColor(.gray)
Text("ID: \(sourceList.id)")
.font(.caption)
.foregroundColor(.gray)
}
.contextMenu {
Button {
navModel.selectedSourceList = sourceList
presentSourceSheet.toggle()
} label: {
Text("Edit")
Image(systemName: "pencil")
}
Button {
PersistenceController.shared.delete(sourceList, context: backgroundContext)
} label: {
Text("Remove")
Image(systemName: "trash")
}
}
}
}
}
.listStyle(.insetGrouped)
.sheet(isPresented: $presentSourceSheet) {
if #available(iOS 16, *) {
SourceListEditorView()
.presentationDetents([.medium])
} else {
SourceListEditorView()
}
}
.navigationTitle("Source lists")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button {
presentSourceSheet.toggle()
} label: {
Image(systemName: "plus")
}
}
}
}
}
struct SettingsSourceListView_Previews: PreviewProvider {
static var previews: some View {
SettingsSourceListView()
}
}