Skip to content

A simple SwiftUI view modifier to empower the usage of popovers on the iPhone.

License

Notifications You must be signed in to change notification settings

mtzaquia/PopoverContainer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PopoverContainer

A simple SwiftUI view modifier to empower the usage of popovers on the iPhone.

Usage

struct ContentView: View {
	
	...

	@State var presentingFirstPopover = false
	@State var presentingSecondPopover = false

	var body: some View {
		NavigationView {
			
			...
			
			Button(action: {
				presentingFirstPopover.toggle()
			}) {
				Text("First popover")
			}
			.popoverAnchor(named: "first")
			
			...
			
			.navigationBarItems(trailing:
			  Button(action: {
				  presentingSecondPopover.toggle()
				}) {
				  Label("Second popover", systemImage: "ellipsis")
					  .labelStyle(IconOnlyLabelStyle())
					}
					.popoverAnchor(named: "second")
			)
		}
		.popoverContainer(isPresented: $presentingFirstPopover, anchorName: "first") {
			Text("First popover is here!")
		}
		.popoverContainer(isPresented: $presentingSecondPopover, anchorName: "second") {
			Text("Second popover is here!")
		}
	}
  
  ...
  
}

Credits

Thanks to @steipete for the original idea, available at SwiftUI in Production.

About

A simple SwiftUI view modifier to empower the usage of popovers on the iPhone.

Topics

Resources

License

Stars

Watchers

Forks

Languages