Skip to content

Commit fad460c

Browse files
committed
fix: tvOS compile error and appearance
1 parent 2a5c6d8 commit fad460c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

ios/TabViewImpl.swift

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,18 @@ struct TabViewImpl: View {
128128
}
129129
.tag(tabData?.key)
130130
.tabBadge(tabData?.badge)
131-
#if os(iOS)
132131
.onAppear {
132+
#if os(iOS)
133133
guard index >= 4,
134134
let key = tabData?.key,
135135
props.selectedPage != key else { return }
136136
onSelect(key)
137+
#endif
138+
#if os(tvOS)
139+
// TV needs this to correctly update appearance on first render
140+
updateTabBarAppearance(props: props, tabBar: tabBar)
141+
#endif
137142
}
138-
#endif
139143
}
140144
}
141145

@@ -213,14 +217,20 @@ private func createFontAttributes(
213217
return attributes
214218
}
215219

220+
#if os(tvOS)
221+
let tabBarDefaultFontSize: CGFloat = 30.0
222+
#else
223+
let tabBarDefaultFontSize: CGFloat = UIFont.smallSystemFontSize
224+
#endif
225+
216226
private func configureTransparentAppearance(tabBar: UITabBar, props: TabViewProps) {
217227
tabBar.barTintColor = props.barTintColor
218228
tabBar.isTranslucent = props.translucent
219229
tabBar.unselectedItemTintColor = props.inactiveTintColor
220230

221231
guard let items = tabBar.items else { return }
222232

223-
let fontSize = props.fontSize != nil ? CGFloat(props.fontSize!) : UIFont.smallSystemFontSize
233+
let fontSize = props.fontSize != nil ? CGFloat(props.fontSize!) : tabBarDefaultFontSize
224234
let attributes = createFontAttributes(
225235
size: fontSize,
226236
family: props.fontFamily,
@@ -247,7 +257,7 @@ private func configureStandardAppearance(tabBar: UITabBar, props: TabViewProps)
247257

248258
// Configure item appearance
249259
let itemAppearance = UITabBarItemAppearance()
250-
let fontSize = props.fontSize != nil ? CGFloat(props.fontSize!) : UIFont.smallSystemFontSize
260+
let fontSize = props.fontSize != nil ? CGFloat(props.fontSize!) : tabBarDefaultFontSize
251261

252262
let attributes = createFontAttributes(
253263
size: fontSize,

0 commit comments

Comments
 (0)