Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update default context for ManagedPlayer to use JSVirtualMachine #119

Merged
merged 1 commit into from
Jan 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions ios/packages/swiftui/Sources/ManagedPlayer/ManagedPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,6 @@ internal struct ManagedPlayer14<Loading: View, Fallback: View>: View {

private var handleScroll: Bool

// Whether or not its a the start of a new flow
// once the animation has been shown we need to remove it
// otherwise you get flickering double transitions between views in a flow
@State private var newFlow = true

/**
Creates a `ManagedPlayer`
- parameters:
Expand Down Expand Up @@ -192,8 +187,7 @@ internal struct ManagedPlayer14<Loading: View, Fallback: View>: View {
flow: flow,
plugins: plugins + [viewModel] + (handleScroll ? [ScrollPlugin()] : []),
result: $viewModel.result,
context: context,
unloadOnDisappear: false
context: context
)
}
}
Expand All @@ -211,7 +205,11 @@ public extension SwiftUIPlayer.Context {
}

private extension JSContext {
static let sharedManaged: JSContext! = JSContext()
static var sharedManaged: JSContext! { JSContext(virtualMachine: .playerShared) }
}

private extension JSVirtualMachine {
static let playerShared: JSVirtualMachine = .init()
}

internal struct ManagedPlayer13<Loading: View, Fallback: View>: View {
Expand All @@ -225,11 +223,6 @@ internal struct ManagedPlayer13<Loading: View, Fallback: View>: View {

private var handleScroll: Bool

// Whether or not its a the start of a new flow
// once the animation has been shown we need to remove it
// otherwise you get flickering double transitions between views in a flow
@State private var newFlow = true

// For ViewInspector testing
internal let inspection = Inspection<Self>()

Expand Down Expand Up @@ -293,8 +286,7 @@ internal struct ManagedPlayer13<Loading: View, Fallback: View>: View {
flow: flow,
plugins: plugins + [viewModel] + (handleScroll ? [ScrollPlugin()] : []),
result: $viewModel.result,
context: context,
unloadOnDisappear: false
context: context
)
}
}
Expand Down