From 914b14f325668fe1aecbd5b594b819d70bed2540 Mon Sep 17 00:00:00 2001 From: Douglas Lowder Date: Mon, 11 Nov 2024 17:11:18 -0800 Subject: [PATCH 1/2] fix: tvOS compile error and appearance --- ios/TabViewImpl.swift | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ios/TabViewImpl.swift b/ios/TabViewImpl.swift index 270fea30..12c0f9b6 100644 --- a/ios/TabViewImpl.swift +++ b/ios/TabViewImpl.swift @@ -125,15 +125,18 @@ struct TabViewImpl: View { } .tag(tabData?.key) .tabBadge(tabData?.badge) -#if os(iOS) .onAppear { updateTabBarAppearance(props: props, tabBar: tabBar) guard index >= 4, let key = tabData?.key, props.selectedPage != key else { return } onSelect(key) + #endif + #if os(tvOS) + // TV needs this to correctly update appearance on first render + updateTabBarAppearance(props: props, tabBar: tabBar) + #endif } -#endif } } @@ -211,6 +214,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 +227,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 +254,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, From a6ec0e889b046b4dc909677d596d0772a00fe4d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Tue, 12 Nov 2024 18:55:34 +0100 Subject: [PATCH 2/2] fix: remove tvos specific update --- ios/TabViewImpl.swift | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ios/TabViewImpl.swift b/ios/TabViewImpl.swift index 12c0f9b6..a4e33363 100644 --- a/ios/TabViewImpl.swift +++ b/ios/TabViewImpl.swift @@ -127,15 +127,13 @@ struct TabViewImpl: View { .tabBadge(tabData?.badge) .onAppear { updateTabBarAppearance(props: props, tabBar: tabBar) + +#if os(iOS) guard index >= 4, let key = tabData?.key, props.selectedPage != key else { return } onSelect(key) - #endif - #if os(tvOS) - // TV needs this to correctly update appearance on first render - updateTabBarAppearance(props: props, tabBar: tabBar) - #endif +#endif } } }