Skip to content

Commit 4b8f2a6

Browse files
authored
fix: tvOS compile error and appearance (#140)
1 parent 653fafe commit 4b8f2a6

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

ios/TabViewImpl.swift

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,16 @@ struct TabViewImpl: View {
125125
}
126126
.tag(tabData?.key)
127127
.tabBadge(tabData?.badge)
128-
#if os(iOS)
129128
.onAppear {
130129
updateTabBarAppearance(props: props, tabBar: tabBar)
130+
131+
#if os(iOS)
131132
guard index >= 4,
132133
let key = tabData?.key,
133134
props.selectedPage != key else { return }
134135
onSelect(key)
135-
}
136136
#endif
137+
}
137138
}
138139
}
139140

@@ -211,14 +212,20 @@ private func createFontAttributes(
211212
return attributes
212213
}
213214

215+
#if os(tvOS)
216+
let tabBarDefaultFontSize: CGFloat = 30.0
217+
#else
218+
let tabBarDefaultFontSize: CGFloat = UIFont.smallSystemFontSize
219+
#endif
220+
214221
private func configureTransparentAppearance(tabBar: UITabBar, props: TabViewProps) {
215222
tabBar.barTintColor = props.barTintColor
216223
tabBar.isTranslucent = props.translucent
217224
tabBar.unselectedItemTintColor = props.inactiveTintColor
218225

219226
guard let items = tabBar.items else { return }
220227

221-
let fontSize = props.fontSize != nil ? CGFloat(props.fontSize!) : UIFont.smallSystemFontSize
228+
let fontSize = props.fontSize != nil ? CGFloat(props.fontSize!) : tabBarDefaultFontSize
222229
let attributes = createFontAttributes(
223230
size: fontSize,
224231
family: props.fontFamily,
@@ -245,7 +252,7 @@ private func configureStandardAppearance(tabBar: UITabBar, props: TabViewProps)
245252

246253
// Configure item appearance
247254
let itemAppearance = UITabBarItemAppearance()
248-
let fontSize = props.fontSize != nil ? CGFloat(props.fontSize!) : UIFont.smallSystemFontSize
255+
let fontSize = props.fontSize != nil ? CGFloat(props.fontSize!) : tabBarDefaultFontSize
249256

250257
let attributes = createFontAttributes(
251258
size: fontSize,

0 commit comments

Comments
 (0)