-
Notifications
You must be signed in to change notification settings - Fork 108
New role prominent (SDK27+)
#585
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b41d77b
New role `prominent` (SDK27+)
retyui b1927fe
Add iOS tab role example
thiagobrez 84d3a2d
fix(ios): preserve label baking for unsupported tab roles
thiagobrez 475128c
chore: improve Roles example
thiagobrez 8b31dec
fix(iOS): refresh prominent tab styling after selection
thiagobrez adb84fd
fix(iOS): stabilize iOS 27 tab selection styling
thiagobrez 477432f
docs: clarify iOS tab role availability
thiagobrez 81be16a
Merge remote-tracking branch 'origin/main' into sdk27
thiagobrez 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'react-native-bottom-tabs': minor | ||
| --- | ||
|
|
||
| Add the `prominent` tab role (iOS 27+), and fix iOS 27 tabs keeping their selected tint after switching tabs or minimizing the tab bar |
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
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
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
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,107 @@ | ||
| import { useMemo, useState } from 'react'; | ||
| import { Button, StyleSheet, Switch, Text, View } from 'react-native'; | ||
| import TabView, { SceneMap } from 'react-native-bottom-tabs'; | ||
| import type { TabRole } from 'react-native-bottom-tabs'; | ||
| import { Article } from '../Screens/Article'; | ||
| import { Albums } from '../Screens/Albums'; | ||
| import { Contacts } from '../Screens/Contacts'; | ||
|
|
||
| const renderScene = SceneMap({ | ||
| article: Article, | ||
| albums: Albums, | ||
| role: Contacts, | ||
| }); | ||
|
|
||
| export default function Roles() { | ||
| const [role, setRole] = useState<TabRole>('search'); | ||
| const [bakedTintColors, setBakedTintColors] = useState(false); | ||
| const [index, setIndex] = useState(0); | ||
| const routes = useMemo( | ||
| () => [ | ||
| { | ||
| key: 'article', | ||
| title: 'Article', | ||
| focusedIcon: { sfSymbol: 'document' }, | ||
| }, | ||
| { | ||
| key: 'albums', | ||
| title: 'Albums', | ||
| focusedIcon: { sfSymbol: 'square.grid.2x2' }, | ||
| }, | ||
| { | ||
| key: 'role', | ||
| title: role === 'search' ? 'Search' : 'Contacts', | ||
| focusedIcon: { | ||
| sfSymbol: | ||
| role === 'search' ? 'magnifyingglass' : 'person.crop.circle', | ||
| }, | ||
| role, | ||
| testID: `roles-${role}-tab`, | ||
| }, | ||
| ], | ||
| [role] | ||
| ); | ||
|
|
||
| const selectRole = (nextRole: TabRole) => { | ||
| setIndex(0); | ||
| setRole(nextRole); | ||
| }; | ||
|
|
||
| return ( | ||
| <View style={styles.container}> | ||
| <View style={styles.controls}> | ||
| <View style={styles.row}> | ||
| <Button | ||
| title="Search" | ||
| disabled={role === 'search'} | ||
| onPress={() => selectRole('search')} | ||
| /> | ||
| <Button | ||
| title="Prominent" | ||
| disabled={role === 'prominent'} | ||
| onPress={() => selectRole('prominent')} | ||
| /> | ||
| </View> | ||
| <Text> | ||
| {role === 'search' | ||
| ? 'Search role (iOS 18+). May receive prominent styling when no tab has the prominent role.' | ||
| : 'Prominent role (iOS 27+). Emphasizes the Contacts tab; falls back to an ordinary tab on older iOS versions.'} | ||
| </Text> | ||
| <View style={styles.row}> | ||
| <Text>Experimental baked tint colors</Text> | ||
| <Switch | ||
| accessibilityLabel="Experimental baked tint colors" | ||
| value={bakedTintColors} | ||
| onValueChange={setBakedTintColors} | ||
| /> | ||
| </View> | ||
| </View> | ||
| <TabView | ||
| key={role} | ||
| navigationState={{ index, routes }} | ||
| onIndexChange={setIndex} | ||
| renderScene={renderScene} | ||
| labeled | ||
| tabBarActiveTintColor="red" | ||
| tabBarInactiveTintColor="orange" | ||
| experimental_bakedTintColors={bakedTintColors} | ||
| minimizeBehavior='onScrollDown' | ||
| /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { | ||
| flex: 1, | ||
| }, | ||
| controls: { | ||
| padding: 12, | ||
| gap: 12, | ||
| }, | ||
| row: { | ||
| flexDirection: 'row', | ||
| alignItems: 'center', | ||
| justifyContent: 'space-between', | ||
| }, | ||
| }); |
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
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.