-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(navigation-bar): modernize to Material Design 3 #5006
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
burczu
wants to merge
15
commits into
callstack:main
Choose a base branch
from
burczu:feat/navigation-bar-md3
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.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
3951136
refactor(navigation-bar): extract module + deprecate Bar alias
burczu b07f21a
feat(navigation-bar): apply MD3 token-based colors and sizing
burczu 44eeaf8
refactor(navigation-bar): remove MD2 shifting mode from the bar
burczu 9196bac
feat(navigation-bar): add visible MD3 state layers
burczu 834ae8a
feat(navigation-bar): drive motion from tokens and spring the indicator
burczu 77d1704
feat(navigation-bar): add flexible horizontal variant
burczu bbedae9
docs(navigation-bar): add example and update JSDoc
burczu 3f2e172
fix(navigation-bar): restore labels and active indicator on tab change
burczu 7d6b909
test(navigation-bar): drop redundant shifting test variants
burczu ee3ede5
test(navigation-bar): add characterization tests before refactor
burczu 6937d58
refactor(navigation-bar): collapse cross-fade, dedupe item render
burczu b102488
refactor(navigation-bar): unify color source on colorRoles
burczu a5a012a
docs(navigation-bar): register NavigationBar page, fix docs build
burczu 13d34e9
refactor(navigation-bar): drop deprecations per review
burczu c6bc35f
refactor(navigation-bar): migrate motion to reanimated
burczu 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
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,108 @@ | ||
| import * as React from 'react'; | ||
| import { StyleSheet, View, useWindowDimensions } from 'react-native'; | ||
|
|
||
| import { | ||
| NavigationBar, | ||
| SegmentedButtons, | ||
| Switch, | ||
| Text, | ||
| } from 'react-native-paper'; | ||
|
|
||
| type VariantMode = 'auto' | 'stacked' | 'horizontal'; | ||
|
|
||
| // The flexible navigation bar switches to a horizontal item arrangement in | ||
| // medium-width windows. M3 recommends ~600dp as the breakpoint, but the | ||
| // component leaves the decision to the consumer — here it is driven by | ||
| // `useWindowDimensions`. | ||
| const MEDIUM_WINDOW_WIDTH = 600; | ||
|
|
||
| const routes = [ | ||
| { key: 'album', title: 'Album', focusedIcon: 'image-album', badge: 3 }, | ||
| { key: 'library', title: 'Library', focusedIcon: 'bookshelf' }, | ||
| { | ||
| key: 'favorites', | ||
| title: 'Favorites', | ||
| focusedIcon: 'heart', | ||
| unfocusedIcon: 'heart-outline', | ||
| }, | ||
| { | ||
| key: 'settings', | ||
| title: 'Settings', | ||
| focusedIcon: 'cog', | ||
| unfocusedIcon: 'cog-outline', | ||
| }, | ||
| ]; | ||
|
|
||
| const NavigationBarExample = () => { | ||
| const [index, setIndex] = React.useState(0); | ||
| const [labeled, setLabeled] = React.useState(true); | ||
| const [variantMode, setVariantMode] = React.useState<VariantMode>('auto'); | ||
|
|
||
| const { width } = useWindowDimensions(); | ||
| const autoVariant = width >= MEDIUM_WINDOW_WIDTH ? 'horizontal' : 'stacked'; | ||
| const variant = variantMode === 'auto' ? autoVariant : variantMode; | ||
|
|
||
| return ( | ||
| <View style={styles.container}> | ||
| <View style={styles.content}> | ||
| <Text variant="headlineSmall">{routes[index].title}</Text> | ||
|
|
||
| <View style={styles.controls}> | ||
| <View style={styles.row}> | ||
| <Text variant="labelLarge">Show labels</Text> | ||
| <Switch value={labeled} onValueChange={setLabeled} /> | ||
| </View> | ||
|
|
||
| <SegmentedButtons | ||
| value={variantMode} | ||
| onValueChange={(value) => setVariantMode(value as VariantMode)} | ||
| buttons={[ | ||
| { value: 'auto', label: `Auto (${autoVariant})` }, | ||
| { value: 'stacked', label: 'Stacked' }, | ||
| { value: 'horizontal', label: 'Horizontal' }, | ||
| ]} | ||
| /> | ||
| </View> | ||
| </View> | ||
|
|
||
| <NavigationBar | ||
| navigationState={{ index, routes }} | ||
| labeled={labeled} | ||
| variant={variant} | ||
| onTabPress={({ route }) => { | ||
| const nextIndex = routes.findIndex((r) => r.key === route.key); | ||
| if (nextIndex !== -1) { | ||
| setIndex(nextIndex); | ||
| } | ||
| }} | ||
| /> | ||
| </View> | ||
| ); | ||
| }; | ||
|
|
||
| NavigationBarExample.title = 'Navigation Bar (flexible)'; | ||
|
|
||
| export default NavigationBarExample; | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { | ||
| flex: 1, | ||
| }, | ||
| content: { | ||
| flex: 1, | ||
| justifyContent: 'center', | ||
| alignItems: 'center', | ||
| padding: 16, | ||
| }, | ||
| controls: { | ||
| marginTop: 32, | ||
| width: '100%', | ||
| maxWidth: 480, | ||
| gap: 24, | ||
| }, | ||
| 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the
BottomNavigationcomponent still needed? it'd be inconsistent to have a mix of old and new APIsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kept intentionally.
BottomNavigationis the router-integrated scene component (owns tab screens + transitions);NavigationBaris the standalone bar for use with React Navigation's own navigator — same layering split as React Navigation itself, so it isn't an old-vs-new API mix. Every deprecation/alias is gone (13d34e9), so there's no MD2 surface remaining.