I am trying to create this UI using @shopify/react-native-skia package.
(Specifically using @shopify/react-native-skia package)
While creating, I was unable to get a round Image inside the circle.. I want the avatar image inside the circle…Can anyone help me with this?
Here’s the code I tried :
const Home = () => {
const [isLoading, setIsLoading] = useState(true)
const image = //Image url
useEffect(() => {
image ? setIsLoading(false) : null
}, [])
return (
<ScrollView style={{flex : 1, backgroundColor : '#010117'}}>
{!isLoading &&
<Canvas style={{height : h}}>
<Group >
<Circle cx={xmiddle} cy={h*0.1} r={radius}>
<Paint color={"#060d29"}/>
<Paint color={'#a1a1ab'} style='stroke' strokeWidth={2}/>
</Circle>
</Group>
</Canvas>
}
{isLoading && <ActivityIndicator animating color={"#a1a1ab"} size="large" style={{top : h*0.4}}/>}
</ScrollView>
)
}
2
Answers
You can try to create everything from a component you put it in a circle shape then you add a border like this :
You can round your
Image
usingGroup
componentHere is documentation link: https://shopify.github.io/react-native-skia/docs/group#clip-rounded-rectangle
Here is a code example where I place the image in the center of the screen and render circle image
Here is the result: