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

Does not play nice with PlatformColor #4

Closed
vbylen opened this issue Aug 7, 2021 · 4 comments
Closed

Does not play nice with PlatformColor #4

vbylen opened this issue Aug 7, 2021 · 4 comments

Comments

@vbylen
Copy link

vbylen commented Aug 7, 2021

I get the following error:

"[object Object]" is not a valid color or brush

import { PlatformColor } from 'react-native'

<SquircleView
      style={style}
      squircleParams={{
        cornerSmoothing: 0.7,
        cornerRadius: 30,
        fillColor: PlatformColor(`systemBlue`)
      }}
 />
@phamfoo
Copy link
Owner

phamfoo commented Aug 7, 2021

This is an issue from react-native-svg. Unfortunately, there doesn't seem to be a workaround. You'll have to wait until the issue is resolved.

@phamfoo
Copy link
Owner

phamfoo commented Aug 7, 2021

It's not ideal, but you could apply the squircle shape to a normal View with masked-view.

@vbylen
Copy link
Author

vbylen commented Aug 7, 2021

For me the issue was fixed by just manually looked up the color codes.

import { useColorScheme } from "react-native"

const theme = useColorScheme();

<SquircleView
      style={style}
      squircleParams={{
        cornerSmoothing: 1,
        cornerRadius: 20,
        fillColor : theme == 'light' ? 'rgb(0, 122, 255)' : 'rgb(10, 132, 255)'
      }}
/>

Works fine for my use case.

Thanks!

@phamfoo
Copy link
Owner

phamfoo commented Aug 7, 2021

Glad you found a solution for your use case. Ideally, I think you still want to use PlatformColor when react-native-svg has support for it to make sure you get the correct native color.

@phamfoo phamfoo closed this as completed Aug 7, 2021
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

No branches or pull requests

2 participants