@@ -12,22 +12,22 @@ class TabViewProps: ObservableObject {
1212 @Published var icons : [ Int : UIImage ] = [ : ]
1313 @Published var sidebarAdaptable : Bool ?
1414 @Published var labeled : Bool ?
15- @Published var ignoresTopSafeArea : Bool ?
16- @Published var disablePageAnimations : Bool = false
1715 @Published var scrollEdgeAppearance : String ?
18- @Published var translucent : Bool = true
1916 @Published var barTintColor : UIColor ?
2017 @Published var activeTintColor : UIColor ?
2118 @Published var inactiveTintColor : UIColor ?
19+ @Published var translucent : Bool = true
20+ @Published var ignoresTopSafeArea : Bool = true
21+ @Published var disablePageAnimations : Bool = false
2222 @Published var hapticFeedbackEnabled : Bool = true
23-
23+
2424 var selectedActiveTintColor : UIColor ? {
2525 if let selectedPage = selectedPage,
2626 let tabData = items. findByKey ( selectedPage) ,
2727 let activeTintColor = tabData. activeTintColor {
2828 return activeTintColor
2929 }
30-
30+
3131 return activeTintColor
3232 }
3333}
@@ -37,11 +37,11 @@ class TabViewProps: ObservableObject {
3737 */
3838struct RepresentableView : UIViewRepresentable {
3939 var view : UIView
40-
40+
4141 func makeUIView( context: Context ) -> UIView {
4242 return view
4343 }
44-
44+
4545 func updateUIView( _ uiView: UIView , context: Context ) { }
4646}
4747
@@ -52,7 +52,7 @@ struct TabViewImpl: View {
5252 @ObservedObject var props : TabViewProps
5353 var onSelect : ( _ key: String ) -> Void
5454 var onLongPress : ( _ key: String ) -> Void
55-
55+
5656 var body : some View {
5757 TabView ( selection: $props. selectedPage) {
5858 ForEach ( props. children. indices, id: \. self) { index in
@@ -63,7 +63,7 @@ struct TabViewImpl: View {
6363 guard let key = props. items. filter ( {
6464 !$0. hidden || $0. key == props. selectedPage
6565 } ) [ safe: index] ? . key else { return }
66-
66+
6767 if isLongPress {
6868 onLongPress ( key)
6969 emitHapticFeedback ( longPress: true )
@@ -84,20 +84,20 @@ struct TabViewImpl: View {
8484 }
8585 }
8686 }
87-
87+
8888 @ViewBuilder
8989 private func renderTabItem( at index: Int ) -> some View {
9090 let tabData = props. items [ safe: index]
9191 let isHidden = tabData? . hidden ?? false
9292 let isFocused = props. selectedPage == tabData? . key
93-
93+
9494 if !isHidden || isFocused {
9595 let child = props. children [ safe: index] ?? UIView ( )
9696 let icon = props. icons [ index]
97-
97+
9898 RepresentableView ( view: child)
9999 . ignoresTopSafeArea (
100- props. ignoresTopSafeArea ?? false ,
100+ props. ignoresTopSafeArea,
101101 frame: child. frame
102102 )
103103 . tabItem {
@@ -120,13 +120,13 @@ struct TabViewImpl: View {
120120#endif
121121 }
122122 }
123-
123+
124124 func emitHapticFeedback( longPress: Bool = false ) {
125125#if os(iOS)
126126 if !props. hapticFeedbackEnabled {
127127 return
128128 }
129-
129+
130130 if longPress {
131131 UINotificationFeedbackGenerator ( ) . notificationOccurred ( . success)
132132 } else {
@@ -141,16 +141,16 @@ private func configureAppearance(for appearanceType: String, appearance: UITabBa
141141 if ( appearanceType == " transparent " ) {
142142 return appearance
143143 }
144-
144+
145145 switch appearanceType {
146146 case " opaque " :
147147 appearance. configureWithOpaqueBackground ( )
148148 default :
149149 appearance. configureWithDefaultBackground ( )
150150 }
151-
151+
152152 UITabBar . appearance ( ) . scrollEdgeAppearance = appearance
153-
153+
154154 return appearance
155155}
156156
@@ -166,7 +166,7 @@ private func configureAppearance(inactiveTint inactiveTintColor: UIColor?, appea
166166 setTabBarItemColors ( appearance. inlineLayoutAppearance, inactiveColor: inactiveTintColor)
167167 setTabBarItemColors ( appearance. compactInlineLayoutAppearance, inactiveColor: inactiveTintColor)
168168 }
169-
169+
170170 return appearance
171171}
172172
@@ -176,23 +176,23 @@ private func updateTabBarAppearance(props: TabViewProps) {
176176 inactiveTint: props. inactiveTintColor,
177177 appearance: appearance
178178 )
179-
180-
179+
180+
181181 if #available( iOS 15 . 0 , * ) {
182182 appearance = configureAppearance ( for: props. scrollEdgeAppearance ?? " " , appearance: appearance)
183-
183+
184184 if props. translucent == false {
185185 appearance. configureWithOpaqueBackground ( )
186186 }
187-
187+
188188 if props. barTintColor != nil {
189189 appearance. backgroundColor = props. barTintColor
190190 }
191191 } else {
192192 UITabBar . appearance ( ) . barTintColor = props. barTintColor
193193 UITabBar . appearance ( ) . isTranslucent = props. translucent
194194 }
195-
195+
196196 UITabBar . appearance ( ) . standardAppearance = appearance
197197}
198198
@@ -201,7 +201,7 @@ struct TabItem: View {
201201 var icon : UIImage ?
202202 var sfSymbol : String ?
203203 var labeled : Bool ?
204-
204+
205205 var body : some View {
206206 if let icon {
207207 Image ( uiImage: icon)
@@ -230,7 +230,7 @@ extension View {
230230 self
231231 }
232232 }
233-
233+
234234 @ViewBuilder
235235 func tabBadge( _ data: String ? ) -> some View {
236236 if #available( iOS 15 . 0 , macOS 15 . 0 , visionOS 2 . 0 , tvOS 15 . 0 , * ) {
@@ -247,7 +247,7 @@ extension View {
247247 self
248248 }
249249 }
250-
250+
251251 @ViewBuilder
252252 func ignoresTopSafeArea(
253253 _ flag: Bool ,
@@ -264,7 +264,7 @@ extension View {
264264 . frame ( idealWidth: frame. width, idealHeight: frame. height)
265265 }
266266 }
267-
267+
268268 @ViewBuilder
269269 func configureAppearance( props: TabViewProps ) -> some View {
270270 self
@@ -287,7 +287,7 @@ extension View {
287287 updateTabBarAppearance ( props: props)
288288 }
289289 }
290-
290+
291291 @ViewBuilder
292292 func tintColor( _ color: UIColor ? ) -> some View {
293293 if let color {
@@ -301,7 +301,7 @@ extension View {
301301 self
302302 }
303303 }
304-
304+
305305 // Allows TabView to use unfilled SFSymbols.
306306 // By default they are always filled.
307307 @ViewBuilder
0 commit comments