Bluesky app fork with some witchin' additions 馃挮
1import {type StyleProp, type ViewStyle} from 'react-native'
2import {LinearGradient} from 'expo-linear-gradient'
3
4import {gradients} from '#/alf/tokens'
5
6export function LinearGradientBackground({
7 style,
8 gradient = 'sky',
9 children,
10 start,
11 end,
12}: {
13 style?: StyleProp<ViewStyle>
14 gradient?: keyof typeof gradients
15 children?: React.ReactNode
16 start?: [number, number]
17 end?: [number, number]
18}) {
19 const colors = gradients[gradient].values.map(([_, color]) => {
20 return color
21 }) as [string, string, ...string[]]
22
23 if (gradient.length < 2) {
24 throw new Error('Gradient must have at least 2 colors')
25 }
26
27 return (
28 <LinearGradient colors={colors} style={style} start={start} end={end}>
29 {children}
30 </LinearGradient>
31 )
32}