mirror of
https://github.com/yattee/yattee.git
synced 2024-12-13 22:00:31 +05:30
36 lines
1.0 KiB
Swift
36 lines
1.0 KiB
Swift
import Defaults
|
|
import SwiftUI
|
|
|
|
struct Player: UIViewControllerRepresentable {
|
|
@EnvironmentObject<CommentsModel> private var comments
|
|
@EnvironmentObject<NavigationModel> private var navigation
|
|
@EnvironmentObject<PlayerModel> private var player
|
|
@EnvironmentObject<SubscriptionsModel> private var subscriptions
|
|
|
|
var controller: PlayerViewController?
|
|
|
|
init(controller: PlayerViewController? = nil) {
|
|
self.controller = controller
|
|
}
|
|
|
|
func makeUIViewController(context _: Context) -> PlayerViewController {
|
|
if self.controller != nil {
|
|
return self.controller!
|
|
}
|
|
|
|
let controller = PlayerViewController()
|
|
|
|
controller.commentsModel = comments
|
|
controller.navigationModel = navigation
|
|
controller.playerModel = player
|
|
controller.subscriptionsModel = subscriptions
|
|
player.controller = controller
|
|
|
|
return controller
|
|
}
|
|
|
|
func updateUIViewController(_: PlayerViewController, context _: Context) {
|
|
player.rebuildTVMenu()
|
|
}
|
|
}
|