Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit 3e353e2

Browse files
committed
update examples
1 parent d5616b3 commit 3e353e2

File tree

29 files changed

+11813
-3141
lines changed

29 files changed

+11813
-3141
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
};

examples/ReactNativeTagsDemo/.flowconfig

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@
55
; Ignore "BUCK" generated dirs
66
<PROJECT_ROOT>/\.buckd/
77

8-
; Ignore unexpected extra "@providesModule"
9-
.*/node_modules/.*/node_modules/fbjs/.*
8+
; Ignore polyfills
9+
node_modules/react-native/Libraries/polyfills/.*
1010

11-
; Ignore duplicate module providers
12-
; For RN Apps installed via npm, "Libraries" folder is inside
13-
; "node_modules/react-native" but in the source repo it is in the root
14-
.*/Libraries/react-native/React.js
11+
; These should not be required directly
12+
; require from fbjs/lib instead: require('fbjs/lib/warning')
13+
node_modules/warning/.*
1514

16-
; Ignore polyfills
17-
.*/Libraries/polyfills/.*
15+
; Flow doesn't support platforms
16+
.*/Libraries/Utilities/LoadingView.js
1817

19-
; Ignore metro
20-
.*/node_modules/metro/.*
18+
[untyped]
19+
.*/node_modules/@react-native-community/cli/.*/.*
2120

2221
[include]
2322

@@ -31,39 +30,46 @@ emoji=true
3130
esproposal.optional_chaining=enable
3231
esproposal.nullish_coalescing=enable
3332

34-
module.system=haste
35-
module.system.haste.use_name_reducers=true
36-
# get basename
37-
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
38-
# strip .js or .js.flow suffix
39-
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
40-
# strip .ios suffix
41-
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
42-
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
43-
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
44-
module.system.haste.paths.blacklist=.*/__tests__/.*
45-
module.system.haste.paths.blacklist=.*/__mocks__/.*
46-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
47-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
33+
module.file_ext=.js
34+
module.file_ext=.json
35+
module.file_ext=.ios.js
4836

4937
munge_underscores=true
5038

51-
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
52-
53-
module.file_ext=.js
54-
module.file_ext=.jsx
55-
module.file_ext=.json
56-
module.file_ext=.native.js
39+
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
40+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
41+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
5742

5843
suppress_type=$FlowIssue
5944
suppress_type=$FlowFixMe
6045
suppress_type=$FlowFixMeProps
6146
suppress_type=$FlowFixMeState
6247

63-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
64-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
65-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
48+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
49+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
6650
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
6751

52+
[lints]
53+
sketchy-null-number=warn
54+
sketchy-null-mixed=warn
55+
sketchy-number=warn
56+
untyped-type-import=warn
57+
nonstrict-import=warn
58+
deprecated-type=warn
59+
unsafe-getters-setters=warn
60+
inexact-spread=warn
61+
unnecessary-invariant=warn
62+
signature-verification-failure=warn
63+
deprecated-utility=error
64+
65+
[strict]
66+
deprecated-type
67+
nonstrict-import
68+
sketchy-null
69+
unclear-type
70+
unsafe-getters-setters
71+
untyped-import
72+
untyped-type-import
73+
6874
[version]
69-
^0.92.0
75+
^0.105.0

examples/ReactNativeTagsDemo/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23-
project.xcworkspace
2423

2524
# Android/IntelliJ
2625
#
@@ -40,6 +39,7 @@ yarn-error.log
4039
buck-out/
4140
\.buckd/
4241
*.keystore
42+
!debug.keystore
4343

4444
# fastlane
4545
#
@@ -54,3 +54,6 @@ buck-out/
5454

5555
# Bundle artifact
5656
*.jsbundle
57+
58+
# CocoaPods
59+
/ios/Pods/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
bracketSpacing: false,
3+
jsxBracketSameLine: true,
4+
singleQuote: true,
5+
trailingComma: 'all',
6+
};
Lines changed: 91 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,91 @@
1-
import React from "react";
2-
import { TouchableOpacity, Text, View } from "react-native";
3-
import Tags from "react-native-tags";
4-
5-
const MyTagInput = () => (
6-
<View style={{ margin: 88 }}>
7-
<Tags
8-
initialText="monkey"
9-
textInputProps={{
10-
placeholder: "Any type of animal"
11-
}}
12-
initialTags={["dog", "cat", "chicken"]}
13-
onChangeTags={tags => console.log(tags)}
14-
onTagPress={(index, tagLabel, event, deleted) =>
15-
console.log(index, tagLabel, event, deleted ? "deleted" : "not deleted")
16-
}
17-
containerStyle={{ justifyContent: "center" }}
18-
inputStyle={{ backgroundColor: "white" }}
19-
renderTag={({ tag, index, onPress, deleteTagOnPress, readonly }) => (
20-
<TouchableOpacity key={`${tag}-${index}`} onPress={onPress}>
21-
<Text>{tag}</Text>
22-
</TouchableOpacity>
23-
)}
24-
/>
25-
</View>
26-
);
27-
28-
export default MyTagInput;
1+
/**
2+
* Sample React Native App
3+
* https://github.com/facebook/react-native
4+
*
5+
* @format
6+
* @flow
7+
*/
8+
9+
import React, {Component} from 'react';
10+
11+
import {StyleSheet, TouchableOpacity, Text, View} from 'react-native';
12+
import Tags from 'react-native-tags';
13+
14+
class App extends Component {
15+
constructor(props) {
16+
super(props);
17+
this.state = {
18+
initialTags: ['dog', 'cat', 'chicken'],
19+
initialText: '',
20+
};
21+
}
22+
23+
_renderTag = ({tag, index, onPress, deleteTagOnPress, readonly}) => {
24+
return (
25+
<TouchableOpacity
26+
key={`${tag}-${index}`}
27+
onPress={onPress}
28+
style={styles.tag}>
29+
<Text style={styles.textTag}>{tag}</Text>
30+
</TouchableOpacity>
31+
);
32+
};
33+
34+
render() {
35+
return (
36+
<View style={styles.screen}>
37+
<Tags
38+
containerStyle={styles.container}
39+
initialText={this.state.initialText}
40+
textInputProps={{
41+
placeholderTextColor: '#D6D6D6',
42+
placeholder: 'Any type of animal',
43+
}}
44+
inputStyle={styles.input}
45+
initialTags={this.state.initialTags}
46+
onChangeTags={this._onChangeTags}
47+
onTagPress={this._onTagPress}
48+
renderTag={this._renderTag}
49+
/>
50+
</View>
51+
);
52+
}
53+
54+
_onTagPress = (index, tagLabel, event, deleted) => {
55+
console.log(index, tagLabel, event, deleted ? 'deleted' : 'not deleted');
56+
};
57+
58+
_onChangeTags = tags => {
59+
this.setState({initialTags: tags});
60+
};
61+
}
62+
63+
const styles = StyleSheet.create({
64+
screen: {
65+
flex: 1,
66+
backgroundColor: '#D6D6D6',
67+
},
68+
container: {
69+
margin: 10,
70+
borderRadius: 10,
71+
backgroundColor: '#FFFFFF',
72+
justifyContent: 'flex-start',
73+
},
74+
tag: {
75+
backgroundColor: '#2A5353',
76+
borderRadius: 10,
77+
padding: 10,
78+
margin: 10,
79+
},
80+
textTag: {
81+
color: '#EBEBEB',
82+
fontWeight: 'bold',
83+
},
84+
input: {
85+
backgroundColor: '#FFFFFF',
86+
color: '#606060',
87+
fontWeight: 'bold',
88+
},
89+
});
90+
91+
export default App;

examples/ReactNativeTagsDemo/android/app/build.gradle

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import com.android.build.OutputFile
1818
* // the entry file for bundle generation
1919
* entryFile: "index.android.js",
2020
*
21+
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
22+
* bundleCommand: "ram-bundle",
23+
*
2124
* // whether to bundle JS and assets in debug mode
2225
* bundleInDebug: false,
2326
*
@@ -73,7 +76,8 @@ import com.android.build.OutputFile
7376
*/
7477

7578
project.ext.react = [
76-
entryFile: "index.js"
79+
entryFile: "index.js",
80+
enableHermes: false, // clean and rebuild if changing
7781
]
7882

7983
apply from: "../../node_modules/react-native/react.gradle"
@@ -93,6 +97,28 @@ def enableSeparateBuildPerCPUArchitecture = false
9397
*/
9498
def enableProguardInReleaseBuilds = false
9599

100+
/**
101+
* The preferred build flavor of JavaScriptCore.
102+
*
103+
* For example, to use the international variant, you can use:
104+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
105+
*
106+
* The international variant includes ICU i18n library and necessary data
107+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
108+
* give correct results when using with locales other than en-US. Note that
109+
* this variant is about 6MiB larger per architecture than default.
110+
*/
111+
def jscFlavor = 'org.webkit:android-jsc:+'
112+
113+
/**
114+
* Whether to enable the Hermes VM.
115+
*
116+
* This should be set on project.ext.react and mirrored here. If it is not set
117+
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
118+
* and the benefits of using Hermes will therefore be sharply reduced.
119+
*/
120+
def enableHermes = project.ext.react.get("enableHermes", false);
121+
96122
android {
97123
compileSdkVersion rootProject.ext.compileSdkVersion
98124

@@ -116,8 +142,22 @@ android {
116142
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
117143
}
118144
}
145+
signingConfigs {
146+
debug {
147+
storeFile file('debug.keystore')
148+
storePassword 'android'
149+
keyAlias 'androiddebugkey'
150+
keyPassword 'android'
151+
}
152+
}
119153
buildTypes {
154+
debug {
155+
signingConfig signingConfigs.debug
156+
}
120157
release {
158+
// Caution! In production, you need to generate your own keystore file.
159+
// see https://facebook.github.io/react-native/docs/signed-apk-android.
160+
signingConfig signingConfigs.debug
121161
minifyEnabled enableProguardInReleaseBuilds
122162
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
123163
}
@@ -126,21 +166,29 @@ android {
126166
applicationVariants.all { variant ->
127167
variant.outputs.each { output ->
128168
// For each separate APK per architecture, set a unique version code as described here:
129-
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
130-
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
169+
// https://developer.android.com/studio/build/configure-apk-splits.html
170+
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
131171
def abi = output.getFilter(OutputFile.ABI)
132172
if (abi != null) { // null for the universal-debug, universal-release variants
133173
output.versionCodeOverride =
134174
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
135175
}
176+
136177
}
137178
}
138179
}
139180

140181
dependencies {
141182
implementation fileTree(dir: "libs", include: ["*.jar"])
142-
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
143183
implementation "com.facebook.react:react-native:+" // From node_modules
184+
185+
if (enableHermes) {
186+
def hermesPath = "../../node_modules/hermes-engine/android/";
187+
debugImplementation files(hermesPath + "hermes-debug.aar")
188+
releaseImplementation files(hermesPath + "hermes-release.aar")
189+
} else {
190+
implementation jscFlavor
191+
}
144192
}
145193

146194
// Run this once to be able to run the application with BUCK
@@ -149,3 +197,5 @@ task copyDownloadableDepsToLibs(type: Copy) {
149197
from configurations.compile
150198
into 'libs'
151199
}
200+
201+
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
2.2 KB
Binary file not shown.

examples/ReactNativeTagsDemo/android/app/proguard-rules.pro

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,3 @@
88
# http://developer.android.com/guide/developing/tools/proguard.html
99

1010
# Add any project specific keep options here:
11-
12-
# If your project uses WebView with JS, uncomment the following
13-
# and specify the fully qualified class name to the JavaScript interface
14-
# class:
15-
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16-
# public *;
17-
#}

examples/ReactNativeTagsDemo/android/app/src/main/java/com/reactnativetagsdemo/MainActivity.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
public class MainActivity extends ReactActivity {
66

7-
/**
8-
* Returns the name of the main component registered from JavaScript.
9-
* This is used to schedule rendering of the component.
10-
*/
11-
@Override
12-
protected String getMainComponentName() {
13-
return "ReactNativeTagsDemo";
14-
}
7+
/**
8+
* Returns the name of the main component registered from JavaScript. This is used to schedule
9+
* rendering of the component.
10+
*/
11+
@Override
12+
protected String getMainComponentName() {
13+
return "ReactNativeTagsDemo";
14+
}
1515
}

0 commit comments

Comments
 (0)