Skip to content
This repository was archived by the owner on Nov 12, 2019. It is now read-only.

Commit 6daabc4

Browse files
committed
fix a bug of getting initial value
1 parent ec0a123 commit 6daabc4

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

js/containers/MainPage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import px2dp from '../utils/px2dp';
1616
import {connect} from 'react-redux';
1717
import {store} from '../store/index';
1818
import {fetchStarList} from '../actions/handleCollectionData';
19-
import {initialSettingsStateFacade, getShowThumbnailValue} from '../actions/modifySettings';
19+
import {initialSettingsStateFacade} from '../actions/modifySettings';
2020

2121
class MainPage extends Component{
2222

@@ -36,7 +36,7 @@ class BottomTabBar extends Component{
3636
constructor(props){
3737
super(props);
3838
this.state = {
39-
selectedTab: 'home'
39+
selectedTab: 'more'
4040
};
4141
}
4242

js/containers/WebViewPage.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,29 @@ class WebViewPage extends BackPageComponent{
4040
onMoveShouldSetPanResponder: (evt, gestureState) => true,
4141
onPanResponderMove: (evt, gestureState) => {
4242
let y = gestureState.dy;
43-
if(y > this.moveYThreshold) //drag down
44-
if(this.state.bottomInfoBarBottomValue === px2dp(0)) return;
43+
if(y > this.moveYThreshold && this.animationFlag) { //drag down
44+
if (this.state.bottomInfoBarBottomValue === px2dp(0)) return;
4545
this.animationFlag = false;
46-
Animated.timing(this.state.bottomInfoBarBottomValue, {toValue: 0}).start(()=>this.animationFlag = true);
47-
Animated.timing(this.state.toolbarTopValue, {toValue: 0}).start();
46+
Animated.timing(this.state.bottomInfoBarBottomValue, {
47+
toValue: 0,
48+
duration: 300
49+
}).start(() => this.animationFlag = true);
50+
Animated.timing(this.state.toolbarTopValue, {
51+
toValue: 0,
52+
duration: 300
53+
}).start();
54+
}
4855
if(y < -this.moveYThreshold && this.animationFlag) { //drag up
49-
if(this.state.bottomInfoBarBottomValue === px2dp(-45)) return;
56+
if (this.state.bottomInfoBarBottomValue === px2dp(-45)) return;
5057
this.animationFlag = false;
51-
Animated.timing(this.state.bottomInfoBarBottomValue, {toValue: px2dp(-45)}).start(()=>this.animationFlag = true);
52-
Animated.timing(this.state.toolbarTopValue, {toValue: -theme.toolbar.height}).start();
58+
Animated.timing(this.state.bottomInfoBarBottomValue, {
59+
toValue: px2dp(-45),
60+
duration: 300
61+
}).start(() => this.animationFlag = true);
62+
Animated.timing(this.state.toolbarTopValue, {
63+
toValue: -theme.toolbar.height,
64+
duration: 300
65+
}).start();
5366
}
5467
}
5568
});
@@ -225,9 +238,8 @@ const styles = StyleSheet.create({
225238
flex: 1
226239
},
227240
contentContainer: {
228-
marginTop: theme.toolbar.height,
241+
//marginTop: theme.toolbar.height,
229242
flex: 1,
230-
paddingTop: theme.toolbar.paddingTop
231243
},
232244
toolbar: {
233245
position: 'absolute',

js/dao/SettingsDataDAO.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import {AsyncStorage} from 'react-native';
1313
export default class SettingsDataDAO{
1414

1515
saveShowThumbnail(value){
16-
AsyncStorage.setItem(SHOW_THUMBNAIL, value+'');
16+
AsyncStorage.setItem(SHOW_THUMBNAIL, value ? 'true' : 'false');
1717
}
1818

1919
getShowThumbnailValue() {
2020
return new Promise((resolve, reject) => {
2121
AsyncStorage.getItem(SHOW_THUMBNAIL, (error, result) => {
22-
if(!error){
22+
if(!error && result){
2323
if(result === 'true')
2424
resolve(true);
2525
else
@@ -32,13 +32,13 @@ export default class SettingsDataDAO{
3232
}
3333

3434
saveOpenNightMode(value){
35-
AsyncStorage.setItem(NIGHT_MODE, value+'');
35+
AsyncStorage.setItem(NIGHT_MODE, value ? 'true' : 'false');
3636
}
3737

3838
getOpenNightModeValue(){
3939
return new Promise((resolve, reject) => {
4040
AsyncStorage.getItem(NIGHT_MODE, (error, result) => {
41-
if(!error){
41+
if(!error && result){
4242
if(result === 'true')
4343
resolve(true);
4444
else

0 commit comments

Comments
 (0)