Ferrite/Ferrite/Views/ComponentViews/Library/LibraryPickerView.swift
kingbri 646c22c9be Debrid: Fix UI updates with auth
If a debrid is authorized, a Published variable needs to be notified
since SwiftUI can't read computed properties on the fly (they are
getters). Therefore, it's better to maintain a single source of truth
of which services are logged in.

Signed-off-by: kingbri <bdashore3@proton.me>
2024-06-16 15:00:35 -05:00

31 lines
978 B
Swift

//
// LibraryPickerView.swift
// Ferrite
//
// Created by Brian Dashore on 2/13/23.
//
import SwiftUI
struct LibraryPickerView: View {
@Environment(\.verticalSizeClass) var verticalSizeClass
@EnvironmentObject var debridManager: DebridManager
@EnvironmentObject var navModel: NavigationViewModel
var body: some View {
HStack {
Picker("Segments", selection: $navModel.libraryPickerSelection) {
Text("Bookmarks").tag(NavigationViewModel.LibraryPickerSegment.bookmarks)
Text("History").tag(NavigationViewModel.LibraryPickerSegment.history)
if !debridManager.enabledDebrids.isEmpty {
Text("Cloud").tag(NavigationViewModel.LibraryPickerSegment.debridCloud)
}
}
}
.pickerStyle(.segmented)
.padding(.horizontal, verticalSizeClass == .compact && UIDevice.current.hasNotch ? 65 : 18)
.padding(.vertical, 5)
}
}