Minor fixes

This commit is contained in:
Arkadiusz Fal 2022-05-29 22:30:00 +02:00
parent f2e9bcaefe
commit d5558b2f85
4 changed files with 24 additions and 26 deletions

View File

@ -24,7 +24,8 @@ final class PiPDelegate: NSObject, AVPictureInPictureControllerDelegate {
} }
if player.avPlayerBackend.switchToMPVOnPipClose, if player.avPlayerBackend.switchToMPVOnPipClose,
!player.currentItem.isNil { !player.currentItem.isNil
{
DispatchQueue.main.async { DispatchQueue.main.async {
player.avPlayerBackend.switchToMPVOnPipClose = false player.avPlayerBackend.switchToMPVOnPipClose = false
player.saveTime { player.saveTime {
@ -45,7 +46,7 @@ final class PiPDelegate: NSObject, AVPictureInPictureControllerDelegate {
if !player.currentItem.isNil { if !player.currentItem.isNil {
player?.show() player?.show()
} }
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
completionHandler(true) completionHandler(true)
} }

View File

@ -41,7 +41,7 @@ struct VideoPlayerView: View {
var mouseLocation: CGPoint { NSEvent.mouseLocation } var mouseLocation: CGPoint { NSEvent.mouseLocation }
#endif #endif
#if !os(macOS) #if os(iOS)
@State private var viewVerticalOffset = Self.hiddenOffset @State private var viewVerticalOffset = Self.hiddenOffset
#endif #endif
@ -74,31 +74,28 @@ struct VideoPlayerView: View {
.onReceive(NotificationCenter.default.publisher(for: UIDevice.orientationDidChangeNotification)) { _ in .onReceive(NotificationCenter.default.publisher(for: UIDevice.orientationDidChangeNotification)) { _ in
handleOrientationDidChangeNotification() handleOrientationDidChangeNotification()
} }
#endif
.onChange(of: player.presentingPlayer) { newValue in .onChange(of: player.presentingPlayer) { newValue in
if newValue { if newValue {
viewVerticalOffset = 0 viewVerticalOffset = 0
#if os(iOS) configureOrientationUpdatesBasedOnAccelerometer()
configureOrientationUpdatesBasedOnAccelerometer()
#endif
} else { } else {
#if os(iOS) if Defaults[.lockPortraitWhenBrowsing] {
if Defaults[.lockPortraitWhenBrowsing] { Orientation.lockOrientation(.portrait, andRotateTo: .portrait)
Orientation.lockOrientation(.portrait, andRotateTo: .portrait) } else {
} else { Orientation.lockOrientation(.allButUpsideDown)
Orientation.lockOrientation(.allButUpsideDown) }
}
motionManager?.stopAccelerometerUpdates() motionManager?.stopAccelerometerUpdates()
motionManager = nil motionManager = nil
viewVerticalOffset = Self.hiddenOffset viewVerticalOffset = Self.hiddenOffset
#endif
} }
} }
#endif
} }
#if os(iOS)
.offset(y: viewVerticalOffset) .offset(y: viewVerticalOffset)
.opacity(viewVerticalOffset == Self.hiddenOffset ? 0 : 1)
.animation(.easeIn(duration: 0.2), value: viewVerticalOffset) .animation(.easeIn(duration: 0.2), value: viewVerticalOffset)
#endif
#endif #endif
} }

View File

@ -62,7 +62,6 @@ struct ChannelPlaylistView: View {
} }
} }
.offset(y: viewVerticalOffset) .offset(y: viewVerticalOffset)
.opacity(viewVerticalOffset == Self.hiddenOffset ? 0 : 1)
.animation(.easeIn(duration: 0.2), value: viewVerticalOffset) .animation(.easeIn(duration: 0.2), value: viewVerticalOffset)
#endif #endif
} else { } else {
@ -76,14 +75,16 @@ struct ChannelPlaylistView: View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
#if os(tvOS) #if os(tvOS)
HStack { HStack {
Text(playlist.title) if let playlist = presentedPlaylist {
.font(.title2) Text(playlist.title)
.frame(alignment: .leading) .font(.title2)
.frame(alignment: .leading)
Spacer() Spacer()
FavoriteButton(item: FavoriteItem(section: .channelPlaylist(playlist.id, playlist.title))) FavoriteButton(item: FavoriteItem(section: .channelPlaylist(playlist.id, playlist.title)))
.labelStyle(.iconOnly) .labelStyle(.iconOnly)
}
playButton playButton
.labelStyle(.iconOnly) .labelStyle(.iconOnly)

View File

@ -58,7 +58,6 @@ struct ChannelVideosView: View {
} }
} }
.offset(y: viewVerticalOffset) .offset(y: viewVerticalOffset)
.opacity(viewVerticalOffset == Self.hiddenOffset ? 0 : 1)
.animation(.easeIn(duration: 0.2), value: viewVerticalOffset) .animation(.easeIn(duration: 0.2), value: viewVerticalOffset)
#endif #endif
} else { } else {