jellyflood/Swiftfin/Views/SettingsView/CustomDeviceProfileSettingsView/CustomDeviceProfileSettingsView.swift
Joe Kribs c0b875ed2a
[tvOS] Various Setting Cleanup (#1473)
* Various setting cleanup

* Remove Double headers

* My gradient did nothing... So resetting back to less.

* Reduce unnecessary formatting changes.

* Revisions https://github.com/jellyfin/Swiftfin/pull/1473#pullrequestreview-2745279339

* Subtitles was missing brightness. Subtitle shouldn't mirror title but image.

* Remove TODO.
2025-04-06 18:05:33 -04:00

84 lines
2.5 KiB
Swift

//
// Swiftfin is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2025 Jellyfin & Jellyfin Contributors
//
import Defaults
import Factory
import SwiftUI
struct CustomDeviceProfileSettingsView: View {
@Default(.VideoPlayer.Playback.customDeviceProfileAction)
private var customDeviceProfileAction
@StoredValue(.User.customDeviceProfiles)
private var customProfiles: [CustomDeviceProfile]
@EnvironmentObject
private var router: SettingsCoordinator.Router
private var isValid: Bool {
customDeviceProfileAction == .add ||
customProfiles.isNotEmpty
}
private func removeProfile(at offsets: IndexSet) {
customProfiles.remove(atOffsets: offsets)
}
var body: some View {
List {
Section {
CaseIterablePicker(
L10n.behavior,
selection: $customDeviceProfileAction
)
} footer: {
VStack(spacing: 8) {
switch customDeviceProfileAction {
case .add:
L10n.customDeviceProfileAdd.text
case .replace:
L10n.customDeviceProfileReplace.text
}
if !isValid {
Label(L10n.noDeviceProfileWarning, systemImage: "exclamationmark.circle.fill")
.labelStyle(.sectionFooterWithImage(imageStyle: .orange))
}
}
}
Section(L10n.profiles) {
if customProfiles.isEmpty {
Button(L10n.add) {
router.route(to: \.createCustomDeviceProfile)
}
}
ForEach($customProfiles, id: \.self) { $profile in
CustomProfileButton(profile: profile) {
router.route(to: \.editCustomDeviceProfile, $profile)
}
}
.onDelete(perform: removeProfile)
}
}
.navigationTitle(L10n.profiles)
.topBarTrailing {
if customProfiles.isNotEmpty {
Button(L10n.add) {
UIDevice.impact(.light)
router.route(to: \.createCustomDeviceProfile)
}
.buttonStyle(.toolbarPill)
}
}
}
}