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>
80 lines
2.3 KiB
Swift
80 lines
2.3 KiB
Swift
//
|
|
// SettingsSourceListView.swift
|
|
// Ferrite
|
|
//
|
|
// Created by Brian Dashore on 7/25/22.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct SettingsSourceListView: View {
|
|
let backgroundContext = PersistenceController.shared.backgroundContext
|
|
|
|
@EnvironmentObject var navModel: NavigationViewModel
|
|
|
|
@FetchRequest(
|
|
entity: SourceList.entity(),
|
|
sortDescriptors: []
|
|
) var sourceLists: FetchedResults<SourceList>
|
|
|
|
@State private var presentSourceSheet = false
|
|
@State private var selectedSourceList: SourceList?
|
|
|
|
var body: some View {
|
|
List {
|
|
ForEach(sourceLists, id: \.self) { sourceList in
|
|
VStack(alignment: .leading, spacing: 5) {
|
|
Text(sourceList.name)
|
|
|
|
Text(sourceList.author)
|
|
.foregroundColor(.gray)
|
|
|
|
Text("ID: \(sourceList.id)")
|
|
.font(.caption)
|
|
.foregroundColor(.gray)
|
|
}
|
|
.contextMenu {
|
|
Button {
|
|
navModel.selectedSourceList = sourceList
|
|
presentSourceSheet.toggle()
|
|
} label: {
|
|
Text("Edit")
|
|
Image(systemName: "pencil")
|
|
}
|
|
|
|
Button {
|
|
PersistenceController.shared.delete(sourceList, context: backgroundContext)
|
|
} label: {
|
|
Text("Remove")
|
|
Image(systemName: "trash")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.listStyle(.insetGrouped)
|
|
.sheet(isPresented: $presentSourceSheet) {
|
|
if #available(iOS 16, *) {
|
|
SourceListEditorView()
|
|
.presentationDetents([.medium])
|
|
} else {
|
|
SourceListEditorView()
|
|
}
|
|
}
|
|
.navigationTitle("Source lists")
|
|
.toolbar {
|
|
ToolbarItem(placement: .navigationBarTrailing) {
|
|
Button {
|
|
presentSourceSheet.toggle()
|
|
} label: {
|
|
Image(systemName: "plus")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct SettingsSourceListView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
SettingsSourceListView()
|
|
}
|
|
}
|