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

Removing Screen width / manual width dependency #7

Merged
merged 5 commits into from
Jul 15, 2024
Merged

Conversation

WrathChaos
Copy link
Owner

This PR is a duplication of #4 , there are just code cleaning and fixes for better looking/understanding.

Credits to @philo23

Rather than calculating the width based off the screen size or passing in a fixed width, this change lets React Native handle sizing the component like any other <View> and then takes the calculated width from the onLayout event to calculate the correct active tab width.

The width and extraSpacing properties have been removed as they're no longer necessary.

That also let me remove all of the dynamic styling from the stylesheet and a couple of magic numbers from the active tab width calculations. The previously dynamic inline styles are now just passed directly into the style property.

The gap around the segments and the background is now also customisable by passing a gap property that defaults to the previous default size of 2 units.

I've tweaked the active tab's border radius to better follow the outer containers' radius too.

Also some missing useEffect/useCallback dependencies were added.


Apologies if I've run roughshod over any of your code linting/formatting rules, I've tried to keep it inline as much as possible with your existing code! Just let me know if you want me to tweak anything.

Also this is quite a big change to the way this component renders, so it's probably worth making it a breaking change considering the width and extraSpacing props are now gone.

Let me know if you'd like me to update the readme too.

Cheers!

philo23 and others added 5 commits April 19, 2023 18:45
Rather than calculating the width based off the screen size or passing
in a fixed width, this change lets React Native handle sizing the
component like any other `<View>` and then takes the calculated width
from the onLayout event to calculate the correct active tab width.

This change also removes all of the dynamic styling from the stylesheet
and a couple of magic numbers from the active tab width calculations.
The previously dynamic inline styles are now just passed directly to
the `style` property.

Additional the gap around the segments and the background customisable
by passing an (optional) `gap` property that defaults to the previous
gap of 2 units.

I've also tweaked the active tab's border radius to follow the outer
containers' radius too.

The `width` and `extraSpacing` properties have been removed.

Some missing `useEffect`/`useCallback` dependencies were also added.
@WrathChaos WrathChaos self-assigned this Jul 15, 2024
@WrathChaos WrathChaos merged commit fd36e8d into master Jul 15, 2024
@WrathChaos
Copy link
Owner Author

WrathChaos commented Jul 15, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants