1
0
mirror of https://github.com/yattee/yattee.git synced 2025-01-09 19:10:32 +05:30

Fix player size handling

This commit is contained in:
Arkadiusz Fal 2022-04-04 00:33:09 +02:00
parent 13688adb6e
commit 84a283ff1d

View File

@ -49,36 +49,43 @@ struct VideoPlayerView: View {
.onOpenURL { OpenURLHandler(accounts: accounts, player: player).handle($0) } .onOpenURL { OpenURLHandler(accounts: accounts, player: player).handle($0) }
.frame(minWidth: 950, minHeight: 700) .frame(minWidth: 950, minHeight: 700)
#else #else
HStack(spacing: 0) { GeometryReader { geometry in
content HStack(spacing: 0) {
.onAppear { content
#if os(iOS) .onAppear {
configureOrientationUpdatesBasedOnAccelerometer() playerSize = geometry.size
#endif
#if os(iOS)
configureOrientationUpdatesBasedOnAccelerometer()
#endif
}
}
.onChange(of: geometry.size) { size in
self.playerSize = size
}
.onChange(of: fullScreenDetails) { value in
player.backend.setNeedsDrawing(!value)
}
#if os(iOS)
.onReceive(NotificationCenter.default.publisher(for: UIDevice.orientationDidChangeNotification)) { _ in
handleOrientationDidChangeNotification()
}
.onDisappear {
guard !playerControls.playingFullscreen else {
return // swiftlint:disable:this implicit_return
} }
}
.onChange(of: fullScreenDetails) { value in
player.backend.setNeedsDrawing(!value)
}
#if os(iOS)
.onReceive(NotificationCenter.default.publisher(for: UIDevice.orientationDidChangeNotification)) { _ in
handleOrientationDidChangeNotification()
}
.onDisappear {
guard !playerControls.playingFullscreen else {
return // swiftlint:disable:this implicit_return
}
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
}
#endif
} }
#endif
#endif #endif
} }