about summary refs log tree commit diff
path: root/src/components/GradientFill.tsx
blob: dc14aa72b79ebc0ec4b523eb0304461bd9ab221c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import React from 'react'
import LinearGradient from 'react-native-linear-gradient'

import {atoms as a, tokens} from '#/alf'

export function GradientFill({
  gradient,
}: {
  gradient:
    | typeof tokens.gradients.sky
    | typeof tokens.gradients.midnight
    | typeof tokens.gradients.sunrise
    | typeof tokens.gradients.sunset
    | typeof tokens.gradients.bonfire
    | typeof tokens.gradients.summer
    | typeof tokens.gradients.nordic
}) {
  return (
    <LinearGradient
      colors={gradient.values.map(c => c[1])}
      locations={gradient.values.map(c => c[0])}
      start={{x: 0, y: 0}}
      end={{x: 1, y: 1}}
      style={[a.absolute, a.inset_0]}
    />
  )
}