|
| 1 | +import { StatusBar } from 'expo-status-bar' |
| 2 | +import React from 'react' |
| 3 | +import { StyleSheet, View } from 'react-native' |
| 4 | +import { LinearGradient } from 'expo-linear-gradient' |
| 5 | +import easeGradient from 'react-native-easing-gradient' |
| 6 | +import { Text } from 'react-native' |
| 7 | + |
| 8 | +const BACKGROUND_COLOR = '#18181B' |
| 9 | + |
| 10 | +const { colors, locations } = easeGradient({ |
| 11 | + colorStops: { |
| 12 | + 0: { |
| 13 | + color: 'transparent', |
| 14 | + }, |
| 15 | + 1: { |
| 16 | + color: BACKGROUND_COLOR, |
| 17 | + }, |
| 18 | + }, |
| 19 | +}) |
| 20 | + |
| 21 | +export default function App() { |
| 22 | + return ( |
| 23 | + <View style={styles.container}> |
| 24 | + <StatusBar style="auto" /> |
| 25 | + <View style={styles.header} /> |
| 26 | + <View style={styles.overlayContainer}> |
| 27 | + <View style={styles.fill}> |
| 28 | + <LinearGradient |
| 29 | + colors={['transparent', BACKGROUND_COLOR]} |
| 30 | + locations={[0, 1]} |
| 31 | + style={styles.fill} |
| 32 | + /> |
| 33 | + <View style={styles.description}> |
| 34 | + <Text style={styles.descriptionText}>Before (linear)</Text> |
| 35 | + </View> |
| 36 | + </View> |
| 37 | + <View style={styles.fill}> |
| 38 | + <LinearGradient |
| 39 | + colors={colors} |
| 40 | + locations={locations} |
| 41 | + style={styles.fill} |
| 42 | + /> |
| 43 | + <View style={styles.description}> |
| 44 | + <Text style={styles.descriptionText}>After (ease-in-out)</Text> |
| 45 | + </View> |
| 46 | + </View> |
| 47 | + </View> |
| 48 | + </View> |
| 49 | + ) |
| 50 | +} |
| 51 | + |
| 52 | +const HEADER_HEIGHT = 300 |
| 53 | + |
| 54 | +const styles = StyleSheet.create({ |
| 55 | + container: { |
| 56 | + flex: 1, |
| 57 | + backgroundColor: BACKGROUND_COLOR, |
| 58 | + }, |
| 59 | + header: { |
| 60 | + height: HEADER_HEIGHT, |
| 61 | + backgroundColor: '#6366F1', |
| 62 | + }, |
| 63 | + overlayContainer: { |
| 64 | + position: 'absolute', |
| 65 | + top: 0, |
| 66 | + left: 0, |
| 67 | + right: 0, |
| 68 | + flexDirection: 'row', |
| 69 | + height: HEADER_HEIGHT / 2, |
| 70 | + marginTop: HEADER_HEIGHT / 2, |
| 71 | + }, |
| 72 | + fill: { |
| 73 | + flex: 1, |
| 74 | + }, |
| 75 | + description: { |
| 76 | + position: 'absolute', |
| 77 | + left: 0, |
| 78 | + right: 0, |
| 79 | + bottom: 0, |
| 80 | + alignItems: 'center', |
| 81 | + }, |
| 82 | + descriptionText: { |
| 83 | + color: '#E0E7FF', |
| 84 | + }, |
| 85 | +}) |
0 commit comments