Skip to content

Commit adecee3

Browse files
Matthew IannucciMatthew Iannucci
authored andcommitted
Initial commit of new module
0 parents  commit adecee3

File tree

75 files changed

+10281
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+10281
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# node.js
6+
#
7+
node_modules/
8+
npm-debug.log
9+
yarn-error.log
10+
11+
# Xcode
12+
#
13+
build/
14+
*.pbxuser
15+
!default.pbxuser
16+
*.mode1v3
17+
!default.mode1v3
18+
*.mode2v3
19+
!default.mode2v3
20+
*.perspectivev3
21+
!default.perspectivev3
22+
xcuserdata
23+
*.xccheckout
24+
*.moved-aside
25+
DerivedData
26+
*.hmap
27+
*.ipa
28+
*.xcuserstate
29+
project.xcworkspace
30+
31+
# Android/IntelliJ
32+
#
33+
build/
34+
.idea
35+
.gradle
36+
local.properties
37+
*.iml
38+
39+
# BUCK
40+
buck-out/
41+
\.buckd/
42+
*.keystore

.npmignore

Whitespace-only changes.

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# react-native-context-menu
2+
3+
## Getting started
4+
5+
`$ npm install react-native-context-menu --save`
6+
7+
### Mostly automatic installation
8+
9+
`$ react-native link react-native-context-menu`
10+
11+
## Usage
12+
```javascript
13+
import ReactNativeContextMenu from 'react-native-context-menu';
14+
15+
// TODO: What to do with the module?
16+
ReactNativeContextMenu;
17+
```

android/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
README
2+
======
3+
4+
If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm:
5+
6+
1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed
7+
2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK
8+
```
9+
ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle
10+
sdk.dir=/Users/{username}/Library/Android/sdk
11+
```
12+
3. Delete the `maven` folder
13+
4. Run `./gradlew installArchives`
14+
5. Verify that latest set of generated files is in the maven folder with the correct version number

android/build.gradle

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
// android/build.gradle
2+
3+
// based on:
4+
//
5+
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
6+
// original location:
7+
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
8+
//
9+
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
10+
// original location:
11+
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
12+
13+
def DEFAULT_COMPILE_SDK_VERSION = 28
14+
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
15+
def DEFAULT_MIN_SDK_VERSION = 16
16+
def DEFAULT_TARGET_SDK_VERSION = 28
17+
18+
def safeExtGet(prop, fallback) {
19+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
20+
}
21+
22+
apply plugin: 'com.android.library'
23+
apply plugin: 'maven'
24+
25+
buildscript {
26+
// The Android Gradle plugin is only required when opening the android folder stand-alone.
27+
// This avoids unnecessary downloads and potential conflicts when the library is included as a
28+
// module dependency in an application project.
29+
// ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
30+
if (project == rootProject) {
31+
repositories {
32+
google()
33+
jcenter()
34+
}
35+
dependencies {
36+
classpath 'com.android.tools.build:gradle:3.4.1'
37+
}
38+
}
39+
}
40+
41+
apply plugin: 'com.android.library'
42+
apply plugin: 'maven'
43+
44+
android {
45+
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
46+
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
47+
defaultConfig {
48+
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
49+
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
50+
versionCode 1
51+
versionName "1.0"
52+
}
53+
lintOptions {
54+
abortOnError false
55+
}
56+
}
57+
58+
repositories {
59+
// ref: https://www.baeldung.com/maven-local-repository
60+
mavenLocal()
61+
maven {
62+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
63+
url "$rootDir/../node_modules/react-native/android"
64+
}
65+
maven {
66+
// Android JSC is installed from npm
67+
url "$rootDir/../node_modules/jsc-android/dist"
68+
}
69+
google()
70+
jcenter()
71+
}
72+
73+
dependencies {
74+
//noinspection GradleDynamicVersion
75+
implementation 'com.facebook.react:react-native:+' // From node_modules
76+
}
77+
78+
def configureReactNativePom(def pom) {
79+
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
80+
81+
pom.project {
82+
name packageJson.title
83+
artifactId packageJson.name
84+
version = packageJson.version
85+
group = "com.mpiannucci"
86+
description packageJson.description
87+
url packageJson.repository.baseUrl
88+
89+
licenses {
90+
license {
91+
name packageJson.license
92+
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
93+
distribution 'repo'
94+
}
95+
}
96+
97+
developers {
98+
developer {
99+
id packageJson.author.username
100+
name packageJson.author.name
101+
}
102+
}
103+
}
104+
}
105+
106+
afterEvaluate { project ->
107+
// some Gradle build hooks ref:
108+
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
109+
task androidJavadoc(type: Javadoc) {
110+
source = android.sourceSets.main.java.srcDirs
111+
classpath += files(android.bootClasspath)
112+
classpath += files(project.getConfigurations().getByName('compile').asList())
113+
include '**/*.java'
114+
}
115+
116+
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
117+
classifier = 'javadoc'
118+
from androidJavadoc.destinationDir
119+
}
120+
121+
task androidSourcesJar(type: Jar) {
122+
classifier = 'sources'
123+
from android.sourceSets.main.java.srcDirs
124+
include '**/*.java'
125+
}
126+
127+
android.libraryVariants.all { variant ->
128+
def name = variant.name.capitalize()
129+
def javaCompileTask = variant.javaCompileProvider.get()
130+
131+
task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
132+
from javaCompileTask.destinationDir
133+
}
134+
}
135+
136+
artifacts {
137+
archives androidSourcesJar
138+
archives androidJavadocJar
139+
}
140+
141+
task installArchives(type: Upload) {
142+
configuration = configurations.archives
143+
repositories.mavenDeployer {
144+
// Deploy to react-native-event-bridge/maven, ready to publish to npm
145+
repository url: "file://${projectDir}/../android/maven"
146+
configureReactNativePom pom
147+
}
148+
}
149+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.mpiannucci">
3+
4+
</manifest>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.mpiannucci;
2+
3+
import android.view.View;
4+
5+
import androidx.appcompat.widget.AppCompatCheckBox;
6+
7+
import com.facebook.react.uimanager.SimpleViewManager;
8+
import com.facebook.react.uimanager.ThemedReactContext;
9+
10+
public class ReactNativeContextMenuManager extends SimpleViewManager<View> {
11+
12+
public static final String REACT_CLASS = "ReactNativeContextMenu";
13+
14+
@Override
15+
public String getName() {
16+
return REACT_CLASS;
17+
}
18+
19+
@Override
20+
public View createViewInstance(ThemedReactContext c) {
21+
// TODO: Implement some actually useful functionality
22+
AppCompatCheckBox cb = new AppCompatCheckBox(c);
23+
cb.setChecked(true);
24+
return cb;
25+
}
26+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.mpiannucci;
2+
3+
import java.util.Arrays;
4+
import java.util.Collections;
5+
import java.util.List;
6+
7+
import com.facebook.react.ReactPackage;
8+
import com.facebook.react.bridge.NativeModule;
9+
import com.facebook.react.bridge.ReactApplicationContext;
10+
import com.facebook.react.uimanager.ViewManager;
11+
import com.facebook.react.bridge.JavaScriptModule;
12+
13+
public class ReactNativeContextMenuPackage implements ReactPackage {
14+
@Override
15+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
16+
return Collections.emptyList();
17+
}
18+
19+
@Override
20+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
21+
return Arrays.<ViewManager>asList(new ReactNativeContextMenuManager());
22+
}
23+
}

example/.buckconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

0 commit comments

Comments
 (0)