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

angle support on react-native-linear-gradient integration #5538

Open
proohit opened this issue Nov 7, 2022 · 3 comments · May be fixed by #5559
Open

angle support on react-native-linear-gradient integration #5538

proohit opened this issue Nov 7, 2022 · 3 comments · May be fixed by #5559

Comments

@proohit
Copy link

proohit commented Nov 7, 2022

Description

react-native-linear-gradient supports passing an angle instead of start and end positions to calculate gradients. The current integration of LinearGradient inside NativeBase does not support that.

Problem Statement

The current implementation strictly uses start and end, but react-native-linear-gradient already supports angle usage.

Proposed Solution or API

Add support for useAngle, angle and angleCenter props in linearGradient style configuration. Since lgrad isn't typed anyway, we could just extract those props from it and pass it to LinearGradient:

return (
      <Gradient
        ref={ref}
        {...safeAreaProps}
        colors={lgrad.colors}
        start={lgrad.useAngle ? null : startObj}
        end={lgrad.useAngle ? null : endObj}
        useAngle={lgrad.useAngle}
        angle={lgrad.angle}
        angleCenter={lgrad.angleCenter}
        locations={lgrad.locations}>
        {/* {React.Children.map(children, (child) =>
          typeof child === 'string' || typeof child === 'number' ? (
            <Text {..._text}>{child}</Text>
          ) : (
            child
          )
        )} */}
        {wrapStringChild(children, _text)}
      </Gradient>
    );

This can be much cleaner, but that's the gist of this request.

Alternatives

No response

Additional Information

I don't know how to handle older versions where the angle props aren't supported

@surajahmed
Copy link
Collaborator

Thanks for the suggestion @proohit. We'll plan to add this feature in the next version.

@proohit proohit linked a pull request Nov 16, 2022 that will close this issue
@proohit
Copy link
Author

proohit commented Nov 27, 2022

Hey, I've added a PR (#5559) to add this feature. Would be nice you looking over it :)

@czaku
Copy link

czaku commented Dec 11, 2022

+1 - needed massively :)

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

Successfully merging a pull request may close this issue.

3 participants