mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Deprecate UIManager.{show,dismiss}PopupMenu
Summary: This API is better implemented as a component: PopupMenuAndroid. Please see the ancestor diff D52712758. Changelog: [Android][Deprecated] Deprecate UIManager.showPopupMenu, and UIManager.dismissPopupMenu Reviewed By: mdvacca Differential Revision: D52887565 fbshipit-source-id: 42da6bdaa707395c5694ec8ae3eb77b64cdefb69
This commit is contained in:
committed by
Facebook GitHub Bot
parent
35308a73a5
commit
8a8f74b7b2
@@ -122,7 +122,7 @@ const UIManagerJSOverridenAPIs = {
|
||||
* In OSS, the New Architecture will just use the Fabric renderer, which uses
|
||||
* different APIs.
|
||||
*/
|
||||
const UIManagerJSUnusedAPIs = {
|
||||
const UIManagerJSUnusedInNewArchAPIs = {
|
||||
createView: (
|
||||
reactTag: ?number,
|
||||
viewName: string,
|
||||
@@ -155,6 +155,34 @@ const UIManagerJSUnusedAPIs = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Leave unimplemented: These APIs are deprecated in UIManager. We will eventually remove
|
||||
* them from React Native.
|
||||
*/
|
||||
const UIManagerJSDeprecatedPlatformAPIs = Platform.select({
|
||||
android: {
|
||||
// TODO(T175424986): Remove UIManager.showPopupMenu() in React Native v0.75.
|
||||
showPopupMenu: (
|
||||
reactTag: ?number,
|
||||
items: Array<string>,
|
||||
error: (error: Object) => void,
|
||||
success: (event: string, selected?: number) => void,
|
||||
): void => {
|
||||
raiseSoftError(
|
||||
'showPopupMenu',
|
||||
'Please use the <PopupMenuAndroid /> component instead.',
|
||||
);
|
||||
},
|
||||
// TODO(T175424986): Remove UIManager.dismissPopupMenu() in React Native v0.75.
|
||||
dismissPopupMenu: (): void => {
|
||||
raiseSoftError(
|
||||
'dismissPopupMenu',
|
||||
'Please use the <PopupMenuAndroid /> component instead.',
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const UIManagerJSPlatformAPIs = Platform.select({
|
||||
android: {
|
||||
getConstantsForViewManager: (viewManagerName: string): ?Object => {
|
||||
@@ -232,17 +260,6 @@ const UIManagerJSPlatformAPIs = Platform.select({
|
||||
|
||||
FabricUIManager.sendAccessibilityEvent(shadowNode, eventName);
|
||||
},
|
||||
showPopupMenu: (
|
||||
reactTag: ?number,
|
||||
items: Array<string>,
|
||||
error: (error: Object) => void,
|
||||
success: (event: string, selected?: number) => void,
|
||||
): void => {
|
||||
raiseSoftError('showPopupMenu');
|
||||
},
|
||||
dismissPopupMenu: (): void => {
|
||||
raiseSoftError('dismissPopupMenu');
|
||||
},
|
||||
},
|
||||
ios: {
|
||||
/**
|
||||
@@ -293,8 +310,9 @@ const UIManagerJSPlatformAPIs = Platform.select({
|
||||
|
||||
const UIManagerJS: UIManagerJSInterface & {[string]: any} = {
|
||||
...UIManagerJSOverridenAPIs,
|
||||
...UIManagerJSDeprecatedPlatformAPIs,
|
||||
...UIManagerJSPlatformAPIs,
|
||||
...UIManagerJSUnusedAPIs,
|
||||
...UIManagerJSUnusedInNewArchAPIs,
|
||||
getViewManagerConfig: (viewManagerName: string): mixed => {
|
||||
if (getUIManagerConstants) {
|
||||
const constants = getUIManagerConstantsCached();
|
||||
|
||||
+13
-1
@@ -866,12 +866,17 @@ public class NativeViewHierarchyManager {
|
||||
/**
|
||||
* Show a {@link PopupMenu}.
|
||||
*
|
||||
* <p>This is deprecated, please use the <PopupMenuAndroid /> component instead.
|
||||
*
|
||||
* <p>TODO(T175424986): Remove UIManager.showPopupMenu() in React Native v0.75.
|
||||
*
|
||||
* @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this
|
||||
* needs to be the tag of a native view (shadow views can not be anchors)
|
||||
* @param items the menu items as an array of strings
|
||||
* @param success will be called with the position of the selected item as the first argument, or
|
||||
* no arguments if the menu is dismissed
|
||||
*/
|
||||
@Deprecated
|
||||
public synchronized void showPopupMenu(
|
||||
int reactTag, ReadableArray items, Callback success, Callback error) {
|
||||
UiThreadUtil.assertOnUiThread();
|
||||
@@ -894,7 +899,14 @@ public class NativeViewHierarchyManager {
|
||||
mPopupMenu.show();
|
||||
}
|
||||
|
||||
/** Dismiss the last opened PopupMenu {@link PopupMenu}. */
|
||||
/**
|
||||
* This is deprecated, please use the <PopupMenuAndroid /> component instead.
|
||||
*
|
||||
* <p>TODO(T175424986): Remove UIManager.dismissPopupMenu() in React Native v0.75.
|
||||
*
|
||||
* <p>Dismiss the last opened PopupMenu {@link PopupMenu}.
|
||||
*/
|
||||
@Deprecated
|
||||
public void dismissPopupMenu() {
|
||||
if (mPopupMenu != null) {
|
||||
mPopupMenu.dismiss();
|
||||
|
||||
+7
@@ -750,6 +750,10 @@ public class UIImplementation {
|
||||
/**
|
||||
* Show a PopupMenu.
|
||||
*
|
||||
* <p>This is deprecated, please use the <PopupMenuAndroid /> component instead.
|
||||
*
|
||||
* <p>TODO(T175424986): Remove UIManager.showPopupMenu() in React Native v0.75.
|
||||
*
|
||||
* @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this
|
||||
* needs to be the tag of a native view (shadow views can not be anchors)
|
||||
* @param items the menu items as an array of strings
|
||||
@@ -757,6 +761,7 @@ public class UIImplementation {
|
||||
* @param success will be called with the position of the selected item as the first argument, or
|
||||
* no arguments if the menu is dismissed
|
||||
*/
|
||||
@Deprecated
|
||||
public void showPopupMenu(int reactTag, ReadableArray items, Callback error, Callback success) {
|
||||
boolean viewExists = checkOrAssertViewExists(reactTag, "showPopupMenu");
|
||||
if (!viewExists) {
|
||||
@@ -766,6 +771,8 @@ public class UIImplementation {
|
||||
mOperationsQueue.enqueueShowPopupMenu(reactTag, items, error, success);
|
||||
}
|
||||
|
||||
/** TODO(T175424986): Remove UIManager.dismissPopupMenu() in React Native v0.75. */
|
||||
@Deprecated
|
||||
public void dismissPopupMenu() {
|
||||
mOperationsQueue.enqueueDismissPopupMenu();
|
||||
}
|
||||
|
||||
+11
@@ -618,6 +618,10 @@ public class UIManagerModule extends ReactContextBaseJavaModule
|
||||
/**
|
||||
* Show a PopupMenu.
|
||||
*
|
||||
* <p>This is deprecated, please use the <PopupMenuAndroid /> component instead.
|
||||
*
|
||||
* <p>TODO(T175424986): Remove UIManager.showPopupMenu() in React Native v0.75.
|
||||
*
|
||||
* @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this
|
||||
* needs to be the tag of a native view (shadow views can not be anchors)
|
||||
* @param items the menu items as an array of strings
|
||||
@@ -626,11 +630,18 @@ public class UIManagerModule extends ReactContextBaseJavaModule
|
||||
* no arguments if the menu is dismissed
|
||||
*/
|
||||
@ReactMethod
|
||||
@Deprecated
|
||||
public void showPopupMenu(int reactTag, ReadableArray items, Callback error, Callback success) {
|
||||
mUIImplementation.showPopupMenu(reactTag, items, error, success);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is deprecated, please use the <PopupMenuAndroid /> component instead.
|
||||
*
|
||||
* <p>TODO(T175424986): Remove UIManager.dismissPopupMenu() in React Native v0.75.
|
||||
*/
|
||||
@ReactMethod
|
||||
@Deprecated
|
||||
public void dismissPopupMenu() {
|
||||
mUIImplementation.dismissPopupMenu();
|
||||
}
|
||||
|
||||
+24
@@ -343,6 +343,12 @@ public class UIViewOperationQueue {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is deprecated, please use the <PopupMenuAndroid /> component instead.
|
||||
*
|
||||
* <p>TODO(T175424986): Remove UIManager.showPopupMenu() in React Native v0.75.
|
||||
*/
|
||||
@Deprecated
|
||||
private final class ShowPopupMenuOperation extends ViewOperation {
|
||||
|
||||
private final ReadableArray mItems;
|
||||
@@ -362,6 +368,12 @@ public class UIViewOperationQueue {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is deprecated, please use the <PopupMenuAndroid /> component instead.
|
||||
*
|
||||
* <p>TODO(T175424986): Remove UIManager.dismissPopupMenu() in React Native v0.75.
|
||||
*/
|
||||
@Deprecated
|
||||
private final class DismissPopupMenuOperation implements UIOperation {
|
||||
@Override
|
||||
public void execute() {
|
||||
@@ -703,11 +715,23 @@ public class UIViewOperationQueue {
|
||||
mOperations.add(new UpdateViewExtraData(reactTag, extraData));
|
||||
}
|
||||
|
||||
/**
|
||||
* This is deprecated, please use the <PopupMenuAndroid /> component instead.
|
||||
*
|
||||
* <p>TODO(T175424986): Remove UIManager.showPopupMenu() in React Native v0.75.
|
||||
*/
|
||||
@Deprecated
|
||||
public void enqueueShowPopupMenu(
|
||||
int reactTag, ReadableArray items, Callback error, Callback success) {
|
||||
mOperations.add(new ShowPopupMenuOperation(reactTag, items, error, success));
|
||||
}
|
||||
|
||||
/**
|
||||
* This is deprecated, please use the <PopupMenuAndroid /> component instead.
|
||||
*
|
||||
* <p>TODO(T175424986): Remove UIManager.dismissPopupMenu() in React Native v0.75.
|
||||
*/
|
||||
@Deprecated
|
||||
public void enqueueDismissPopupMenu() {
|
||||
mOperations.add(new DismissPopupMenuOperation());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user