Skip to content

Commit 8bced4b

Browse files
RSNarafacebook-github-bot
authored andcommitted
Pull PopupMenuAndroid out of React Native core
Summary: **History:** This component was originally introduced into React Native core in D52712758, to replace UIManagerModule.showPopupMenu(). **Problem:** But, React Native core should be lean. Adding this component to React Native bloats the core. **Changes:** So, this diff pulls PopupMenuAndroid out into its own package in the react-native GitHub repository. In the future, this will be migrated to a community package! Changelog: [Android][Removed] Move PopupMenu out of React Native core Reviewed By: NickGerleman Differential Revision: D53328110 fbshipit-source-id: 469d8dc3e756c06040c72e08fa004aafa1bd6e18
1 parent e6e5822 commit 8bced4b

File tree

37 files changed

+482
-129
lines changed

37 files changed

+482
-129
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ project.xcworkspace
4242
/packages/react-native/ReactAndroid/hermes-engine/.cxx/
4343
/packages/react-native/template/android/app/build/
4444
/packages/react-native/template/android/build/
45+
/packages/react-native-popup-menu-android/android/build/
4546

4647
# Buck
4748
.buckd
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
8+
plugins {
9+
id("com.facebook.react")
10+
alias(libs.plugins.android.library)
11+
alias(libs.plugins.kotlin.android)
12+
}
13+
14+
android {
15+
compileSdk = libs.versions.compileSdk.get().toInt()
16+
buildToolsVersion = libs.versions.buildTools.get()
17+
namespace = "com.facebook.react.popupmenu"
18+
19+
defaultConfig {
20+
minSdk = libs.versions.minSdk.get().toInt()
21+
targetSdk = libs.versions.targetSdk.get().toInt()
22+
}
23+
24+
compileOptions {
25+
sourceCompatibility = JavaVersion.VERSION_17
26+
targetCompatibility = JavaVersion.VERSION_17
27+
}
28+
29+
kotlinOptions { jvmTarget = "17" }
30+
}
31+
32+
dependencies {
33+
// Build React Native from source
34+
implementation(project(":packages:react-native:ReactAndroid"))
35+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# We want to have more fine grained control on the Java version for
2+
# ReactAndroid, therefore we disable RGNP Java version alignment mechanism
3+
react.internal.disableJavaVersionAlignment=true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
/**
3+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4+
*
5+
* Do not edit this file as changes may cause incorrect behavior and will be lost
6+
* once the code is regenerated.
7+
*
8+
* @generated by codegen project: GenerateComponentDescriptorH.js
9+
*/
10+
11+
#pragma once
12+
13+
#include "ShadowNodes.h"
14+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
15+
16+
namespace facebook::react {
17+
18+
using AndroidPopupMenuComponentDescriptor = ConcreteComponentDescriptor<AndroidPopupMenuShadowNode>;
19+
20+
} // namespace facebook::react
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
/**
3+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4+
*
5+
* Do not edit this file as changes may cause incorrect behavior and will be lost
6+
* once the code is regenerated.
7+
*
8+
* @generated by codegen project: GenerateEventEmitterCpp.js
9+
*/
10+
11+
#include "EventEmitters.h"
12+
13+
14+
namespace facebook::react {
15+
16+
void AndroidPopupMenuEventEmitter::onSelectionChange(OnSelectionChange $event) const {
17+
dispatchEvent("selectionChange", [$event=std::move($event)](jsi::Runtime &runtime) {
18+
auto $payload = jsi::Object(runtime);
19+
$payload.setProperty(runtime, "item", $event.item);
20+
return $payload;
21+
});
22+
}
23+
24+
} // namespace facebook::react
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
/**
3+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4+
*
5+
* Do not edit this file as changes may cause incorrect behavior and will be lost
6+
* once the code is regenerated.
7+
*
8+
* @generated by codegen project: GenerateEventEmitterH.js
9+
*/
10+
#pragma once
11+
12+
#include <react/renderer/components/view/ViewEventEmitter.h>
13+
14+
15+
namespace facebook::react {
16+
class AndroidPopupMenuEventEmitter : public ViewEventEmitter {
17+
public:
18+
using ViewEventEmitter::ViewEventEmitter;
19+
20+
struct OnSelectionChange {
21+
int item;
22+
};
23+
void onSelectionChange(OnSelectionChange value) const;
24+
};
25+
} // namespace facebook::react
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
/**
3+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4+
*
5+
* Do not edit this file as changes may cause incorrect behavior and will be lost
6+
* once the code is regenerated.
7+
*
8+
* @generated by codegen project: GeneratePropsCpp.js
9+
*/
10+
11+
#include "Props.h"
12+
#include <react/renderer/core/PropsParserContext.h>
13+
#include <react/renderer/core/propsConversions.h>
14+
15+
namespace facebook::react {
16+
17+
AndroidPopupMenuProps::AndroidPopupMenuProps(
18+
const PropsParserContext &context,
19+
const AndroidPopupMenuProps &sourceProps,
20+
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
21+
22+
menuItems(convertRawProp(context, rawProps, "menuItems", sourceProps.menuItems, {}))
23+
{}
24+
25+
} // namespace facebook::react
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
/**
3+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4+
*
5+
* Do not edit this file as changes may cause incorrect behavior and will be lost
6+
* once the code is regenerated.
7+
*
8+
* @generated by codegen project: GeneratePropsH.js
9+
*/
10+
#pragma once
11+
12+
#include <react/renderer/components/view/ViewProps.h>
13+
#include <react/renderer/core/PropsParserContext.h>
14+
#include <vector>
15+
16+
namespace facebook::react {
17+
18+
class AndroidPopupMenuProps final : public ViewProps {
19+
public:
20+
AndroidPopupMenuProps() = default;
21+
AndroidPopupMenuProps(const PropsParserContext& context, const AndroidPopupMenuProps &sourceProps, const RawProps &rawProps);
22+
23+
#pragma mark - Props
24+
25+
std::vector<std::string> menuItems{};
26+
};
27+
28+
} // namespace facebook::react
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
/**
3+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4+
*
5+
* Do not edit this file as changes may cause incorrect behavior and will be lost
6+
* once the code is regenerated.
7+
*
8+
* @generated by codegen project: GenerateShadowNodeCpp.js
9+
*/
10+
11+
#include "ShadowNodes.h"
12+
13+
namespace facebook::react {
14+
15+
extern const char AndroidPopupMenuComponentName[] = "AndroidPopupMenu";
16+
17+
} // namespace facebook::react
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
/**
3+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4+
*
5+
* Do not edit this file as changes may cause incorrect behavior and will be lost
6+
* once the code is regenerated.
7+
*
8+
* @generated by codegen project: GenerateShadowNodeH.js
9+
*/
10+
11+
#pragma once
12+
13+
#include "EventEmitters.h"
14+
#include "Props.h"
15+
#include "States.h"
16+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
17+
#include <jsi/jsi.h>
18+
19+
namespace facebook::react {
20+
21+
JSI_EXPORT extern const char AndroidPopupMenuComponentName[];
22+
23+
/*
24+
* `ShadowNode` for <AndroidPopupMenu> component.
25+
*/
26+
using AndroidPopupMenuShadowNode = ConcreteViewShadowNode<
27+
AndroidPopupMenuComponentName,
28+
AndroidPopupMenuProps,
29+
AndroidPopupMenuEventEmitter,
30+
AndroidPopupMenuState>;
31+
32+
} // namespace facebook::react

0 commit comments

Comments
 (0)