mirror of
https://github.com/yattee/yattee.git
synced 2024-12-14 22:30:32 +05:30
Improve orientation observing
This commit is contained in:
parent
cff3838a94
commit
cddb52f152
@ -46,6 +46,7 @@ struct VideoPlayerView: View {
|
|||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
@State private var viewVerticalOffset = Self.hiddenOffset
|
@State private var viewVerticalOffset = Self.hiddenOffset
|
||||||
|
@State private var orientationObserver: Any?
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@EnvironmentObject<AccountsModel> private var accounts
|
@EnvironmentObject<AccountsModel> private var accounts
|
||||||
@ -117,6 +118,7 @@ struct VideoPlayerView: View {
|
|||||||
Orientation.lockOrientation(.allButUpsideDown)
|
Orientation.lockOrientation(.allButUpsideDown)
|
||||||
}
|
}
|
||||||
viewVerticalOffset = Self.hiddenOffset
|
viewVerticalOffset = Self.hiddenOffset
|
||||||
|
stopOrientationUpdates()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -441,7 +443,7 @@ struct VideoPlayerView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(
|
orientationObserver = NotificationCenter.default.addObserver(
|
||||||
forName: OrientationTracker.deviceOrientationChangedNotification,
|
forName: OrientationTracker.deviceOrientationChangedNotification,
|
||||||
object: nil,
|
object: nil,
|
||||||
queue: .main
|
queue: .main
|
||||||
@ -476,6 +478,11 @@ struct VideoPlayerView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func stopOrientationUpdates() {
|
||||||
|
guard let observer = orientationObserver else { return }
|
||||||
|
NotificationCenter.default.removeObserver(observer)
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
|
Loading…
Reference in New Issue
Block a user