├── .babelrc ├── .buckconfig ├── .flowconfig ├── .gitattributes ├── .gitignore ├── .watchmanconfig ├── App.js ├── README.md ├── __tests__ └── App.js ├── android ├── app │ ├── BUCK │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── reactnativetemplate │ │ │ ├── MainActivity.java │ │ │ └── MainApplication.java │ │ └── res │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ └── values │ │ ├── strings.xml │ │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── keystores │ ├── BUCK │ └── debug.keystore.properties └── settings.gradle ├── app.json ├── app ├── Common │ ├── Config.js │ ├── FontSize.js │ ├── Global.js │ ├── Request.js │ ├── SetTheme.js │ └── Tool.js ├── Component │ └── TabIcon.js ├── Pages │ ├── Login.js │ ├── Login │ │ ├── Component │ │ │ └── LoginInput.js │ │ ├── Login.js │ │ └── LoginPublic.js │ ├── Test1.js │ ├── Test2.js │ ├── Test3.js │ └── Test4.js ├── Resources │ ├── Images.js │ ├── images │ │ ├── Gank.png │ │ ├── Main.png │ │ └── ShiTu.png │ └── index.js ├── Router.js └── index.js ├── index.js ├── ios ├── ReactNativeTemplate-tvOS │ └── Info.plist ├── ReactNativeTemplate-tvOSTests │ └── Info.plist ├── ReactNativeTemplate.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ ├── ReactNativeTemplate-tvOS.xcscheme │ │ └── ReactNativeTemplate.xcscheme ├── ReactNativeTemplate │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ └── LaunchScreen.xib │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ └── main.m └── ReactNativeTemplateTests │ ├── Info.plist │ └── ReactNativeTemplateTests.m ├── package.json ├── screenshots └── Login.gif └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"], 3 | "plugins": [ 4 | "syntax-decorators", 5 | "transform-decorators-legacy" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore unexpected extra "@providesModule" 9 | .*/node_modules/.*/node_modules/fbjs/.* 10 | 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 15 | 16 | ; Ignore polyfills 17 | .*/Libraries/polyfills/.* 18 | 19 | [include] 20 | 21 | [libs] 22 | node_modules/react-native/Libraries/react-native/react-native-interface.js 23 | node_modules/react-native/flow/ 24 | 25 | [options] 26 | emoji=true 27 | 28 | module.system=haste 29 | 30 | munge_underscores=true 31 | 32 | 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' 33 | 34 | suppress_type=$FlowIssue 35 | suppress_type=$FlowFixMe 36 | suppress_type=$FlowFixMeProps 37 | suppress_type=$FlowFixMeState 38 | suppress_type=$FixMe 39 | 40 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-3]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 41 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-3]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 42 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 43 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 44 | 45 | unsafe.enable_getters_and_setters=true 46 | 47 | [version] 48 | ^0.53.0 49 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 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/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | yarn-error.log 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /App.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * @flow 5 | */ 6 | 7 | import React, { Component } from 'react'; 8 | import { 9 | Platform, 10 | StyleSheet, 11 | Text, 12 | View 13 | } from 'react-native'; 14 | 15 | import Router from './app/Router'; 16 | 17 | export default class App extends Component<{}> { 18 | render() { 19 | return ( 20 | 21 | ); 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-template 2 | 3 | 致力于打造一个快速开发RN项目的模板 4 | 5 | ![登录效果](https://github.com/SurpassRabbit/react-native-template/blob/master/screenshots/Login.gif) 6 | 7 | ### 使用小技巧 8 | ##### 项目中常用的封装都放在app目录下Common文件夹 9 | 1、`FontSize.js`:基于屏幕分辨率封装的字体适配方法,使用方法:`fontSize:FONT_SIZE(14)` 10 | 11 | 2、`Tool.js`:封装常用的属性方法,比如说判断是否登录,或者其他的方法,在这个方法中,提供了用来做安卓,iOS换算px的方法,使用方法:`width:px2dp(100)` 12 | 13 | 3、`global.js`:全局变量方法,一般我会用来设置全局的方法,比如说:系统判断,屏幕宽高,主题设置,图片初始化。 14 | 具体的详情可以查看`global.js`内部注释。 15 | 16 | 4、`Config.js`:配置文件,可以用来配置请求网址,配置表等等。 17 | 18 | 5、`SetTheme.js`:更改主题,`teaset`提供了设置主题和切换主题的能力,但有些时候,有一些颜色需要再手动调整,所以创建了这个文件,通过在里面配置颜色,并在项目的入口中引入,就可以直接使用`Theme.backgroundColor`的方式调用颜色了。 19 | 20 | 6、`Request.js`:基于`react-native-fetch-blob`封装的网络请求方法,很简单,不喜勿喷。 21 | 22 | 7、`Images.js`:在`Resources`目录下有`index.js`和`Images.js`两个文件,这是基于`Marno`关于图片管理文章封装的实践。 23 | 24 | 25 | ### 2017.11.7更新说明 26 | 1、使用`teaset`的`SegmentedView`组件实现左右滑动的效果。 27 | 28 | 2、使用`teaset`的`Theme`控制页面中的颜色。 29 | 30 | 3、使用`Mobx`控制登录中的状态,简单使用。 31 | 32 | 4、修改`tabbar`选中图标和文字的颜色,使其更符合**识兔**项目的效果。 33 | 34 | 35 | -------------------------------------------------------------------------------- /__tests__/App.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import App from '../App'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /android/app/BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | lib_deps = [] 12 | 13 | for jarfile in glob(['libs/*.jar']): 14 | name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')] 15 | lib_deps.append(':' + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | 21 | for aarfile in glob(['libs/*.aar']): 22 | name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')] 23 | lib_deps.append(':' + name) 24 | android_prebuilt_aar( 25 | name = name, 26 | aar = aarfile, 27 | ) 28 | 29 | android_library( 30 | name = "all-libs", 31 | exported_deps = lib_deps, 32 | ) 33 | 34 | android_library( 35 | name = "app-code", 36 | srcs = glob([ 37 | "src/main/java/**/*.java", 38 | ]), 39 | deps = [ 40 | ":all-libs", 41 | ":build_config", 42 | ":res", 43 | ], 44 | ) 45 | 46 | android_build_config( 47 | name = "build_config", 48 | package = "com.reactnativetemplate", 49 | ) 50 | 51 | android_resource( 52 | name = "res", 53 | package = "com.reactnativetemplate", 54 | res = "src/main/res", 55 | ) 56 | 57 | android_binary( 58 | name = "app", 59 | keystore = "//android/keystores:debug", 60 | manifest = "src/main/AndroidManifest.xml", 61 | package_type = "debug", 62 | deps = [ 63 | ":app-code", 64 | ], 65 | ) 66 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 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: "../../node_modules/react-native/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 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 37 | * // for example: to disable dev mode in the staging build type (if configured) 38 | * devDisabledInStaging: true, 39 | * // The configuration property can be in the following formats 40 | * // 'devDisabledIn${productFlavor}${buildType}' 41 | * // 'devDisabledIn${buildType}' 42 | * 43 | * // the root of your project, i.e. where "package.json" lives 44 | * root: "../../", 45 | * 46 | * // where to put the JS bundle asset in debug mode 47 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 48 | * 49 | * // where to put the JS bundle asset in release mode 50 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 51 | * 52 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 53 | * // require('./image.png')), in debug mode 54 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 55 | * 56 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 57 | * // require('./image.png')), in release mode 58 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 59 | * 60 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 61 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 62 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 63 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 64 | * // for example, you might want to remove it from here. 65 | * inputExcludes: ["android/**", "ios/**"], 66 | * 67 | * // override which node gets called and with what additional arguments 68 | * nodeExecutableAndArgs: ["node"], 69 | * 70 | * // supply additional arguments to the packager 71 | * extraPackagerArgs: [] 72 | * ] 73 | */ 74 | 75 | project.ext.react = [ 76 | entryFile: "index.js" 77 | ] 78 | 79 | apply from: "../../node_modules/react-native/react.gradle" 80 | 81 | /** 82 | * Set this to true to create two separate APKs instead of one: 83 | * - An APK that only works on ARM devices 84 | * - An APK that only works on x86 devices 85 | * The advantage is the size of the APK is reduced by about 4MB. 86 | * Upload all the APKs to the Play Store and people will download 87 | * the correct one based on the CPU architecture of their device. 88 | */ 89 | def enableSeparateBuildPerCPUArchitecture = false 90 | 91 | /** 92 | * Run Proguard to shrink the Java bytecode in release builds. 93 | */ 94 | def enableProguardInReleaseBuilds = false 95 | 96 | android { 97 | compileSdkVersion 23 98 | buildToolsVersion "23.0.1" 99 | 100 | defaultConfig { 101 | applicationId "com.reactnativetemplate" 102 | minSdkVersion 16 103 | targetSdkVersion 22 104 | versionCode 1 105 | versionName "1.0" 106 | ndk { 107 | abiFilters "armeabi-v7a", "x86" 108 | } 109 | } 110 | splits { 111 | abi { 112 | reset() 113 | enable enableSeparateBuildPerCPUArchitecture 114 | universalApk false // If true, also generate a universal APK 115 | include "armeabi-v7a", "x86" 116 | } 117 | } 118 | buildTypes { 119 | release { 120 | minifyEnabled enableProguardInReleaseBuilds 121 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 122 | } 123 | } 124 | // applicationVariants are e.g. debug, release 125 | applicationVariants.all { variant -> 126 | variant.outputs.each { output -> 127 | // For each separate APK per architecture, set a unique version code as described here: 128 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 129 | def versionCodes = ["armeabi-v7a":1, "x86":2] 130 | def abi = output.getFilter(OutputFile.ABI) 131 | if (abi != null) { // null for the universal-debug, universal-release variants 132 | output.versionCodeOverride = 133 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 134 | } 135 | } 136 | } 137 | } 138 | 139 | dependencies { 140 | compile project(':react-native-fetch-blob') 141 | compile fileTree(dir: "libs", include: ["*.jar"]) 142 | compile "com.android.support:appcompat-v7:23.0.1" 143 | compile "com.facebook.react:react-native:+" // From node_modules 144 | } 145 | 146 | // Run this once to be able to run the application with BUCK 147 | // puts all compile dependencies into folder libs for BUCK to use 148 | task copyDownloadableDepsToLibs(type: Copy) { 149 | from configurations.compile 150 | into 'libs' 151 | } 152 | -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 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 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 30 | 31 | # Do not strip any method/class that is annotated with @DoNotStrip 32 | -keep @com.facebook.proguard.annotations.DoNotStrip class * 33 | -keep @com.facebook.common.internal.DoNotStrip class * 34 | -keepclassmembers class * { 35 | @com.facebook.proguard.annotations.DoNotStrip *; 36 | @com.facebook.common.internal.DoNotStrip *; 37 | } 38 | 39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 40 | void set*(***); 41 | *** get*(); 42 | } 43 | 44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; } 46 | -keepclassmembers,includedescriptorclasses class * { native ; } 47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } 48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } 49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } 50 | 51 | -dontwarn com.facebook.react.** 52 | 53 | # TextLayoutBuilder uses a non-public Android constructor within StaticLayout. 54 | # See libs/proxy/src/main/java/com/facebook/fbui/textlayoutbuilder/proxy for details. 55 | -dontwarn android.text.StaticLayout 56 | 57 | # okhttp 58 | 59 | -keepattributes Signature 60 | -keepattributes *Annotation* 61 | -keep class okhttp3.** { *; } 62 | -keep interface okhttp3.** { *; } 63 | -dontwarn okhttp3.** 64 | 65 | # okio 66 | 67 | -keep class sun.misc.Unsafe { *; } 68 | -dontwarn java.nio.file.* 69 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 70 | -dontwarn okio.** 71 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 19 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/reactnativetemplate/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.reactnativetemplate; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 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 "ReactNativeTemplate"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/reactnativetemplate/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.reactnativetemplate; 2 | 3 | import android.app.Application; 4 | 5 | import com.facebook.react.ReactApplication; 6 | import com.RNFetchBlob.RNFetchBlobPackage; 7 | import com.facebook.react.ReactNativeHost; 8 | import com.facebook.react.ReactPackage; 9 | import com.facebook.react.shell.MainReactPackage; 10 | import com.facebook.soloader.SoLoader; 11 | 12 | import java.util.Arrays; 13 | import java.util.List; 14 | 15 | public class MainApplication extends Application implements ReactApplication { 16 | 17 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 18 | @Override 19 | public boolean getUseDeveloperSupport() { 20 | return BuildConfig.DEBUG; 21 | } 22 | 23 | @Override 24 | protected List getPackages() { 25 | return Arrays.asList( 26 | new MainReactPackage(), 27 | new RNFetchBlobPackage() 28 | ); 29 | } 30 | 31 | @Override 32 | protected String getJSMainModuleName() { 33 | return "index"; 34 | } 35 | }; 36 | 37 | @Override 38 | public ReactNativeHost getReactNativeHost() { 39 | return mReactNativeHost; 40 | } 41 | 42 | @Override 43 | public void onCreate() { 44 | super.onCreate(); 45 | SoLoader.init(this, /* native exopackage */ false); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeRabbitYu/react-native-template/f16abccec8510c000aac47d217994969e88ce27c/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeRabbitYu/react-native-template/f16abccec8510c000aac47d217994969e88ce27c/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeRabbitYu/react-native-template/f16abccec8510c000aac47d217994969e88ce27c/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeRabbitYu/react-native-template/f16abccec8510c000aac47d217994969e88ce27c/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ReactNativeTemplate 3 | 4 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenLocal() 18 | jcenter() 19 | maven { 20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 21 | url "$rootDir/../node_modules/react-native/android" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeRabbitYu/react-native-template/f16abccec8510c000aac47d217994969e88ce27c/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 6 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = "debug", 3 | properties = "debug.keystore.properties", 4 | store = "debug.keystore", 5 | visibility = [ 6 | "PUBLIC", 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'ReactNativeTemplate' 2 | include ':react-native-fetch-blob' 3 | project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fetch-blob/android') 4 | 5 | include ':app' 6 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ReactNativeTemplate", 3 | "displayName": "ReactNativeTemplate" 4 | } -------------------------------------------------------------------------------- /app/Common/Config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Rabbit 下午2:13 3 | */ 4 | 5 | const Config = { 6 | baseApi : __DEV__ ? 'http://shitu.leanapp.cn/api' : 'http://shitu.leanapp.cn/api', 7 | }; 8 | 9 | export default Config; -------------------------------------------------------------------------------- /app/Common/FontSize.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Rabbit on 2017/4/20. 3 | */ 4 | const FontSize = (size) => { 5 | if (PixelRatio === 2) { 6 | // iphone 5s and older Androids 7 | if (SCREEN_WIDTH < 360) { 8 | return size * 0.95; 9 | } 10 | // iphone 5 11 | if (SCREEN_HEIGHT < 667) { 12 | return size; 13 | // iphone 6-6s 14 | } else if (SCREEN_HEIGHT >= 667 && SCREEN_HEIGHT <= 735) { 15 | return size * 1.15; 16 | } 17 | // older phablets 18 | return size * 1.25; 19 | } 20 | if (PixelRatio === 3) { 21 | // catch Android font scaling on small machines 22 | // where pixel ratio / font scale ratio => 3:3 23 | if (SCREEN_WIDTH <= 360) { 24 | return size; 25 | } 26 | // Catch other weird android width sizings 27 | if (SCREEN_HEIGHT < 667) { 28 | return size * 1.15; 29 | // catch in-between size Androids and scale font up 30 | // a tad but not too much 31 | } 32 | if (SCREEN_HEIGHT >= 667 && SCREEN_HEIGHT <= 735) { 33 | return size * 1.2; 34 | } 35 | // catch larger devices 36 | // ie iphone 6s plus / 7 plus / mi note 等等 37 | return size * 1.27; 38 | } 39 | if (PixelRatio === 3.5) { 40 | // catch Android font scaling on small machines 41 | // where pixel ratio / font scale ratio => 3:3 42 | if (SCREEN_WIDTH <= 360) { 43 | return size; 44 | // Catch other smaller android height sizings 45 | } 46 | if (SCREEN_HEIGHT < 667) { 47 | return size * 1.20; 48 | // catch in-between size Androids and scale font up 49 | // a tad but not too much 50 | } 51 | if(SCREEN_HEIGHT >= 667 && SCREEN_HEIGHT <= 735) { 52 | return size * 1.25; 53 | } 54 | // catch larger phablet devices 55 | return size * 1.40; 56 | } 57 | // if older device ie pixelRatio !== 2 || 3 || 3.5 58 | return size; 59 | }; 60 | 61 | module.exports = FontSize; // eslint-disable-line no-undef -------------------------------------------------------------------------------- /app/Common/Global.js: -------------------------------------------------------------------------------- 1 | 2 | import React, { Component } from 'react'; 3 | import { Dimensions, AsyncStorage, PixelRatio, Platform, Alert } from 'react-native'; 4 | 5 | // 项目中的图片可以通过Images.xxx 获取 6 | import { Images } from '../Resources/index'; 7 | 8 | // 统一管理项目中的路由 9 | import { Actions } from "react-native-router-flux"; 10 | 11 | // 处理安卓,iOS字体不同的类,使用方法 fontSize:FONT_SIZE(20) 12 | import FontSize from './FontSize'; 13 | // 处理安卓,iOS宽高的区别,使用方法 width:px2dp(20) 14 | import { px2dp } from './Tool'; 15 | 16 | // teaset中提供的一些常用方法 17 | import { Theme, Toast } from 'teaset'; 18 | 19 | // 基于react-native-fetch-blob封装的网络请求 20 | import RTRequest from './Request'; 21 | // 配置文件,可以放网络请求等 22 | import Config from './Config'; 23 | 24 | // 通过系统API获得屏幕宽高 25 | let { height, width } = Dimensions.get('window'); 26 | 27 | // 系统是iOS 28 | global.iOS = (Platform.OS === 'ios'); 29 | // 系统是安卓 30 | global.Android = (Platform.OS === 'android'); 31 | // 获取屏幕宽度 32 | global.SCREEN_WIDTH = width; 33 | // 获取屏幕高度 34 | global.SCREEN_HEIGHT = height; 35 | // 获取屏幕分辨率 36 | global.PixelRatio = PixelRatio.get(); 37 | // 最小线宽 38 | global.pixel = 1 / PixelRatio; 39 | // 适配字体 40 | global.FONT_SIZE = FontSize; 41 | // 屏幕适配 42 | global.px2dp = px2dp; 43 | // 主题 44 | global.Theme = Theme; 45 | // 网络请求 46 | global.RTRequest = RTRequest; 47 | // 配置 48 | global.Config = Config; 49 | // router跳转的方法 50 | global.Actions = Actions; 51 | // 图片加载 52 | global.Images = Images; 53 | // 弹出框 54 | global.Alert = Alert; 55 | // 存储 56 | global.AsyncStorage = AsyncStorage; 57 | // 弹框Toast 58 | global.Toast = Toast; 59 | 60 | 61 | -------------------------------------------------------------------------------- /app/Common/Request.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Rabbit on 2017/12/21. 3 | */ 4 | 'use strict'; 5 | import RNFetchBlob from 'react-native-fetch-blob'; 6 | 7 | import { 8 | AsyncStorage 9 | } from 'react-native'; 10 | 11 | // 处理url 12 | const encodeQuery = (url, params = {}) => { 13 | let _url = url; 14 | if (!params || !Object.keys(params).length) { 15 | return _url 16 | }; 17 | 18 | _url = _url.indexOf("?") === -1 ? `${_url}?` : `${_url}&`; 19 | 20 | const query = Object.keys(params) 21 | .map(key => `${key}=${params[key]}`) 22 | .join("&"); 23 | 24 | return `${_url}${query}`; 25 | }; 26 | 27 | // 处理错误请求 28 | const throwError = (json) => { 29 | const error = new Error(json) 30 | error.msg = json.msg; 31 | error.status = json.status; 32 | throw error; 33 | }; 34 | 35 | 36 | const checkStatus = (resp, json) => { 37 | // console.log(resp, json); 38 | if (resp.respInfo.status === 200 && json.status === 0){ 39 | return json; 40 | }else{ 41 | throwError(json); 42 | }; 43 | return json; 44 | }; 45 | 46 | const Request = { 47 | // 框架可以用过cancel 取消某个网络请求 48 | /** 49 | * 设置Header请求头 50 | */ 51 | header:{ 52 | // 'Accept': 'application/json', 53 | // 'Content-Type': 'application/json', 54 | }, 55 | /** 56 | * Config参数 57 | */ 58 | config:{ 59 | // 指示器,iOS专属 60 | // indicator:true, 61 | // 超时 62 | // timeout:3000 63 | // 缓存 64 | // fileCache : bool, 65 | // 缓存地址 66 | // path : string, 67 | // appendExt : string, 68 | // session : string, 69 | // addAndroidDownloads : any, 70 | }, 71 | 72 | /** 73 | * 74 | * @param method 请求方式GET, POST, PUT, DELETE 75 | * @param url 请求网址 76 | * @param params 请求参数 77 | * @param config 网络配置文件 78 | * @param header 请求头 79 | * @returns {Promise.} 80 | * 81 | */ 82 | fetch: async( { method, url, params = {}, config = {}, header = {} } ) => { 83 | let _method; 84 | let _params; 85 | let _url = url; 86 | let _config = { indicator:true, timeout:3000, ...config};; 87 | let _header = { 'Content-Type': 'application/json', ...header };; 88 | 89 | // let userData = await AsyncStorage.getItem('USER_TOKEN'); 90 | 91 | if (!method) _method = 'GET'; 92 | else _method = method.toUpperCase(); 93 | 94 | if (_method === 'GET' && params) { 95 | _url = encodeQuery(url, params); 96 | } 97 | 98 | if (_method === 'POST' && params) { 99 | _params = JSON.stringify(params); 100 | } 101 | 102 | if (__DEV__){ 103 | console.log('_url:', _url); 104 | console.log('_config:', _config); 105 | console.log('_method:', _method); 106 | console.log('_header:', _header); 107 | } 108 | 109 | return RNFetchBlob 110 | .config(_config) 111 | .fetch(_method ,_url, _header, _params) 112 | .then(resp => { 113 | return checkStatus(resp, resp.json()); 114 | }) 115 | .then((response)=>{ 116 | return response; 117 | }) 118 | .catch((error)=>{ 119 | throw error 120 | }) 121 | }, 122 | 123 | /** 124 | * 125 | * @param url 请求网址 126 | * @param params 参数 127 | * @param header 请求头 128 | * @param config fetchblob配置 129 | * @returns 130 | * 131 | */ 132 | get:( url, params = {}, header = {}, config = {} ) => { 133 | 134 | return RTRequest.fetch({method:'get', url, params, header, config }) 135 | .then((data)=>{ 136 | // console.log(data); 137 | return data; 138 | }) 139 | .catch((error)=>{ 140 | // console.log(error.msg); 141 | throw error; 142 | }) 143 | }, 144 | 145 | post:( url, params = {}, header = {}, config = {} ) => { 146 | 147 | return RTRequest.fetch({method:'post', url, params, header, config }) 148 | .then((data)=>{ 149 | // console.log(data); 150 | return data; 151 | }) 152 | .catch((error)=>{ 153 | // console.log(error.msg); 154 | throw error; 155 | }) 156 | }, 157 | 158 | /** 159 | * @param url 请求网址 160 | * @param body 要上传的信息,会自动转码 161 | * @param uploadProgress 上传进度 162 | * @param successCallBack 返回正确的值 163 | * @param failCallBack 返回错误的值 164 | * @returns 165 | * 166 | */ 167 | upload:(url,body,uploadProgress,successCallBack,failCallBack) => { 168 | return RNFetchBlob 169 | .config(Request.config) 170 | .fetch('POST',url,{ 171 | 'Content-Type' : 'multipart/form-data', 172 | },body) 173 | .uploadProgress((written, total) => { 174 | // 搜索进度打印 175 | // console.log('搜索进度:'+written / total); 176 | }) 177 | .progress((received, total) => { 178 | let perent = received / total; 179 | // console.log('上传进度:' + perent); 180 | uploadProgress(perent); 181 | }) 182 | .then((response)=>{ 183 | if (response.respInfo.status === 200){ 184 | return response.json(); 185 | }else { 186 | return failCallBack(response); 187 | } 188 | }) 189 | .then((response)=> { 190 | // console.log(response); 191 | successCallBack(response); 192 | }) 193 | .catch((error)=>{ 194 | failCallBack(error); 195 | }); 196 | } 197 | }; 198 | 199 | export default Request; 200 | -------------------------------------------------------------------------------- /app/Common/SetTheme.js: -------------------------------------------------------------------------------- 1 | import { Theme } from 'teaset'; 2 | 3 | Theme.set({ 4 | 5 | backgroundColor:'white', 6 | transparentColor : 'transparent', 7 | }); -------------------------------------------------------------------------------- /app/Common/Tool.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Rabbit on 2017/5/11. 3 | */ 4 | 5 | import { 6 | AsyncStorage, 7 | Platform 8 | } from 'react-native'; 9 | 10 | export default { 11 | async isLogin(){ 12 | let data = await AsyncStorage.getItem('TOKEN'); 13 | // console.log(data); 14 | if (data === null){ 15 | console.log('false'); 16 | global.TOKEN = false; 17 | return false; 18 | }else { 19 | console.log('true'); 20 | global.TOKEN = true; 21 | return true; 22 | } 23 | 24 | } 25 | } 26 | 27 | // 设计图上的比例,宽度 28 | let basePx = Platform.OS === 'ios' ? 750 : 720; 29 | 30 | exports.px2dp = function px2dp(px: number): number { 31 | return px / basePx * SCREEN_WIDTH; 32 | }; -------------------------------------------------------------------------------- /app/Component/TabIcon.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Rabbit 下午6:40 3 | */ 4 | 5 | import React from 'react'; 6 | import { 7 | Text, 8 | View, 9 | Image 10 | } from 'react-native'; 11 | 12 | const TabIcon = (props) => { 13 | // console.log(props); 14 | return( 15 | 16 | 20 | 23 | {props.title} 24 | 25 | 26 | ) 27 | }; 28 | 29 | 30 | export default TabIcon; -------------------------------------------------------------------------------- /app/Pages/Login.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Rabbit on 2017/11/3. 3 | */ 4 | 5 | import React, {Component} from 'react'; 6 | import { 7 | StyleSheet, 8 | Text, 9 | View, 10 | Image, 11 | } from 'react-native'; 12 | 13 | export default class Login extends Component { 14 | constructor(props) { 15 | super(props); 16 | this.state = {}; 17 | } 18 | 19 | render() { 20 | return ( 21 | 22 | 23 | 24 | ); 25 | } 26 | } 27 | 28 | const styles = StyleSheet.create({ 29 | container: { 30 | flex: 1, 31 | }, 32 | }); -------------------------------------------------------------------------------- /app/Pages/Login/Component/LoginInput.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Rabbit on 2017/11/3. 3 | */ 4 | 5 | import React, {Component} from 'react'; 6 | import { 7 | StyleSheet, 8 | Text, 9 | View, 10 | Image, 11 | TouchableOpacity 12 | } from 'react-native'; 13 | 14 | import { Input } from 'teaset'; 15 | 16 | const LoginInput = (props) => { 17 | 18 | 19 | return( 20 | 21 | 31 | { 32 | props.isVerify ? 33 | 34 | 获取验证码 35 | 36 | :null 37 | } 38 | 39 | 40 | ) 41 | } 42 | 43 | export default LoginInput; 44 | 45 | const iStyle = StyleSheet.create({ 46 | inputViewStyle:{ 47 | height:px2dp(88), 48 | marginTop:px2dp(20), 49 | // alignItems:'center', 50 | marginLeft:px2dp(108), 51 | marginRight:px2dp(108), 52 | borderBottomColor:'#d1d1d1', 53 | borderBottomWidth:px2dp(1), 54 | flexDirection:'row', 55 | justifyContent:'space-between', 56 | alignItems:'center', 57 | }, 58 | inputStyle:{ 59 | borderColor:'transparent', 60 | borderRadius:0, 61 | height:px2dp(86), 62 | flex:1, 63 | backgroundColor:'transparent', 64 | }, 65 | inputTitleStyle:{ 66 | fontSize:FONT_SIZE(12), 67 | color:'#333' 68 | } 69 | }); -------------------------------------------------------------------------------- /app/Pages/Login/Login.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Rabbit on 2017/11/2. 3 | */ 4 | 5 | import React, {Component} from 'react'; 6 | import { 7 | StyleSheet, 8 | Text, 9 | View, 10 | Image, 11 | 12 | TouchableOpacity, 13 | } from 'react-native'; 14 | 15 | import { SegmentedView, Button, NavigationBar, Overlay, Input , } from 'teaset'; 16 | import { observer } from 'mobx-react/native' 17 | import { observable, computed, action, runInAction } from 'mobx' 18 | 19 | 20 | import LoginInput from './Component/LoginInput'; 21 | 22 | 23 | const LoginView = (props) => { 24 | return( 25 | 26 | 29 | { 30 | props.isPass ? 31 | 32 | 35 | 41 | Actions.LoginPublic({headerTitle:'重置密码'})} 43 | > 44 | 忘记密码 45 | 46 | 47 | 48 | : 49 | 50 | 56 | { 57 | props.isImage? 58 | 66 | : 67 | null 68 | } 69 | 70 | 71 | } 72 | 73 |