├── .watchmanconfig ├── .gitattributes ├── .babelrc ├── img └── Tips.gif ├── android ├── settings.gradle ├── app │ ├── src │ │ └── main │ │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ └── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── java │ │ │ └── com │ │ │ │ └── reactnativetips │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── AndroidManifest.xml │ ├── BUCK │ ├── proguard-rules.pro │ └── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── keystores │ ├── debug.keystore.properties │ └── BUCK ├── build.gradle ├── gradle.properties ├── gradlew.bat └── gradlew ├── .buckconfig ├── __tests__ ├── index.ios.js └── index.android.js ├── package.json ├── ios ├── ReactNativeTips │ ├── AppDelegate.h │ ├── main.m │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── AppDelegate.m │ ├── Info.plist │ └── Base.lproj │ │ └── LaunchScreen.xib ├── ReactNativeTipsTests │ ├── Info.plist │ └── ReactNativeTipsTests.m └── ReactNativeTips.xcodeproj │ ├── xcshareddata │ └── xcschemes │ │ └── ReactNativeTips.xcscheme │ └── project.pbxproj ├── .gitignore ├── README.md ├── index.ios.js ├── index.android.js ├── .flowconfig └── src └── component ├── Alert.js ├── Button.js ├── Demo.js ├── Confirm.js ├── ToastSuccessAndError.js ├── Toast.js └── Tips.js /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"] 3 | } -------------------------------------------------------------------------------- /img/Tips.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BingKui/ReactNativeTips/HEAD/img/Tips.gif -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'ReactNativeTips' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ReactNativeTips 3 | 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BingKui/ReactNativeTips/HEAD/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BingKui/ReactNativeTips/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BingKui/ReactNativeTips/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BingKui/ReactNativeTips/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BingKui/ReactNativeTips/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /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/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = 'debug', 3 | store = 'debug.keystore', 4 | properties = 'debug.keystore.properties', 5 | visibility = [ 6 | 'PUBLIC', 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /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.4-all.zip 6 | -------------------------------------------------------------------------------- /__tests__/index.ios.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.ios.js'; 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 | -------------------------------------------------------------------------------- /__tests__/index.android.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.android.js'; 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/src/main/java/com/reactnativetips/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.reactnativetips; 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 "ReactNativeTips"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ReactNativeTips", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node node_modules/react-native/local-cli/cli.js start", 7 | "test": "jest" 8 | }, 9 | "dependencies": { 10 | "react": "15.4.1", 11 | "react-native": "0.39.2" 12 | }, 13 | "devDependencies": { 14 | "babel-jest": "17.0.2", 15 | "babel-preset-react-native": "1.9.0", 16 | "jest": "17.0.3", 17 | "react-test-renderer": "15.4.1" 18 | }, 19 | "jest": { 20 | "preset": "react-native" 21 | } 22 | } -------------------------------------------------------------------------------- /ios/ReactNativeTips/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/ReactNativeTips/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.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 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | android/app/libs 42 | *.keystore 43 | -------------------------------------------------------------------------------- /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:1.3.1' 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 | -------------------------------------------------------------------------------- /ios/ReactNativeTips/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ReactNativeTips 2 | 3 | 移动端各类Tips提示组件合集,提供toast,success,error,alert,confirm等。 4 | 5 | ###效果 6 | 7 | ![Tips](./img/Tips.gif) 8 | 9 | ##Dev 10 | 11 | 1.下载项目到本地目录 12 | 13 | git clone https://github.com/BingKui/ReactNativeTips.git 14 | 15 | 2.安装所需依赖(默认机器已经安装nodejs以及react-native-cli) 16 | 17 | npm install 18 | 19 | 3.打开模拟器或者连接手机,运行项目 20 | 21 | react-native run-android 22 | 23 | 或者 24 | 25 | react-native run-ios 26 | 27 | 28 | ##说明 29 | 30 | 组件提供多种样式,目前类型(type)分为:success,wrong,help,info,warning五种,可根据自己需要添加其他。 31 | 32 | ##资源 33 | 34 | 图标:[Alibaba国际站图标库](http://www.iconfont.cn/plus/collections/detail?cid=31 "Alibaba国际站图标库") 35 | 36 | 参考资料:[ReactNative中文网](http://reactnative.cn/docs/0.39/getting-started.html#content "reactnative中文网") 37 | 38 | ##联系我 39 | 40 | 有什么疑问,或者在使用过程中有什么需要改进的,可以联系我。 41 | 42 | 邮箱:<178974662@qq.com> -------------------------------------------------------------------------------- /ios/ReactNativeTipsTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 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/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/reactnativetips/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.reactnativetips; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactInstanceManager; 8 | import com.facebook.react.ReactNativeHost; 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.react.shell.MainReactPackage; 11 | import com.facebook.soloader.SoLoader; 12 | 13 | import java.util.Arrays; 14 | import java.util.List; 15 | 16 | public class MainApplication extends Application implements ReactApplication { 17 | 18 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 19 | @Override 20 | protected boolean getUseDeveloperSupport() { 21 | return BuildConfig.DEBUG; 22 | } 23 | 24 | @Override 25 | protected List getPackages() { 26 | return Arrays.asList( 27 | new MainReactPackage() 28 | ); 29 | } 30 | }; 31 | 32 | @Override 33 | public ReactNativeHost getReactNativeHost() { 34 | return mReactNativeHost; 35 | } 36 | 37 | @Override 38 | public void onCreate() { 39 | super.onCreate(); 40 | SoLoader.init(this, /* native exopackage */ false); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /index.ios.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * @flow 5 | */ 6 | 7 | import React, { 8 | Component 9 | } from 'react'; 10 | import { 11 | AppRegistry, 12 | StyleSheet, 13 | Text, 14 | View 15 | } from 'react-native'; 16 | 17 | import Demo from './src/component/Demo'; 18 | 19 | export default class ReactNativeTips extends Component { 20 | render() { 21 | return ( 22 | 23 | 24 | Welcome to React Native! 25 | 26 | 27 | To get started, edit index.ios.js 28 | 29 | 30 | Press Cmd+R to reload,{'\n'} 31 | Cmd+D or shake for dev menu 32 | 33 | 34 | ); 35 | } 36 | } 37 | 38 | const styles = StyleSheet.create({ 39 | container: { 40 | flex: 1, 41 | justifyContent: 'center', 42 | alignItems: 'center', 43 | backgroundColor: '#F5FCFF', 44 | }, 45 | welcome: { 46 | fontSize: 20, 47 | textAlign: 'center', 48 | margin: 10, 49 | }, 50 | instructions: { 51 | textAlign: 'center', 52 | color: '#333333', 53 | marginBottom: 5, 54 | }, 55 | }); 56 | 57 | AppRegistry.registerComponent('ReactNativeTips', () => Demo); -------------------------------------------------------------------------------- /index.android.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * @flow 5 | */ 6 | 7 | import React, { 8 | Component 9 | } from 'react'; 10 | import { 11 | AppRegistry, 12 | StyleSheet, 13 | Text, 14 | View 15 | } from 'react-native'; 16 | 17 | import Demo from './src/component/Demo'; 18 | 19 | export default class ReactNativeTips extends Component { 20 | render() { 21 | return ( 22 | 23 | 24 | Welcome to React Native! 25 | 26 | 27 | To get started, edit index.android.js 28 | 29 | 30 | Double tap R on your keyboard to reload,{'\n'} 31 | Shake or press menu button for dev menu 32 | 33 | 34 | ); 35 | } 36 | } 37 | 38 | const styles = StyleSheet.create({ 39 | container: { 40 | flex: 1, 41 | justifyContent: 'center', 42 | alignItems: 'center', 43 | backgroundColor: '#F5FCFF', 44 | }, 45 | welcome: { 46 | fontSize: 20, 47 | textAlign: 'center', 48 | margin: 10, 49 | }, 50 | instructions: { 51 | textAlign: 'center', 52 | color: '#333333', 53 | marginBottom: 5, 54 | }, 55 | }); 56 | 57 | AppRegistry.registerComponent('ReactNativeTips', () => Demo); -------------------------------------------------------------------------------- /ios/ReactNativeTips/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "AppDelegate.h" 11 | 12 | #import "RCTBundleURLProvider.h" 13 | #import "RCTRootView.h" 14 | 15 | @implementation AppDelegate 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 18 | { 19 | NSURL *jsCodeLocation; 20 | 21 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; 22 | 23 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 24 | moduleName:@"ReactNativeTips" 25 | initialProperties:nil 26 | launchOptions:launchOptions]; 27 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 28 | 29 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 30 | UIViewController *rootViewController = [UIViewController new]; 31 | rootViewController.view = rootView; 32 | self.window.rootViewController = rootViewController; 33 | [self.window makeKeyAndVisible]; 34 | return YES; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /.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 | .*/Libraries/react-native/ReactNative.js 16 | 17 | [include] 18 | 19 | [libs] 20 | node_modules/react-native/Libraries/react-native/react-native-interface.js 21 | node_modules/react-native/flow 22 | flow/ 23 | 24 | [options] 25 | module.system=haste 26 | 27 | experimental.strict_type_args=true 28 | 29 | munge_underscores=true 30 | 31 | module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub' 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=$FixMe 37 | 38 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-5]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 39 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-5]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 40 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 41 | 42 | unsafe.enable_getters_and_setters=true 43 | 44 | [version] 45 | ^0.35.0 46 | -------------------------------------------------------------------------------- /android/app/BUCK: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | # To learn about Buck see [Docs](https://buckbuild.com/). 4 | # To run your application with Buck: 5 | # - install Buck 6 | # - `npm start` - to start the packager 7 | # - `cd android` 8 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 9 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 10 | # - `buck install -r android/app` - compile, install and run application 11 | # 12 | 13 | lib_deps = [] 14 | for jarfile in glob(['libs/*.jar']): 15 | name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) 16 | lib_deps.append(':' + name) 17 | prebuilt_jar( 18 | name = name, 19 | binary_jar = jarfile, 20 | ) 21 | 22 | for aarfile in glob(['libs/*.aar']): 23 | name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile) 24 | lib_deps.append(':' + name) 25 | android_prebuilt_aar( 26 | name = name, 27 | aar = aarfile, 28 | ) 29 | 30 | android_library( 31 | name = 'all-libs', 32 | exported_deps = lib_deps 33 | ) 34 | 35 | android_library( 36 | name = 'app-code', 37 | srcs = glob([ 38 | 'src/main/java/**/*.java', 39 | ]), 40 | deps = [ 41 | ':all-libs', 42 | ':build_config', 43 | ':res', 44 | ], 45 | ) 46 | 47 | android_build_config( 48 | name = 'build_config', 49 | package = 'com.reactnativetips', 50 | ) 51 | 52 | android_resource( 53 | name = 'res', 54 | res = 'src/main/res', 55 | package = 'com.reactnativetips', 56 | ) 57 | 58 | android_binary( 59 | name = 'app', 60 | package_type = 'debug', 61 | manifest = 'src/main/AndroidManifest.xml', 62 | keystore = '//android/keystores:debug', 63 | deps = [ 64 | ':app-code', 65 | ], 66 | ) 67 | -------------------------------------------------------------------------------- /ios/ReactNativeTips/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UIViewControllerBasedStatusBarAppearance 38 | 39 | NSLocationWhenInUseUsageDescription 40 | 41 | NSAppTransportSecurity 42 | 43 | 44 | NSExceptionDomains 45 | 46 | localhost 47 | 48 | NSExceptionAllowsInsecureHTTPLoads 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /ios/ReactNativeTipsTests/ReactNativeTipsTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | #import 12 | 13 | #import "RCTLog.h" 14 | #import "RCTRootView.h" 15 | 16 | #define TIMEOUT_SECONDS 600 17 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 18 | 19 | @interface ReactNativeTipsTests : XCTestCase 20 | 21 | @end 22 | 23 | @implementation ReactNativeTipsTests 24 | 25 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 26 | { 27 | if (test(view)) { 28 | return YES; 29 | } 30 | for (UIView *subview in [view subviews]) { 31 | if ([self findSubviewInView:subview matching:test]) { 32 | return YES; 33 | } 34 | } 35 | return NO; 36 | } 37 | 38 | - (void)testRendersWelcomeScreen 39 | { 40 | UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; 41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 42 | BOOL foundElement = NO; 43 | 44 | __block NSString *redboxError = nil; 45 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 46 | if (level >= RCTLogLevelError) { 47 | redboxError = message; 48 | } 49 | }); 50 | 51 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 52 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 53 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 54 | 55 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 56 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 57 | return YES; 58 | } 59 | return NO; 60 | }]; 61 | } 62 | 63 | RCTSetLogFunction(RCTDefaultLogFunction); 64 | 65 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 66 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 67 | } 68 | 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /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/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 | # okhttp 54 | 55 | -keepattributes Signature 56 | -keepattributes *Annotation* 57 | -keep class okhttp3.** { *; } 58 | -keep interface okhttp3.** { *; } 59 | -dontwarn okhttp3.** 60 | 61 | # okio 62 | 63 | -keep class sun.misc.Unsafe { *; } 64 | -dontwarn java.nio.file.* 65 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 66 | -dontwarn okio.** 67 | -------------------------------------------------------------------------------- /src/component/Alert.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 提示Alert组件 3 | * @author 康兵奎 4 | * @date 2016年12月13日 5 | */ 6 | 'use strict'; 7 | 8 | import React, { 9 | Component, 10 | PropTypes 11 | } from 'react'; 12 | 13 | import { 14 | StyleSheet, 15 | View, 16 | Modal, 17 | Text, 18 | Dimensions, 19 | TouchableHighlight 20 | } from 'react-native'; 21 | 22 | class Alert extends Component { 23 | constructor(props) { 24 | super(props); 25 | this.state = { 26 | flag: false, 27 | }; 28 | } 29 | static defaultProps = { 30 | title: '标题', 31 | msg: '提示信息', 32 | callback: () => {}, 33 | btnText: '确定' 34 | }; 35 | static propTypes = { 36 | msg: PropTypes.string.isRequired, //提示信息 37 | title: PropTypes.string.isRequired, 38 | callback: PropTypes.func, 39 | btnText: PropTypes.string 40 | } 41 | open = () => { 42 | this.setState({ 43 | flag: true 44 | }); 45 | } 46 | _onPress = () => { 47 | this.setState({ 48 | flag: false 49 | }); 50 | this.props.callback(); 51 | } 52 | render() { 53 | return ( 54 | {}}> 58 | 59 | 60 | 61 | {this.props.title} 62 | 63 | {this.props.msg} 64 | 65 | 66 | {this.props.btnText} 67 | 68 | 69 | 70 | 71 | 72 | ); 73 | } 74 | } 75 | let _width = Dimensions.get('window').width; 76 | const styles = StyleSheet.create({ 77 | alertModal: { 78 | flex: 1, 79 | alignItems: 'center', 80 | justifyContent: 'center', 81 | flexDirection: 'column', 82 | backgroundColor: 'rgba(0,0,0,.45)' 83 | }, 84 | alert: { 85 | width: _width * .7, 86 | backgroundColor: 'rgba(255,255,255,1)', 87 | flexDirection: 'column', 88 | alignItems: 'center', 89 | justifyContent: 'center', 90 | borderRadius: 5, 91 | overflow: 'hidden' 92 | }, 93 | title: { 94 | flexDirection: 'row', 95 | alignItems: 'center', 96 | justifyContent: 'center', 97 | height: 40, 98 | borderBottomColor: '#eee', 99 | borderBottomWidth: .5 100 | }, 101 | titleCon: { 102 | flex: 1, 103 | textAlign: 'center', 104 | fontSize: 25 105 | }, 106 | text: { 107 | paddingTop: 10, 108 | paddingBottom: 10, 109 | marginTop: 5, 110 | marginBottom: 5, 111 | fontSize: 18 112 | }, 113 | btn: { 114 | flexDirection: 'row', 115 | alignItems: 'center', 116 | justifyContent: 'center', 117 | height: 40, 118 | borderTopColor: '#eee', 119 | borderTopWidth: .5, 120 | overflow: 'hidden' 121 | }, 122 | btnClick: { 123 | flex: 1, 124 | alignItems: 'center', 125 | justifyContent: 'center', 126 | overflow: 'hidden', 127 | borderBottomLeftRadius: 5, 128 | borderBottomRightRadius: 5 129 | }, 130 | btnText: { 131 | flex: 1, 132 | textAlign: 'center', 133 | textAlignVertical: 'center', 134 | overflow: 'hidden', 135 | fontSize: 20, 136 | fontWeight: '700' 137 | } 138 | }); 139 | 140 | 141 | export default Alert; -------------------------------------------------------------------------------- /src/component/Button.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Button 3 | * @author kangbingkui 4 | * @description normal[45,100],big[55,140],samll[35,60] 5 | * line[**,width-20] 6 | */ 7 | 'use strict'; 8 | 9 | import React, { 10 | Component, 11 | PropTypes 12 | } from 'react'; 13 | 14 | import { 15 | StyleSheet, 16 | TouchableOpacity, 17 | Text, 18 | Dimensions, 19 | } from 'react-native'; 20 | 21 | const _width = Dimensions.get('window').width; 22 | const _height = Dimensions.get('window').height; 23 | 24 | class Button extends Component { 25 | height = 45; 26 | constructor(props) { 27 | super(props); //这一句不能省略,照抄即可 28 | this.state = { 29 | disabled: false, 30 | }; 31 | } 32 | static propTypes = { 33 | type: PropTypes.oneOf(['normal', 'redius', 'line']), 34 | size: PropTypes.oneOf(['normal', 'big', 'small']), 35 | btnText: PropTypes.string.isRequired, 36 | bgcolor: PropTypes.string, 37 | onPress: PropTypes.func.isRequired, 38 | }; 39 | static defaultProps = { 40 | type: 'normal', 41 | size: 'normal', 42 | btnText: 'OK', 43 | bgcolor: '#44abe5', 44 | onPress: () => {}, 45 | } 46 | onClick = () => { 47 | const { 48 | onPress 49 | } = this.props; 50 | this.disable(); 51 | onPress(this.enable); 52 | } 53 | _setSize = () => { 54 | const { 55 | size 56 | } = this.props; 57 | let _re = {}; 58 | if (size === 'big') { 59 | _re = { 60 | height: 55, 61 | width: 140, 62 | }; 63 | } 64 | if (size === 'small') { 65 | _re = { 66 | height: 35, 67 | width: 60, 68 | }; 69 | } 70 | return _re; 71 | } 72 | _setFontSize = () => { 73 | const { 74 | size 75 | } = this.props; 76 | let _re = {}; 77 | if (size === 'big') { 78 | _re = { 79 | fontSize: 26, 80 | }; 81 | } 82 | if (size === 'small') { 83 | _re = { 84 | fontSize: 14, 85 | }; 86 | } 87 | return _re; 88 | } 89 | _setType = () => { 90 | const { 91 | type, 92 | size 93 | } = this.props; 94 | let _re = {}; 95 | if (type === 'redius') { 96 | _re = { 97 | borderRadius: (this.height - 10) / 2, 98 | }; 99 | } 100 | if (type === 'line') { 101 | _re = { 102 | width: _width - 20, 103 | marginLeft: 10, 104 | marginRight: 10, 105 | }; 106 | } 107 | return _re; 108 | } 109 | enable = () => { 110 | this.setState({ 111 | disabled: false 112 | }); 113 | } 114 | disable = () => { 115 | this.setState({ 116 | disabled: true 117 | }); 118 | } 119 | render() { 120 | const { 121 | btnText 122 | } = this.props; 123 | return ( 124 | 128 | {btnText} 129 | 130 | ); 131 | } 132 | } 133 | 134 | const styles = StyleSheet.create({ 135 | btn: { 136 | height: 45, 137 | width: 100, 138 | borderRadius: 3, 139 | alignItems: 'center', 140 | justifyContent: 'center', 141 | margin: 5, 142 | alignSelf: 'flex-start' 143 | }, 144 | btnText: { 145 | color: '#fff', 146 | textAlign: 'center', 147 | fontSize: 20 148 | }, 149 | disabled: { 150 | backgroundColor: '#ccc' 151 | }, 152 | disabledText: { 153 | color: '#eee' 154 | }, 155 | }); 156 | 157 | 158 | export default Button; -------------------------------------------------------------------------------- /src/component/Demo.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import React, { 4 | Component 5 | } from 'react'; 6 | 7 | import { 8 | StyleSheet, 9 | View, 10 | Text, 11 | TouchableHighlight, 12 | TextInput, 13 | AlertIOS, 14 | } from 'react-native'; 15 | 16 | import Toast from './Toast'; 17 | import Button from './Button'; 18 | import ToastSuccessAndError from './ToastSuccessAndError'; 19 | import Tip from './Tips'; 20 | import Alert from './Alert'; 21 | import Confirm from './Confirm'; 22 | 23 | class Demo extends Component { 24 | constructor(props) { 25 | super(props); 26 | 27 | this.state = { 28 | tipType: 'success', 29 | toastType: 'success' 30 | }; 31 | } 32 | _successOnPress = (callback) => { 33 | this.refs.toast_su.success(); 34 | this.timer = setTimeout(() => { 35 | callback(); 36 | }, 2000); 37 | } 38 | _errorOnPress = (callback) => { 39 | this.refs.toast_su.error(); 40 | this.timer = setTimeout(() => { 41 | callback(); 42 | }, 2000); 43 | } 44 | _tipOnPress = (callback) => { 45 | this.refs.tip.changeType(this.state.tipType); 46 | this.refs.tip.open(); 47 | this.timer = setTimeout(() => { 48 | callback(); 49 | }, 2000); 50 | } 51 | _toastOnPress = (callback) => { 52 | this.refs.toast.changeType(this.state.toastType); 53 | this.refs.toast.open(); 54 | this.timer = setTimeout(() => { 55 | callback(); 56 | }, 2000); 57 | } 58 | _alertOnPress = (callback) => { 59 | // this.refs.alert.changeType(this.state.toastType); 60 | this.refs.alert.open(); 61 | callback(); 62 | } 63 | _confirmOnPress = (callback) => { 64 | this.refs.confirm.open(); 65 | callback(); 66 | } 67 | componentWillUnmount() { 68 | // 如果存在this.timer,则使用clearTimeout清空。 69 | // 如果你使用多个timer,那么用多个变量,或者用个数组来保存引用,然后逐个clear 70 | this.timer && clearTimeout(this.timer); 71 | } 72 | render() { 73 | return ( 74 | 75 | 76 | 77 | 78 | 79 | {}} rightFunc={() => {}} btnLeftText='确定' btnRightText='取消' title='弹框' msg='这个是提示内容!'> 80 | 81 |