@amazon-devices/expo-linear-gradient 2.0.1758683737 → 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.
@@ -1,24 +1,4 @@
1
1
  License from package.json:
2
2
  ==============================
3
3
 
4
- The MIT License (MIT)
5
-
6
- Copyright (c) 2015-present 650 Industries, Inc. (aka Expo)
7
-
8
- Permission is hereby granted, free of charge, to any person obtaining a copy
9
- of this software and associated documentation files (the "Software"), to deal
10
- in the Software without restriction, including without limitation the rights
11
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
- copies of the Software, and to permit persons to whom the Software is
13
- furnished to do so, subject to the following conditions:
14
-
15
- The above copyright notice and this permission notice shall be included in all
16
- copies or substantial portions of the Software.
17
-
18
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
- SOFTWARE.
4
+ MIT
@@ -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,EAA0B,SAAS,EAAE,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;CAqBP"}
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"}
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { Platform, processColor } from 'react-native';
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,YAAY,EAAa,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,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 { Platform, processColor, ViewProps } 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 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
+ {"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, ColorValue } from 'react-native';
2
+ import { ViewProps } from 'react-native';
3
+ import { NativeLinearGradientPoint } from './NativeLinearGradient.types';
3
4
  interface NativeProps extends ViewProps {
4
- colors: (number | ColorValue)[];
5
- startPoint?: {
6
- x: number;
7
- y: number;
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":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAOrD,UAAU,WAAY,SAAQ,SAAS;IACrC,MAAM,EAAE,CAAC,MAAM,GAAG,UAAU,CAAC,EAAE,CAAC;IAChC,UAAU,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,QAAQ,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAcD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,WAAW,KAAK,EAAE,WAAW,qBAE1C"}
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
- // @ts-ignore
3
- import register from 'react-native/Libraries/Utilities/registerGeneratedViewConfig';
4
- const NativeComponent = 'ExpoLinearGradient';
5
- register(NativeComponent, {
6
- uiViewClassName: NativeComponent,
7
- validAttributes: {
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,KAAK,MAAM,OAAO,CAAA;AAEzB,aAAa;AACb,OAAO,QAAQ,MAAM,8DAA8D,CAAC;AAYpF,MAAM,eAAe,GAAG,oBAA6D,CAAC;AAEtF,QAAQ,CAAC,eAAe,EAAE;IACxB,eAAe,EAAE,eAAe;IAChC,eAAe,EAAE;QACf,MAAM,EAAE,IAAI;QACZ,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,IAAI;KAChB;CACF,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,OAAO,WAAW,KAAkB;IACzC,OAAO,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AACxC,CAAC","sourcesContent":["import React from 'react'\nimport { ViewProps, ColorValue } from 'react-native';\n// @ts-ignore\nimport register from 'react-native/Libraries/Utilities/registerGeneratedViewConfig';\nimport {\n HostComponent,\n} from 'react-native';\n\ninterface NativeProps extends ViewProps {\n colors: (number | ColorValue)[];\n startPoint?: { x: number; y: number };\n endPoint?: { x: number; y: number };\n locations?: number[];\n}\n\nconst NativeComponent = 'ExpoLinearGradient' as unknown as HostComponent<NativeProps>;\n\nregister(NativeComponent, {\n uiViewClassName: NativeComponent,\n validAttributes: {\n colors: true,\n startPoint: true,\n endPoint: true,\n locations: true,\n },\n});\n\n/**\n * This responsive component displays native React View that transitions between multiple colours along the respective dimensions.\n * You can pass different colors, angles, locations etc. to communicate different visuals of gradient.\n * @param props The properties passed to this component for rendering\n * @constructor\n */\nexport default function (props: NativeProps) {\n return <NativeComponent {...props} />;\n}\n"]}
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"]}
@@ -1,21 +1,22 @@
1
1
  /*
2
- * Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ * Copyright (c) 2024-2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  *
4
4
  * PROPRIETARY/CONFIDENTIAL
5
5
  *
6
6
  * Use is subject to license terms.
7
7
  */
8
8
 
9
+ #include "../ExpoLinearGradientDrawableLayer.h"
10
+
9
11
  #include <gmock/gmock-actions.h>
10
12
  #include <gmock/gmock.h>
11
13
  #include <gtest/gtest.h>
12
14
 
13
15
  #include "catch.hpp"
14
16
 
15
- #include "../ExpoLinearGradientDrawableLayer.h"
16
-
17
- using namespace volta::react;
17
+ namespace volta::react {
18
18
 
19
+ // NOLINTNEXTLINE - warnings caused by catch2 macro internal implementation
19
20
  TEST_CASE("ExpoLinearGradientDrawableLayer") {
20
21
  std::vector<uint32_t> colors{0xFF0000, 0x00FF00, 0x0000FF};
21
22
  std::vector<float> locations{10, 20, 30};
@@ -25,32 +26,25 @@ TEST_CASE("ExpoLinearGradientDrawableLayer") {
25
26
  volta::graphics::Path path;
26
27
  path.addRect(rect);
27
28
 
28
- // TODO: PROJVEGA-211833 - Fix these test cases - removing volta::graphics::Canvas mocks
29
- // SECTION("Test ExpoLinearGradientDrawableLayer::onDraw - No metrics set") {
30
- // ExpoLinearGradientDrawableLayer testExpoLinearGradientDrawableLayer{};
31
- // volta::graphics::Canvas canvas{};
32
- // EXPECT_CALL(canvas, drawPath(::testing::_, ::testing::_)).Times(0);
33
- // EXPECT_CALL(canvas, drawRect(::testing::_, ::testing::_)).Times(0);
34
- // testExpoLinearGradientDrawableLayer.onDraw(canvas);
35
- // }
36
-
37
- // SECTION("Test ExpoLinearGradientDrawableLayer::onDraw - Rect not set") {
38
- // ExpoLinearGradientDrawableLayer testExpoLinearGradientDrawableLayer{};
39
- // volta::graphics::Canvas canvas{};
40
- // testExpoLinearGradientDrawableLayer.setRect(rect);
41
- // EXPECT_CALL(canvas, drawPath(::testing::_, ::testing::_)).Times(0);
42
- // EXPECT_CALL(canvas, drawRect(::testing::_, ::testing::_)).Times(1);
43
- // testExpoLinearGradientDrawableLayer.onDraw(canvas);
44
- // }
45
-
46
- // SECTION("Test ExpoLinearGradientDrawableLayer::onDraw - Path not set") {
47
- // ExpoLinearGradientDrawableLayer testExpoLinearGradientDrawableLayer{};
48
- // volta::graphics::Canvas canvas{};
49
- // testExpoLinearGradientDrawableLayer.setPath(path);
50
- // EXPECT_CALL(canvas, drawPath(::testing::_, ::testing::_)).Times(1);
51
- // EXPECT_CALL(canvas, drawRect(::testing::_, ::testing::_)).Times(0);
52
- // testExpoLinearGradientDrawableLayer.onDraw(canvas);
53
- // }
29
+ SECTION("Test ExpoLinearGradientDrawableLayer::onDraw - No metrics set") {
30
+ ExpoLinearGradientDrawableLayer testExpoLinearGradientDrawableLayer{};
31
+ auto canvas = volta::graphics::Canvas::makeTestingCanvas();
32
+ testExpoLinearGradientDrawableLayer.onDraw(canvas);
33
+ }
34
+
35
+ SECTION("Test ExpoLinearGradientDrawableLayer::onDraw - Rect not set") {
36
+ ExpoLinearGradientDrawableLayer testExpoLinearGradientDrawableLayer{};
37
+ auto canvas = volta::graphics::Canvas::makeTestingCanvas();
38
+ testExpoLinearGradientDrawableLayer.setRect(rect);
39
+ testExpoLinearGradientDrawableLayer.onDraw(canvas);
40
+ }
41
+
42
+ SECTION("Test ExpoLinearGradientDrawableLayer::onDraw - Path not set") {
43
+ ExpoLinearGradientDrawableLayer testExpoLinearGradientDrawableLayer{};
44
+ auto canvas = volta::graphics::Canvas::makeTestingCanvas();
45
+ testExpoLinearGradientDrawableLayer.setPath(path);
46
+ testExpoLinearGradientDrawableLayer.onDraw(canvas);
47
+ }
54
48
 
55
49
  SECTION("Test ExpoLinearGradientDrawableLayer::calculateGradient - Colors are empty") {
56
50
  ExpoLinearGradientDrawableLayer testExpoLinearGradientDrawableLayer{};
@@ -60,8 +54,8 @@ TEST_CASE("ExpoLinearGradientDrawableLayer") {
60
54
 
61
55
  SECTION("Test ExpoLinearGradientDrawableLayer::calculateGradient - MismatchedLocationsWithColors") {
62
56
  ExpoLinearGradientDrawableLayer testExpoLinearGradientDrawableLayer{};
63
- std::vector<uint32_t> colors_more{0xFF0000, 0x00FF00, 0x0000FF, 0x000000};
64
- testExpoLinearGradientDrawableLayer.setColors(colors_more);
57
+ std::vector<uint32_t> colorsMore{0xFF0000, 0x00FF00, 0x0000FF, 0x000000};
58
+ testExpoLinearGradientDrawableLayer.setColors(colorsMore);
65
59
  testExpoLinearGradientDrawableLayer.setLocations(locations);
66
60
  testExpoLinearGradientDrawableLayer.calculateGradient();
67
61
  REQUIRE(testExpoLinearGradientDrawableLayer.linearGradientShader_ == nullptr);
@@ -76,7 +70,7 @@ TEST_CASE("ExpoLinearGradientDrawableLayer") {
76
70
  testExpoLinearGradientDrawableLayer.calculateGradient();
77
71
  REQUIRE(testExpoLinearGradientDrawableLayer.linearGradientShader_ != nullptr);
78
72
  }
79
-
73
+
80
74
  SECTION("Test ExpoLinearGradientDrawableLayer::calculateGradient - Locations are not empty") {
81
75
  ExpoLinearGradientDrawableLayer testExpoLinearGradientDrawableLayer{};
82
76
  REQUIRE(testExpoLinearGradientDrawableLayer.linearGradientShader_ == nullptr);
@@ -87,7 +81,7 @@ TEST_CASE("ExpoLinearGradientDrawableLayer") {
87
81
  testExpoLinearGradientDrawableLayer.calculateGradient();
88
82
  REQUIRE(testExpoLinearGradientDrawableLayer.linearGradientShader_ != nullptr);
89
83
  }
90
-
84
+
91
85
  SECTION("Test ExpoLinearGradientDrawableLayer::setColors") {
92
86
  ExpoLinearGradientDrawableLayer testExpoLinearGradientDrawableLayer{};
93
87
  testExpoLinearGradientDrawableLayer.setColors(colors);
@@ -127,8 +121,11 @@ TEST_CASE("ExpoLinearGradientDrawableLayer") {
127
121
 
128
122
  SECTION("Test ExpoLinearGradientDrawableLayer::setSize") {
129
123
  ExpoLinearGradientDrawableLayer testExpoLinearGradientDrawableLayer{};
130
- float w=10.0f, h=20.0f;
124
+ float w = 10.0f;
125
+ float h = 20.0f;
131
126
  testExpoLinearGradientDrawableLayer.setSize(w, h);
132
127
  REQUIRE(testExpoLinearGradientDrawableLayer.size_ == volta::graphics::Point{w, h});
133
128
  }
134
129
  }
130
+
131
+ } // namespace volta::react
@@ -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.1758683737+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", "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": {"@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": "*"}}
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": "*"}}
@@ -12,6 +12,7 @@ module.exports = {
12
12
  autolink: {
13
13
  ExpoLinearGradientLib: {
14
14
  provider: 'system',
15
+ libraryName: 'libexpo-linear-gradient-2.so.2',
15
16
  components: ['ExpoLinearGradient'],
16
17
  },
17
18
  },
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { Platform, processColor, ViewProps } from 'react-native';
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 React from 'react'
2
- import { ViewProps, ColorValue } from 'react-native';
3
- // @ts-ignore
4
- import register from 'react-native/Libraries/Utilities/registerGeneratedViewConfig';
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: (number | ColorValue)[];
11
- startPoint?: { x: number; y: number };
12
- endPoint?: { x: number; y: number };
13
- locations?: number[];
8
+ colors: string[];
9
+ startPoint?: NativeLinearGradientPoint | null;
10
+ endPoint?: NativeLinearGradientPoint | null;
11
+ locations?: number[] | null;
14
12
  }
15
13
 
16
- const NativeComponent = 'ExpoLinearGradient' as unknown as HostComponent<NativeProps>;
17
-
18
- register(NativeComponent, {
19
- uiViewClassName: NativeComponent,
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
- * This responsive component displays native React View that transitions between multiple colours along the respective dimensions.
30
- * You can pass different colors, angles, locations etc. to communicate different visuals of gradient.
31
- * @param props The properties passed to this component for rendering
32
- * @constructor
33
- */
34
- export default function (props: NativeProps) {
35
- return <NativeComponent {...props} />;
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
  }