Skip to content

Commit

Permalink
fix: tvOS compile error and appearance (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
douglowder authored Nov 12, 2024
1 parent 653fafe commit 4b8f2a6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions ios/TabViewImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,16 @@ struct TabViewImpl: View {
}
.tag(tabData?.key)
.tabBadge(tabData?.badge)
#if os(iOS)
.onAppear {
updateTabBarAppearance(props: props, tabBar: tabBar)

#if os(iOS)
guard index >= 4,
let key = tabData?.key,
props.selectedPage != key else { return }
onSelect(key)
}
#endif
}
}
}

Expand Down Expand Up @@ -211,14 +212,20 @@ private func createFontAttributes(
return attributes
}

#if os(tvOS)
let tabBarDefaultFontSize: CGFloat = 30.0
#else
let tabBarDefaultFontSize: CGFloat = UIFont.smallSystemFontSize
#endif

private func configureTransparentAppearance(tabBar: UITabBar, props: TabViewProps) {
tabBar.barTintColor = props.barTintColor
tabBar.isTranslucent = props.translucent
tabBar.unselectedItemTintColor = props.inactiveTintColor

guard let items = tabBar.items else { return }

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

// Configure item appearance
let itemAppearance = UITabBarItemAppearance()
let fontSize = props.fontSize != nil ? CGFloat(props.fontSize!) : UIFont.smallSystemFontSize
let fontSize = props.fontSize != nil ? CGFloat(props.fontSize!) : tabBarDefaultFontSize

let attributes = createFontAttributes(
size: fontSize,
Expand Down

0 comments on commit 4b8f2a6

Please sign in to comment.