getsidetrack / swiftui-pipify

A SwiftUI component for launching custom picture-in-picture experiences
MIT License
152 stars 12 forks source link

Failed to start PictureInPicture #29

Open mrsunx opened 1 year ago

mrsunx commented 1 year ago

When I add a Form and Picker, PiP fails to start.

"The UIScene for the content source has an activation state other than UISceneActivationStateForegroundActive, which is not allowed."

import SwiftUI
import Pipify

struct ContentView: View {
    @State var isPresentedOne = false
    @State var isPresentedTwo = false
    @State var isPresentedThree = false
    @State var isPresentedFour = false

    @State var selected: Int = 0

    var body: some View {
        Form {

            Picker(selection: $selected) {
                ForEach([1, 2, 3, 4, 0], id:\.self) { value in
                    Text("\(value)").tag(value)
                }
            } label: {
                Text("Number")
            }
            .pickerStyle(.inline)

            Text("SwiftUI Pipify")
                .font(.title)

            Button("Launch Basic Example") {
                isPresentedTwo.toggle()
            }

            Text("Pipify View (Tap on me!)")
                .foregroundColor(.red)
                .fontWeight(.medium)
                .padding()
                .background(Color.gray.opacity(0.2))
                .cornerRadius(8)
                .pipify(isPresented: $isPresentedOne)
                .padding(.top)
                .onTapGesture {
                    isPresentedOne.toggle()
                }

            Button("Basic Example") { isPresentedThree.toggle() }
                .pipify(isPresented: $isPresentedThree) {
                    Text("Example Three")
                        .foregroundColor(.red)
                        .padding()
                        .onPipSkip { _ in }
                        .onPipPlayPause { _ in }
                }

            Button("Progress Bar") { isPresentedFour.toggle() }
                .pipify(isPresented: $isPresentedFour) { PipifyLoadingBarView() }
        }
        .frame(maxWidth: .infinity, maxHeight: .infinity)
        .pipify(isPresented: $isPresentedTwo, content: BasicExample.init)
    }
}
mrsunx commented 1 year ago

Only on iPad OS