Skip to content

Commit cb4f82e

Browse files
author
soliury
committed
some litile refactor
1 parent e60ee78 commit cb4f82e

3 files changed

Lines changed: 31 additions & 15 deletions

File tree

src/layouts/Home.js

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import React,{
55
Text,
66
StyleSheet,
77
Dimensions,
8-
Image
8+
Image,
9+
Animated,
10+
Easing
911
} from 'react-native';
1012
import UserOverlay from '../components/UserOverlay';
1113
import config from '../configs';
@@ -15,20 +17,41 @@ const { height, width } = Dimensions.get('window');
1517

1618

1719
class Home extends Component {
20+
constructor(props) {
21+
super(props);
22+
this.state = {
23+
fadeAnim: new Animated.Value(0.4)
24+
};
25+
}
26+
27+
28+
componentDidMount() {
29+
Animated.timing(this.state.fadeAnim, {
30+
toValue: 1,
31+
easing: Easing.quad
32+
}).start();
33+
}
34+
35+
36+
componentDidFocus() {
37+
console.log(2222);
38+
}
39+
40+
1841
render() {
1942
const { home, actions, router, user } = this.props;
2043
return (
2144
<View style={styles.container}>
22-
<Image
23-
style={styles.bgImg}
45+
<Animated.Image
46+
style={[styles.bgImg,{opacity: this.state.fadeAnim}]}
2447
source={{ uri: config.bgImgUri }}>
2548

2649
<Text onPress={()=>{
2750
this.props.actions.toast('测试');
2851
}}>
2952
toAbout
3053
</Text>
31-
</Image>
54+
</Animated.Image>
3255

3356

3457
<UserOverlay user={user.secret} toLogin={() => router.toLogin() }
@@ -43,16 +66,15 @@ class Home extends Component {
4366

4467
const styles = StyleSheet.create({
4568
container: {
46-
width: width,
47-
flex: 1,
48-
backgroundColor: "transparent"
69+
backgroundColor: 'transparent'
4970
},
5071
bgImg: {
5172
width,
5273
height,
5374
flexDirection: 'row',
5475
alignItems: 'center',
55-
justifyContent: 'center'
76+
justifyContent: 'center',
77+
backgroundColor: 'transparent'
5678
}
5779
});
5880

src/layouts/Navigation.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class Navigation extends Component {
5555
return (
5656
<View style={styles.container}>
5757
<Navigator
58-
sceneStyle={styles.scene}
5958
ref={view => this.navigator=view}
6059
initialRoute={initialRoute}
6160
configureScene={this.configureScene.bind(this)}
@@ -70,11 +69,6 @@ const styles = StyleSheet.create({
7069
container: {
7170
flex: 1
7271
},
73-
scene: {
74-
top: 0,
75-
bottom: 0,
76-
opacity: 1,
77-
},
7872
flexCenter: {
7973
flex: 1,
8074
justifyContent: 'center',

src/store/utilsMiddleware.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as utilsActions from '../actions/utils';
44

55
export default function utilsMiddleware({ dispatch }) {
66
return next => action => {
7-
const { payload, error, type } = action;
7+
const { payload, error } = action;
88
const { toast } = action.meta || {};
99

1010
const dispatchToast = (...args)=> {

0 commit comments

Comments
 (0)