yattee/macOS/Player.swift

28 lines
692 B
Swift
Raw Permalink 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: NSViewControllerRepresentable {
@EnvironmentObject<PlayerModel> private var player
2021-07-18 22:32:46 +00:00
@State private var controller: PlayerViewController?
init(controller: PlayerViewController? = nil) {
self.controller = controller
}
2021-09-25 08:18:22 +00:00
2021-07-18 22:32:46 +00:00
func makeNSViewController(context _: Context) -> PlayerViewController {
if self.controller != nil {
return self.controller!
}
2021-08-22 19:13:33 +00:00
let controller = PlayerViewController()
2021-09-25 08:18:22 +00:00
controller.playerModel = player
2021-10-13 22:10:29 +00:00
player.controller = controller
2021-07-18 22:32:46 +00:00
return controller
}
func updateNSViewController(_: PlayerViewController, context _: Context) {}
}