Permalink
Browse files

`react-web start` worked well

  • Loading branch information...
1 parent c8e8eaf commit 4a07577e29ab1d9ebff7a28eec4544e878434e12 @flyskywhy flyskywhy committed Aug 16, 2016
Showing with 74 additions and 33 deletions.
  1. +6 −1 README.md
  2. +1 −1 package.json
  3. +4 −1 post_npm_install.sh
  4. +3 −1 src/components/base/Modal.js
  5. +19 −13 src/layouts/Login.js
  6. +17 −2 src/layouts/QRCode.js
  7. +24 −14 src/layouts/Utils.js
View
@@ -23,7 +23,7 @@ npm install
Click the run button in Xcode, if something went wrong, you need to rebuild all packages that be used in this project with Xcode (Just select the package and press **command+B** to run compile).
-If you want to run it on you iPhone, please follow the [Offical Doc](http://facebook.github.io/react-native/docs/runningondevice.html#content).
+If you want to run it on your iPhone, please follow the [Offical Doc](http://facebook.github.io/react-native/docs/runningondevice.html#content).
If you don't want to update the ip manually, please run:
@@ -39,6 +39,11 @@ npm start
The ip will be replaced automatically.
+If you want to run it on your Browser (localhost:3000), please run:
+```
+react-web start
+```
+
## Screenshots
View
@@ -36,7 +36,7 @@
"react-native-scrollable-tab-view": "^0.5.1",
"react-native-vector-icons": "^2.0.3",
"react-redux": "^4.4.5",
- "react-web": "0.3.2",
+ "react-web": "git+https://github.com/flyskywhy/react-web.git",
"redux": "^3.5.2",
"redux-actions": "^0.10.0",
"redux-logger": "^2.6.1",
View
@@ -1,5 +1,5 @@
#!/bin/bash
-# patch some node_modules to build well
+# patch some node_modules to build and run well
if [ ! -d node_modules ]; then
npm install
@@ -8,3 +8,6 @@ fi
# react-web can't recognize *.android.js and *.ios.js now, so be it
cp post_npm_install/react-native-blur/src/* node_modules/react-native-blur/src/
cp post_npm_install/react-native-scrollable-tab-view/Button.js node_modules/react-native-scrollable-tab-view/
+
+# looks like a BUG
+sed -i "s/export default parseHtml = function (html, done) {/export default function (html, done) {/" node_modules/react-native-html-render/lib/htmlParse.js
@@ -1,6 +1,8 @@
import React, {Component, PropTypes} from 'react';
import {Dimensions, View, StyleSheet, Animated, Easing, Platform, TouchableWithoutFeedback, findNodeHandle} from 'react-native';
-import {BlurView} from 'react-native-blur';
+if (Platform.OS !== 'web') {
+ var BlurView = require('react-native-blur').BlurView;
+}
const {height, width} = Dimensions.get('window');
View
@@ -1,5 +1,6 @@
import React, {Component, PropTypes} from 'react';
import {
+ Platform,
View,
Text,
TouchableHighlight,
@@ -10,7 +11,11 @@ import {
TouchableOpacity
} from 'react-native';
import Icon from 'react-native-vector-icons/Ionicons';
-import Camera from 'react-native-camera';
+
+if (Platform.OS !== 'web') {
+ var Camera = require('react-native-camera');
+}
+
import Spinner from '../components/base/Spinner';
import packageObj from '../../package.json';
@@ -21,18 +26,19 @@ class Login extends Component {
_onLoginPress() {
const {ui, router, actions} = this.props;
if (ui.checkTokenPending) return;
- Camera.checkDeviceAuthorizationStatus()
- .then((isAuth)=> {
- if (isAuth) {
- router.toQRCode();
- }
- else {
- actions.toast('请在设置中开启Noder对相机的访问');
- }
- })
- .catch((err)=> {
- actions.toast('获取相机访问权错误');
- });
+ if (Platform.OS !== 'web') {
+ Camera.checkDeviceAuthorizationStatus()
+ .then((isAuth) => {
+ if (isAuth) {
+ router.toQRCode();
+ } else {
+ actions.toast('请在设置中开启Noder对相机的访问');
+ }
+ })
+ .catch((err) => {
+ actions.toast('获取相机访问权错误');
+ });
+ }
}
View
@@ -1,7 +1,11 @@
import React, {Component} from 'react';
import {StyleSheet, View, Text, Dimensions, Platform, TouchableOpacity, Vibration} from 'react-native';
-import Camera from 'react-native-camera';
-import BarcodeScanner from 'react-native-barcodescanner';
+
+if (Platform.OS !== 'web') {
+ var Camera = require('react-native-camera');
+ var BarcodeScanner = require('react-native-barcodescanner');
+}
+
import Icon from 'react-native-vector-icons/Ionicons';
import OverlayButton from '../components/base/OverlayButton';
@@ -54,6 +58,17 @@ class QRCode extends Component {
);
+ // for web
+ if (Platform.OS === 'web') {
+ return (
+ <View style={styles.camera}>
+ <Text style={styles.infoText}>
+ 只有原生 APP 才支持二维码
+ </Text>
+ </View>
+ );
+ }
+
// for android
if (Platform.OS === 'android') {
return (
View
@@ -1,5 +1,5 @@
import React, {Component} from 'react';
-import {View, StyleSheet, Text, StatusBar, AppState} from 'react-native';
+import {Platform, View, StyleSheet, Text, StatusBar, AppState} from 'react-native';
import Toast from '../components/base/Toast';
import * as codePushUtils from '../utils/codePushSync';
@@ -12,13 +12,15 @@ class Utils extends Component {
actions.getUnreadMessageCount();
}
});
- codePushUtils.sync();
- AppState.addEventListener("change", (newState) => {
- if (newState === "active") {
- codePushUtils.sync();
- this.props.user.secret && actions.getUnreadMessageCount();
- }
- });
+ if (Platform.OS !== 'web') {
+ codePushUtils.sync();
+ AppState.addEventListener("change", (newState) => {
+ if (newState === "active") {
+ codePushUtils.sync();
+ this.props.user.secret && actions.getUnreadMessageCount();
+ }
+ });
+ }
// if (__DEV__) {
// actions.checkToken('your secretKey', ()=> {
@@ -36,12 +38,20 @@ class Utils extends Component {
render() {
- return (
- <View style={styles.container}>
- <StatusBar barStyle="light-content"/>
- <Toast ref={ (view)=> this.toast=view }/>
- </View>
- );
+ if (Platform.OS === 'web') {
+ return (
+ <View style={styles.container}>
+ <Toast ref={ (view)=> this.toast=view }/>
+ </View>
+ );
+ } else {
+ return (
+ <View style={styles.container}>
+ <StatusBar barStyle="light-content"/>
+ <Toast ref={ (view)=> this.toast=view }/>
+ </View>
+ );
+ }
}
}

0 comments on commit 4a07577

Please sign in to comment.