UNPKG

1.8 kBJavaScriptView Raw
1import React from 'react';
2import { StyleSheet, View } from 'react-native';
3import { requireNativeViewManager } from '@unimodules/core';
4export default class NativeLinearGradient extends React.Component {
5 render() {
6 let { colors, locations, startPoint, endPoint, children, style, ...props } = this.props;
7 // TODO: revisit whether we need to inherit the container's borderRadius since this issue has
8 // been resolved: https://github.com/facebook/react-native/issues/3198
9 let flatStyle = StyleSheet.flatten(style) || {};
10 let borderRadius = flatStyle.borderRadius || 0;
11 // This is the format from:
12 // https://developer.android.com/reference/android/graphics/Path.html#addRoundRect(android.graphics.RectF,%20float[],%20android.graphics.Path.Direction)
13 let borderRadiiPerCorner = [
14 flatStyle.borderTopLeftRadius || borderRadius,
15 flatStyle.borderTopLeftRadius || borderRadius,
16 flatStyle.borderTopRightRadius || borderRadius,
17 flatStyle.borderTopRightRadius || borderRadius,
18 flatStyle.borderBottomRightRadius || borderRadius,
19 flatStyle.borderBottomRightRadius || borderRadius,
20 flatStyle.borderBottomLeftRadius || borderRadius,
21 flatStyle.borderBottomLeftRadius || borderRadius,
22 ];
23 return (<View {...props} style={style}>
24 <BaseNativeLinearGradient style={{ position: 'absolute', top: 0, left: 0, bottom: 0, right: 0 }} colors={colors} startPoint={startPoint} endPoint={endPoint} locations={locations} borderRadii={borderRadiiPerCorner}/>
25 {children}
26 </View>);
27 }
28}
29const BaseNativeLinearGradient = requireNativeViewManager('ExpoLinearGradient');
30//# sourceMappingURL=NativeLinearGradient.android.js.map
\No newline at end of file