mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React from 'react'
2import {StyleProp, ViewStyle} from 'react-native'
3import {LinearGradient} from 'expo-linear-gradient'
4
5import {gradients} from '#/alf/tokens'
6
7export function LinearGradientBackground({
8 style,
9 children,
10}: {
11 style: StyleProp<ViewStyle>
12 children: React.ReactNode
13}) {
14 const gradient = gradients.sky.values.map(([_, color]) => {
15 return color
16 }) as [string, string, ...string[]]
17
18 if (gradient.length < 2) {
19 throw new Error('Gradient must have at least 2 colors')
20 }
21
22 return (
23 <LinearGradient colors={gradient} style={style}>
24 {children}
25 </LinearGradient>
26 )
27}