Skip to content
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

feat: add children prop to tab bar indicator component #11566

Merged
merged 3 commits into from
Sep 4, 2023

Conversation

grezxune
Copy link
Contributor

Motivation

I want to be able to display a <LinearGradient/> component inside the <TabBarIndicator/>. While you can use the renderIndicator prop on TabBar, you cannot render a wrapper or child of the indicator and have it inherit the animation the library already provides. By providing a children option to TabBarIndicator, this problem is easily solved.

Test plan

Tests all still pass and to test this specific change, try something like this:

<TabBar
  renderIndicator={(props) => {
    return (
      <TabBarIndicator {...props}>
        {someChildComponent}
      </TabBarIndicator>
    )
  }}
/>

This allows more complex components to be animated and accurately denote the active tab. I have some screenshots of an example where I'm using a <LinearGradient/> container to display a gradient indicator - something not possible with just a style object.

Screenshot 2023-08-28 at 4 16 24 PM Screenshot 2023-08-28 at 4 16 46 PM

@github-actions
Copy link

Hey @grezxune! Thanks for opening your first pull request in this repo. If you haven't already, make sure to read our contribution guidelines.

@codecov-commenter
Copy link

codecov-commenter commented Aug 28, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (bd96d89) 75.78% compared to head (3da179e) 75.78%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the GitHub App Integration for your organization. Read more.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11566   +/-   ##
=======================================
  Coverage   75.78%   75.78%           
=======================================
  Files         196      196           
  Lines        5789     5789           
  Branches     2267     2267           
=======================================
  Hits         4387     4387           
  Misses       1355     1355           
  Partials       47       47           
Files Changed Coverage Δ
...ages/react-native-tab-view/src/TabBarIndicator.tsx 48.97% <ø> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@netlify
Copy link

netlify bot commented Aug 28, 2023

Deploy Preview for react-navigation-example ready!

Name Link
🔨 Latest commit 3da179e
🔍 Latest deploy log https://app.netlify.com/sites/react-navigation-example/deploys/64f60b7c8f67800008667a6c
😎 Deploy Preview https://deploy-preview-11566--react-navigation-example.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@osdnk osdnk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks nice! Thanks

I guess it wasn't supported earlier as there was no deep motivation, but it looks like you found one :)

@osdnk osdnk merged commit fe3b560 into react-navigation:main Sep 4, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants