-
-
Notifications
You must be signed in to change notification settings - Fork 663
chore(test): add tab-item-icon appearance scenario for iOS #4104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
832e828
chore(test):test-tabs-item-icon-ios new test screen and scneario
LKuchno 1fb48bf
Merge branch 'main' of github.com:software-mansion/react-native-scree…
LKuchno 1e1c157
Update scanario with new naming in e2e section
LKuchno a0892a4
change settins for XcassetIcon to use only icon config without select…
LKuchno 923f38f
update scenario after adding new tab
LKuchno c531361
Changing expectation about Image tab icon color as its non-tintable
LKuchno File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
205 changes: 205 additions & 0 deletions
205
apps/src/tests/single-feature-tests/tabs/test-tabs-item-icon-ios/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,205 @@ | ||
| import React from 'react'; | ||
| import { StyleSheet, Text, View } from 'react-native'; | ||
| import { scenarioDescription } from './scenario-description'; | ||
| import { createScenario } from '@apps/tests/shared/helpers'; | ||
| import { | ||
| TabsContainerWithHostConfigContext, | ||
| type TabRouteConfig, | ||
| DEFAULT_TAB_ROUTE_OPTIONS, | ||
| } from '@apps/shared/gamma/containers/tabs'; | ||
| import { Colors } from '@apps/shared/styling'; | ||
|
|
||
| function TintTab() { | ||
| return ( | ||
| <View style={styles.screen}> | ||
| <Text style={styles.label}>Template Source (Host Tint)</Text> | ||
| <Text style={styles.hint}> | ||
| Host `tabBarTintColor`:{' '} | ||
| <Text style={{ color: Colors.GreenDark100 }}>GreenDark100</Text>{'\n'} | ||
| `icon`: templateSource icon.png{'\n'} | ||
| `selectedIcon`: templateSource icon_fill.png{'\n'} | ||
| `tabBarItemIconColor` is NOT set.{'\n'} | ||
| {'\n'} | ||
| Selected: filled template image, tinted{' '} | ||
| <Text style={{ color: Colors.GreenDark100 }}>GREEN</Text>.{'\n'} | ||
| Unselected: Titles and icons render in the system theme color. For the last tab, the icon retains the black color from its source image. </Text> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| function OverrideTab() { | ||
| return ( | ||
| <View style={styles.screen}> | ||
| <Text style={styles.label}>SF Symbol (Tint Color Override)</Text> | ||
| <Text style={styles.hint}> | ||
| Host `tabBarTintColor`:{' '} | ||
| <Text style={{ color: Colors.GreenDark100 }}>GreenDark100</Text>{'\n'} | ||
| `selected.tabBarItemIconColor`:{' '} | ||
| <Text style={{ color: Colors.RedLight100 }}>RedLight100</Text>{'\n'} | ||
| `icon`: SF Symbol "star"{'\n'} | ||
| `selectedIcon`: SF Symbol "star.fill"{'\n'} | ||
| {'\n'} | ||
| Selected: filled star, tinted{' '} | ||
| <Text style={{ color: Colors.RedLight100 }}>RED</Text>{'\n'} title on iOS18: <Text style={{ color: Colors.GreenDark100 }}>GREEN</Text> on iOS26: <Text style={{ color: Colors.RedLight100 }}>RED</Text>{'\n'} | ||
| Unselected: Titles and icons render in the system theme color. For the last tab, the icon retains the black color from its source image. </Text> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| function XcassetTab() { | ||
| return ( | ||
| <View style={styles.screen}> | ||
| <Text style={styles.label}>Xcasset (Host Tint)</Text> | ||
| <Text style={styles.hint}> | ||
| Host `tabBarTintColor`:{' '} | ||
| <Text style={{ color: Colors.GreenDark100 }}>GreenDark100</Text>{'\n'} | ||
| `icon`: Xcasset custom-icon-fill{'\n'} | ||
| `tabBarItemIconColor` is NOT set.{'\n'} | ||
| {'\n'} | ||
| Selected: filled template image, tinted{' '} | ||
| <Text style={{ color: Colors.GreenDark100 }}>GREEN</Text>.{'\n'} | ||
| Unselected: Titles and icons render in the system theme color. For the last tab, the icon retains the black color from its source image. </Text> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| function ImageTab() { | ||
| return ( | ||
| <View style={styles.screen}> | ||
| <Text style={styles.label}>Image Source (Non-Tintable)</Text> | ||
| <Text style={styles.hint}> | ||
| Host `tabBarTintColor`:{' '} | ||
| <Text style={{ color: Colors.GreenDark100 }}>GreenDark100</Text>{'\n'} | ||
| `normal.tabBarItemIconColor`:{' '} | ||
| <Text style={{ color: Colors.BlueDark100 }}>BlueDark100</Text>{'\n'} | ||
| `icon`: imageSource icon.png{'\n'} | ||
| `selectedIcon`: imageSource icon_fill.png{'\n'} | ||
| {'\n'} | ||
| `imageSource` icons render in their original colors and are NOT | ||
| affected by `tabBarTintColor` or `tabBarItemIconColor`.{'\n'} | ||
| {'\n'} | ||
| Selected: filled image in its black color{'\n'}(the host{' '} | ||
| <Text style={{ color: Colors.GreenDark100 }}>green</Text> tint is | ||
| ignored).{'\n'} | ||
| Unselected iOS18: outline icons in <Text style={{ color: Colors.BlueDark100 }}>BLUE</Text> color.{'\n'} | ||
| Unselected iOS26: icons in system theme color. | ||
| </Text> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const ROUTE_CONFIGS: TabRouteConfig[] = [ | ||
| { | ||
| name: 'Tint', | ||
| Component: TintTab, | ||
| options: { | ||
| ...DEFAULT_TAB_ROUTE_OPTIONS, | ||
| title: 'Tint', | ||
| ios: { | ||
| icon: { | ||
| type: 'templateSource', | ||
| templateSource: require('@assets/variableIcons/icon.png'), | ||
| }, | ||
| selectedIcon: { | ||
| type: 'templateSource', | ||
| templateSource: require('@assets/variableIcons/icon_fill.png'), | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| name: 'Override', | ||
| Component: OverrideTab, | ||
| options: { | ||
| ...DEFAULT_TAB_ROUTE_OPTIONS, | ||
| title: 'Override', | ||
| ios: { | ||
| icon: { | ||
| type: 'sfSymbol', | ||
| name: 'star', | ||
| }, | ||
| selectedIcon: { | ||
| type: 'sfSymbol', | ||
| name: 'star.fill', | ||
| }, | ||
| standardAppearance: { | ||
| stacked: { | ||
| selected: { | ||
| tabBarItemIconColor: Colors.RedLight100, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| name: 'XcassetIcon', | ||
| Component: XcassetTab, | ||
| options: { | ||
| title: 'Xcasset', | ||
| ios: { | ||
| icon: { | ||
| type: 'xcasset', | ||
| name: 'custom-icon-fill', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| name: 'Image', | ||
| Component: ImageTab, | ||
| options: { | ||
| ...DEFAULT_TAB_ROUTE_OPTIONS, | ||
| title: 'Image', | ||
| ios: { | ||
| icon: { | ||
| type: 'imageSource', | ||
| imageSource: require('@assets/variableIcons/icon.png'), | ||
| }, | ||
| selectedIcon: { | ||
| type: 'imageSource', | ||
| imageSource: require('@assets/variableIcons/icon_fill.png'), | ||
| }, | ||
| standardAppearance: { | ||
| stacked: { | ||
| normal: { | ||
| tabBarItemIconColor: Colors.BlueDark100, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ]; | ||
|
|
||
| export function App() { | ||
| return ( | ||
| <TabsContainerWithHostConfigContext | ||
| routeConfigs={ROUTE_CONFIGS} | ||
| ios={{ tabBarTintColor: Colors.GreenDark100 }} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| screen: { | ||
| flex: 1, | ||
| justifyContent: 'center', | ||
| alignItems: 'center', | ||
| padding: 24, | ||
| gap: 12, | ||
| }, | ||
| label: { | ||
| fontSize: 17, | ||
| fontWeight: '600', | ||
| textAlign: 'center', | ||
| }, | ||
| hint: { | ||
| fontSize: 13, | ||
| color: Colors.LightOffNavy, | ||
| textAlign: 'center', | ||
| lineHeight: 20, | ||
| }, | ||
| }); | ||
|
|
||
| export default createScenario(App, scenarioDescription); | ||
12 changes: 12 additions & 0 deletions
12
apps/src/tests/single-feature-tests/tabs/test-tabs-item-icon-ios/scenario-description.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import type { ScenarioDescription } from '@apps/tests/shared/helpers'; | ||
|
|
||
| export const scenarioDescription: ScenarioDescription = { | ||
| name: 'Tab Bar Item Icon', | ||
| key: 'test-tabs-item-icon-ios', | ||
| details: | ||
| 'Exercises iOS tab bar item icon props: icon, selectedIcon, host' + | ||
| ' tabBarTintColor, and per-tab tabBarItemIconColor override.', | ||
| platforms: ['ios'], | ||
| e2eCoverage: 'incomplete', | ||
| smokeTest: false, | ||
| }; |
119 changes: 119 additions & 0 deletions
119
apps/src/tests/single-feature-tests/tabs/test-tabs-item-icon-ios/scenario.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| # Test Scenario: Tab Bar Item Icon (iOS) | ||
|
|
||
| ## Details | ||
|
|
||
| **Description:** Validates iOS tab bar item icon props: `icon` and | ||
| `selectedIcon` (different images for selected vs. unselected states), the | ||
| host-level `tabBarTintColor`, and the per-tab | ||
| `standardAppearance.stacked.selected.tabBarItemIconColor` override that | ||
| takes precedence over the host tint. Covers four `PlatformIconIOS` types: | ||
| `templateSource` (tintable), `sfSymbol` (tintable), `xcasset` (tintable), and `imageSource` | ||
| (non-tintable). | ||
|
|
||
| **OS test creation version:** iOS 18.6 and iOS 26.5 | ||
|
|
||
| ## E2E test | ||
|
|
||
| Incomplete: Not automated. All observable outcomes are purely visual (icon color, selected vs. | ||
| unselected glyph). Detox does not expose tint color or rendered image | ||
| attributes of native tab bar items, so automated assertion is not feasible. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - iOS device or simulator running iOS 18 or later. | ||
| - The iPhone in portrait orientation is the primary verification surface (stacked layout). | ||
|
|
||
| ## Note | ||
|
|
||
| - **Normal (unselected) state ([iOS26 KI](https://github.com/software-mansion/react-native-screens-labs/discussions/395)):** | ||
| On iOS 18 and lower, any per-tab | ||
| `normal.tabBarItemIconColor` apply to unselected tab icons. On iOS 26, | ||
| only the selected tab is tinted by `tabBarItemIconColor`; | ||
| unselected tabs adopt the system theme appearance. | ||
| - `tabBarTintColor` is applied only to selected tab bar item icon and title. | ||
| - **`imageSource` icons are non-tintable:** they render in their original | ||
| colors regardless of `tabBarTintColor` or `tabBarItemIconColor`. | ||
| `templateSource`, `xcasset` and `sfSymbol` icons are tintable. | ||
|
|
||
| ## Steps | ||
|
|
||
| ### Host `tabBarTintColor` applies to a tintable selected icon | ||
|
|
||
| 1. Launch the app and navigate to the **Tab Bar Item Icon** screen. | ||
|
|
||
| - [ ] Expected: Four tabs are visible in the tab bar: **Tint**, | ||
| **Override**, **Xcasset**, and **Image**. The **Tint** tab is | ||
| selected by default. Its icon is the filled template image | ||
| tinted **green** by the host | ||
| `tabBarTintColor`. The unselected **Override** and **Xcasset** | ||
| tabs render their icons and titles in the system theme color. The | ||
| unselected **Image** tab title renders in the system theme color, | ||
| but its icon keeps its original source colors. | ||
|
|
||
| --- | ||
|
|
||
| ### `icon` vs `selectedIcon` swap | ||
|
|
||
| 2. Tap the **Override** tab. | ||
|
|
||
| - [ ] Expected: The **Override** tab's icon swaps from the outline | ||
| star to the filled star. The | ||
| previously selected **Tint** tab swaps from the filled template | ||
| image back to the outline template image. | ||
|
|
||
| --- | ||
|
|
||
| ### `tabBarItemIconColor` overrides `tabBarTintColor` | ||
|
|
||
| 3. With **Override** still selected, observe the selected icon color. | ||
|
|
||
| - [ ] Expected: The filled star is **red**, NOT green. | ||
| On iOS 18 the selected title is | ||
| green (host tint); on iOS 26 the selected title is red (override - it's native | ||
| bug KI linked in Notes section). | ||
|
|
||
| 4. Tap the **Tint** tab, then tap **Override** again. | ||
|
|
||
| - [ ] Expected: On re-selection the red filled star reappears | ||
| immediately with no visual glitch. The **Tint** tab shows the system-theme | ||
| outline template | ||
| image. | ||
|
|
||
| --- | ||
|
|
||
| ### `xcasset` icon uses host tint, no `selectedIcon` | ||
|
|
||
| 5. Tap the **Xcasset** tab. | ||
|
|
||
| - [ ] Expected: The **Xcasset** tab's icon shows the `custom-icon-fill` | ||
| xcasset image tinted **green**. Because no `selectedIcon` is configured for this | ||
| tab, the same icon asset is used in both selected and unselected | ||
| states. The previously selected **Override** tab reverts to the | ||
| outline star in system theme color. | ||
|
|
||
| --- | ||
|
|
||
| ### `imageSource` icons are non-tintable | ||
|
|
||
| 6. Tap the **Image** tab. | ||
|
|
||
| - [ ] Expected: The icon swaps from the outline image to | ||
| the filled image. Both renders use the original PNG | ||
| colors - the host `tabBarTintColor` (green) have NO effect on the | ||
| selected icon. On iOS 18, the unselected icon renders in | ||
| **blue**; on iOS 26+ it renders in the system theme | ||
| color. | ||
|
LKuchno marked this conversation as resolved.
|
||
|
|
||
| --- | ||
|
|
||
| ### Stability check | ||
|
|
||
| 7. Cycle through all four tabs in order | ||
| (Tint -> Override -> Xcasset -> Image), then in reverse. | ||
|
|
||
| - [ ] Expected: Each tab swaps between its `icon` and `selectedIcon` | ||
| (where configured) consistently on selection. The correct tint | ||
| behavior is applied each time: green host tint for **Tint** and | ||
| **Xcasset**, red override for **Override**'s selected state, and | ||
| no tint effect for **Image**. No crash, layout freeze, or visual | ||
| artifact occurs during rapid cycling. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.