Skip to content

Commit 48774f6

Browse files
author
Rene Weber
committed
Initial commit
1 parent c4a3158 commit 48774f6

36 files changed

+1688
-20
lines changed

.gitignore

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,6 @@ logs
33
*.log
44
npm-debug.log*
55

6-
# Runtime data
7-
pids
8-
*.pid
9-
*.seed
10-
11-
# Directory for instrumented libs generated by jscoverage/JSCover
12-
lib-cov
13-
14-
# Coverage directory used by tools like istanbul
15-
coverage
16-
17-
# nyc test coverage
18-
.nyc_output
19-
20-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21-
.grunt
22-
23-
# node-waf configuration
24-
.lock-wscript
25-
266
# Compiled binary addons (http://nodejs.org/api/addons.html)
277
build/Release
288

@@ -35,3 +15,54 @@ jspm_packages
3515

3616
# Optional REPL history
3717
.node_repl_history
18+
19+
yarn.lock
20+
21+
.DS_Store
22+
23+
# Built application files
24+
*.apk
25+
*.ap_
26+
27+
# Files for the ART/Dalvik VM
28+
*.dex
29+
30+
# Java class files
31+
*.class
32+
33+
# Generated files
34+
bin/
35+
gen/
36+
out/
37+
38+
# Gradle files
39+
.gradle/
40+
build/
41+
42+
# Local configuration file (sdk path, etc)
43+
local.properties
44+
45+
# Proguard folder generated by Eclipse
46+
proguard/
47+
48+
# Log Files
49+
*.log
50+
51+
# Android Studio Navigation editor temp files
52+
.navigation/
53+
54+
# Android Studio captures folder
55+
captures/
56+
57+
# Intellij
58+
*.iml
59+
.idea
60+
61+
# Keystore files
62+
*.jks
63+
64+
# External native build folder generated in Android Studio 2.2 and later
65+
.externalNativeBuild
66+
67+
68+
xcuserdata/

MyText-1/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
# react-native-my-text
3+
4+
## Getting started
5+
6+
`$ npm install react-native-my-text --save`
7+
8+
### Mostly automatic installation
9+
10+
`$ react-native link react-native-my-text`
11+
12+
### Manual installation
13+
14+
15+
#### iOS
16+
17+
1. In XCode, in the project navigator, right click `Libraries``Add Files to [your project's name]`
18+
2. Go to `node_modules``react-native-my-text` and add `RNMyText.xcodeproj`
19+
3. In XCode, in the project navigator, select your project. Add `libRNMyText.a` to your project's `Build Phases``Link Binary With Libraries`
20+
4. Run your project (`Cmd+R`)<
21+
22+
#### Android
23+
24+
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
25+
- Add `import com.reactlibrary.RNMyTextPackage;` to the imports at the top of the file
26+
- Add `new RNMyTextPackage()` to the list returned by the `getPackages()` method
27+
2. Append the following lines to `android/settings.gradle`:
28+
```
29+
include ':react-native-my-text'
30+
project(':react-native-my-text').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-my-text/android')
31+
```
32+
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
33+
```
34+
compile project(':react-native-my-text')
35+
```
36+
37+
#### Windows
38+
[Read it! :D](https://github.com/ReactWindows/react-native)
39+
40+
1. In Visual Studio add the `RNMyText.sln` in `node_modules/react-native-my-text/windows/RNMyText.sln` folder to their solution, reference from their app.
41+
2. Open up your `MainPage.cs` app
42+
- Add `using Cl.Json.RNMyText;` to the usings at the top of the file
43+
- Add `new RNMyTextPackage()` to the `List<IReactPackage>` returned by the `Packages` method
44+
45+
46+
## Usage
47+
```javascript
48+
import RNMyText from 'react-native-my-text';
49+
50+
// TODO: What do with the module?
51+
RNMyText;
52+
```
53+

MyText-1/android/build.gradle

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
buildscript {
2+
repositories {
3+
jcenter()
4+
}
5+
6+
dependencies {
7+
classpath 'com.android.tools.build:gradle:2.0.0'
8+
}
9+
}
10+
11+
apply plugin: 'com.android.library'
12+
13+
android {
14+
compileSdkVersion 23
15+
buildToolsVersion "23.0.1"
16+
17+
defaultConfig {
18+
minSdkVersion 16
19+
targetSdkVersion 22
20+
versionCode 1
21+
versionName "1.0"
22+
}
23+
lintOptions {
24+
warning 'InvalidPackage'
25+
}
26+
}
27+
28+
repositories {
29+
maven {
30+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
31+
url "$rootDir/../node_modules/react-native/android"
32+
mavenCentral()
33+
}
34+
}
35+
36+
37+
dependencies {
38+
compile 'com.facebook.react:react-native:+'
39+
}
40+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.reactlibrary">
4+
5+
</manifest>
6+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
package com.reactlibrary;
3+
4+
import java.util.Arrays;
5+
import java.util.Collections;
6+
import java.util.List;
7+
8+
import com.facebook.react.ReactPackage;
9+
import com.facebook.react.bridge.NativeModule;
10+
import com.facebook.react.bridge.ReactApplicationContext;
11+
import com.facebook.react.uimanager.ViewManager;
12+
import com.facebook.react.bridge.JavaScriptModule;
13+
public class RNMyTextPackage implements ReactPackage {
14+
@Override
15+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
16+
return Arrays.<NativeModule>asList();
17+
}
18+
19+
@Override
20+
public List<Class<? extends JavaScriptModule>> createJSModules() {
21+
return Collections.emptyList();
22+
}
23+
24+
@Override
25+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
26+
return Collections.<ViewManager>singletonList(new RNMyTextViewManager());
27+
}
28+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.reactlibrary;
2+
3+
import android.widget.TextView;
4+
import com.facebook.react.uimanager.SimpleViewManager;
5+
import com.facebook.react.uimanager.ThemedReactContext;
6+
import com.facebook.react.uimanager.annotations.ReactProp;
7+
8+
import javax.annotation.Nullable;
9+
10+
public class RNMyTextViewManager extends SimpleViewManager<TextView> {
11+
@Override
12+
public String getName() {
13+
return "RNMyText";
14+
}
15+
16+
@Override
17+
protected TextView createViewInstance(ThemedReactContext reactContext) {
18+
return new TextView(reactContext);
19+
}
20+
21+
@ReactProp(name = "text")
22+
public void setText(TextView view, @Nullable String text) {
23+
view.setText(text);
24+
}
25+
}

MyText-1/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { requireNativeComponent, View } from 'react-native';
2+
import { PropTypes } from 'react';
3+
4+
const myText = {
5+
name: 'MyText',
6+
propTypes: {
7+
...View.propTypes,
8+
text: PropTypes.string
9+
}
10+
}
11+
12+
const MyText = requireNativeComponent('RNMyText', myText);
13+
export default MyText

MyText-1/ios/RNMyText.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#import "RCTViewManager.h"
2+
3+
@interface RNMyText : RCTViewManager
4+
5+
@end
6+

MyText-1/ios/RNMyText.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
#import "RNMyText.h"
3+
#import "UIView+React.h"
4+
5+
@implementation RNMyText
6+
7+
RCT_EXPORT_MODULE();
8+
9+
- (UIView *)view
10+
{
11+
return [UILabel new];
12+
}
13+
14+
RCT_EXPORT_VIEW_PROPERTY(text, NSString *);
15+
16+
@end
17+

0 commit comments

Comments
 (0)