yattee/Shared/Player/Player.swift

36 lines
1.0 KiB
Swift
Raw Normal View History

2021-09-25 08:18:22 +00:00
import Defaults
2021-07-18 22:32:46 +00:00
import SwiftUI
struct Player: UIViewControllerRepresentable {
2021-12-04 19:35:41 +00:00
@EnvironmentObject<CommentsModel> private var comments
2021-10-28 17:14:55 +00:00
@EnvironmentObject<NavigationModel> private var navigation
@EnvironmentObject<PlayerModel> private var player
2021-12-17 20:01:05 +00:00
@EnvironmentObject<SubscriptionsModel> private var subscriptions
2021-08-23 21:31:51 +00:00
var controller: PlayerViewController?
init(controller: PlayerViewController? = nil) {
self.controller = controller
}
2021-07-18 22:32:46 +00:00
func makeUIViewController(context _: Context) -> PlayerViewController {
if self.controller != nil {
return self.controller!
}
2021-07-18 22:32:46 +00:00
let controller = PlayerViewController()
2021-08-22 19:13:33 +00:00
2021-12-04 19:35:41 +00:00
controller.commentsModel = comments
2021-10-28 17:14:55 +00:00
controller.navigationModel = navigation
controller.playerModel = player
2021-12-17 20:01:05 +00:00
controller.subscriptionsModel = subscriptions
2021-10-16 22:48:58 +00:00
player.controller = controller
2021-07-18 22:32:46 +00:00
return controller
}
2021-10-24 22:26:25 +00:00
func updateUIViewController(_: PlayerViewController, context _: Context) {
player.rebuildTVMenu()
}
2021-07-18 22:32:46 +00:00
}