Player overlaying other views and swipe gesture (fix #44, #130)

This commit is contained in:
Arkadiusz Fal
2022-05-28 23:41:23 +02:00
parent 687949fbd5
commit 78d7693128
17 changed files with 187 additions and 209 deletions

View File

@@ -10,7 +10,6 @@ struct ChannelPlaylistView: View {
@StateObject private var store = Store<ChannelPlaylist>()
@Environment(\.colorScheme) private var colorScheme
@Environment(\.inNavigationView) private var inNavigationView
@EnvironmentObject<AccountsModel> private var accounts
@EnvironmentObject<PlayerModel> private var player
@@ -24,19 +23,9 @@ struct ChannelPlaylistView: View {
}
var body: some View {
#if os(iOS)
if inNavigationView {
content
} else {
BrowserPlayerControls {
content
}
}
#else
BrowserPlayerControls {
content
}
#endif
BrowserPlayerControls {
content
}
}
var content: some View {
@@ -94,9 +83,6 @@ struct ChannelPlaylistView: View {
}
}
.navigationTitle(playlist.title)
#if os(iOS)
.navigationBarHidden(player.playerNavigationLinkActive)
#endif
#endif
}
@@ -110,7 +96,7 @@ struct ChannelPlaylistView: View {
private var playButton: some View {
Button {
player.play(videos, inNavigationView: inNavigationView)
player.play(videos)
} label: {
Label("Play All", systemImage: "play")
}
@@ -118,7 +104,7 @@ struct ChannelPlaylistView: View {
private var shuffleButton: some View {
Button {
player.play(videos, shuffling: true, inNavigationView: inNavigationView)
player.play(videos, shuffling: true)
} label: {
Label("Shuffle", systemImage: "shuffle")
}

View File

@@ -13,7 +13,6 @@ struct ChannelVideosView: View {
@Environment(\.colorScheme) private var colorScheme
#if os(iOS)
@Environment(\.inNavigationView) private var inNavigationView
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
@EnvironmentObject<PlayerModel> private var player
#endif
@@ -29,19 +28,9 @@ struct ChannelVideosView: View {
}
var body: some View {
#if os(iOS)
if inNavigationView {
content
} else {
BrowserPlayerControls {
content
}
}
#else
BrowserPlayerControls {
content
}
#endif
BrowserPlayerControls {
content
}
}
var content: some View {
@@ -115,9 +104,6 @@ struct ChannelVideosView: View {
resource.load()
}
}
#if os(iOS)
.navigationBarHidden(player.playerNavigationLinkActive)
#endif
.navigationTitle(navigationTitle)
return Group {

View File

@@ -4,7 +4,6 @@ import SwiftUI
struct PlaylistVideosView: View {
let playlist: Playlist
@Environment(\.inNavigationView) private var inNavigationView
@EnvironmentObject<PlayerModel> private var player
@EnvironmentObject<PlaylistsModel> private var model
@@ -66,13 +65,13 @@ struct PlaylistVideosView: View {
FavoriteButton(item: FavoriteItem(section: .channelPlaylist(playlist.id, playlist.title)))
Button {
player.play(videos, inNavigationView: inNavigationView)
player.play(videos)
} label: {
Label("Play All", systemImage: "play")
}
Button {
player.play(videos, shuffling: true, inNavigationView: inNavigationView)
player.play(videos, shuffling: true)
} label: {
Label("Shuffle", systemImage: "shuffle")
}

View File

@@ -5,9 +5,6 @@ import SwiftUI
struct VideoContextMenuView: View {
let video: Video
@Binding var playerNavigationLinkActive: Bool
@Environment(\.inNavigationView) private var inNavigationView
@Environment(\.inChannelView) private var inChannelView
@Environment(\.inChannelPlaylistView) private var inChannelPlaylistView
@Environment(\.navigationStyle) private var navigationStyle
@@ -26,9 +23,8 @@ struct VideoContextMenuView: View {
private var viewContext: NSManagedObjectContext = PersistenceController.shared.container.viewContext
init(video: Video, playerNavigationLinkActive: Binding<Bool>) {
init(video: Video) {
self.video = video
_playerNavigationLinkActive = playerNavigationLinkActive
_watchRequest = video.watchFetchRequest
}
@@ -111,7 +107,7 @@ struct VideoContextMenuView: View {
private var continueButton: some View {
Button {
player.play(video, at: .secondsInDefaultTimescale(watch!.stoppedAt), inNavigationView: inNavigationView)
player.play(video, at: .secondsInDefaultTimescale(watch!.stoppedAt))
} label: {
Label("Continue from \(watch!.stoppedAt.formattedAsPlaybackTime() ?? "where I left off")", systemImage: "playpause")
}
@@ -131,7 +127,7 @@ struct VideoContextMenuView: View {
private var playNowButton: some View {
Button {
player.play(video, inNavigationView: inNavigationView)
player.play(video)
} label: {
Label("Play Now", systemImage: "play")
}