Skip to content

Masataka-n/PopupViewSwiftUI

Repository files navigation

PopupViewSwiftUI

This is a library that displays View in a popup.

Version License Platform

demo

Usage

ParentView

struct ContentView: View {

    @State var isPresented: Bool = false

    var body: some View {
        VStack {
            Text("Popup View")
                .padding()
            Button("Show Popup") {
                self.isPresented.toggle()
            }
        }
        .popup(isPresented: $isPresented, animation: nil, content: {
            PopupView(isPresented: self.$isPresented)
        })
        .edgesIgnoringSafeArea(.all)
    }
}

ChildView

struct PopupView: View {

    @Binding var isPresented: Bool

    var body: some View {
        VStack {
            Text("PopupView")
                .padding()
            Button("Close") {
                self.isPresented.toggle()
            }
            .padding()
        }
        .frame(width: 300, height: 300)
        .background(Color.orange)
        .cornerRadius(10)
        .padding()
    }
}

Installation

PopupViewSwiftUI is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'PopupViewSwiftUI', '~> 1.0'

License

PopupViewSwiftUI is available under the MIT license. See the LICENSE file for more info.

About

This is a library that displays View in a popup.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages