@react-native-oh/react-native-harmony 0.72.23 → 0.72.27
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/Libraries/Alert/Alert.harmony.js +71 -71
- package/Libraries/Alert/AlertManager.ts +35 -35
- package/Libraries/Animated/NativeAnimatedHelper.harmony.js +601 -601
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.harmony.js +445 -426
- package/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.harmony.js +30 -0
- package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.harmony.js +26 -0
- package/Libraries/Components/Button/Button.harmony.js +450 -450
- package/Libraries/Components/Image/Image.flow.harmony.js +53 -0
- package/Libraries/Components/Image/Image.harmony.js +299 -0
- package/Libraries/Components/Image/NativeImageLoaderHarmony.js +38 -0
- package/Libraries/Components/RefreshControl/RefreshControl.harmony.js +210 -208
- package/Libraries/Components/SafeAreaView/SafeAreaView.harmony.tsx +76 -75
- package/Libraries/Components/ScrollView/ScrollView.harmony.js +1951 -1930
- package/Libraries/Components/ScrollView/processDecelerationRate.harmony.js +24 -24
- package/Libraries/Components/StatusBar/NativeStatusBarManagerHarmony.js +71 -68
- package/Libraries/Components/StatusBar/StatusBar.harmony.js +447 -447
- package/Libraries/Components/TextInput/TextInput.harmony.js +1707 -1697
- package/Libraries/Components/TextInput/TextInputState.harmony.js +220 -220
- package/Libraries/Components/Touchable/TouchableHighlight.harmony.js +396 -396
- package/Libraries/Components/Touchable/TouchableNativeFeedback.harmony.js +364 -364
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.harmony.js +227 -227
- package/Libraries/Components/View/View.harmony.js +149 -149
- package/Libraries/Core/setUpReactDevTools.harmony.js +93 -93
- package/Libraries/Image/AssetSourceResolver.harmony.ts +78 -78
- package/Libraries/NativeComponent/BaseViewConfig.harmony.js +337 -337
- package/Libraries/ReactNative/UIManager.harmony.js +210 -210
- package/Libraries/Settings/Settings.harmony.js +15 -15
- package/Libraries/Share/Share.harmony.js +174 -0
- package/Libraries/StyleSheet/NativePlatformColor.ts +8 -8
- package/Libraries/StyleSheet/PlatformColorValueTypes.harmony.ts +14 -14
- package/Libraries/Utilities/BackHandler.harmony.js +109 -109
- package/Libraries/Utilities/{NativePlatformConstantsHarmony.ts → NativePlatformConstants.harmony.ts} +8 -8
- package/Libraries/Utilities/Platform.d.ts +117 -117
- package/Libraries/Utilities/Platform.harmony.ts +33 -33
- package/Libraries/Utilities/createPerformanceLogger.harmony.js +328 -328
- package/Libraries/Vibration/Vibration.harmony.js +88 -88
- package/index.js +212 -202
- package/jest.config.js +5 -5
- package/metro.config.js +348 -349
- package/package.json +58 -55
- package/react-native.config.js +10 -10
- package/{rnoh-4.1.0.404-vmall.har → react_native_openharmony.har} +0 -0
- package/tsconfig.json +13 -13
- package/types/index.d.ts +101 -101
|
@@ -1,210 +1,210 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
// RNOH patch: imports
|
|
12
|
-
import type {RootTag} from 'react-native/Libraries/Types/RootTagTypes';
|
|
13
|
-
import type {Spec} from 'react-native/Libraries/ReactNative/NativeUIManager';
|
|
14
|
-
|
|
15
|
-
import {getFabricUIManager} from 'react-native/Libraries/ReactNative/FabricUIManager';
|
|
16
|
-
import nullthrows from 'nullthrows';
|
|
17
|
-
|
|
18
|
-
export interface UIManagerJSInterface extends Spec {
|
|
19
|
-
+getViewManagerConfig: (viewManagerName: string) => Object;
|
|
20
|
-
+hasViewManagerConfig: (viewManagerName: string) => boolean;
|
|
21
|
-
+createView: (
|
|
22
|
-
reactTag: ?number,
|
|
23
|
-
viewName: string,
|
|
24
|
-
rootTag: RootTag,
|
|
25
|
-
props: Object,
|
|
26
|
-
) => void;
|
|
27
|
-
+updateView: (reactTag: number, viewName: string, props: Object) => void;
|
|
28
|
-
+manageChildren: (
|
|
29
|
-
containerTag: ?number,
|
|
30
|
-
moveFromIndices: Array<number>,
|
|
31
|
-
moveToIndices: Array<number>,
|
|
32
|
-
addChildReactTags: Array<number>,
|
|
33
|
-
addAtIndices: Array<number>,
|
|
34
|
-
removeAtIndices: Array<number>,
|
|
35
|
-
) => void;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function isFabricReactTag(reactTag: number): boolean {
|
|
39
|
-
// React reserves even numbers for Fabric.
|
|
40
|
-
return reactTag % 2 === 0;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// RNOH patch: always export BridgelessUIManager properties
|
|
44
|
-
const BridgelessUIManager: UIManagerJSInterface = require('react-native/Libraries/ReactNative/BridgelessUIManager')
|
|
45
|
-
const PaperUIManager: UIManagerJSInterface =
|
|
46
|
-
global.RN$Bridgeless === true
|
|
47
|
-
? {}
|
|
48
|
-
: require('react-native/Libraries/ReactNative/PaperUIManager');
|
|
49
|
-
|
|
50
|
-
// $FlowFixMe[cannot-spread-interface]
|
|
51
|
-
const UIManager = {
|
|
52
|
-
...BridgelessUIManager,
|
|
53
|
-
...PaperUIManager,
|
|
54
|
-
measure(
|
|
55
|
-
reactTag: number,
|
|
56
|
-
callback: (
|
|
57
|
-
left: number,
|
|
58
|
-
top: number,
|
|
59
|
-
width: number,
|
|
60
|
-
height: number,
|
|
61
|
-
pageX: number,
|
|
62
|
-
pageY: number,
|
|
63
|
-
) => void,
|
|
64
|
-
): void {
|
|
65
|
-
if (isFabricReactTag(reactTag)) {
|
|
66
|
-
const FabricUIManager = nullthrows(getFabricUIManager());
|
|
67
|
-
const shadowNode =
|
|
68
|
-
FabricUIManager.findShadowNodeByTag_DEPRECATED(reactTag);
|
|
69
|
-
if (shadowNode) {
|
|
70
|
-
FabricUIManager.measure(shadowNode, callback);
|
|
71
|
-
} else {
|
|
72
|
-
console.warn(`measure cannot find view with tag #${reactTag}`);
|
|
73
|
-
// $FlowFixMe[incompatible-call]
|
|
74
|
-
callback();
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
// Paper
|
|
78
|
-
UIManagerImpl.measure(reactTag, callback);
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
measureInWindow(
|
|
83
|
-
reactTag: number,
|
|
84
|
-
callback: (
|
|
85
|
-
left: number,
|
|
86
|
-
top: number,
|
|
87
|
-
width: number,
|
|
88
|
-
height: number,
|
|
89
|
-
) => void,
|
|
90
|
-
): void {
|
|
91
|
-
if (isFabricReactTag(reactTag)) {
|
|
92
|
-
const FabricUIManager = nullthrows(getFabricUIManager());
|
|
93
|
-
const shadowNode =
|
|
94
|
-
FabricUIManager.findShadowNodeByTag_DEPRECATED(reactTag);
|
|
95
|
-
if (shadowNode) {
|
|
96
|
-
FabricUIManager.measureInWindow(shadowNode, callback);
|
|
97
|
-
} else {
|
|
98
|
-
console.warn(`measure cannot find view with tag #${reactTag}`);
|
|
99
|
-
// $FlowFixMe[incompatible-call]
|
|
100
|
-
callback();
|
|
101
|
-
}
|
|
102
|
-
} else {
|
|
103
|
-
// Paper
|
|
104
|
-
UIManagerImpl.measureInWindow(reactTag, callback);
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
measureLayout(
|
|
109
|
-
reactTag: number,
|
|
110
|
-
ancestorReactTag: number,
|
|
111
|
-
errorCallback: (error: Object) => void,
|
|
112
|
-
callback: (
|
|
113
|
-
left: number,
|
|
114
|
-
top: number,
|
|
115
|
-
width: number,
|
|
116
|
-
height: number,
|
|
117
|
-
) => void,
|
|
118
|
-
): void {
|
|
119
|
-
if (isFabricReactTag(reactTag)) {
|
|
120
|
-
const FabricUIManager = nullthrows(getFabricUIManager());
|
|
121
|
-
const shadowNode =
|
|
122
|
-
FabricUIManager.findShadowNodeByTag_DEPRECATED(reactTag);
|
|
123
|
-
const ancestorShadowNode =
|
|
124
|
-
FabricUIManager.findShadowNodeByTag_DEPRECATED(ancestorReactTag);
|
|
125
|
-
|
|
126
|
-
if (!shadowNode || !ancestorShadowNode) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
FabricUIManager.measureLayout(
|
|
131
|
-
shadowNode,
|
|
132
|
-
ancestorShadowNode,
|
|
133
|
-
errorCallback,
|
|
134
|
-
callback,
|
|
135
|
-
);
|
|
136
|
-
} else {
|
|
137
|
-
// Paper
|
|
138
|
-
UIManagerImpl.measureLayout(
|
|
139
|
-
reactTag,
|
|
140
|
-
ancestorReactTag,
|
|
141
|
-
errorCallback,
|
|
142
|
-
callback,
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
-
measureLayoutRelativeToParent(
|
|
148
|
-
reactTag: number,
|
|
149
|
-
errorCallback: (error: Object) => void,
|
|
150
|
-
callback: (
|
|
151
|
-
left: number,
|
|
152
|
-
top: number,
|
|
153
|
-
width: number,
|
|
154
|
-
height: number,
|
|
155
|
-
) => void,
|
|
156
|
-
): void {
|
|
157
|
-
if (isFabricReactTag(reactTag)) {
|
|
158
|
-
console.warn(
|
|
159
|
-
'RCTUIManager.measureLayoutRelativeToParent method is deprecated and it will not be implemented in newer versions of RN (Fabric) - T47686450',
|
|
160
|
-
);
|
|
161
|
-
const FabricUIManager = nullthrows(getFabricUIManager());
|
|
162
|
-
const shadowNode =
|
|
163
|
-
FabricUIManager.findShadowNodeByTag_DEPRECATED(reactTag);
|
|
164
|
-
if (shadowNode) {
|
|
165
|
-
FabricUIManager.measure(
|
|
166
|
-
shadowNode,
|
|
167
|
-
(left, top, width, height, pageX, pageY) => {
|
|
168
|
-
callback(left, top, width, height);
|
|
169
|
-
},
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
} else {
|
|
173
|
-
// Paper
|
|
174
|
-
UIManagerImpl.measureLayoutRelativeToParent(
|
|
175
|
-
reactTag,
|
|
176
|
-
errorCallback,
|
|
177
|
-
callback,
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
|
|
182
|
-
dispatchViewManagerCommand(
|
|
183
|
-
reactTag: number,
|
|
184
|
-
commandName: number | string,
|
|
185
|
-
commandArgs: any[],
|
|
186
|
-
) {
|
|
187
|
-
if (isFabricReactTag(reactTag)) {
|
|
188
|
-
const FabricUIManager = nullthrows(getFabricUIManager());
|
|
189
|
-
const shadowNode =
|
|
190
|
-
FabricUIManager.findShadowNodeByTag_DEPRECATED(reactTag);
|
|
191
|
-
if (shadowNode) {
|
|
192
|
-
// Transform the accidental CommandID into a CommandName which is the stringified number.
|
|
193
|
-
// The interop layer knows how to convert this number into the right method name.
|
|
194
|
-
// Stringify a string is a no-op, so it's safe.
|
|
195
|
-
commandName = `${commandName}`;
|
|
196
|
-
FabricUIManager.dispatchCommand(shadowNode, commandName, commandArgs);
|
|
197
|
-
}
|
|
198
|
-
} else {
|
|
199
|
-
UIManagerImpl.dispatchViewManagerCommand(
|
|
200
|
-
reactTag,
|
|
201
|
-
// We have some legacy components that are actually already using strings. ¯\_(ツ)_/¯
|
|
202
|
-
// $FlowFixMe[incompatible-call]
|
|
203
|
-
commandName,
|
|
204
|
-
commandArgs,
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
module.exports = UIManager;
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// RNOH patch: imports
|
|
12
|
+
import type {RootTag} from 'react-native/Libraries/Types/RootTagTypes';
|
|
13
|
+
import type {Spec} from 'react-native/Libraries/ReactNative/NativeUIManager';
|
|
14
|
+
|
|
15
|
+
import {getFabricUIManager} from 'react-native/Libraries/ReactNative/FabricUIManager';
|
|
16
|
+
import nullthrows from 'nullthrows';
|
|
17
|
+
|
|
18
|
+
export interface UIManagerJSInterface extends Spec {
|
|
19
|
+
+getViewManagerConfig: (viewManagerName: string) => Object;
|
|
20
|
+
+hasViewManagerConfig: (viewManagerName: string) => boolean;
|
|
21
|
+
+createView: (
|
|
22
|
+
reactTag: ?number,
|
|
23
|
+
viewName: string,
|
|
24
|
+
rootTag: RootTag,
|
|
25
|
+
props: Object,
|
|
26
|
+
) => void;
|
|
27
|
+
+updateView: (reactTag: number, viewName: string, props: Object) => void;
|
|
28
|
+
+manageChildren: (
|
|
29
|
+
containerTag: ?number,
|
|
30
|
+
moveFromIndices: Array<number>,
|
|
31
|
+
moveToIndices: Array<number>,
|
|
32
|
+
addChildReactTags: Array<number>,
|
|
33
|
+
addAtIndices: Array<number>,
|
|
34
|
+
removeAtIndices: Array<number>,
|
|
35
|
+
) => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function isFabricReactTag(reactTag: number): boolean {
|
|
39
|
+
// React reserves even numbers for Fabric.
|
|
40
|
+
return reactTag % 2 === 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// RNOH patch: always export BridgelessUIManager properties
|
|
44
|
+
const BridgelessUIManager: UIManagerJSInterface = require('react-native/Libraries/ReactNative/BridgelessUIManager')
|
|
45
|
+
const PaperUIManager: UIManagerJSInterface =
|
|
46
|
+
global.RN$Bridgeless === true
|
|
47
|
+
? {}
|
|
48
|
+
: require('react-native/Libraries/ReactNative/PaperUIManager');
|
|
49
|
+
|
|
50
|
+
// $FlowFixMe[cannot-spread-interface]
|
|
51
|
+
const UIManager = {
|
|
52
|
+
...BridgelessUIManager,
|
|
53
|
+
...PaperUIManager,
|
|
54
|
+
measure(
|
|
55
|
+
reactTag: number,
|
|
56
|
+
callback: (
|
|
57
|
+
left: number,
|
|
58
|
+
top: number,
|
|
59
|
+
width: number,
|
|
60
|
+
height: number,
|
|
61
|
+
pageX: number,
|
|
62
|
+
pageY: number,
|
|
63
|
+
) => void,
|
|
64
|
+
): void {
|
|
65
|
+
if (isFabricReactTag(reactTag)) {
|
|
66
|
+
const FabricUIManager = nullthrows(getFabricUIManager());
|
|
67
|
+
const shadowNode =
|
|
68
|
+
FabricUIManager.findShadowNodeByTag_DEPRECATED(reactTag);
|
|
69
|
+
if (shadowNode) {
|
|
70
|
+
FabricUIManager.measure(shadowNode, callback);
|
|
71
|
+
} else {
|
|
72
|
+
console.warn(`measure cannot find view with tag #${reactTag}`);
|
|
73
|
+
// $FlowFixMe[incompatible-call]
|
|
74
|
+
callback();
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
// Paper
|
|
78
|
+
UIManagerImpl.measure(reactTag, callback);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
measureInWindow(
|
|
83
|
+
reactTag: number,
|
|
84
|
+
callback: (
|
|
85
|
+
left: number,
|
|
86
|
+
top: number,
|
|
87
|
+
width: number,
|
|
88
|
+
height: number,
|
|
89
|
+
) => void,
|
|
90
|
+
): void {
|
|
91
|
+
if (isFabricReactTag(reactTag)) {
|
|
92
|
+
const FabricUIManager = nullthrows(getFabricUIManager());
|
|
93
|
+
const shadowNode =
|
|
94
|
+
FabricUIManager.findShadowNodeByTag_DEPRECATED(reactTag);
|
|
95
|
+
if (shadowNode) {
|
|
96
|
+
FabricUIManager.measureInWindow(shadowNode, callback);
|
|
97
|
+
} else {
|
|
98
|
+
console.warn(`measure cannot find view with tag #${reactTag}`);
|
|
99
|
+
// $FlowFixMe[incompatible-call]
|
|
100
|
+
callback();
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
// Paper
|
|
104
|
+
UIManagerImpl.measureInWindow(reactTag, callback);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
measureLayout(
|
|
109
|
+
reactTag: number,
|
|
110
|
+
ancestorReactTag: number,
|
|
111
|
+
errorCallback: (error: Object) => void,
|
|
112
|
+
callback: (
|
|
113
|
+
left: number,
|
|
114
|
+
top: number,
|
|
115
|
+
width: number,
|
|
116
|
+
height: number,
|
|
117
|
+
) => void,
|
|
118
|
+
): void {
|
|
119
|
+
if (isFabricReactTag(reactTag)) {
|
|
120
|
+
const FabricUIManager = nullthrows(getFabricUIManager());
|
|
121
|
+
const shadowNode =
|
|
122
|
+
FabricUIManager.findShadowNodeByTag_DEPRECATED(reactTag);
|
|
123
|
+
const ancestorShadowNode =
|
|
124
|
+
FabricUIManager.findShadowNodeByTag_DEPRECATED(ancestorReactTag);
|
|
125
|
+
|
|
126
|
+
if (!shadowNode || !ancestorShadowNode) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
FabricUIManager.measureLayout(
|
|
131
|
+
shadowNode,
|
|
132
|
+
ancestorShadowNode,
|
|
133
|
+
errorCallback,
|
|
134
|
+
callback,
|
|
135
|
+
);
|
|
136
|
+
} else {
|
|
137
|
+
// Paper
|
|
138
|
+
UIManagerImpl.measureLayout(
|
|
139
|
+
reactTag,
|
|
140
|
+
ancestorReactTag,
|
|
141
|
+
errorCallback,
|
|
142
|
+
callback,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
measureLayoutRelativeToParent(
|
|
148
|
+
reactTag: number,
|
|
149
|
+
errorCallback: (error: Object) => void,
|
|
150
|
+
callback: (
|
|
151
|
+
left: number,
|
|
152
|
+
top: number,
|
|
153
|
+
width: number,
|
|
154
|
+
height: number,
|
|
155
|
+
) => void,
|
|
156
|
+
): void {
|
|
157
|
+
if (isFabricReactTag(reactTag)) {
|
|
158
|
+
console.warn(
|
|
159
|
+
'RCTUIManager.measureLayoutRelativeToParent method is deprecated and it will not be implemented in newer versions of RN (Fabric) - T47686450',
|
|
160
|
+
);
|
|
161
|
+
const FabricUIManager = nullthrows(getFabricUIManager());
|
|
162
|
+
const shadowNode =
|
|
163
|
+
FabricUIManager.findShadowNodeByTag_DEPRECATED(reactTag);
|
|
164
|
+
if (shadowNode) {
|
|
165
|
+
FabricUIManager.measure(
|
|
166
|
+
shadowNode,
|
|
167
|
+
(left, top, width, height, pageX, pageY) => {
|
|
168
|
+
callback(left, top, width, height);
|
|
169
|
+
},
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
// Paper
|
|
174
|
+
UIManagerImpl.measureLayoutRelativeToParent(
|
|
175
|
+
reactTag,
|
|
176
|
+
errorCallback,
|
|
177
|
+
callback,
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
dispatchViewManagerCommand(
|
|
183
|
+
reactTag: number,
|
|
184
|
+
commandName: number | string,
|
|
185
|
+
commandArgs: any[],
|
|
186
|
+
) {
|
|
187
|
+
if (isFabricReactTag(reactTag)) {
|
|
188
|
+
const FabricUIManager = nullthrows(getFabricUIManager());
|
|
189
|
+
const shadowNode =
|
|
190
|
+
FabricUIManager.findShadowNodeByTag_DEPRECATED(reactTag);
|
|
191
|
+
if (shadowNode) {
|
|
192
|
+
// Transform the accidental CommandID into a CommandName which is the stringified number.
|
|
193
|
+
// The interop layer knows how to convert this number into the right method name.
|
|
194
|
+
// Stringify a string is a no-op, so it's safe.
|
|
195
|
+
commandName = `${commandName}`;
|
|
196
|
+
FabricUIManager.dispatchCommand(shadowNode, commandName, commandArgs);
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
UIManagerImpl.dispatchViewManagerCommand(
|
|
200
|
+
reactTag,
|
|
201
|
+
// We have some legacy components that are actually already using strings. ¯\_(ツ)_/¯
|
|
202
|
+
// $FlowFixMe[incompatible-call]
|
|
203
|
+
commandName,
|
|
204
|
+
commandArgs,
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
module.exports = UIManager;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const Settings = {
|
|
2
|
-
get(key: string): mixed {
|
|
3
|
-
return null;
|
|
4
|
-
},
|
|
5
|
-
|
|
6
|
-
set(settings: Object) {},
|
|
7
|
-
|
|
8
|
-
watchKeys(keys: string | Array<string>, callback: Function): number {
|
|
9
|
-
return -1;
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
clearWatch(watchId: number) {},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
module.exports = Settings;
|
|
1
|
+
const Settings = {
|
|
2
|
+
get(key: string): mixed {
|
|
3
|
+
return null;
|
|
4
|
+
},
|
|
5
|
+
|
|
6
|
+
set(settings: Object) {},
|
|
7
|
+
|
|
8
|
+
watchKeys(keys: string | Array<string>, callback: Function): number {
|
|
9
|
+
return -1;
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
clearWatch(watchId: number) {},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
module.exports = Settings;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @flow strict-local
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import NativeActionSheetManager from 'react-native/Libraries/ActionSheetIOS/NativeActionSheetManager';
|
|
12
|
+
import NativeShareModule from 'react-native/Libraries/Share/NativeShareModule';
|
|
13
|
+
|
|
14
|
+
const processColor = require('react-native/Libraries/StyleSheet/processColor').default;
|
|
15
|
+
const PlatformOS = 'android'; // rnoh: patch
|
|
16
|
+
const invariant = require('invariant');
|
|
17
|
+
|
|
18
|
+
type Content =
|
|
19
|
+
| {
|
|
20
|
+
title?: string,
|
|
21
|
+
message: string,
|
|
22
|
+
...
|
|
23
|
+
}
|
|
24
|
+
| {
|
|
25
|
+
title?: string,
|
|
26
|
+
url: string,
|
|
27
|
+
...
|
|
28
|
+
};
|
|
29
|
+
type Options = {
|
|
30
|
+
dialogTitle?: string,
|
|
31
|
+
excludedActivityTypes?: Array<string>,
|
|
32
|
+
tintColor?: string,
|
|
33
|
+
subject?: string,
|
|
34
|
+
anchor?: number,
|
|
35
|
+
...
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
class Share {
|
|
39
|
+
/**
|
|
40
|
+
* Open a dialog to share text content.
|
|
41
|
+
*
|
|
42
|
+
* In iOS, Returns a Promise which will be invoked an object containing `action`, `activityType`.
|
|
43
|
+
* If the user dismissed the dialog, the Promise will still be resolved with action being `Share.dismissedAction`
|
|
44
|
+
* and all the other keys being undefined.
|
|
45
|
+
*
|
|
46
|
+
* In Android, Returns a Promise which always be resolved with action being `Share.sharedAction`.
|
|
47
|
+
*
|
|
48
|
+
* ### Content
|
|
49
|
+
*
|
|
50
|
+
* - `message` - a message to share
|
|
51
|
+
*
|
|
52
|
+
* #### iOS
|
|
53
|
+
*
|
|
54
|
+
* - `url` - a URL to share
|
|
55
|
+
*
|
|
56
|
+
* At least one of URL and message is required.
|
|
57
|
+
*
|
|
58
|
+
* #### Android
|
|
59
|
+
*
|
|
60
|
+
* - `title` - title of the message
|
|
61
|
+
*
|
|
62
|
+
* ### Options
|
|
63
|
+
*
|
|
64
|
+
* #### iOS
|
|
65
|
+
*
|
|
66
|
+
* - `subject` - a subject to share via email
|
|
67
|
+
* - `excludedActivityTypes`
|
|
68
|
+
* - `tintColor`
|
|
69
|
+
*
|
|
70
|
+
* #### Android
|
|
71
|
+
*
|
|
72
|
+
* - `dialogTitle`
|
|
73
|
+
*
|
|
74
|
+
*/
|
|
75
|
+
static share(
|
|
76
|
+
content: Content,
|
|
77
|
+
options: Options = {},
|
|
78
|
+
): Promise<{action: string, activityType: ?string}> {
|
|
79
|
+
invariant(
|
|
80
|
+
typeof content === 'object' && content !== null,
|
|
81
|
+
'Content to share must be a valid object',
|
|
82
|
+
);
|
|
83
|
+
invariant(
|
|
84
|
+
typeof content.url === 'string' || typeof content.message === 'string' || typeof content.title === 'string', // rnoh: patch
|
|
85
|
+
'At least one of URL, title and message is required', // rnoh: patch
|
|
86
|
+
);
|
|
87
|
+
invariant(
|
|
88
|
+
typeof options === 'object' && options !== null,
|
|
89
|
+
'Options must be a valid object',
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
if (PlatformOS === 'android') {
|
|
93
|
+
invariant(
|
|
94
|
+
NativeShareModule,
|
|
95
|
+
'ShareModule should be registered on Android.',
|
|
96
|
+
);
|
|
97
|
+
invariant(
|
|
98
|
+
content.title == null || typeof content.title === 'string',
|
|
99
|
+
'Invalid title: title should be a string.',
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const newContent = {
|
|
103
|
+
title: content.title,
|
|
104
|
+
message:
|
|
105
|
+
typeof content.message === 'string' ? content.message : undefined,
|
|
106
|
+
url: typeof content.url === 'string' ? content.url : undefined, // rnoh: patch
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return NativeShareModule.share(newContent, options.dialogTitle)
|
|
110
|
+
.then(
|
|
111
|
+
result => ({
|
|
112
|
+
activityType: null,
|
|
113
|
+
...result,
|
|
114
|
+
}),
|
|
115
|
+
);
|
|
116
|
+
} else if (PlatformOS=== 'ios') { // rnoh: patch
|
|
117
|
+
return new Promise((resolve, reject) => {
|
|
118
|
+
const tintColor = processColor(options.tintColor);
|
|
119
|
+
|
|
120
|
+
invariant(
|
|
121
|
+
tintColor == null || typeof tintColor === 'number',
|
|
122
|
+
'Unexpected color given for options.tintColor',
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
invariant(
|
|
126
|
+
NativeActionSheetManager,
|
|
127
|
+
'NativeActionSheetManager is not registered on iOS, but it should be.',
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
NativeActionSheetManager.showShareActionSheetWithOptions(
|
|
131
|
+
{
|
|
132
|
+
message:
|
|
133
|
+
typeof content.message === 'string' ? content.message : undefined,
|
|
134
|
+
url: typeof content.url === 'string' ? content.url : undefined,
|
|
135
|
+
subject: options.subject,
|
|
136
|
+
tintColor: typeof tintColor === 'number' ? tintColor : undefined,
|
|
137
|
+
anchor:
|
|
138
|
+
typeof options.anchor === 'number' ? options.anchor : undefined,
|
|
139
|
+
excludedActivityTypes: options.excludedActivityTypes,
|
|
140
|
+
},
|
|
141
|
+
error => reject(error),
|
|
142
|
+
(success, activityType) => {
|
|
143
|
+
if (success) {
|
|
144
|
+
resolve({
|
|
145
|
+
action: 'sharedAction',
|
|
146
|
+
activityType: activityType,
|
|
147
|
+
});
|
|
148
|
+
} else {
|
|
149
|
+
resolve({
|
|
150
|
+
action: 'dismissedAction',
|
|
151
|
+
activityType: null,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
);
|
|
156
|
+
});
|
|
157
|
+
} else {
|
|
158
|
+
return Promise.reject(new Error('Unsupported platform'));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* The content was successfully shared.
|
|
164
|
+
*/
|
|
165
|
+
static sharedAction: 'sharedAction' = 'sharedAction';
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The dialog has been dismissed.
|
|
169
|
+
* @platform ios
|
|
170
|
+
*/
|
|
171
|
+
static dismissedAction: 'dismissedAction' = 'dismissedAction';
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
module.exports = Share;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TurboModule, TurboModuleRegistry } from "react-native";
|
|
2
|
-
|
|
3
|
-
interface Spec extends TurboModule {
|
|
4
|
-
getSystemColor: () => string | null;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const NativePlatformColor =
|
|
8
|
-
TurboModuleRegistry.getEnforcing<Spec>("PlatformColor");
|
|
1
|
+
import { TurboModule, TurboModuleRegistry } from "react-native";
|
|
2
|
+
|
|
3
|
+
interface Spec extends TurboModule {
|
|
4
|
+
getSystemColor: () => string | null;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const NativePlatformColor =
|
|
8
|
+
TurboModuleRegistry.getEnforcing<Spec>("PlatformColor");
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { NativePlatformColor } from "./NativePlatformColor";
|
|
2
|
-
|
|
3
|
-
export const PlatformColor = (...colors: string[]) => {
|
|
4
|
-
const color = NativePlatformColor.getSystemColor(colors);
|
|
5
|
-
return color;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const normalizeColorObject = (color: string) => {
|
|
9
|
-
return color;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const processColorObject = (color: string) => {
|
|
13
|
-
return color;
|
|
14
|
-
};
|
|
1
|
+
import { NativePlatformColor } from "./NativePlatformColor";
|
|
2
|
+
|
|
3
|
+
export const PlatformColor = (...colors: string[]) => {
|
|
4
|
+
const color = NativePlatformColor.getSystemColor(colors);
|
|
5
|
+
return color;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const normalizeColorObject = (color: string) => {
|
|
9
|
+
return color;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const processColorObject = (color: string) => {
|
|
13
|
+
return color;
|
|
14
|
+
};
|