UNPKG

expo-linear-gradient

Version:

Provides a React component that renders a gradient view.

25 lines 1.72 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { requireNativeViewManager } from 'expo-modules-core'; import * as React from 'react'; import { StyleSheet, View } from 'react-native'; export default function NativeLinearGradient({ colors, locations, startPoint, endPoint, children, style, dither, ...props }) { // TODO: revisit whether we need to inherit the container's borderRadius since this issue has // been resolved: https://github.com/facebook/react-native/issues/3198 const flatStyle = StyleSheet.flatten(style) ?? {}; const borderRadius = flatStyle.borderRadius ?? 0; // This is the format from: // https://developer.android.com/reference/android/graphics/Path.html#addRoundRect(android.graphics.RectF,%20float[],%20android.graphics.Path.Direction) const borderRadiiPerCorner = [ flatStyle.borderTopLeftRadius ?? borderRadius, flatStyle.borderTopLeftRadius ?? borderRadius, flatStyle.borderTopRightRadius ?? borderRadius, flatStyle.borderTopRightRadius ?? borderRadius, flatStyle.borderBottomRightRadius ?? borderRadius, flatStyle.borderBottomRightRadius ?? borderRadius, flatStyle.borderBottomLeftRadius ?? borderRadius, flatStyle.borderBottomLeftRadius ?? borderRadius, ]; return (_jsxs(View, { ...props, style: style, children: [_jsx(BaseNativeLinearGradient, { style: StyleSheet.absoluteFill, colors: colors, startPoint: startPoint, endPoint: endPoint, locations: locations, borderRadii: borderRadiiPerCorner, dither: dither }), children] })); } const BaseNativeLinearGradient = requireNativeViewManager('ExpoLinearGradient'); //# sourceMappingURL=NativeLinearGradient.android.js.map