SwiftUI implementation of a Hamburger menu
BurgerMenuView
is a SwiftUI that presents subviews and a popup 'hamburger' menu.
BurberMenuView
wraps the subviews with a dynamic menu and binds the isShowing
and currentPage
states.
This demo creates two sub-views (page0
and page1
) which, critially, need to be cast to AnyView
type structs. The Pages
View then dynamically presents the subviews, based on currentPage
state.
This demo has two fixed menus, but can be easily extended to support multiple subviews and, a better menu icon.
- Refactor into a Swift Package
- Add dynamic list of menu items, likely as a
stuct
input type