1 | import { requireNativeViewManager } from '@unimodules/core';
|
2 | import * as React from 'react';
|
3 | import { StyleSheet, View } from 'react-native';
|
4 |
|
5 | import { NativeLinearGradientProps } from './NativeLinearGradient.types';
|
6 |
|
7 | export default function NativeLinearGradient({
|
8 | colors,
|
9 | locations,
|
10 | startPoint,
|
11 | endPoint,
|
12 | children,
|
13 | style,
|
14 | ...props
|
15 | }: NativeLinearGradientProps): React.ReactElement {
|
16 |
|
17 |
|
18 | const flatStyle = StyleSheet.flatten(style) ?? {};
|
19 | const borderRadius = flatStyle.borderRadius ?? 0;
|
20 |
|
21 |
|
22 |
|
23 | const borderRadiiPerCorner = [
|
24 | flatStyle.borderTopLeftRadius ?? borderRadius,
|
25 | flatStyle.borderTopLeftRadius ?? borderRadius,
|
26 | flatStyle.borderTopRightRadius ?? borderRadius,
|
27 | flatStyle.borderTopRightRadius ?? borderRadius,
|
28 | flatStyle.borderBottomRightRadius ?? borderRadius,
|
29 | flatStyle.borderBottomRightRadius ?? borderRadius,
|
30 | flatStyle.borderBottomLeftRadius ?? borderRadius,
|
31 | flatStyle.borderBottomLeftRadius ?? borderRadius,
|
32 | ];
|
33 |
|
34 | return (
|
35 | <View {...props} style={style}>
|
36 | <BaseNativeLinearGradient
|
37 | style={StyleSheet.absoluteFill}
|
38 | colors={colors}
|
39 | startPoint={startPoint}
|
40 | endPoint={endPoint}
|
41 | locations={locations}
|
42 | borderRadii={borderRadiiPerCorner}
|
43 | />
|
44 | {children}
|
45 | </View>
|
46 | );
|
47 | }
|
48 |
|
49 | const BaseNativeLinearGradient = requireNativeViewManager('ExpoLinearGradient');
|