@react-native-menu/menu 0.9.0 → 1.0.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.
Files changed (72) hide show
  1. package/README.md +21 -1
  2. package/android/.project +11 -0
  3. package/android/build.gradle +69 -77
  4. package/android/gradle.properties +5 -4
  5. package/android/src/main/AndroidManifest.xml +0 -1
  6. package/android/src/main/AndroidManifestNew.xml +2 -0
  7. package/android/src/main/java/com/reactnativemenu/MenuPackage.kt +1 -1
  8. package/android/src/main/java/com/reactnativemenu/MenuViewManager.kt +3 -3
  9. package/android/src/newarch/MenuViewManagerSpec.kt +21 -0
  10. package/android/src/oldarch/MenuViewManagerSpec.kt +9 -0
  11. package/ios/Menu-Bridging-Header.h +0 -2
  12. package/ios/MenuViewManager.mm +64 -0
  13. package/ios/NewArch/FabricActionSheetView.swift +11 -0
  14. package/ios/NewArch/FabricMenuViewImplementation.swift +20 -0
  15. package/ios/NewArch/FabricViewImplementationProtocol.swift +6 -0
  16. package/ios/NewArch/MenuView.h +19 -0
  17. package/ios/NewArch/MenuView.mm +155 -0
  18. package/ios/OldArch/LegacyActionSheetView.swift +11 -0
  19. package/ios/OldArch/LegacyMenuViewImplementation.swift +13 -0
  20. package/ios/{ActionSheetView.swift → Shared/ActionSheetView.swift} +41 -26
  21. package/ios/{MenuView.swift → Shared/MenuViewImplementation.swift} +22 -16
  22. package/ios/{RCTMenuItem.swift → Shared/RCTMenuItem.swift} +9 -1
  23. package/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.js +18 -0
  24. package/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.js.map +1 -0
  25. package/lib/commonjs/UIMenuView.android.js +1 -4
  26. package/lib/commonjs/UIMenuView.android.js.map +1 -1
  27. package/lib/commonjs/UIMenuView.ios.js +3 -6
  28. package/lib/commonjs/UIMenuView.ios.js.map +1 -1
  29. package/lib/commonjs/UIMenuView.js +3 -10
  30. package/lib/commonjs/UIMenuView.js.map +1 -1
  31. package/lib/commonjs/index.js +12 -14
  32. package/lib/commonjs/index.js.map +1 -1
  33. package/lib/commonjs/types.js.map +1 -1
  34. package/lib/commonjs/utils.js +31 -0
  35. package/lib/commonjs/utils.js.map +1 -0
  36. package/lib/module/NativeModuleSpecs/UIMenuNativeComponent.js +12 -0
  37. package/lib/module/NativeModuleSpecs/UIMenuNativeComponent.js.map +1 -0
  38. package/lib/module/UIMenuView.android.js.map +1 -1
  39. package/lib/module/UIMenuView.ios.js +2 -3
  40. package/lib/module/UIMenuView.ios.js.map +1 -1
  41. package/lib/module/UIMenuView.js +0 -2
  42. package/lib/module/UIMenuView.js.map +1 -1
  43. package/lib/module/index.js +10 -10
  44. package/lib/module/index.js.map +1 -1
  45. package/lib/module/types.js.map +1 -1
  46. package/lib/module/utils.js +25 -0
  47. package/lib/module/utils.js.map +1 -0
  48. package/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts +44 -0
  49. package/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts.map +1 -0
  50. package/lib/typescript/src/UIMenuView.android.d.ts +1 -0
  51. package/lib/typescript/src/UIMenuView.android.d.ts.map +1 -0
  52. package/lib/typescript/src/UIMenuView.d.ts +1 -0
  53. package/lib/typescript/src/UIMenuView.d.ts.map +1 -0
  54. package/lib/typescript/src/UIMenuView.ios.d.ts +3 -4
  55. package/lib/typescript/src/UIMenuView.ios.d.ts.map +1 -0
  56. package/lib/typescript/src/index.d.ts +1 -0
  57. package/lib/typescript/src/index.d.ts.map +1 -0
  58. package/lib/typescript/src/types.d.ts +4 -3
  59. package/lib/typescript/src/types.d.ts.map +1 -0
  60. package/lib/typescript/src/utils.d.ts +2 -0
  61. package/lib/typescript/src/utils.d.ts.map +1 -0
  62. package/package.json +23 -12
  63. package/react-native-menu.podspec +26 -4
  64. package/src/NativeModuleSpecs/UIMenuNativeComponent.ts +55 -0
  65. package/src/UIMenuView.ios.tsx +2 -7
  66. package/src/index.tsx +8 -2
  67. package/src/types.ts +4 -3
  68. package/src/utils.ts +24 -0
  69. package/ios/Menu.xcodeproj/project.pbxproj +0 -297
  70. package/ios/RCTUIMenuManager.m +0 -27
  71. package/ios/RCTUIMenuManager.swift +0 -19
  72. /package/ios/{RCTAlertAction.swift → Shared/RCTAlertAction.swift} +0 -0
@@ -0,0 +1,44 @@
1
+ import type { DirectEventHandler, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
2
+ import type { HostComponent, ViewProps } from 'react-native';
3
+ declare type SubAction = {
4
+ id?: string;
5
+ title: string;
6
+ titleColor?: Int32;
7
+ subtitle?: string;
8
+ state?: string;
9
+ image?: string;
10
+ imageColor?: Int32;
11
+ displayInline?: boolean;
12
+ attributes?: {
13
+ destructive?: boolean;
14
+ disabled?: boolean;
15
+ hidden?: boolean;
16
+ };
17
+ };
18
+ declare type MenuAction = {
19
+ id?: string;
20
+ title: string;
21
+ titleColor?: Int32;
22
+ subtitle?: string;
23
+ state?: string;
24
+ image?: string;
25
+ imageColor?: Int32;
26
+ displayInline?: boolean;
27
+ attributes?: {
28
+ destructive?: boolean;
29
+ disabled?: boolean;
30
+ hidden?: boolean;
31
+ };
32
+ subactions?: Array<SubAction>;
33
+ };
34
+ export interface NativeProps extends ViewProps {
35
+ onPressAction?: DirectEventHandler<{
36
+ event: string;
37
+ }>;
38
+ actions: Array<MenuAction>;
39
+ actionsHash: string;
40
+ title?: string;
41
+ }
42
+ declare const _default: HostComponent<NativeProps>;
43
+ export default _default;
44
+ //# sourceMappingURL=UIMenuNativeComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UIMenuNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/NativeModuleSpecs/UIMenuNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,KAAK,EACN,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAU7D,aAAK,SAAS,GAAG;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE;QACX,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC;CACH,CAAC;AACF,aAAK,UAAU,GAAG;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE;QACX,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CAC/B,CAAC;AACF,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,aAAa,CAAC,EAAE,kBAAkB,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtD,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;;AAED,wBAEgC"}
@@ -2,3 +2,4 @@ import { HostComponent } from 'react-native';
2
2
  import type { NativeMenuComponentProps } from './types';
3
3
  declare const MenuComponent: HostComponent<NativeMenuComponentProps>;
4
4
  export default MenuComponent;
5
+ //# sourceMappingURL=UIMenuView.android.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UIMenuView.android.d.ts","sourceRoot":"","sources":["../../../src/UIMenuView.android.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0B,MAAM,cAAc,CAAC;AACrE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,QAAA,MAAM,aAAa,yCAEyB,CAAC;AAE7C,eAAe,aAAa,CAAC"}
@@ -5,3 +5,4 @@ import type { NativeMenuComponentProps } from './types';
5
5
  */
6
6
  declare const MenuView: React.FC<React.PropsWithChildren<NativeMenuComponentProps>>;
7
7
  export default MenuView;
8
+ //# sourceMappingURL=UIMenuView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UIMenuView.d.ts","sourceRoot":"","sources":["../../../src/UIMenuView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD;;GAEG;AACH,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,CAKzE,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -1,4 +1,3 @@
1
- import { HostComponent } from 'react-native';
2
- import type { NativeMenuComponentProps } from './types';
3
- declare const MenuComponent: HostComponent<NativeMenuComponentProps>;
4
- export default MenuComponent;
1
+ import UIMenuNativeComponent from './NativeModuleSpecs/UIMenuNativeComponent';
2
+ export default UIMenuNativeComponent;
3
+ //# sourceMappingURL=UIMenuView.ios.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UIMenuView.ios.d.ts","sourceRoot":"","sources":["../../../src/UIMenuView.ios.tsx"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,2CAA2C,CAAC;AAE9E,eAAe,qBAAqB,CAAC"}
@@ -3,3 +3,4 @@ import type { MenuComponentProps, MenuAction, NativeActionEvent } from './types'
3
3
  declare const MenuView: React.FC<MenuComponentProps>;
4
4
  export { MenuView };
5
5
  export type { MenuComponentProps, MenuAction, NativeActionEvent };
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAIvC,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EAEV,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAYjB,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAU1C,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC"}
@@ -115,13 +115,12 @@ declare type MenuComponentPropsBase = {
115
115
  */
116
116
  shouldOpenOnLongPress?: boolean;
117
117
  /**
118
- * Determines if menu should be displayed in dark mode or light mode
118
+ * Overrides theme variant of menu to light mode, dark mode or system theme
119
119
  * (Only support iOS for now)
120
120
  *
121
- * @default false
122
121
  * @platform iOS
123
122
  */
124
- darkMode?: boolean;
123
+ themeVariant?: string;
125
124
  };
126
125
  export declare type MenuComponentProps = React.PropsWithChildren<MenuComponentPropsBase>;
127
126
  export declare type ProcessedMenuAction = Omit<MenuAction, 'imageColor' | 'titleColor' | 'subactions'> & {
@@ -133,6 +132,8 @@ export declare type NativeMenuComponentProps = {
133
132
  style?: StyleProp<ViewStyle>;
134
133
  onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;
135
134
  actions: ProcessedMenuAction[];
135
+ actionsHash: string;
136
136
  title?: string;
137
137
  };
138
138
  export {};
139
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAEpC,oBAAY,iBAAiB,GAAG;IAC9B,WAAW,EAAE;QACX,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,aAAK,cAAc,GAAG;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;;;GAKG;AACH,aAAK,SAAS,GAAG,KAAK,GAAG,IAAI,GAAG,OAAO,CAAC;AAExC,oBAAY,UAAU,GAAG;IACvB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IACjC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;;;;;;;;OAUG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IACjC;;;;OAIG;IACH,UAAU,CAAC,EAAE,UAAU,EAAE,CAAC;IAC1B;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,aAAK,sBAAsB,GAAG;IAC5B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC7D;;OAEG;IACH,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,oBAAY,kBAAkB,GAC5B,KAAK,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,CAAC;AAElD,oBAAY,mBAAmB,GAAG,IAAI,CACpC,UAAU,EACV,YAAY,GAAG,YAAY,GAAG,YAAY,CAC3C,GAAG;IACF,UAAU,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IAC5C,UAAU,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IAC5C,UAAU,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACpC,CAAC;AAEF,oBAAY,wBAAwB,GAAG;IACrC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,aAAa,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC7D,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function objectHash(obj: Record<string, any>): string;
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAWA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAY3D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-menu/menu",
3
- "version": "0.9.0",
3
+ "version": "1.0.0",
4
4
  "description": "UIMenu component for react-native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -23,11 +23,12 @@
23
23
  "test": "jest",
24
24
  "typescript": "tsc --noEmit",
25
25
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
26
+ "format": "prettier --write \"**/*.{js,ts,tsx}\"",
26
27
  "prepare": "bob build",
27
28
  "release": "release-it",
28
29
  "example": "yarn --cwd example",
29
30
  "pods": "cd example && pod-install --quiet",
30
- "bootstrap": "yarn example && yarn && yarn pods"
31
+ "bootstrap": "yarn && yarn example && yarn pods"
31
32
  },
32
33
  "keywords": [
33
34
  "react-native",
@@ -42,21 +43,22 @@
42
43
  },
43
44
  "homepage": "https://github.com/react-native-menu/menu#readme",
44
45
  "devDependencies": {
45
- "@react-native-community/bob": "^0.17.1",
46
- "@react-native/eslint-config": "^0.72.2",
47
- "@release-it/conventional-changelog": "^3.0.1",
46
+ "@react-native/babel-preset": "^0.75.0-main",
47
+ "@react-native/eslint-config": "^0.74.0",
48
+ "@release-it/conventional-changelog": "^4.3.0",
48
49
  "@types/jest": "^29.1.2",
49
50
  "@types/react": "^18.2.2",
50
51
  "@types/react-native": "0.72.2",
51
- "eslint": "8.47.0",
52
- "eslint-config-prettier": "^9.0.0",
53
- "eslint-plugin-prettier": "^4.2.1",
52
+ "eslint": "8.57.0",
53
+ "eslint-config-prettier": "^9.1.0",
54
+ "eslint-plugin-ft-flow": "^3.0.0",
55
+ "eslint-plugin-prettier": "^5.1.2",
54
56
  "jest": "^29.1.2",
55
- "pod-install": "^0.1.0",
56
- "prettier": "^2.2.1",
57
+ "pod-install": "^0.2.0",
58
+ "prettier": "^3.1.1",
57
59
  "react": "18.2.0",
58
60
  "react-native": "0.72.2",
59
- "react-native-test-app": "^2.5.20",
61
+ "react-native-builder-bob": "^0.23.2",
60
62
  "release-it": "^14.10.0",
61
63
  "typescript": "4.8.4"
62
64
  },
@@ -117,7 +119,7 @@
117
119
  "trailingComma": "es5",
118
120
  "useTabs": false
119
121
  },
120
- "@react-native-community/bob": {
122
+ "react-native-builder-bob": {
121
123
  "source": "src",
122
124
  "output": "lib",
123
125
  "targets": [
@@ -128,5 +130,14 @@
128
130
  },
129
131
  "publishConfig": {
130
132
  "access": "public"
133
+ },
134
+ "volta": {
135
+ "node": "20.10.0",
136
+ "yarn": "1.22.21"
137
+ },
138
+ "codegenConfig": {
139
+ "name": "RNMenuViewSpec",
140
+ "type": "components",
141
+ "jsSrcsDir": "src"
131
142
  }
132
143
  }
@@ -1,6 +1,7 @@
1
1
  require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
4
5
 
5
6
  Pod::Spec.new do |s|
6
7
  s.name = "react-native-menu"
@@ -10,12 +11,33 @@ Pod::Spec.new do |s|
10
11
  s.license = package["license"]
11
12
  s.authors = package["author"]
12
13
 
13
- s.platforms = { :ios => "9.0" }
14
+ s.platforms = { :ios => "11.0" }
14
15
  s.source = { :git => "https://github.com/react-native-menu/menu.git", :tag => "#{s.version}" }
15
16
 
16
-
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
-
19
18
 
20
- s.dependency "React"
19
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then # new architecture
20
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
21
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
22
+ if respond_to?(:install_modules_dependencies, true)
23
+ install_modules_dependencies(s)
24
+ else
25
+ s.dependency "React-Core"
26
+ # Don't install the dependencies when we run `pod install` in the old architecture.
27
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
28
+ s.pod_target_xcconfig = {
29
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
30
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
31
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
32
+ }
33
+ s.dependency "React-RCTFabric"
34
+ s.dependency "React-Codegen"
35
+ s.dependency "RCT-Folly"
36
+ s.dependency "RCTRequired"
37
+ s.dependency "RCTTypeSafety"
38
+ s.dependency "ReactCommon/turbomodule/core"
39
+ end
40
+ else # old arch
41
+ s.dependency "React"
42
+ end
21
43
  end
@@ -0,0 +1,55 @@
1
+ import type {
2
+ DirectEventHandler,
3
+ Int32,
4
+ } from 'react-native/Libraries/Types/CodegenTypes';
5
+ import type { HostComponent, ViewProps } from 'react-native';
6
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
7
+ /*
8
+ Caution, those below are not just typescript types.
9
+ Codegen is using them to create the corresponding C++ data types.
10
+
11
+ Codegen doesn't play very well with reusing the same type within a type,
12
+ OR with extending types in an interface, so for now we'll just keep some duplicate
13
+ types here, to avoid issues while `pod install` takes place.
14
+ */
15
+ type SubAction = {
16
+ id?: string;
17
+ title: string;
18
+ titleColor?: Int32;
19
+ subtitle?: string;
20
+ state?: string;
21
+ image?: string;
22
+ imageColor?: Int32;
23
+ displayInline?: boolean;
24
+ attributes?: {
25
+ destructive?: boolean;
26
+ disabled?: boolean;
27
+ hidden?: boolean;
28
+ };
29
+ };
30
+ type MenuAction = {
31
+ id?: string;
32
+ title: string;
33
+ titleColor?: Int32;
34
+ subtitle?: string;
35
+ state?: string;
36
+ image?: string;
37
+ imageColor?: Int32;
38
+ displayInline?: boolean;
39
+ attributes?: {
40
+ destructive?: boolean;
41
+ disabled?: boolean;
42
+ hidden?: boolean;
43
+ };
44
+ subactions?: Array<SubAction>;
45
+ };
46
+ export interface NativeProps extends ViewProps {
47
+ onPressAction?: DirectEventHandler<{ event: string }>;
48
+ actions: Array<MenuAction>;
49
+ actionsHash: string; // just a workaround to make sure we don't have to manually compare MenuActions manually in C++ (since it's a struct and that's a pain)
50
+ title?: string;
51
+ }
52
+
53
+ export default codegenNativeComponent<NativeProps>(
54
+ 'MenuView'
55
+ ) as HostComponent<NativeProps>;
@@ -1,8 +1,3 @@
1
- import { HostComponent, requireNativeComponent } from 'react-native';
2
- import type { NativeMenuComponentProps } from './types';
1
+ import UIMenuNativeComponent from './NativeModuleSpecs/UIMenuNativeComponent';
3
2
 
4
- const MenuComponent = requireNativeComponent(
5
- 'RCTUIMenu'
6
- ) as HostComponent<NativeMenuComponentProps>;
7
-
8
- export default MenuComponent;
3
+ export default UIMenuNativeComponent;
package/src/index.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import { processColor } from 'react-native';
3
3
 
4
4
  import UIMenuView from './UIMenuView';
@@ -8,6 +8,7 @@ import type {
8
8
  ProcessedMenuAction,
9
9
  NativeActionEvent,
10
10
  } from './types';
11
+ import { objectHash } from './utils';
11
12
 
12
13
  function processAction(action: MenuAction): ProcessedMenuAction {
13
14
  return {
@@ -22,7 +23,12 @@ const MenuView: React.FC<MenuComponentProps> = ({ actions, ...props }) => {
22
23
  const processedActions = actions.map<ProcessedMenuAction>((action) =>
23
24
  processAction(action)
24
25
  );
25
- return <UIMenuView {...props} actions={processedActions} />;
26
+ const hash = useMemo(() => {
27
+ return objectHash(processedActions);
28
+ }, [processedActions]);
29
+ return (
30
+ <UIMenuView {...props} actions={processedActions} actionsHash={hash} />
31
+ );
26
32
  };
27
33
 
28
34
  export { MenuView };
package/src/types.ts CHANGED
@@ -111,6 +111,7 @@ type MenuComponentPropsBase = {
111
111
  * The title of the menu.
112
112
  */
113
113
  title?: string;
114
+
114
115
  /**
115
116
  * (Android API 23+)
116
117
  * Boolean value determines whether popup menu should be anchored
@@ -125,13 +126,12 @@ type MenuComponentPropsBase = {
125
126
  */
126
127
  shouldOpenOnLongPress?: boolean;
127
128
  /**
128
- * Determines if menu should be displayed in dark mode or light mode
129
+ * Overrides theme variant of menu to light mode, dark mode or system theme
129
130
  * (Only support iOS for now)
130
131
  *
131
- * @default false
132
132
  * @platform iOS
133
133
  */
134
- darkMode?: boolean;
134
+ themeVariant?: string;
135
135
  };
136
136
 
137
137
  export type MenuComponentProps =
@@ -150,5 +150,6 @@ export type NativeMenuComponentProps = {
150
150
  style?: StyleProp<ViewStyle>;
151
151
  onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;
152
152
  actions: ProcessedMenuAction[];
153
+ actionsHash: string;
153
154
  title?: string;
154
155
  };
package/src/utils.ts ADDED
@@ -0,0 +1,24 @@
1
+ // Function to calculate a simple hash code for a string
2
+ function hashCode(str: string): number {
3
+ let hash = 0;
4
+ for (let i = 0; i < str.length; i++) {
5
+ const char = str.charCodeAt(i);
6
+ hash = (hash << 5) - hash + char;
7
+ }
8
+ return hash;
9
+ }
10
+
11
+ // Function to create a string hash from a TypeScript object
12
+ export function objectHash(obj: Record<string, any>): string {
13
+ if (!obj) {
14
+ return '';
15
+ }
16
+ // Convert the object to a JSON string
17
+ const jsonString = JSON.stringify(obj);
18
+
19
+ // Calculate the hash code of the JSON string
20
+ const hash = hashCode(jsonString);
21
+
22
+ // Convert the hash code to a string (optional)
23
+ return String(hash);
24
+ }