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>
53 lines
1.4 KiB
Swift
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")
|
|
}
|
|
}
|
|
}
|
|
}
|