提交 74c0f01c authored 作者: 吴强's avatar 吴强

add progress bar

上级 d51b5570
...@@ -2,14 +2,24 @@ import { AsyncStorage } from 'react-native'; ...@@ -2,14 +2,24 @@ import { AsyncStorage } from 'react-native';
import { NavigationActions } from 'react-navigation'; import { NavigationActions } from 'react-navigation';
// import codePush from 'react-native-code-push'; // import codePush from 'react-native-code-push';
import { checkUpdate } from '../services/update'; import { checkUpdate } from '../services/update';
import { addUpdaterDownloadingCallback, update, addUpdaterDownloadedCallback } from '../native/Updater'; import { update } from '../native/Updater';
import config from '../utils/config'; import config from '../utils/config';
import { encrypt } from '../utils/helper'; import { encrypt } from '../utils/helper';
export default { export default {
namespace: 'welcome', namespace: 'welcome',
state: { }, state: {
reducers: {}, percent: 0,
},
reducers: {
setPercent(state, { payload }) {
console.info(payload);
return {
...state,
percent: payload.progress,
};
},
},
effects: { effects: {
*init(ignored, { put, call }) { *init(ignored, { put, call }) {
try { try {
...@@ -20,7 +30,13 @@ export default { ...@@ -20,7 +30,13 @@ export default {
const token = encrypt(tokenId); const token = encrypt(tokenId);
// console.info(`${config.updateContextPath}/resource/${token}/${encodeURIComponent(deploymentInfo.uri)}`); // console.info(`${config.updateContextPath}/resource/${token}/${encodeURIComponent(deploymentInfo.uri)}`);
console.log('开始'); console.log('开始');
yield call(update, `${config.updateContextPath}/resource/${token}/${encodeURIComponent(deploymentInfo.uri)}`, (event) => { console.info(event); }); yield call(
update, `${config.updateContextPath}/resource/${token}/${encodeURIComponent(deploymentInfo.uri)}`,
(event) => {
put({ type: 'setPercent', payload: { progress: event.progress } });
console.info(event);
},
);
console.log('结束结束结束结束结束结束结束结束结束结束'); console.log('结束结束结束结束结束结束结束结束结束结束');
} }
} catch (e) { } catch (e) {
......
...@@ -3,6 +3,7 @@ import { View, StyleSheet, Text } from 'react-native'; ...@@ -3,6 +3,7 @@ import { View, StyleSheet, Text } from 'react-native';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import SplashScreen from 'react-native-splash-screen'; import SplashScreen from 'react-native-splash-screen';
import { createAction } from '../utils/index'; import { createAction } from '../utils/index';
import PercentageCircle from '../components/roundProgressBarComponent';
@connect(({ welcome }) => ({ welcome })) @connect(({ welcome }) => ({ welcome }))
class WelcomeScreen extends Component { class WelcomeScreen extends Component {
...@@ -17,8 +18,10 @@ class WelcomeScreen extends Component { ...@@ -17,8 +18,10 @@ class WelcomeScreen extends Component {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<Text>wlecome</Text> <Text>wlecome</Text>
<View>
<PercentageCircle radius={60} percent={this.props.welcome.percent} color="#3498db" />
</View>
</View> </View>
); );
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论