Ferrite-backup/Ferrite/Views/SourceViews/InstalledSourceView.swift
kingbri ff23a854ef Sources: Add source updating and source list edits
Sources can now be updated based on the repo ID. To preserve repo IDs
across single URL links, the source lists can be edited and the ID
is transferred over.

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

53 lines
1.4 KiB
Swift

//
// InstalledSourceView.swift
// Ferrite
//
// Created by Brian Dashore on 8/5/22.
//
import SwiftUI
struct InstalledSourceView: View {
let backgroundContext = PersistenceController.shared.backgroundContext
@EnvironmentObject var navModel: NavigationViewModel
@ObservedObject var installedSource: Source
var body: some View {
Toggle(isOn: Binding<Bool>(
get: { installedSource.enabled },
set: {
installedSource.enabled = $0
PersistenceController.shared.save()
}
)) {
VStack(alignment: .leading, spacing: 5) {
HStack {
Text(installedSource.name)
Text("v\(installedSource.version)")
.foregroundColor(.secondary)
}
Text("by \(installedSource.author)")
.foregroundColor(.secondary)
}
}
.contextMenu {
Button {
navModel.selectedSource = installedSource
navModel.showSourceSettings.toggle()
} label: {
Text("Settings")
Image(systemName: "gear")
}
Button {
PersistenceController.shared.delete(installedSource, context: backgroundContext)
} label: {
Text("Remove")
Image(systemName: "trash")
}
}
}
}