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