@amazon-devices/expo-linear-gradient 2.0.9000000000 → 2.0.9000000001
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/LinearGradient.d.ts.map +1 -1
- package/build/LinearGradient.js +8 -1
- package/build/LinearGradient.js.map +1 -1
- package/build/NativeLinearGradient.kepler.d.ts +7 -18
- package/build/NativeLinearGradient.kepler.d.ts.map +1 -1
- package/build/NativeLinearGradient.kepler.js +7 -20
- package/build/NativeLinearGradient.kepler.js.map +1 -1
- package/kepler-compatibility.json +7 -0
- package/package.json +1 -1
- package/react-native.config.js +1 -0
- package/src/LinearGradient.tsx +8 -1
- package/src/NativeLinearGradient.kepler.tsx +29 -30
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinearGradient.d.ts","sourceRoot":"","sources":["../src/LinearGradient.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,
|
|
1
|
+
{"version":3,"file":"LinearGradient.d.ts","sourceRoot":"","sources":["../src/LinearGradient.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAA0B,MAAM,cAAc,CAAC;AAGjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAGzE;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAC3B;IACE;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;CACX,GACD,yBAAyB,CAAC;AAG9B,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG;IAC5C;;;OAGG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC5B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnC;;;;;OAKG;IACH,GAAG,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC;IACtE,MAAM;CA4BP"}
|
package/build/LinearGradient.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { processColor, Platform } from 'react-native';
|
|
3
3
|
import NativeLinearGradient from './NativeLinearGradient';
|
|
4
4
|
/**
|
|
5
5
|
* Renders a native view that transitions between multiple colors in a linear direction.
|
|
@@ -14,6 +14,13 @@ export class LinearGradient extends React.Component {
|
|
|
14
14
|
}
|
|
15
15
|
return (<NativeLinearGradient {...props} colors={Platform.select({
|
|
16
16
|
web: colors,
|
|
17
|
+
// @amznmod_react - Platform.select's typing doesn't know about the "kepler" key (it's only aware
|
|
18
|
+
// of the built-in platforms like ios/android/web/default), so this line is
|
|
19
|
+
// flagged as an excess property. On Vega/Kepler, colors are consumed as raw
|
|
20
|
+
// strings by @amazon-devices/react-linear-gradient's kepler wrapper, so we pass them
|
|
21
|
+
// through without running processColor() (unlike the default native path).
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
kepler: colors,
|
|
17
24
|
default: colors.map(processColor),
|
|
18
25
|
})} locations={resolvedLocations} startPoint={_normalizePoint(start)} endPoint={_normalizePoint(end)}/>);
|
|
19
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinearGradient.js","sourceRoot":"","sources":["../src/LinearGradient.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"LinearGradient.js","sourceRoot":"","sources":["../src/LinearGradient.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAa,YAAY,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AA2D1D;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK,CAAC,SAA8B;IACtE,MAAM;QACJ,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC/D,IAAI,iBAAiB,GAAG,SAAS,CAAC;QAClC,IAAI,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;YACpD,OAAO,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAC;YAC9F,iBAAiB,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QACxD,CAAC;QAED,OAAO,CACL,CAAC,oBAAoB,CACnB,IAAI,KAAK,CAAC,CACV,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;gBACtB,GAAG,EAAE,MAAa;gBAClB,iGAAiG;gBACjG,2EAA2E;gBAC3E,4EAA4E;gBAC5E,2EAA2E;gBAC3E,2EAA2E;gBAC3E,aAAa;gBACb,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC;aAClC,CAAC,CAAC,CACH,SAAS,CAAC,CAAC,iBAAiB,CAAC,CAC7B,UAAU,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CACnC,QAAQ,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,EAC/B,CACH,CAAC;IACJ,CAAC;CACF;AAED,SAAS,eAAe,CACtB,KAA6C;IAE7C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,8EAA8E,CAAC,CAAC;QAC7F,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["import * as React from 'react';\nimport { ViewProps, processColor, Platform } from 'react-native';\n\nimport NativeLinearGradient from './NativeLinearGradient';\nimport { NativeLinearGradientPoint } from './NativeLinearGradient.types';\n\n// @needsAudit\n/**\n * An object `{ x: number; y: number }` or array `[x, y]` that represents the point\n * at which the gradient starts or ends, as a fraction of the overall size of the gradient ranging\n * from `0` to `1`, inclusive.\n */\nexport type LinearGradientPoint =\n | {\n /**\n * A number ranging from `0` to `1`, representing the position of gradient transformation.\n */\n x: number;\n /**\n * A number ranging from `0` to `1`, representing the position of gradient transformation.\n */\n y: number;\n }\n | NativeLinearGradientPoint;\n\n// @needsAudit\nexport type LinearGradientProps = ViewProps & {\n /**\n * An array of colors that represent stops in the gradient. At least two colors are required\n * (for a single-color background, use the `style.backgroundColor` prop on a `View` component).\n */\n colors: string[];\n /**\n * An array that contains `number`s ranging from `0` to `1`, inclusive, and is the same length as the `colors` property.\n * Each number indicates a color-stop location where each respective color should be located.\n * If not specified, the colors will be distributed evenly across the gradient.\n *\n * For example, `[0.5, 0.8]` would render:\n * - the first color, solid, from the beginning of the gradient view to 50% through (the middle);\n * - a gradient from the first color to the second from the 50% point to the 80% point; and\n * - the second color, solid, from the 80% point to the end of the gradient view.\n *\n * > The color-stop locations must be ascending from least to greatest.\n * @default []\n */\n locations?: number[] | null;\n /**\n * For example, `{ x: 0.1, y: 0.2 }` means that the gradient will start `10%` from the left and `20%` from the top.\n *\n * **On web**, this only changes the angle of the gradient because CSS gradients don't support changing the starting position.\n * @default { x: 0.5, y: 0.0 }\n */\n start?: LinearGradientPoint | null;\n /**\n * For example, `{ x: 0.1, y: 0.2 }` means that the gradient will end `10%` from the left and `20%` from the bottom.\n *\n * **On web**, this only changes the angle of the gradient because CSS gradients don't support changing the end position.\n * @default { x: 0.5, y: 1.0 }\n */\n end?: LinearGradientPoint | null;\n};\n\n/**\n * Renders a native view that transitions between multiple colors in a linear direction.\n */\nexport class LinearGradient extends React.Component<LinearGradientProps> {\n render() {\n const { colors, locations, start, end, ...props } = this.props;\n let resolvedLocations = locations;\n if (locations && colors.length !== locations.length) {\n console.warn('LinearGradient colors and locations props should be arrays of the same length');\n resolvedLocations = locations.slice(0, colors.length);\n }\n\n return (\n <NativeLinearGradient\n {...props}\n colors={Platform.select({\n web: colors as any,\n // @amznmod_react - Platform.select's typing doesn't know about the \"kepler\" key (it's only aware\n // of the built-in platforms like ios/android/web/default), so this line is\n // flagged as an excess property. On Vega/Kepler, colors are consumed as raw\n // strings by @amazon-devices/react-linear-gradient's kepler wrapper, so we pass them\n // through without running processColor() (unlike the default native path).\n // @ts-ignore\n kepler: colors,\n default: colors.map(processColor),\n })}\n locations={resolvedLocations}\n startPoint={_normalizePoint(start)}\n endPoint={_normalizePoint(end)}\n />\n );\n }\n}\n\nfunction _normalizePoint(\n point: LinearGradientPoint | null | undefined\n): NativeLinearGradientPoint | undefined {\n if (!point) {\n return undefined;\n }\n\n if (Array.isArray(point) && point.length !== 2) {\n console.warn('start and end props for LinearGradient must be of the format [x,y] or {x, y}');\n return undefined;\n }\n\n return Array.isArray(point) ? point : [point.x, point.y];\n}\n"]}
|
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ViewProps
|
|
2
|
+
import { ViewProps } from 'react-native';
|
|
3
|
+
import { NativeLinearGradientPoint } from './NativeLinearGradient.types';
|
|
3
4
|
interface NativeProps extends ViewProps {
|
|
4
|
-
colors:
|
|
5
|
-
startPoint?:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
endPoint?: {
|
|
10
|
-
x: number;
|
|
11
|
-
y: number;
|
|
12
|
-
};
|
|
13
|
-
locations?: number[];
|
|
5
|
+
colors: string[];
|
|
6
|
+
startPoint?: NativeLinearGradientPoint | null;
|
|
7
|
+
endPoint?: NativeLinearGradientPoint | null;
|
|
8
|
+
locations?: number[] | null;
|
|
14
9
|
}
|
|
15
|
-
|
|
16
|
-
* This responsive component displays native React View that transitions between multiple colours along the respective dimensions.
|
|
17
|
-
* You can pass different colors, angles, locations etc. to communicate different visuals of gradient.
|
|
18
|
-
* @param props The properties passed to this component for rendering
|
|
19
|
-
* @constructor
|
|
20
|
-
*/
|
|
21
|
-
export default function (props: NativeProps): React.JSX.Element;
|
|
10
|
+
export default function NativeLinearGradient({ colors, startPoint, endPoint, locations, ...viewProps }: NativeProps): React.JSX.Element;
|
|
22
11
|
export {};
|
|
23
12
|
//# sourceMappingURL=NativeLinearGradient.kepler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeLinearGradient.kepler.d.ts","sourceRoot":"","sources":["../src/NativeLinearGradient.kepler.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NativeLinearGradient.kepler.d.ts","sourceRoot":"","sources":["../src/NativeLinearGradient.kepler.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,UAAU,WAAY,SAAQ,SAAS;IACrC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC9C,QAAQ,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC5C,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CAC7B;AAOD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,MAAM,EACN,UAAU,EACV,QAAQ,EACR,SAAS,EACT,GAAG,SAAS,EACb,EAAE,WAAW,qBAUb"}
|
|
@@ -1,23 +1,10 @@
|
|
|
1
|
+
import LinearGradient from '@amazon-devices/react-linear-gradient';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
// @
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
colors: true,
|
|
9
|
-
startPoint: true,
|
|
10
|
-
endPoint: true,
|
|
11
|
-
locations: true,
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
/**
|
|
15
|
-
* This responsive component displays native React View that transitions between multiple colours along the respective dimensions.
|
|
16
|
-
* You can pass different colors, angles, locations etc. to communicate different visuals of gradient.
|
|
17
|
-
* @param props The properties passed to this component for rendering
|
|
18
|
-
* @constructor
|
|
19
|
-
*/
|
|
20
|
-
export default function (props) {
|
|
21
|
-
return <NativeComponent {...props}/>;
|
|
3
|
+
// @amznmod_react - Defaults mirror the old native `ExpoLinearGradient` component (start_ = {0.5, 0},
|
|
4
|
+
// end_ = {0.5, 1} in kepler/ExpoLinearGradientDrawableLayer.h).
|
|
5
|
+
const DEFAULT_START = { x: 0.5, y: 0 };
|
|
6
|
+
const DEFAULT_END = { x: 0.5, y: 1 };
|
|
7
|
+
export default function NativeLinearGradient({ colors, startPoint, endPoint, locations, ...viewProps }) {
|
|
8
|
+
return (<LinearGradient {...viewProps} colors={colors} start={startPoint ? { x: startPoint[0], y: startPoint[1] } : DEFAULT_START} end={endPoint ? { x: endPoint[0], y: endPoint[1] } : DEFAULT_END} locations={locations ?? undefined}/>);
|
|
22
9
|
}
|
|
23
10
|
//# sourceMappingURL=NativeLinearGradient.kepler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeLinearGradient.kepler.js","sourceRoot":"","sources":["../src/NativeLinearGradient.kepler.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"NativeLinearGradient.kepler.js","sourceRoot":"","sources":["../src/NativeLinearGradient.kepler.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,6BAA6B,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,qGAAqG;AACrG,gEAAgE;AAChE,MAAM,aAAa,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACvC,MAAM,WAAW,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAErC,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,MAAM,EACN,UAAU,EACV,QAAQ,EACR,SAAS,EACT,GAAG,SAAS,EACA;IACZ,OAAO,CACL,CAAC,cAAc,CACb,IAAI,SAAS,CAAC,CACd,MAAM,CAAC,CAAC,MAAM,CAAC,CACf,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAC3E,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CACjE,SAAS,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,EAClC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import LinearGradient from '@amazon-devices/react-linear-gradient';\nimport React from 'react';\nimport { ViewProps } from 'react-native';\n\nimport { NativeLinearGradientPoint } from './NativeLinearGradient.types';\n\ninterface NativeProps extends ViewProps {\n colors: string[];\n startPoint?: NativeLinearGradientPoint | null;\n endPoint?: NativeLinearGradientPoint | null;\n locations?: number[] | null;\n}\n\n// @amznmod_react - Defaults mirror the old native `ExpoLinearGradient` component (start_ = {0.5, 0},\n// end_ = {0.5, 1} in kepler/ExpoLinearGradientDrawableLayer.h).\nconst DEFAULT_START = { x: 0.5, y: 0 };\nconst DEFAULT_END = { x: 0.5, y: 1 };\n\nexport default function NativeLinearGradient({\n colors,\n startPoint,\n endPoint,\n locations,\n ...viewProps\n}: NativeProps) {\n return (\n <LinearGradient\n {...viewProps}\n colors={colors}\n start={startPoint ? { x: startPoint[0], y: startPoint[1] } : DEFAULT_START}\n end={endPoint ? { x: endPoint[0], y: endPoint[1] } : DEFAULT_END}\n locations={locations ?? undefined}\n />\n );\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"versions": {
|
|
3
|
+
"2.0.0": "/com.amazon.kepler.expo_linear_gradient_2@IExpoLinearGradient_0",
|
|
4
|
+
"2.0.9000000000": "/com.amazon.kepler.expo_linear_gradient_2@IExpoLinearGradient_0",
|
|
5
|
+
"2.0.9000000001": "/com.amazon.kepler.expo_linear_gradient_2@IExpoLinearGradient_0"
|
|
6
|
+
}
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@amazon-devices/expo-linear-gradient", "version": "2.0.
|
|
1
|
+
{"name": "@amazon-devices/expo-linear-gradient", "version": "2.0.9000000001+12.6.0", "description": "Provides a React component that renders a gradient view.", "main": "build/LinearGradient.js", "types": "build/LinearGradient.d.ts", "sideEffects": false, "scripts": {"build": "expo-module build", "clean": "expo-module clean", "lint": "expo-module lint", "test": "expo-module test", "prepublishOnly": "expo-module prepublishOnly", "expo-module": "expo-module"}, "kepler": {"temporary-alias-for-package": {"name": "expo-linear-gradient", "version": "12.6.0"}}, "keywords": ["react-native", "expo", "gradient"], "jest": {"preset": "expo-module-scripts"}, "repository": {"type": "git", "url": "https://github.com/expo/expo.git", "directory": "packages/expo-linear-gradient"}, "bugs": {"url": "https://github.com/expo/expo/issues"}, "author": "650 Industries, Inc.", "license": "See license in LICENSE", "homepage": "https://docs.expo.dev/versions/latest/sdk/linear-gradient/", "devDependencies": {"@amazon-devices/react-linear-gradient": "^2.0.0", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^13.4.0", "@testing-library/react-native": "^11.3.0", "expo-module-scripts": "^3.0.0"}, "peerDependencies": {"expo": "^50.0.0-alpha.1", "@amazon-devices/react-linear-gradient": "*"}}
|
package/react-native.config.js
CHANGED
package/src/LinearGradient.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ViewProps, processColor, Platform } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import NativeLinearGradient from './NativeLinearGradient';
|
|
5
5
|
import { NativeLinearGradientPoint } from './NativeLinearGradient.types';
|
|
@@ -77,6 +77,13 @@ export class LinearGradient extends React.Component<LinearGradientProps> {
|
|
|
77
77
|
{...props}
|
|
78
78
|
colors={Platform.select({
|
|
79
79
|
web: colors as any,
|
|
80
|
+
// @amznmod_react - Platform.select's typing doesn't know about the "kepler" key (it's only aware
|
|
81
|
+
// of the built-in platforms like ios/android/web/default), so this line is
|
|
82
|
+
// flagged as an excess property. On Vega/Kepler, colors are consumed as raw
|
|
83
|
+
// strings by @amazon-devices/react-linear-gradient's kepler wrapper, so we pass them
|
|
84
|
+
// through without running processColor() (unlike the default native path).
|
|
85
|
+
// @ts-ignore
|
|
86
|
+
kepler: colors,
|
|
80
87
|
default: colors.map(processColor),
|
|
81
88
|
})}
|
|
82
89
|
locations={resolvedLocations}
|
|
@@ -1,36 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
HostComponent,
|
|
7
|
-
} from 'react-native';
|
|
1
|
+
import LinearGradient from '@amazon-devices/react-linear-gradient';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ViewProps } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import { NativeLinearGradientPoint } from './NativeLinearGradient.types';
|
|
8
6
|
|
|
9
7
|
interface NativeProps extends ViewProps {
|
|
10
|
-
colors:
|
|
11
|
-
startPoint?:
|
|
12
|
-
endPoint?:
|
|
13
|
-
locations?: number[];
|
|
8
|
+
colors: string[];
|
|
9
|
+
startPoint?: NativeLinearGradientPoint | null;
|
|
10
|
+
endPoint?: NativeLinearGradientPoint | null;
|
|
11
|
+
locations?: number[] | null;
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
validAttributes: {
|
|
21
|
-
colors: true,
|
|
22
|
-
startPoint: true,
|
|
23
|
-
endPoint: true,
|
|
24
|
-
locations: true,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
14
|
+
// @amznmod_react - Defaults mirror the old native `ExpoLinearGradient` component (start_ = {0.5, 0},
|
|
15
|
+
// end_ = {0.5, 1} in kepler/ExpoLinearGradientDrawableLayer.h).
|
|
16
|
+
const DEFAULT_START = { x: 0.5, y: 0 };
|
|
17
|
+
const DEFAULT_END = { x: 0.5, y: 1 };
|
|
27
18
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return
|
|
19
|
+
export default function NativeLinearGradient({
|
|
20
|
+
colors,
|
|
21
|
+
startPoint,
|
|
22
|
+
endPoint,
|
|
23
|
+
locations,
|
|
24
|
+
...viewProps
|
|
25
|
+
}: NativeProps) {
|
|
26
|
+
return (
|
|
27
|
+
<LinearGradient
|
|
28
|
+
{...viewProps}
|
|
29
|
+
colors={colors}
|
|
30
|
+
start={startPoint ? { x: startPoint[0], y: startPoint[1] } : DEFAULT_START}
|
|
31
|
+
end={endPoint ? { x: endPoint[0], y: endPoint[1] } : DEFAULT_END}
|
|
32
|
+
locations={locations ?? undefined}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
36
35
|
}
|