From 4b8f2a6922f7c8990de0680dd9b002b003ff5959 Mon Sep 17 00:00:00 2001 From: Douglas Lowder Date: Tue, 12 Nov 2024 10:02:02 -0800 Subject: [PATCH] fix: tvOS compile error and appearance (#140) --- ios/TabViewImpl.swift | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ios/TabViewImpl.swift b/ios/TabViewImpl.swift index 270fea3..a4e3336 100644 --- a/ios/TabViewImpl.swift +++ b/ios/TabViewImpl.swift @@ -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 + } } } @@ -211,6 +212,12 @@ 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 @@ -218,7 +225,7 @@ private func configureTransparentAppearance(tabBar: UITabBar, props: TabViewProp 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, @@ -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,