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

Commit d5580cc

Browse files
committed
settingState for open thumbnail
1 parent c4913d0 commit d5580cc

File tree

9 files changed

+59
-14
lines changed

9 files changed

+59
-14
lines changed

js/actions/actionTypes.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ export const FETCH_TARGET_MORE_DATA_REQUEST = 'FETCH_TARGET_MORE_DATA_REQUEST';
2121
export const FETCH_TARGET_MORE_DATA_FAILURE = 'FETCH_TARGET_MORE_DATA_FAILURE';
2222
export const FETCH_TARGET_DATA_IS_FULL = 'FETCH_TARGET_DATA_IS_FULL';
2323

24-
export const CHANGE_COLOR = 'CHANGE_COLOR';
25-
2624
export const UPDATE_STAR_LIST = 'UPDATE_STAR_LIST';
2725
export const STAR_DATA_SUCCESS = 'STAR_DATA_SUCCESS';
2826
export const UNSTAR_DATA_SUCCESS = 'UNSTAR_DATA_SUCCESS';
29-
export const UPDATE_STAR_STATE = 'UPDATE_STAR_STATE';
27+
export const UPDATE_STAR_STATE = 'UPDATE_STAR_STATE';
28+
29+
export const CHANGE_COLOR = 'CHANGE_COLOR';
30+
export const OPEN_SHOW_THUMBNAIL = 'OPEN_SHOW_THUMBNAIL';
31+
export const CLOSE_SHOW_THUMBNAIL = 'CLOSE_SHOW_THUMBNAIL';

js/actions/modifySettings.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,17 @@ export function changeColor(color) {
99
return {
1010
type: TYPES.CHANGE_COLOR,
1111
color: color
12+
};
13+
}
14+
15+
export function changeShowThumbnail(value) {
16+
if(value) {
17+
return {
18+
type: TYPES.OPEN_SHOW_THUMBNAIL
19+
};
20+
}else {
21+
return {
22+
type: TYPES.CLOSE_SHOW_THUMBNAIL
23+
};
1224
}
1325
}

js/components/ListViewWithInfo.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export default class ListViewWithInfo extends Component{
2323
renderTag: PropTypes.bool,
2424
isRenderFooter: PropTypes.bool,
2525
onEndReached: PropTypes.func,
26-
isFullData: PropTypes.bool
26+
isFullData: PropTypes.bool,
27+
isOpenThumbnail: PropTypes.bool
2728
};
2829

2930
render(){
@@ -89,7 +90,7 @@ export default class ListViewWithInfo extends Component{
8990
return(
9091
<View style={styles.itemContainer}>
9192
<View style={styles.imgPart}>
92-
{rowData.images ?
93+
{(rowData.images && this.props.isOpenThumbnail) ?
9394
<Image style={styles.image} source={{uri: getCorrectImageSizeUrl(rowData.images[0])}} />
9495
:
9596
<Image style={styles.image} source={require('../assets/user_article_no_data.png')}/>

js/containers/DiscoveryTab/TextTabPage.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class TextTabPage extends BackPageComponent{
5151
onEndReached={this._listViewOnEndReached.bind(this)}
5252
isFullData={this.props.isFullData}
5353
mainThemeColor={this.props.mainThemeColor}
54+
isOpenThumbnail={this.props.isOpenThumbnail}
5455
/>
5556
)
5657
}
@@ -109,7 +110,8 @@ const mapStateToProps = (state) => {
109110
pageNumber: state.targetData.pageNumber,
110111
isFullData: state.targetData.isFullData,
111112
error: state.targetData.error,
112-
mainThemeColor: state.settingState.mainThemeColor
113+
mainThemeColor: state.settingState.mainThemeColor,
114+
isOpenThumbnail: state.settingState.isOpenThumbnail
113115
};
114116
};
115117

js/containers/DiscoveryTab/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class DiscoveryFragment extends Component{
162162
</View>
163163
</View>
164164
<View style={styles.imgPart}>
165-
{rowData.images ?
165+
{(rowData.images && this.props.isOpenThumbnail) ?
166166
<Image style={styles.image} source={{uri: getCorrectImageSizeUrl(rowData.images[0])}} />
167167
:
168168
<Image style={styles.image} source={require('../../assets/user_article_no_data.png')}/>
@@ -310,7 +310,8 @@ const mapStateToProps = (state) => {
310310
loading: state.randomData.loading,
311311
error: state.randomData.error,
312312
isRenderFooter: state.randomData.isRenderFooter,
313-
mainThemeColor: state.settingState.mainThemeColor
313+
mainThemeColor: state.settingState.mainThemeColor,
314+
isOpenThumbnail: state.settingState.isOpenThumbnail
314315
};
315316
};
316317

js/containers/MainPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class BottomTabBar extends Component{
3030
constructor(props){
3131
super(props);
3232
this.state = {
33-
selectedTab: 'discovery'
33+
selectedTab: 'more'
3434
};
3535
}
3636

js/containers/MoreTab/index.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import px2dp from '../../utils/px2dp';
1414
import Avatar from '../../components/Avatar';
1515
import colors from '../../constants/colors';
1616
import {connect} from 'react-redux'
17+
import {bindActionCreators} from 'redux';
18+
import * as Actions from '../../actions/modifySettings';
1719
import ShareUtil from '../../utils/ShareUtil';
1820

1921
import ThemeColorPage from './ThemeColorPage';
@@ -27,6 +29,7 @@ class MoreFragment extends Component{
2729
}
2830

2931
render(){
32+
const {actions, mainThemeColor, isOpenThumbnail} = this.props;
3033
return(
3134
<View style={styles.container}>
3235
<NavigationBar title="更多"/>
@@ -50,13 +53,13 @@ class MoreFragment extends Component{
5053
<RowItem title="首页内容展示顺序" icon="md-reorder" iconColor='lightskyblue' onPress={this._itemClickCallback.bind(this, 1)}/>
5154
<RowItem title="自定义主题" icon="md-brush" iconColor={colors.orange} onPress={this._itemClickCallback.bind(this, 2)}/>
5255
{/*<RowItem title="选择语言 / Language" icon="md-globe" iconColor={colors.purple} onPress={this._itemClickCallback.bind(this, 3)}/>*/}
53-
<RowItemWithSwitcher title="夜间模式" icon="md-moon" iconColor="#7b68ee" renderSegment={false} onTintColor={this.props.mainThemeColor} />
56+
<RowItemWithSwitcher title="夜间模式" icon="md-moon" iconColor="#7b68ee" onTintColor={mainThemeColor} switcherValue={false}/>
57+
<RowItemWithSwitcher title="显示列表缩略图" icon="md-browsers" iconColor='plum' onTintColor={mainThemeColor} switcherValue={isOpenThumbnail} onValueChange={(value) => actions.changeShowThumbnail(value)} renderSegment={false}/>
5458
</View>
5559
<View style={styles.block}>
5660
<RowItem title="关于作者" icon="md-happy" iconColor="#9acd32" renderSegment={false} onPress={this._itemClickCallback.bind(this, 4)}/>
5761
</View>
5862
<View style={styles.block}>
59-
<RowItemWithSwitcher title="显示列表缩略图" icon="md-browsers" iconColor='plum' onTintColor={this.props.mainThemeColor} switcherValue={false} />
6063
<RowItem title="反馈" icon="md-text" iconColor={colors.lightGreen} onPress={this._itemClickCallback.bind(this, 6)} isShowRightArrow={false}/>
6164
<RowItem title="分享" icon="md-share" iconColor={colors.orangeRed} renderSegment={false} onPress={this._itemClickCallback.bind(this, 7)} isShowRightArrow={false}/>
6265
</View>
@@ -161,8 +164,15 @@ const styles = StyleSheet.create({
161164

162165
const mapStateToProps = (state) => {
163166
return {
164-
mainThemeColor: state.settingState.mainThemeColor
167+
mainThemeColor: state.settingState.mainThemeColor,
168+
isOpenThumbnail: state.settingState.isOpenThumbnail
165169
};
166170
};
167171

168-
export default connect(mapStateToProps)(MoreFragment);
172+
const mapDispatchToProps = (dispatch) => {
173+
return {
174+
actions: bindActionCreators(Actions, dispatch)
175+
};
176+
};
177+
178+
export default connect(mapStateToProps, mapDispatchToProps)(MoreFragment);

js/dao/SettingsDataDAO.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/**
2+
* Created by wangdi on 4/12/16.
3+
*/

js/reducers/settingState.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,30 @@ import colors from '../constants/colors';
77
import * as TYPES from '../actions/actionTypes';
88

99
const initialState = {
10-
mainThemeColor: colors.dodgerBlue
10+
mainThemeColor: colors.dodgerBlue,
11+
isOpenThumbnail: false
1112
}
1213

1314
export default function settingState(state=initialState, action) {
1415
switch(action.type){
1516
case TYPES.CHANGE_COLOR:
1617
return Object.assign({}, state, {
18+
...state,
1719
mainThemeColor: action.color
1820
});
1921

22+
case TYPES.OPEN_SHOW_THUMBNAIL:
23+
return Object.assign({}, state, {
24+
...state,
25+
isOpenThumbnail: true
26+
});
27+
28+
case TYPES.CLOSE_SHOW_THUMBNAIL:
29+
return Object.assign({}, state, {
30+
...state,
31+
isOpenThumbnail: false
32+
});
33+
2034
default:
2135
return state;
2236
}

0 commit comments

Comments
 (0)