-
-
Notifications
You must be signed in to change notification settings - Fork 661
chore(test): add test-tabs-item-icon appearance scenario #4108
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
Open
LKuchno
wants to merge
7
commits into
main
Choose a base branch
from
@lkuchno/test-tabs-item-icon
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+501
−0
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6429872
refacotred existing screen for test-tabs-item-icon to use it in Andro…
LKuchno 46a2030
removing ios from sceanrio title
LKuchno 61804d6
removing ios from sceanrio title
LKuchno 70eb289
Fix typo
LKuchno 9554df8
restructure expected section and provide corrects
LKuchno edd1238
small changes after review
LKuchno 346fc34
Merge branch 'main' of github.com:software-mansion/react-native-scree…
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
330 changes: 330 additions & 0 deletions
330
apps/src/tests/single-feature-tests/tabs/test-tabs-item-icon/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,330 @@ | ||
| import React from 'react'; | ||
| import { Platform, 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 XcassetDrawableResourceTab() { | ||
| return ( | ||
| <View style={styles.screen}> | ||
| {Platform.OS === 'ios' ? ( | ||
| <> | ||
| <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> | ||
| </> | ||
| ) : ( | ||
| <> | ||
| <Text style={styles.label}>Drawable Resource</Text> | ||
| <Text style={styles.hint}> | ||
|
|
||
| `icon`: drawableResource sym_call_missed{'\n'} | ||
| `selectedIcon`: drawableResource sym_call_incoming{'\n'} | ||
| `tabBarItemIconColor` is NOT set.{'\n'} | ||
| {'\n'} | ||
| Both icons (for selected and unselected tabs) displayed in the system default color. | ||
| </Text> | ||
| </> | ||
| )} | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| function ImageTab() { | ||
| return ( | ||
| <View style={styles.screen}> | ||
| <Text style={styles.label}> | ||
| {Platform.OS === 'ios' ? 'Image Source (Non-Tintable)' : 'Image Source'} | ||
| </Text> | ||
| <Text style={styles.hint}> | ||
| {Platform.OS === 'ios' ? ( | ||
| <> | ||
| 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 (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. | ||
| </> | ||
| ) : ( | ||
| <> | ||
| `selected.tabBarItemIconColor`:{' '} | ||
| <Text style={{ color: Colors.RedDark100 }}>RedDark100</Text> | ||
| {'\n'} | ||
| `normal.tabBarItemIconColor`:{' '} | ||
| <Text style={{ color: Colors.GreenDark100 }}>GreenDark100</Text> | ||
| {'\n'} | ||
| `focused.tabBarItemIconColor`:{' '} | ||
| <Text style={{ color: Colors.NavyLight100 }}>NavyLight100</Text> | ||
| {'\n'} | ||
| `icon`: imageSource icon.png{'\n'} | ||
| `selectedIcon`: imageSource icon_fill.png{'\n'} | ||
| {'\n'} | ||
| Selected: filled image in {' '} | ||
| <Text style={{ color: Colors.RedDark100 }}>RED</Text> color. | ||
| {'\n'} | ||
| Unselected: outline icons in {' '} | ||
| <Text style={{ color: Colors.GreenDark100 }}>GREEN</Text> color. | ||
| {'\n'} | ||
| Focused (via keyboard navigation Tab key):{'\n'} | ||
| icon should appear{' '} | ||
| <Text style={{ color: Colors.NavyLight100 }}>DARK BLUE</Text>. | ||
| </> | ||
| )} | ||
| </Text> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const IOS_ROUTES: 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: XcassetDrawableResourceTab, | ||
| options: { | ||
| ...DEFAULT_TAB_ROUTE_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, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ]; | ||
|
|
||
| const ANDROID_ROUTES: TabRouteConfig[] = [ | ||
| { | ||
| name: 'DrawableResource', | ||
| Component: XcassetDrawableResourceTab, | ||
| options: { | ||
| ...DEFAULT_TAB_ROUTE_OPTIONS, | ||
| title: 'DrawableResource', | ||
| android: { | ||
| icon: { | ||
| type: 'drawableResource', | ||
| name: 'sym_call_missed', | ||
| }, | ||
| selectedIcon: { | ||
| type: 'drawableResource', | ||
| name: 'sym_call_incoming', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| name: 'Image', | ||
| Component: ImageTab, | ||
| options: { | ||
| ...DEFAULT_TAB_ROUTE_OPTIONS, | ||
| title: 'Image', | ||
| android: { | ||
| icon: { | ||
| type: 'imageSource', | ||
| imageSource: require('@assets/variableIcons/icon.png'), | ||
| }, | ||
| selectedIcon: { | ||
| type: 'imageSource', | ||
| imageSource: require('@assets/variableIcons/icon_fill.png'), | ||
| }, | ||
| standardAppearance: { | ||
| selected: { | ||
| tabBarItemIconColor: Colors.RedDark100, | ||
| }, | ||
| normal: { | ||
| tabBarItemIconColor: Colors.GreenDark100, | ||
| }, | ||
| focused: { | ||
| tabBarItemIconColor: Colors.NavyLight100, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ]; | ||
|
|
||
| export const ROUTE_CONFIGS = Platform.select({ | ||
| ios: IOS_ROUTES, | ||
| android: ANDROID_ROUTES, | ||
| default: IOS_ROUTES, // fallback | ||
| }); | ||
|
|
||
| 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); | ||
13 changes: 13 additions & 0 deletions
13
apps/src/tests/single-feature-tests/tabs/test-tabs-item-icon/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,13 @@ | ||
| import type { ScenarioDescription } from '@apps/tests/shared/helpers'; | ||
|
|
||
| export const scenarioDescription: ScenarioDescription = { | ||
| name: 'Tab Bar Item Icon', | ||
| key: 'test-tabs-item-icon', | ||
| details: | ||
| 'Exercises tab bar item icon props: iOS icon types (templateSource, sfSymbol,' + | ||
| ' xcasset, imageSource) with tabBarItemIconColor overrides; Android' + | ||
| ' tabBarItemIconColor in normal, selected and focused states.', | ||
| platforms: ['ios', 'android'], | ||
| e2eCoverage: 'incomplete', | ||
| smokeTest: false, | ||
| }; |
Oops, something went wrong.
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.