jellyflood/Swiftfin/Views/SettingsView/VideoPlayerSettingsView/Components/Sections/ButtonSection.swift

46 lines
1.4 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 SwiftUI
extension VideoPlayerSettingsView {
struct ButtonSection: View {
@Default(.VideoPlayer.barActionButtons)
private var barActionButtons
@Default(.VideoPlayer.menuActionButtons)
private var menuActionButtons
@Default(.VideoPlayer.autoPlayEnabled)
private var autoPlayEnabled
@Router
private var router
var body: some View {
Section(L10n.buttons) {
ChevronButton(L10n.barButtons) {
router.route(to: .actionButtonSelector(selectedButtonsBinding: $barActionButtons))
}
ChevronButton(L10n.menuButtons) {
router.route(to: .actionButtonSelector(selectedButtonsBinding: $menuActionButtons))
}
}
.onChange(of: barActionButtons) { newValue in
autoPlayEnabled = newValue.contains(.autoPlay) || menuActionButtons.contains(.autoPlay)
}
.onChange(of: menuActionButtons) { newValue in
autoPlayEnabled = newValue.contains(.autoPlay) || barActionButtons.contains(.autoPlay)
}
}
}
}