Skip to content

Commit 3fd05de

Browse files
committed
1.减少启动屏延时\n2.Dialog自定义视图
1 parent 7c4c7ab commit 3fd05de

File tree

6 files changed

+35
-27
lines changed

6 files changed

+35
-27
lines changed

src/modules/PopupDialog.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { View,Text,TouchableOpacity,StyleSheet } from "react-native";
44
import PopupDialog,{ SlideAnimation,DialogTitle,ScaleAnimation,DialogButton } from 'react-native-popup-dialog';
55

66
const dialogTitle = props => <DialogTitle {...props} />;
7-
//const dialogTitle = () => null;
87
class PopupDialogView extends Component {
98
render(){
109
return(

src/navigators/index.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ReduxNavigation extends Component {
2323
BackHandler.addEventListener("hardwareBackPress", this.onBackButtonPressAndroid);
2424
setTimeout(()=>{
2525
SplashScreen.hide();
26-
},2000);
26+
},1500);
2727
}
2828
componentWillUnmount() {
2929
BackHandler.removeEventListener("hardwareBackPress", this.onBackButtonPressAndroid);
@@ -47,7 +47,6 @@ class ReduxNavigation extends Component {
4747
}
4848
render() {
4949
const { dispatch, nav, dialog, setTheme, theme } = this.props;
50-
console.log(this.props);
5150
const navigation = addNavigationHelpers({
5251
dispatch,
5352
state: nav,
@@ -60,20 +59,8 @@ class ReduxNavigation extends Component {
6059
show={dialog.isShow}
6160
confirmBtn={{title:'set dark',bgColor:'#188eee',disabled:theme.id === 'dark',onPress:this.props.setTheme}}
6261
cancelBtn={{title:'关闭按钮',bgColor:'#9DABC0',onPress:this.props.hideDialog}}
63-
dialogTitle={<DialogTitle title="PopupDialog"/>}
62+
dialogTitle={dialog.dialogTitle}
6463
>
65-
<View style={{marginTop:10}}>
66-
<Text style={theme.styles.navFont} >
67-
知止而后有定,定而后能静,静而后能安,安而后能虑,虑而后能得。物有本末,事有终始。知所先后,则近道矣。
68-
</Text>
69-
{
70-
theme.id !== 'default' && <Button
71-
onClick={this.props.setDefaultTheme}
72-
title={"默认颜色"}
73-
bgColor='#16A085'
74-
/>
75-
}
76-
</View>
7764
{dialog.children}
7865
</PopupDialog>
7966
</View>

src/page/home/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ColorUtils } from "../../equipment/ColorUtils";
77
import * as CONFIG from "../../equipment/ComponentUtil";
88
import ToastRoot from "../../modules/Toast";
99

10+
1011
class HomeScreen extends Component {
1112
static navigationOptions = ({ navigation, navigationOptions }) => {
1213
const { params } = navigation.state;
@@ -105,7 +106,7 @@ const styles = StyleSheet.create({
105106
const mapStateToProps = () => ({});
106107
const mapDispatchToProps = (dispatch, ownProps) => {
107108
return {
108-
showDialog: ()=>dispatch(dialogType.SHOW_DIALOG)
109+
showDialog: () =>dispatch(dialogType.HOME_DIALOG)
109110
}
110111
};
111112
export default connect(mapStateToProps,mapDispatchToProps)(HomeScreen)

src/page/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class LoginScreen extends Component {
105105
bgColor='#16A085'
106106
/>
107107
<Button
108-
onClick={this.props.showDialog.bind(this,{type:'SHOW_DIALOG',children:null})}
108+
onClick={this.props.showDialog}
109109
title={"Dialog"}
110110
bgColor='#188eee'
111111
/>
@@ -163,8 +163,9 @@ const mapStateToProps = (state) => {
163163
const mapDispatchToProps = (dispatch, ownProps) => {
164164
return {
165165
actions: bindActionCreators(actionCreators, dispatch),
166-
showDialog: (element)=>dispatch(element),
166+
showDialog: () => dispatch(dialogType.LOGIN_DIALOG),
167167
hideDialog: ()=>dispatch(dialogType.HIDE_DIALOG),
168+
setDefaultTheme:()=>dispatch({type:'DEFAULT_THEME'})
168169
}
169170
};
170171
export default connect(mapStateToProps,mapDispatchToProps)(LoginScreen)

src/redux/actions/dialogType.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
1-
export const SHOW_DIALOG = {type:"SHOW_DIALOG"};
2-
export const HIDE_DIALOG = {type:"HIDE_DIALOG"};
1+
import React from 'react';
2+
import ViewTest from '../../page/DialogModules/ViewTest'
3+
import { DialogTitle } from "react-native-popup-dialog";
4+
5+
export const SHOW_DIALOG = "SHOW_DIALOG";
6+
export const HIDE_DIALOG = {
7+
type: "HIDE_DIALOG"
8+
};
9+
10+
export const LOGIN_DIALOG = {
11+
type: SHOW_DIALOG,
12+
children: <ViewTest routh="LOGIN"/>,
13+
dialogTitle: <DialogTitle title="LOGIN"/>
14+
};
15+
16+
export const HOME_DIALOG = {
17+
type: SHOW_DIALOG,
18+
children: <ViewTest routh="HOME"/>
19+
};

src/redux/reducers/dialog.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
const initialState={
2-
isShow:false,
3-
children:null
1+
const initialState = {
2+
isShow: false,
3+
children: null,
4+
dialogTitle: null
45
};
56
export default dialog = (state = initialState, action) => {
6-
console.log(action)
77
switch (action.type) {
88
case 'SHOW_DIALOG':
9-
return {isShow:true,children:action.children}
9+
return Object.assign({}, initialState, {
10+
isShow: true,
11+
...action
12+
})
1013
case 'HIDE_DIALOG':
11-
return {isShow:false,children:null}
14+
return initialState
1215
default:
1316
return state
1417
}

0 commit comments

Comments
 (0)