@@ -7,9 +7,9 @@ import React
77 */
88class TabViewProps : ObservableObject {
99 @Published var children : [ UIView ] ?
10+ @Published var config : TabViewConfig ?
1011 @Published var items : TabData ?
1112 @Published var selectedPage : String ?
12- @Published var tabViewStyle : String ?
1313 @Published var icons : [ Int : UIImage ] = [ : ]
1414}
1515
@@ -38,50 +38,56 @@ struct TabViewImpl: View {
3838 let child = props. children ? [ safe: index] ?? UIView ( )
3939 let tabData = props. items? . tabs [ safe: index]
4040 let icon = props. icons [ index]
41+
4142 RepresentableView ( view: child)
4243 . frame ( maxWidth: . infinity, maxHeight: . infinity)
4344 . tabItem {
44- TabItem ( icon: icon, sfSymbol: tabData? . sfSymbol, title: tabData? . title)
45+ TabItem (
46+ title: tabData? . title,
47+ icon: icon,
48+ sfSymbol: tabData? . sfSymbol,
49+ labeled: props. config? . labeled
50+ )
4551 }
4652 . tag ( tabData? . key)
4753 . tabBadge ( tabData? . badge)
4854 }
49- . getTabViewStyle ( name: props. tabViewStyle ?? " " )
5055 . onChange ( of: props. selectedPage ?? " " ) { newValue in
5156 onSelect ( newValue)
5257 }
5358 }
59+ . getSidebarAdaptable ( enabled: props. config? . sidebarAdaptable ?? false )
5460 }
5561}
5662
5763struct TabItem : View {
64+ var title : String ?
5865 var icon : UIImage ?
5966 var sfSymbol : String ?
60- var title : String ?
67+ var labeled : Bool ?
6168
6269 var body : some View {
6370 if let icon {
6471 Image ( uiImage: icon)
6572 } else if let sfSymbol, !sfSymbol. isEmpty {
6673 Image ( systemName: sfSymbol)
6774 }
68- Text ( title ?? " " )
75+ if ( labeled != false ) {
76+ Text ( title ?? " " )
77+ }
6978 }
7079}
7180
7281extension View {
7382 @ViewBuilder
74- func getTabViewStyle( name: String ) -> some View {
75- switch name {
76- case " automatic " :
77- self . tabViewStyle ( . automatic)
78- case " sidebarAdaptable " :
79- if #available( iOS 18 . 0 , macOS 15 . 0 , tvOS 18 . 0 , visionOS 2 . 0 , * ) {
83+ func getSidebarAdaptable( enabled: Bool ) -> some View {
84+ if #available( iOS 18 . 0 , macOS 15 . 0 , tvOS 18 . 0 , visionOS 2 . 0 , * ) {
85+ if ( enabled) {
8086 self . tabViewStyle ( . sidebarAdaptable)
8187 } else {
8288 self
8389 }
84- default :
90+ } else {
8591 self
8692 }
8793 }
0 commit comments