expo-mesh-gradient 0.1.0 → 0.2.0

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/.eslintrc.js CHANGED
@@ -1,5 +1,2 @@
1
- module.exports = {
2
- root: true,
3
- extends: ['universe/native', 'universe/web'],
4
- ignorePatterns: ['build'],
5
- };
1
+ // @generated by expo-module-scripts
2
+ module.exports = require('expo-module-scripts/eslintrc.base.js');
package/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ ## Unpublished
4
+
5
+ ### 🛠 Breaking changes
6
+
7
+ ### 🎉 New features
8
+
9
+ ### 🐛 Bug fixes
10
+
11
+ ### 💡 Others
12
+
13
+ ## 0.2.0 — 2024-11-29
14
+
15
+ ### 🎉 New features
16
+
17
+ - Allow passing children to render views on top of the gradient. ([#33271](https://github.com/expo/expo/pull/33271) by [@tsapeta](https://github.com/tsapeta))
18
+ - Exported `MeshGradientViewProps` type. ([#33299](https://github.com/expo/expo/pull/33299) by [@tsapeta](https://github.com/tsapeta))
19
+ - Added `mask` prop to mask the gradient using the alpha channel of the given children views.
20
+
21
+ ## 0.1.0 — 2024-10-20
22
+
23
+ ### 🎉 New features
24
+
25
+ - Initial release 🎉
package/README.md CHANGED
@@ -1,6 +1,13 @@
1
- # expo-mesh-gradient
1
+ <p>
2
+ <a href="https://docs.expo.dev/versions/latest/sdk/mesh-gradient/">
3
+ <img
4
+ src="../../.github/resources/expo-mesh-gradient.svg"
5
+ alt="expo-mesh-gradient"
6
+ height="64" />
7
+ </a>
8
+ </p>
2
9
 
3
- My new module
10
+ A module that exposes MeshGradient view from SwiftUI to React Native.
4
11
 
5
12
  # API documentation
6
13
 
@@ -18,18 +25,13 @@ For bare React Native projects, you must ensure that you have [installed and con
18
25
  ### Add the package to your npm dependencies
19
26
 
20
27
  ```
21
- npm install expo-mesh-gradient
28
+ npx expo install expo-mesh-gradient
22
29
  ```
23
30
 
24
- ### Configure for Android
25
-
26
-
27
-
28
-
29
- ### Configure for iOS
31
+ ### Configure for iOS, tvOS and macOS
30
32
 
31
33
  Run `npx pod-install` after installing the npm package.
32
34
 
33
35
  # Contributing
34
36
 
35
- Contributions are very welcome! Please refer to guidelines described in the [contributing guide]( https://github.com/expo/expo#contributing).
37
+ Contributions are very welcome! Please refer to guidelines described in the [contributing guide](https://github.com/expo/expo#contributing).
@@ -1,6 +1,5 @@
1
- import type { StyleProp, ViewStyle } from "react-native";
2
- export type MeshGradientViewProps = {
3
- style?: StyleProp<ViewStyle>;
1
+ import type { ViewProps } from 'react-native';
2
+ export interface MeshGradientViewProps extends ViewProps {
4
3
  /**
5
4
  * Width of the mesh, i.e. the number of vertices per row.
6
5
  * @default 0
@@ -13,6 +12,7 @@ export type MeshGradientViewProps = {
13
12
  rows?: number;
14
13
  /**
15
14
  * An array of two-dimensional points on the mesh. Must contain `columns * rows` elements.
15
+ * @default []
16
16
  */
17
17
  points?: number[][];
18
18
  /**
@@ -31,5 +31,11 @@ export type MeshGradientViewProps = {
31
31
  * @default true
32
32
  */
33
33
  ignoresSafeArea?: boolean;
34
- };
34
+ /**
35
+ * Masks the gradient using the alpha channel of the given children views.
36
+ * > **Note**: When this option is enabled, all user interactions (gestures) on children views are ignored.
37
+ * @default false
38
+ */
39
+ mask?: boolean;
40
+ }
35
41
  //# sourceMappingURL=MeshGradient.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MeshGradient.types.d.ts","sourceRoot":"","sources":["../src/MeshGradient.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAE7B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IAEpB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC"}
1
+ {"version":3,"file":"MeshGradient.types.d.ts","sourceRoot":"","sources":["../src/MeshGradient.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,WAAW,qBAAsB,SAAQ,SAAS;IACtD;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IAEpB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB"}
@@ -1,4 +1,4 @@
1
- import { MeshGradientViewProps } from "./MeshGradient.types";
2
- declare const NativeView: import("react").ComponentType<MeshGradientViewProps>;
3
- export default NativeView;
1
+ import { MeshGradientViewProps } from './MeshGradient.types';
2
+ declare const _default: import("react").ComponentType<MeshGradientViewProps>;
3
+ export default _default;
4
4
  //# sourceMappingURL=MeshGradientView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MeshGradientView.d.ts","sourceRoot":"","sources":["../src/MeshGradientView.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,QAAA,MAAM,UAAU,sDAA+D,CAAC;AAEhF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"MeshGradientView.d.ts","sourceRoot":"","sources":["../src/MeshGradientView.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;;AAE7D,wBAA4E"}
package/build/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { default as MeshGradientView } from "./MeshGradientView";
1
+ export { default as MeshGradientView } from './MeshGradientView';
2
+ export { MeshGradientViewProps } from './MeshGradient.types';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -12,10 +12,11 @@ Pod::Spec.new do |s|
12
12
  s.homepage = package['homepage']
13
13
  s.platforms = {
14
14
  :ios => '15.1',
15
- :tvos => '15.1'
15
+ :tvos => '15.1',
16
+ :osx => '10.15',
16
17
  }
17
18
  s.swift_version = '5.4'
18
- s.source = { git: 'https://github.com/expo/expo' }
19
+ s.source = { git: 'https://github.com/expo/expo.git' }
19
20
  s.static_framework = true
20
21
 
21
22
  s.dependency 'ExpoModulesCore'
@@ -10,4 +10,5 @@ class MeshGradientProps: ExpoSwiftUI.ViewProps {
10
10
  @Field var colors: [Color] = []
11
11
  @Field var smoothsColors: Bool = true
12
12
  @Field var ignoresSafeArea: Bool = true
13
+ @Field var mask: Bool = false
13
14
  }
@@ -7,17 +7,32 @@ struct MeshGradientView: ExpoSwiftUI.View {
7
7
  @EnvironmentObject var props: MeshGradientProps
8
8
 
9
9
  var body: some View {
10
- if #available(iOS 18.0, *) {
11
- MeshGradient(
12
- width: props.columns,
13
- height: props.rows,
14
- points: props.points,
15
- colors: props.colors,
16
- smoothsColors: props.smoothsColors
17
- )
18
- .ignoresSafeArea(edges: props.ignoresSafeArea ? .all : [])
19
- } else {
20
- EmptyView()
10
+ ZStack(alignment: .topLeading) {
11
+ let gradient = if #available(iOS 18.0, *) {
12
+ AnyView(
13
+ MeshGradient(
14
+ width: props.columns,
15
+ height: props.rows,
16
+ points: props.points,
17
+ colors: props.colors,
18
+ smoothsColors: props.smoothsColors
19
+ )
20
+ .ignoresSafeArea(edges: props.ignoresSafeArea ? .all : [])
21
+ )
22
+ } else {
23
+ AnyView(EmptyView())
24
+ }
25
+
26
+ if props.mask {
27
+ gradient.mask(alignment: .topLeading) {
28
+ Children()
29
+ }
30
+ } else {
31
+ Group {
32
+ gradient
33
+ Children()
34
+ }
35
+ }
21
36
  }
22
37
  }
23
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-mesh-gradient",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "A module that exposes MeshGradient view from SwiftUI to React Native",
5
5
  "main": "src/index.ts",
6
6
  "types": "build/index.d.ts",
@@ -11,30 +11,32 @@
11
11
  "test": "expo-module test",
12
12
  "prepare": "expo-module prepare",
13
13
  "prepublishOnly": "expo-module prepublishOnly",
14
- "expo-module": "expo-module",
15
- "open:ios": "xed example/ios",
16
- "open:android": "open -a \"Android Studio\" example/android"
14
+ "expo-module": "expo-module"
15
+ },
16
+ "homepage": "https://docs.expo.dev/versions/latest/sdk/mesh-gradient/",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/expo/expo.git",
20
+ "directory": "packages/expo-mesh-gradient"
17
21
  },
18
22
  "keywords": [
19
23
  "react-native",
20
24
  "expo",
21
- "expo-mesh-gradient",
22
- "ExpoMeshGradient"
25
+ "mesh-gradient",
26
+ "gradient",
27
+ "mesh"
23
28
  ],
24
- "repository": "https://github.com/tsapeta/expo-mesh-gradient",
25
- "author": "Tomasz Sapeta (tsapeta)",
29
+ "author": "650 Industries, Inc.",
26
30
  "license": "MIT",
27
- "homepage": "https://github.com/expo/expo#readme",
28
31
  "dependencies": {},
29
32
  "devDependencies": {
30
33
  "@types/react": "~18.3.12",
31
- "expo-module-scripts": "^4.0.2",
32
- "expo": "~52.0.0",
33
- "react-native": "0.76.0"
34
+ "expo-module-scripts": "^4.0.2"
34
35
  },
35
36
  "peerDependencies": {
36
37
  "expo": "*",
37
38
  "react": "*",
38
39
  "react-native": "*"
39
- }
40
+ },
41
+ "gitHead": "728158f99d680cf64fb06f08301d3806c18c6f63"
40
42
  }
@@ -1,8 +1,6 @@
1
- import type { StyleProp, ViewStyle } from "react-native";
2
-
3
- export type MeshGradientViewProps = {
4
- style?: StyleProp<ViewStyle>;
1
+ import type { ViewProps } from 'react-native';
5
2
 
3
+ export interface MeshGradientViewProps extends ViewProps {
6
4
  /**
7
5
  * Width of the mesh, i.e. the number of vertices per row.
8
6
  * @default 0
@@ -17,6 +15,7 @@ export type MeshGradientViewProps = {
17
15
 
18
16
  /**
19
17
  * An array of two-dimensional points on the mesh. Must contain `columns * rows` elements.
18
+ * @default []
20
19
  */
21
20
  points?: number[][];
22
21
 
@@ -38,4 +37,11 @@ export type MeshGradientViewProps = {
38
37
  * @default true
39
38
  */
40
39
  ignoresSafeArea?: boolean;
41
- };
40
+
41
+ /**
42
+ * Masks the gradient using the alpha channel of the given children views.
43
+ * > **Note**: When this option is enabled, all user interactions (gestures) on children views are ignored.
44
+ * @default false
45
+ */
46
+ mask?: boolean;
47
+ }
@@ -1,7 +1,5 @@
1
- import { requireNativeView } from "expo";
1
+ import { requireNativeView } from 'expo';
2
2
 
3
- import { MeshGradientViewProps } from "./MeshGradient.types";
3
+ import { MeshGradientViewProps } from './MeshGradient.types';
4
4
 
5
- const NativeView = requireNativeView<MeshGradientViewProps>("ExpoMeshGradient");
6
-
7
- export default NativeView;
5
+ export default requireNativeView<MeshGradientViewProps>('ExpoMeshGradient');
package/src/index.ts CHANGED
@@ -1,4 +1,2 @@
1
- // Reexport the native module. On web, it will be resolved to ExpoMeshGradientModule.web.ts
2
- // and on native platforms to ExpoMeshGradientModule.ts
3
-
4
- export { default as MeshGradientView } from "./MeshGradientView";
1
+ export { default as MeshGradientView } from './MeshGradientView';
2
+ export { MeshGradientViewProps } from './MeshGradient.types';