@@ -17,6 +17,7 @@ public struct TabBar<Content>: View where Content: View {
1717 // MARK: - PROPERTIES
1818
1919 private let content : Content
20+ private let usesVerticalLayout : Bool
2021
2122 @Binding private var selection : TabBarItem
2223 @State private var tabs : [ TabBarItem ] = [ ]
@@ -28,20 +29,35 @@ public struct TabBar<Content>: View where Content: View {
2829 /// - Parameters:
2930 /// - selection: Binding to the selected tab item.
3031 /// - content: The main content of the view.
31- public init ( selection: Binding < TabBarItem > , @ViewBuilder content: ( ) -> Content ) {
32+ /// - usesVerticalLayout: A Boolean value indicating whether to use a vertical layout for the tab bar.
33+ public init ( selection: Binding < TabBarItem > , usesVerticalLayout: Bool = false , @ViewBuilder content: ( ) -> Content ) {
3234 self . _selection = selection
3335 self . content = content ( )
36+ self . usesVerticalLayout = usesVerticalLayout
3437 }
3538
3639 // MARK: - View BODY
3740
3841 public var body : some View {
39- ZStack ( alignment: . bottom) {
40- content
41- . frame ( maxWidth: . infinity, maxHeight: . infinity)
42- . ignoresSafeArea ( edges: . bottom)
43-
44- TabBarContainer ( tabs: tabs, selection: $selection, localSelection: selection)
42+ Group {
43+ if usesVerticalLayout {
44+ VStack ( spacing: . zero) {
45+ ZStack ( alignment: . bottom) {
46+ content
47+ . frame ( maxWidth: . infinity, maxHeight: . infinity)
48+ }
49+
50+ TabBarContainer ( tabs: tabs, selection: $selection, localSelection: selection)
51+ }
52+ } else {
53+ ZStack ( alignment: . bottom) {
54+ content
55+ . frame ( maxWidth: . infinity, maxHeight: . infinity)
56+ . ignoresSafeArea ( edges: . bottom)
57+
58+ TabBarContainer ( tabs: tabs, selection: $selection, localSelection: selection)
59+ }
60+ }
4561 }
4662 . ignoresSafeArea ( . keyboard)
4763 . onPreferenceChange ( TabBarPreferenceKey . self) { value in
0 commit comments