Ferrite-backup/Ferrite/Views/ComponentViews/Debrid/DebridLabelView.swift
kingbri 4512318e8f Ferrite: Add actions, plugins, and tags
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>
2023-02-08 12:09:37 -05:00

45 lines
1.1 KiB
Swift

//
// DebridLabelView.swift
// Ferrite
//
// Created by Brian Dashore on 11/27/22.
//
import SwiftUI
struct DebridLabelView: View {
@EnvironmentObject var debridManager: DebridManager
@State var cloudLinks: [String] = []
var magnet: Magnet?
var body: some View {
if let selectedDebridType = debridManager.selectedDebridType {
Tag(
name: selectedDebridType.toString(abbreviated: true),
color: getTagColor(),
horizontalPadding: 5,
verticalPadding: 3
)
}
}
func getTagColor() -> Color {
if let magnet, cloudLinks.isEmpty {
switch debridManager.matchMagnetHash(magnet) {
case .full:
return Color.green
case .partial:
return Color.orange
case .none:
return Color.red
}
} else if cloudLinks.count == 1 {
return Color.green
} else if cloudLinks.count > 1 {
return Color.orange
} else {
return Color.red
}
}
}