Skip to content

Firely-Pasha/LuckyModal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LuckyModal

How to use

  1. Apply luckyModal() to your ContentView:
@main
struct LibTestApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .luckyModal()
        }
    }
}
  1. luckyModal() will automatically add LuckyModalManager as an EnvironmentObject. So just add EnvironmentObject in a view where you want to use modal:
struct SomeView: View {
    
    @EnvironmentObject var luckyModal: LuckyModalManager

    var body: some View {
        ... // some code        
    }
}
  1. And call showModal() method of LuckyModalManager object:
struct SomeView: View {
    
    ... // some code
    
    var body: some View {
        VStack {
            Button (action: {
                luckyModal.showModal(alignment: .bottom, edge: .bottom) {
                    VStack {
                        HStack {
                            Image(systemName: "person")
                            Text("Some text")
                        }
                        Button {
                            luckyModal.closeModal()
                        } label: {
                            Text("Close")
                        }
                    }
                    .padding()
                    .background(Color.init(.systemBackground))
                }
            }, label: {
                Text("Open")
            })
        }
    }
}
  1. To close modal call closeModal() method.

Docs

Documentation will be later... I hope.

About

A Flexible SwiftUI modal dialog library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages