Plugins are now a unified format for both sources and actions. Actions dictate what to do with a link and can now be added through a plugin JSON file. Backups have also been versioned to improve performance and add action support. Tags are used to give small amounts of information before a user installs a plugin. Signed-off-by: kingbri <bdashore3@proton.me>
51 lines
1.5 KiB
Swift
51 lines
1.5 KiB
Swift
//
|
|
// SourceCatalogButtonView.swift
|
|
// Ferrite
|
|
//
|
|
// Created by Brian Dashore on 8/5/22.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct PluginCatalogButtonView<PJ: PluginJson>: View {
|
|
@EnvironmentObject var pluginManager: PluginManager
|
|
|
|
let availablePlugin: PJ
|
|
let doUpsert: Bool
|
|
|
|
var body: some View {
|
|
HStack {
|
|
VStack(alignment: .leading) {
|
|
VStack(alignment: .leading, spacing: 5) {
|
|
HStack {
|
|
Text(availablePlugin.name)
|
|
Text("v\(availablePlugin.version)")
|
|
.foregroundColor(.secondary)
|
|
}
|
|
|
|
Text("by \(availablePlugin.author ?? "No author")")
|
|
.foregroundColor(.secondary)
|
|
}
|
|
|
|
if let tags = availablePlugin.getTags(), !tags.isEmpty {
|
|
PluginTagsView(tags: tags)
|
|
}
|
|
}
|
|
|
|
Spacer()
|
|
|
|
Button("Install") {
|
|
Task {
|
|
if let availableSource = availablePlugin as? SourceJson {
|
|
await pluginManager.installSource(sourceJson: availableSource, doUpsert: doUpsert)
|
|
} else if let availableAction = availablePlugin as? ActionJson {
|
|
await pluginManager.installAction(actionJson: availableAction, doUpsert: doUpsert)
|
|
} else {
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.padding(.vertical, 2)
|
|
}
|
|
}
|