Ferrite-backup/Ferrite/Views/SettingsViews/DefaultActionsPickerViews.swift
kingbri 1761f8dfb4 Debrid: Add loading indicator and fix iOS <14.5 issues
When a search result is selected, there is usually a delay due to
the debrid dance of API routes for grabbing a download link to stream.
Add a loading indicator and prevent any other tasks from loading
unless the user cancels it.

iOS 14.5 was a huge update which added many QoL SwiftUI changes that
are consistent to modern iOS versions.

However, Ferrite supports iOS versions less than 14.5, mainly 14.3.
More fixes had to be added to make sure UI is consistent across
all OS versions.

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

88 lines
2.6 KiB
Swift

//
// DefaultActionsPickerViews.swift
// Ferrite
//
// Created by Brian Dashore on 8/11/22.
//
import SwiftUI
struct MagnetActionPickerView: View {
@AppStorage("Actions.DefaultMagnet") var defaultMagnetAction: DefaultMagnetActionType = .none
var body: some View {
List {
ForEach(DefaultMagnetActionType.allCases, id: \.self) { action in
Button {
defaultMagnetAction = action
} label: {
HStack {
Text(fetchPickerChoiceName(choice: action))
Spacer()
if action == defaultMagnetAction {
Image(systemName: "checkmark")
.foregroundColor(.blue)
}
}
}
.dynamicAccentColor(.primary)
}
}
.listStyle(.insetGrouped)
.navigationTitle("Default magnet action")
.navigationBarTitleDisplayMode(.inline)
}
func fetchPickerChoiceName(choice: DefaultMagnetActionType) -> String {
switch choice {
case .none:
return "Let me choose"
case .webtor:
return "Open in Webtor"
case .shareMagnet:
return "Share magnet link"
}
}
}
struct DebridActionPickerView: View {
@AppStorage("Actions.DefaultDebrid") var defaultDebridAction: DefaultDebridActionType = .none
var body: some View {
List {
ForEach(DefaultDebridActionType.allCases, id: \.self) { action in
Button {
defaultDebridAction = action
} label: {
HStack {
Text(fetchPickerChoiceName(choice: action))
Spacer()
if action == defaultDebridAction {
Image(systemName: "checkmark")
.foregroundColor(.blue)
}
}
}
.dynamicAccentColor(.primary)
}
}
.listStyle(.insetGrouped)
.navigationTitle("Default debrid action")
.navigationBarTitleDisplayMode(.inline)
}
func fetchPickerChoiceName(choice: DefaultDebridActionType) -> String {
switch choice {
case .none:
return "Let me choose"
case .outplayer:
return "Open in Outplayer"
case .vlc:
return "Open in VLC"
case .infuse:
return "Open in Infuse"
case .shareDownload:
return "Share download link"
}
}
}