LeoNatan / LNPopupUI

A SwiftUI library for presenting views as popups, much like the Apple Music and Podcasts apps.
MIT License
320 stars 29 forks source link

Minimal Example Crashes on Load #1

Closed olirice closed 4 years ago

olirice commented 4 years ago

A minimal example is crashing on load

Xcode 11.6 LNPopupUI 1.0.2 LNPopupController 2.10.1 iOS Deployment Target 13.5 Swift version 5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53) Target: x86_64-apple-darwin19.4.0

Here's the reproducible case:

ContentView.swift

import SwiftUI
import LNPopupUI

struct BasicView: View {

    var body: some View {
        VStack {
            Text("Hello, world!")
        }
        .popupTitle("Hi")
        .popupImage("heart")
        .popupProgress(0.5)
        .popupBarItems(leading: {
            HStack(spacing: 20) {
                Button(action: {}) {
                    Image(systemName: "pause.fill")
                }
            }
        }, trailing: {
            HStack(spacing: 20) {
                Button(action: {
                    print("Next")
                }) {
                    Image(systemName: "forward.fill")
                }
            }
        })
    }
}

struct ContentView: View {
    @State var selectedTabIndex: Int = 2

    @State var isPopupPresented: Bool = true
    @State var isPopupOpen: Bool = false

    var body: some View {
        TabView(selection: self.$selectedTabIndex) {

            Text("First View").tabItem {
                VStack {
                    Text("Tab 1")
                    Image(systemName: "list.bullet")
                }

            }.tag(1)
            Text("Second View").tabItem {
                VStack {
                    Text("Tab 2")
                    Image(systemName: "rectangle.stack")
                }
            }.tag(2)
        }        .popup(isBarPresented: $isPopupPresented, isPopupOpen: $isPopupOpen) {
                    BasicView()
                }
                .popupBarStyle(.prominent)
                .popupBarProgressViewStyle(.top)
                .popupBarMarqueeScrollEnabled(true)

    }

}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Crashes with:

crash

Am I missing a required component, or is this a bug?

LeoNatan commented 4 years ago

Hello, Can you please expand the stack trace to include the entire trace? If you run the included example project, does it also crash?

Thanks!

LeoNatan commented 4 years ago

Reproduced with your code, investigating.

LeoNatan commented 4 years ago

Interestingly, it doesn't crash on iOS 14 beta.

olirice commented 4 years ago

Thanks for the fast response

Reproduced with your code, investigating.

Skipping the stack trace b/c you were able to reproduce (didn't want to not respond to the request)

LeoNatan commented 4 years ago

Fixed in 1.0.3. Let me know if it works for you. Cheers

LeoNatan commented 4 years ago

LNPopupUI is my first foray into SwiftUI, so pardon the initial difficulties. LNPopupController is a mature framework with many users: https://github.com/LeoNatan/LNPopupController If you find that there is some feature in -Controller that isn't exposed in -UI, let me know. Thanks

olirice commented 4 years ago

1.0.3 is working great, thanks for your help!

LeoNatan commented 4 years ago

There was another issue in 1.0.3 which is now fixed in 1.0.4. Thnks