Skip to content

Commit 16ec5b4

Browse files
committed
chore: simplify solution
1 parent 5177c2f commit 16ec5b4

4 files changed

Lines changed: 8 additions & 44 deletions

File tree

packages/react-native-bottom-tabs/ios/TabItem.swift

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,20 @@ struct TabItem: View {
55
var icon: PlatformImage?
66
var sfSymbol: String?
77
var labeled: Bool?
8-
var inactiveTintColor: PlatformColor?
9-
10-
private var tint: Color? {
11-
inactiveTintColor.map(Color.init)
12-
}
13-
14-
#if !os(macOS)
15-
private var tintedIcon: PlatformImage? {
16-
guard let icon else { return nil }
17-
guard let inactiveTintColor else { return icon }
18-
return icon.withTintColor(inactiveTintColor, renderingMode: .alwaysOriginal)
19-
}
20-
#endif
218

229
var body: some View {
2310
if let icon {
2411
#if os(macOS)
2512
Image(nsImage: icon)
2613
#else
27-
Image(uiImage: tintedIcon ?? icon)
14+
Image(uiImage: icon)
2815
#endif
2916
} else if let sfSymbol, !sfSymbol.isEmpty {
3017
Image(systemName: sfSymbol)
3118
.noneSymbolVariant()
32-
.foregroundColor(tint)
3319
}
3420
if labeled != false {
3521
Text(title ?? "")
36-
.foregroundColor(tint)
3722
}
3823
}
3924
}

packages/react-native-bottom-tabs/ios/TabView/LegacyTabView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ struct LegacyTabView: AnyTabView {
5656
title: tabData.title,
5757
icon: icon,
5858
sfSymbol: tabData.sfSymbol,
59-
labeled: props.labeled,
60-
inactiveTintColor: props.inactiveTintColor
59+
labeled: props.labeled
6160
)
6261
.accessibilityIdentifier(tabData.testID ?? "")
6362
}

packages/react-native-bottom-tabs/ios/TabView/NewTabView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ struct NewTabView: AnyTabView {
4848
title: tabData.title,
4949
icon: icon,
5050
sfSymbol: tabData.sfSymbol,
51-
labeled: props.labeled,
52-
inactiveTintColor: props.inactiveTintColor
51+
labeled: props.labeled
5352
)
5453
}
5554
#if !os(tvOS)

packages/react-native-bottom-tabs/ios/TabViewImpl.swift

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ struct TabViewImpl: View {
8383
.tintColor(props.selectedActiveTintColor)
8484
.getSidebarAdaptable(enabled: props.sidebarAdaptable ?? false)
8585
.onChange(of: props.selectedPage ?? "") { newValue in
86-
#if !os(macOS)
87-
tabBar?.tintColor = props.selectedActiveTintColor
88-
#endif
8986
#if !os(macOS)
9087
if props.disablePageAnimations {
9188
UIView.setAnimationsEnabled(false)
@@ -124,9 +121,9 @@ struct TabViewImpl: View {
124121
if props.scrollEdgeAppearance == "transparent" {
125122
configureTransparentAppearance(tabBar: tabBar, props: props)
126123
return
127-
} else {
128-
configureStandardAppearance(tabBar: tabBar, props: props)
129124
}
125+
126+
configureStandardAppearance(tabBar: tabBar, props: props)
130127
}
131128
#endif
132129

@@ -141,15 +138,15 @@ struct TabViewImpl: View {
141138

142139
guard let items = tabBar.items else { return }
143140

144-
let attributes = TabBarFontSize.createNormalStateAttributes(
141+
let fontAttributes = TabBarFontSize.createNormalStateAttributes(
145142
fontSize: props.fontSize,
146143
fontFamily: props.fontFamily,
147144
fontWeight: props.fontWeight,
148-
inactiveColor: props.inactiveTintColor
145+
inactiveColor: nil
149146
)
150147

151148
items.forEach { item in
152-
item.setTitleTextAttributes(attributes, for: .normal)
149+
item.setTitleTextAttributes(fontAttributes, for: .normal)
153150
item.setTitleTextAttributes(selectedAttributes(props: props), for: .selected)
154151
}
155152
configureTabBarItemImages(items: items, props: props)
@@ -208,27 +205,11 @@ struct TabViewImpl: View {
208205
tabBar.scrollEdgeAppearance = appearance.copy()
209206
}
210207
if let items = tabBar.items {
211-
configureTabBarItemTitles(items: items, props: props)
212208
configureTabBarItemImages(items: items, props: props)
213209
configureTabBarItemImagesAfterLayout(tabBar: tabBar, props: props)
214210
}
215211
}
216212

217-
private func configureTabBarItemTitles(items: [UITabBarItem], props: TabViewProps) {
218-
let normalAttributes = TabBarFontSize.createNormalStateAttributes(
219-
fontSize: props.fontSize,
220-
fontFamily: props.fontFamily,
221-
fontWeight: props.fontWeight,
222-
inactiveColor: props.inactiveTintColor
223-
)
224-
let selectedAttributes = selectedAttributes(props: props)
225-
226-
items.forEach { item in
227-
item.setTitleTextAttributes(normalAttributes, for: .normal)
228-
item.setTitleTextAttributes(selectedAttributes, for: .selected)
229-
}
230-
}
231-
232213
private func configureTabBarItemImages(items: [UITabBarItem], props: TabViewProps) {
233214
for (tabBarIndex, item) in items.enumerated() {
234215
guard let tabData = props.filteredItems[safe: tabBarIndex],

0 commit comments

Comments
 (0)