Shared seek model

This commit is contained in:
Arkadiusz Fal 2022-09-01 19:00:56 +02:00
parent 6643208579
commit 02617a7c42
5 changed files with 6 additions and 6 deletions

View File

@ -3,6 +3,8 @@ import Foundation
import SwiftUI
final class SeekModel: ObservableObject {
static let shared = SeekModel()
@Published var currentTime = CMTime.zero
@Published var duration = CMTime.zero

View File

@ -12,7 +12,6 @@ struct ContentView: View {
@EnvironmentObject<CommentsModel> private var comments
@EnvironmentObject<InstancesModel> private var instances
@EnvironmentObject<NavigationModel> private var navigation
@EnvironmentObject<PlayerModel> private var player
@EnvironmentObject<PlayerControlsModel> private var playerControls
@EnvironmentObject<PlaylistsModel> private var playlists
@EnvironmentObject<RecentsModel> private var recents
@ -29,6 +28,8 @@ struct ContentView: View {
@State private var playerInitialized = false
private var player = PlayerModel.shared
let persistenceController = PersistenceController.shared
var body: some View {

View File

@ -7,7 +7,7 @@ struct Seek: View {
#endif
@EnvironmentObject<PlayerControlsModel> private var controls
@EnvironmentObject<SeekModel> private var model
@StateObject private var model = SeekModel.shared
private var updateThrottle = Throttle(interval: 2)

View File

@ -461,7 +461,6 @@ struct VideoPlayerView: View {
struct VideoPlayerView_Previews: PreviewProvider {
static var previews: some View {
VideoPlayerView()
.environmentObject(SeekModel())
.injectFixtureEnvironmentObjects()
}
}

View File

@ -43,7 +43,6 @@ struct YatteeApp: App {
@StateObject private var playlists = PlaylistsModel()
@StateObject private var recents = RecentsModel()
@StateObject private var search = SearchModel()
@StateObject private var seek = SeekModel()
@StateObject private var settings = SettingsModel()
@StateObject private var subscriptions = SubscriptionsModel()
@StateObject private var thumbnails = ThumbnailsModel()
@ -64,7 +63,6 @@ struct YatteeApp: App {
.environmentObject(playerControls)
.environmentObject(playlists)
.environmentObject(recents)
.environmentObject(seek)
.environmentObject(settings)
.environmentObject(subscriptions)
.environmentObject(thumbnails)
@ -204,7 +202,7 @@ struct YatteeApp: App {
player.controls = playerControls
player.navigation = navigation
player.networkState = networkState
player.seek = seek
player.seek = .shared
PlayerTimeModel.shared.player = player