Skip to content

Commit

Permalink
[iOS] Fix playback speed + repeat mode buttons in Playlist fullscreen
Browse files Browse the repository at this point in the history
There is unfortunately a SwiftUI regression in iOS 18 which causes `simultaneousGesture` to break the primary tap gesture on `Menu(_:label:primaryAction:)` views. This change swaps the fullscreen buttons that used to have a long-press gesture back to standard Button's that cycle but have no long-press ability to choose an explicit speed/repeat mode.
  • Loading branch information
kylehickinson committed Oct 28, 2024
1 parent 4408d6f commit 7e1e2cc
Showing 1 changed file with 49 additions and 3 deletions.
52 changes: 49 additions & 3 deletions ios/brave-ios/Sources/PlaylistUI/PlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,22 @@ extension PlayerView {
var body: some View {
VStack {
HStack(spacing: 16) {
PlaybackSpeedPicker(playbackSpeed: $model.playbackSpeed)
if #available(iOS 18.0, *) {
// iOS 18 breaks simultaneous gestures on `Menu`, so we'll swap in a the old Button
// instead for those users for the time being...
Button {
model.playbackSpeed.cycle()
} label: {
Label(
Strings.Playlist.accessibilityPlaybackSpeed,
braveSystemImage: model.playbackSpeed.braveSystemName
)
.transition(.opacity.animation(.linear(duration: 0.1)))
.contentShape(.rect)
}
} else {
PlaybackSpeedPicker(playbackSpeed: $model.playbackSpeed)
}
Spacer()
Toggle(isOn: $model.isShuffleEnabled) {
if model.isShuffleEnabled {
Expand All @@ -164,8 +179,39 @@ extension PlayerView {
}
}
.toggleStyle(.button)
RepeatModePicker(repeatMode: $model.repeatMode)
.disabled(model.duration.isIndefinite)
Group {
if #available(iOS 18.0, *) {
// iOS 18 breaks simultaneous gestures on `Menu`, so we'll swap in a the old Button
// instead for those users for the time being...
Button {
model.repeatMode.cycle()
} label: {
Group {
switch model.repeatMode {
case .none:
Label(
Strings.Playlist.accessibilityRepeatModeOff,
braveSystemImage: "leo.loop.off"
)
case .one:
Label(
Strings.Playlist.accessibilityRepeatModeOne,
braveSystemImage: "leo.loop.1"
)
case .all:
Label(
Strings.Playlist.accessibilityRepeatModeAll,
braveSystemImage: "leo.loop.all"
)
}
}
.transition(.opacity.animation(.linear(duration: 0.1)))
}
} else {
RepeatModePicker(repeatMode: $model.repeatMode)
}
}
.disabled(model.duration.isIndefinite)
Button {
Task {
await model.playNextItem()
Expand Down

0 comments on commit 7e1e2cc

Please sign in to comment.