mirror of
https://github.com/yattee/yattee.git
synced 2024-12-13 22:00:31 +05:30
Merge pull request #799 from stonerl/controls-background
player controls: add background opacity selection
This commit is contained in:
commit
7aed6ac0d9
@ -10,6 +10,7 @@ final class ConstrolsSettingsGroupExporter: SettingsGroupExporter {
|
|||||||
"seekGestureSpeed": Defaults[.seekGestureSpeed],
|
"seekGestureSpeed": Defaults[.seekGestureSpeed],
|
||||||
"playerControlsLayout": Defaults[.playerControlsLayout].rawValue,
|
"playerControlsLayout": Defaults[.playerControlsLayout].rawValue,
|
||||||
"fullScreenPlayerControlsLayout": Defaults[.fullScreenPlayerControlsLayout].rawValue,
|
"fullScreenPlayerControlsLayout": Defaults[.fullScreenPlayerControlsLayout].rawValue,
|
||||||
|
"playerControlsBackgroundOpacity": Defaults[.playerControlsBackgroundOpacity],
|
||||||
"systemControlsCommands": Defaults[.systemControlsCommands].rawValue,
|
"systemControlsCommands": Defaults[.systemControlsCommands].rawValue,
|
||||||
"buttonBackwardSeekDuration": Defaults[.buttonBackwardSeekDuration],
|
"buttonBackwardSeekDuration": Defaults[.buttonBackwardSeekDuration],
|
||||||
"buttonForwardSeekDuration": Defaults[.buttonForwardSeekDuration],
|
"buttonForwardSeekDuration": Defaults[.buttonForwardSeekDuration],
|
||||||
|
@ -33,6 +33,10 @@ struct ConstrolsSettingsGroupImporter {
|
|||||||
Defaults[.fullScreenPlayerControlsLayout] = fullScreenPlayerControlsLayout
|
Defaults[.fullScreenPlayerControlsLayout] = fullScreenPlayerControlsLayout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let playerControlsBackgroundOpacity = json["playerControlsBackgroundOpacity"].double {
|
||||||
|
Defaults[.playerControlsBackgroundOpacity] = playerControlsBackgroundOpacity
|
||||||
|
}
|
||||||
|
|
||||||
if let systemControlsCommandsString = json["systemControlsCommands"].string,
|
if let systemControlsCommandsString = json["systemControlsCommands"].string,
|
||||||
let systemControlsCommands = SystemControlsCommands(rawValue: systemControlsCommandsString)
|
let systemControlsCommands = SystemControlsCommands(rawValue: systemControlsCommandsString)
|
||||||
{
|
{
|
||||||
|
@ -134,6 +134,7 @@ extension Defaults.Keys {
|
|||||||
|
|
||||||
static let playerControlsLayout = Key<PlayerControlsLayout>("playerControlsLayout", default: playerControlsLayoutDefault)
|
static let playerControlsLayout = Key<PlayerControlsLayout>("playerControlsLayout", default: playerControlsLayoutDefault)
|
||||||
static let fullScreenPlayerControlsLayout = Key<PlayerControlsLayout>("fullScreenPlayerControlsLayout", default: fullScreenPlayerControlsLayoutDefault)
|
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)
|
static let systemControlsCommands = Key<SystemControlsCommands>("systemControlsCommands", default: .restartAndAdvanceToNext)
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ struct PlayerControls: View {
|
|||||||
|
|
||||||
@Default(.playerControlsLayout) private var regularPlayerControlsLayout
|
@Default(.playerControlsLayout) private var regularPlayerControlsLayout
|
||||||
@Default(.fullScreenPlayerControlsLayout) private var fullScreenPlayerControlsLayout
|
@Default(.fullScreenPlayerControlsLayout) private var fullScreenPlayerControlsLayout
|
||||||
|
@Default(.playerControlsBackgroundOpacity) private var playerControlsBackgroundOpacity
|
||||||
@Default(.buttonBackwardSeekDuration) private var buttonBackwardSeekDuration
|
@Default(.buttonBackwardSeekDuration) private var buttonBackwardSeekDuration
|
||||||
@Default(.buttonForwardSeekDuration) private var buttonForwardSeekDuration
|
@Default(.buttonForwardSeekDuration) private var buttonForwardSeekDuration
|
||||||
|
|
||||||
@ -270,6 +271,9 @@ struct PlayerControls: View {
|
|||||||
}
|
}
|
||||||
} else if player.videoForDisplay == nil {
|
} else if player.videoForDisplay == nil {
|
||||||
Color.black
|
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(.playerControlsAdvanceToNextEnabled) private var playerControlsAdvanceToNextEnabled
|
||||||
@Default(.playerControlsPlaybackModeEnabled) private var playerControlsPlaybackModeEnabled
|
@Default(.playerControlsPlaybackModeEnabled) private var playerControlsPlaybackModeEnabled
|
||||||
@Default(.playerControlsMusicModeEnabled) private var playerControlsMusicModeEnabled
|
@Default(.playerControlsMusicModeEnabled) private var playerControlsMusicModeEnabled
|
||||||
|
@Default(.playerControlsBackgroundOpacity) private var playerControlsBackgroundOpacity
|
||||||
|
|
||||||
private var player = PlayerModel.shared
|
private var player = PlayerModel.shared
|
||||||
|
|
||||||
@ -76,6 +77,8 @@ struct PlayerControlsSettings: View {
|
|||||||
playerControlsLayoutPicker
|
playerControlsLayoutPicker
|
||||||
SettingsHeader(text: "Fullscreen size".localized(), secondary: true)
|
SettingsHeader(text: "Fullscreen size".localized(), secondary: true)
|
||||||
fullScreenPlayerControlsLayoutPicker
|
fullScreenPlayerControlsLayoutPicker
|
||||||
|
SettingsHeader(text: "Background opacity".localized(), secondary: true)
|
||||||
|
playerControlsBackgroundOpacityPicker
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -202,6 +205,15 @@ struct PlayerControlsSettings: View {
|
|||||||
.modifier(SettingsPickerModifier())
|
.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 {
|
@ViewBuilder private var seekingSection: some View {
|
||||||
seekingDurationSetting("System controls", $systemControlsSeekDuration)
|
seekingDurationSetting("System controls", $systemControlsSeekDuration)
|
||||||
.foregroundColor(systemControlsCommands == .restartAndAdvanceToNext ? .secondary : .primary)
|
.foregroundColor(systemControlsCommands == .restartAndAdvanceToNext ? .secondary : .primary)
|
||||||
|
Loading…
Reference in New Issue
Block a user