phamfoo / react-native-figma-squircle

Figma-flavored squircles for React Native
MIT License
318 stars 15 forks source link

Does not play nice with PlatformColor #4

Closed vbylen closed 3 years ago

vbylen commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

vbylen commented 3 years ago

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 commented 3 years ago

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.