mirror of
https://github.com/yattee/yattee.git
synced 2024-11-09 15:58:20 +00:00
player controls: add background opacity selection
Signed-off-by: Toni Förster <toni.foerster@gmail.com>
This commit is contained in:
parent
9bf3df1a29
commit
5313e4ead0
@ -10,6 +10,7 @@ final class ConstrolsSettingsGroupExporter: SettingsGroupExporter {
|
||||
"seekGestureSpeed": Defaults[.seekGestureSpeed],
|
||||
"playerControlsLayout": Defaults[.playerControlsLayout].rawValue,
|
||||
"fullScreenPlayerControlsLayout": Defaults[.fullScreenPlayerControlsLayout].rawValue,
|
||||
"playerControlsBackgroundOpacity": Defaults[.playerControlsBackgroundOpacity],
|
||||
"systemControlsCommands": Defaults[.systemControlsCommands].rawValue,
|
||||
"buttonBackwardSeekDuration": Defaults[.buttonBackwardSeekDuration],
|
||||
"buttonForwardSeekDuration": Defaults[.buttonForwardSeekDuration],
|
||||
|
@ -33,6 +33,10 @@ struct ConstrolsSettingsGroupImporter {
|
||||
Defaults[.fullScreenPlayerControlsLayout] = fullScreenPlayerControlsLayout
|
||||
}
|
||||
|
||||
if let playerControlsBackgroundOpacity = json["playerControlsBackgroundOpacity"].double {
|
||||
Defaults[.playerControlsBackgroundOpacity] = playerControlsBackgroundOpacity
|
||||
}
|
||||
|
||||
if let systemControlsCommandsString = json["systemControlsCommands"].string,
|
||||
let systemControlsCommands = SystemControlsCommands(rawValue: systemControlsCommandsString)
|
||||
{
|
||||
|
@ -134,6 +134,7 @@ extension Defaults.Keys {
|
||||
|
||||
static let playerControlsLayout = Key<PlayerControlsLayout>("playerControlsLayout", default: playerControlsLayoutDefault)
|
||||
static let fullScreenPlayerControlsLayout = Key<PlayerControlsLayout>("fullScreenPlayerControlsLayout", default: fullScreenPlayerControlsLayoutDefault)
|
||||
static let playerControlsBackgroundOpacity = Key<Double>("playerControlsBackgroundOpacity", default: 0.2)
|
||||
|
||||
static let systemControlsCommands = Key<SystemControlsCommands>("systemControlsCommands", default: .restartAndAdvanceToNext)
|
||||
|
||||
|
@ -29,6 +29,7 @@ struct PlayerControls: View {
|
||||
|
||||
@Default(.playerControlsLayout) private var regularPlayerControlsLayout
|
||||
@Default(.fullScreenPlayerControlsLayout) private var fullScreenPlayerControlsLayout
|
||||
@Default(.playerControlsBackgroundOpacity) private var playerControlsBackgroundOpacity
|
||||
@Default(.buttonBackwardSeekDuration) private var buttonBackwardSeekDuration
|
||||
@Default(.buttonForwardSeekDuration) private var buttonForwardSeekDuration
|
||||
|
||||
@ -270,6 +271,9 @@ struct PlayerControls: View {
|
||||
}
|
||||
} else if player.videoForDisplay == nil {
|
||||
Color.black
|
||||
} else if model.presentingControls {
|
||||
Color.black.opacity(playerControlsBackgroundOpacity)
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ struct PlayerControlsSettings: View {
|
||||
@Default(.playerControlsAdvanceToNextEnabled) private var playerControlsAdvanceToNextEnabled
|
||||
@Default(.playerControlsPlaybackModeEnabled) private var playerControlsPlaybackModeEnabled
|
||||
@Default(.playerControlsMusicModeEnabled) private var playerControlsMusicModeEnabled
|
||||
@Default(.playerControlsBackgroundOpacity) private var playerControlsBackgroundOpacity
|
||||
|
||||
private var player = PlayerModel.shared
|
||||
|
||||
@ -76,6 +77,8 @@ struct PlayerControlsSettings: View {
|
||||
playerControlsLayoutPicker
|
||||
SettingsHeader(text: "Fullscreen size".localized(), secondary: true)
|
||||
fullScreenPlayerControlsLayoutPicker
|
||||
SettingsHeader(text: "Background opacity".localized(), secondary: true)
|
||||
playerControlsBackgroundOpacityPicker
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -202,6 +205,15 @@ struct PlayerControlsSettings: View {
|
||||
.modifier(SettingsPickerModifier())
|
||||
}
|
||||
|
||||
private var playerControlsBackgroundOpacityPicker: some View {
|
||||
Picker("Background opacity", selection: $playerControlsBackgroundOpacity) {
|
||||
ForEach(Array(stride(from: 0.0, through: 1.0, by: 0.1)), id: \.self) { value in
|
||||
Text("\(Int(value * 100))%").tag(value)
|
||||
}
|
||||
}
|
||||
.modifier(SettingsPickerModifier())
|
||||
}
|
||||
|
||||
@ViewBuilder private var seekingSection: some View {
|
||||
seekingDurationSetting("System controls", $systemControlsSeekDuration)
|
||||
.foregroundColor(systemControlsCommands == .restartAndAdvanceToNext ? .secondary : .primary)
|
||||
|
Loading…
Reference in New Issue
Block a user