- Apply
luckyModal()to yourContentView:
@main
struct LibTestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.luckyModal()
}
}
}luckyModal()will automatically addLuckyModalManageras anEnvironmentObject. So just addEnvironmentObjectin a view where you want to use modal:
struct SomeView: View {
@EnvironmentObject var luckyModal: LuckyModalManager
var body: some View {
... // some code
}
}- And call
showModal()method ofLuckyModalManagerobject:
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")
})
}
}
}- To close modal call
closeModal()method.
Documentation will be later... I hope.