mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import {LinearGradient} from 'expo-linear-gradient'
2
3import {atoms as a, tokens} from '#/alf'
4
5export function GradientFill({
6 gradient,
7}: {
8 gradient:
9 | typeof tokens.gradients.sky
10 | typeof tokens.gradients.midnight
11 | typeof tokens.gradients.sunrise
12 | typeof tokens.gradients.sunset
13 | typeof tokens.gradients.bonfire
14 | typeof tokens.gradients.summer
15 | typeof tokens.gradients.nordic
16}) {
17 if (gradient.values.length < 2) {
18 throw new Error('Gradient must have at least 2 colors')
19 }
20
21 return (
22 <LinearGradient
23 colors={gradient.values.map(c => c[1]) as [string, string, ...string[]]}
24 locations={
25 gradient.values.map(c => c[0]) as [number, number, ...number[]]
26 }
27 start={{x: 0, y: 0}}
28 end={{x: 1, y: 1}}
29 style={[a.absolute, a.inset_0]}
30 />
31 )
32}