Skip to content

Commit 80567cb

Browse files
committed
Added DrawerExample
1 parent 07655e8 commit 80567cb

Some content is hidden

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

47 files changed

+2559
-0
lines changed

DrawerExample/.flowconfig

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
[ignore]
2+
3+
# We fork some components by platform.
4+
.*/*.web.js
5+
.*/*.android.js
6+
7+
# Some modules have their own node_modules with overlap
8+
.*/node_modules/node-haste/.*
9+
10+
# Ugh
11+
.*/node_modules/babel.*
12+
.*/node_modules/babylon.*
13+
.*/node_modules/invariant.*
14+
15+
# Ignore react and fbjs where there are overlaps, but don't ignore
16+
# anything that react-native relies on
17+
.*/node_modules/fbjs/lib/Map.js
18+
.*/node_modules/fbjs/lib/fetch.js
19+
.*/node_modules/fbjs/lib/ExecutionEnvironment.js
20+
.*/node_modules/fbjs/lib/ErrorUtils.js
21+
22+
# Flow has a built-in definition for the 'react' module which we prefer to use
23+
# over the currently-untyped source
24+
.*/node_modules/react/react.js
25+
.*/node_modules/react/lib/React.js
26+
.*/node_modules/react/lib/ReactDOM.js
27+
28+
.*/__mocks__/.*
29+
.*/__tests__/.*
30+
31+
.*/commoner/test/source/widget/share.js
32+
33+
# Ignore commoner tests
34+
.*/node_modules/commoner/test/.*
35+
36+
# See https://github.com/facebook/flow/issues/442
37+
.*/react-tools/node_modules/commoner/lib/reader.js
38+
39+
# Ignore jest
40+
.*/node_modules/jest-cli/.*
41+
42+
# Ignore Website
43+
.*/website/.*
44+
45+
[include]
46+
47+
[libs]
48+
node_modules/react-native/Libraries/react-native/react-native-interface.js
49+
50+
[options]
51+
module.system=haste
52+
53+
esproposal.class_static_fields=enable
54+
esproposal.class_instance_fields=enable
55+
56+
munge_underscores=true
57+
58+
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
59+
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\)$' -> 'RelativeImageStub'
60+
61+
suppress_type=$FlowIssue
62+
suppress_type=$FlowFixMe
63+
suppress_type=$FixMe
64+
65+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-1]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
66+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-1]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
67+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
68+
69+
[version]
70+
0.21.0

DrawerExample/.gitignore

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

DrawerExample/.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

DrawerExample/Example.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import React, {AppRegistry, Navigator, StyleSheet, Text, View} from 'react-native'
2+
import Launch from './components/Launch'
3+
import Register from './components/Register'
4+
import Login from './components/Login'
5+
import Login2 from './components/Login2'
6+
import {Scene, Reducer, Router, Switch, TabBar, Modal, Schema, Actions} from 'react-native-router-flux'
7+
import Error from './components/Error'
8+
import Home from './components/Home'
9+
import TabView from './components/TabView'
10+
import EchoView from './components/EchoView'
11+
import NavigationDrawer from './components/NavigationDrawer'
12+
13+
class TabIcon extends React.Component {
14+
render(){
15+
return (
16+
<Text style={{color: this.props.selected ? 'red' :'black'}}>{this.props.title}</Text>
17+
);
18+
}
19+
}
20+
21+
class Right extends React.Component {
22+
render(){
23+
return <Text style={{
24+
width: 80,
25+
height: 37,
26+
position: 'absolute',
27+
bottom: 4,
28+
right: 2,
29+
padding: 8,
30+
}}>Right</Text>
31+
}
32+
}
33+
const styles = StyleSheet.create({
34+
container: {flex:1, backgroundColor:'transparent',justifyContent: 'center',
35+
alignItems: 'center',}
36+
37+
});
38+
39+
const reducerCreate = params=>{
40+
const defaultReducer = Reducer(params);
41+
return (state, action)=>{
42+
console.log("ACTION:", action);
43+
return defaultReducer(state, action);
44+
}
45+
};
46+
47+
export default class Example extends React.Component {
48+
render() {
49+
return <Router createReducer={reducerCreate} sceneStyle={{backgroundColor:'#F7F7F7'}}>
50+
<Scene key="modal" component={Modal} >
51+
<Scene key="drawer" component={NavigationDrawer}>
52+
<Scene key="root">
53+
<Scene key="echo" clone component={EchoView} />
54+
<Scene key="register" component={Register} title="Register"/>
55+
<Scene key="register2" component={Register} title="Register2" duration={1}/>
56+
<Scene key="home" component={Home} title="Replace" type="replace"/>
57+
<Scene key="launch" component={Launch} title="Launch" initial={true} style={{flex:1, backgroundColor:'transparent'}}/>
58+
<Scene key="login" direction="vertical">
59+
<Scene key="loginModal" component={Login} title="Login"/>
60+
<Scene key="loginModal2" hideNavBar={true} component={Login2} title="Login2" panHandlers={null} duration={1}/>
61+
</Scene>
62+
<Scene key="tabbar" tabs={true} default="tab2" >
63+
<Scene key="tab1" title="Tab #1" icon={TabIcon} navigationBarStyle={{backgroundColor:'red'}} titleStyle={{color:'white'}}>
64+
<Scene key="tab1_1" component={TabView} title="Tab #1_1" onRight={()=>alert("Right button")} rightTitle="Right" />
65+
<Scene key="tab1_2" component={TabView} title="Tab #1_2" titleStyle={{color:'black'}}/>
66+
</Scene>
67+
<Scene key="tab2" initial={true} title="Tab #2" icon={TabIcon}>
68+
<Scene key="tab2_1" component={TabView} title="Tab #2_1" onLeft={()=>alert("Left button!")} leftTitle="Left"/>
69+
<Scene key="tab2_2" component={TabView} title="Tab #2_2" duration={1} panHandlers={null}/>
70+
</Scene>
71+
<Scene key="tab3" component={TabView} title="Tab #3" hideTabBar={true} icon={TabIcon}/>
72+
<Scene key="tab4" component={TabView} title="Tab #4" hideNavBar={true} icon={TabIcon}/>
73+
<Scene key="tab5" component={TabView} title="Tab #5" icon={TabIcon} renderRightButton={()=><Right/>}/>
74+
</Scene>
75+
</Scene>
76+
</Scene>
77+
<Scene key="error" component={Error}/>
78+
</Scene>
79+
</Router>;
80+
}
81+
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
apply plugin: "com.android.application"
2+
3+
import com.android.build.OutputFile
4+
5+
/**
6+
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7+
* and bundleReleaseJsAndAssets).
8+
* These basically call `react-native bundle` with the correct arguments during the Android build
9+
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10+
* bundle directly from the development server. Below you can see all the possible configurations
11+
* and their defaults. If you decide to add a configuration block, make sure to add it before the
12+
* `apply from: "react.gradle"` line.
13+
*
14+
* project.ext.react = [
15+
* // the name of the generated asset file containing your JS bundle
16+
* bundleAssetName: "index.android.bundle",
17+
*
18+
* // the entry file for bundle generation
19+
* entryFile: "index.android.js",
20+
*
21+
* // whether to bundle JS and assets in debug mode
22+
* bundleInDebug: false,
23+
*
24+
* // whether to bundle JS and assets in release mode
25+
* bundleInRelease: true,
26+
*
27+
* // whether to bundle JS and assets in another build variant (if configured).
28+
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
29+
* // The configuration property can be in the following formats
30+
* // 'bundleIn${productFlavor}${buildType}'
31+
* // 'bundleIn${buildType}'
32+
* // bundleInFreeDebug: true,
33+
* // bundleInPaidRelease: true,
34+
* // bundleInBeta: true,
35+
*
36+
* // the root of your project, i.e. where "package.json" lives
37+
* root: "../../",
38+
*
39+
* // where to put the JS bundle asset in debug mode
40+
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
41+
*
42+
* // where to put the JS bundle asset in release mode
43+
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
44+
*
45+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
46+
* // require('./image.png')), in debug mode
47+
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
48+
*
49+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
50+
* // require('./image.png')), in release mode
51+
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
52+
*
53+
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
54+
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
55+
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
56+
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
57+
* // for example, you might want to remove it from here.
58+
* inputExcludes: ["android/**", "ios/**"]
59+
* ]
60+
*/
61+
62+
apply from: "react.gradle"
63+
64+
/**
65+
* Set this to true to create two separate APKs instead of one:
66+
* - An APK that only works on ARM devices
67+
* - An APK that only works on x86 devices
68+
* The advantage is the size of the APK is reduced by about 4MB.
69+
* Upload all the APKs to the Play Store and people will download
70+
* the correct one based on the CPU architecture of their device.
71+
*/
72+
def enableSeparateBuildPerCPUArchitecture = false
73+
74+
/**
75+
* Run Proguard to shrink the Java bytecode in release builds.
76+
*/
77+
def enableProguardInReleaseBuilds = false
78+
79+
android {
80+
compileSdkVersion 23
81+
buildToolsVersion "23.0.1"
82+
83+
defaultConfig {
84+
applicationId "com.drawerexample"
85+
minSdkVersion 16
86+
targetSdkVersion 22
87+
versionCode 1
88+
versionName "1.0"
89+
ndk {
90+
abiFilters "armeabi-v7a", "x86"
91+
}
92+
}
93+
splits {
94+
abi {
95+
reset()
96+
enable enableSeparateBuildPerCPUArchitecture
97+
universalApk false // If true, also generate a universal APK
98+
include "armeabi-v7a", "x86"
99+
}
100+
}
101+
buildTypes {
102+
release {
103+
minifyEnabled enableProguardInReleaseBuilds
104+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
105+
}
106+
}
107+
// applicationVariants are e.g. debug, release
108+
applicationVariants.all { variant ->
109+
variant.outputs.each { output ->
110+
// For each separate APK per architecture, set a unique version code as described here:
111+
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
112+
def versionCodes = ["armeabi-v7a":1, "x86":2]
113+
def abi = output.getFilter(OutputFile.ABI)
114+
if (abi != null) { // null for the universal-debug, universal-release variants
115+
output.versionCodeOverride =
116+
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
117+
}
118+
}
119+
}
120+
}
121+
122+
dependencies {
123+
compile fileTree(dir: "libs", include: ["*.jar"])
124+
compile "com.android.support:appcompat-v7:23.0.1"
125+
compile "com.facebook.react:react-native:+" // From node_modules
126+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# 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+
#}
18+
19+
# Disabling obfuscation is useful if you collect stack traces from production crashes
20+
# (unless you are using a system that supports de-obfuscate the stack traces).
21+
-dontobfuscate
22+
23+
# React Native
24+
25+
# Keep our interfaces so they can be used by other ProGuard rules.
26+
# See http://sourceforge.net/p/proguard/bugs/466/
27+
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
28+
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
29+
30+
# Do not strip any method/class that is annotated with @DoNotStrip
31+
-keep @com.facebook.proguard.annotations.DoNotStrip class *
32+
-keepclassmembers class * {
33+
@com.facebook.proguard.annotations.DoNotStrip *;
34+
}
35+
36+
-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
37+
void set*(***);
38+
*** get*();
39+
}
40+
41+
-keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
42+
-keep class * extends com.facebook.react.bridge.NativeModule { *; }
43+
-keepclassmembers,includedescriptorclasses class * { native <methods>; }
44+
-keepclassmembers class * { @com.facebook.react.uimanager.UIProp <fields>; }
45+
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp <methods>; }
46+
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; }
47+
48+
-dontwarn com.facebook.react.**
49+
50+
# okhttp
51+
52+
-keepattributes Signature
53+
-keepattributes *Annotation*
54+
-keep class com.squareup.okhttp.** { *; }
55+
-keep interface com.squareup.okhttp.** { *; }
56+
-dontwarn com.squareup.okhttp.**
57+
58+
# okio
59+
60+
-keep class sun.misc.Unsafe { *; }
61+
-dontwarn java.nio.file.*
62+
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
63+
-dontwarn okio.**
64+
65+
# stetho
66+
67+
-dontwarn com.facebook.stetho.**

0 commit comments

Comments
 (0)