modify toast, review by redding
Showing
5 changed files
with
37 additions
and
38 deletions
@@ -23,7 +23,7 @@ export default class ProductListView extends Component { | @@ -23,7 +23,7 @@ export default class ProductListView extends Component { | ||
23 | rowHasChanged: (r1, r2) => r1.key != r2.key, | 23 | rowHasChanged: (r1, r2) => r1.key != r2.key, |
24 | }); | 24 | }); |
25 | this._renderSeparator = this._renderSeparator.bind(this); | 25 | this._renderSeparator = this._renderSeparator.bind(this); |
26 | - | 26 | + this.tipMessage = ''; |
27 | this.state = { | 27 | this.state = { |
28 | selectedIndex: 0, | 28 | selectedIndex: 0, |
29 | }; | 29 | }; |
@@ -82,11 +82,14 @@ export default class ProductListView extends Component { | @@ -82,11 +82,14 @@ export default class ProductListView extends Component { | ||
82 | } | 82 | } |
83 | </View> | 83 | </View> |
84 | <TouchableOpacity onPress={() => { | 84 | <TouchableOpacity onPress={() => { |
85 | + if (this.tipMessage == '') { | ||
85 | if (rowData.wait) { | 86 | if (rowData.wait) { |
86 | this.props.onPressRemindBtn && this.props.onPressRemindBtn(rowData); | 87 | this.props.onPressRemindBtn && this.props.onPressRemindBtn(rowData); |
87 | }else { | 88 | }else { |
88 | this.props.onPressProductItem && this.props.onPressProductItem(rowData); | 89 | this.props.onPressProductItem && this.props.onPressProductItem(rowData); |
89 | } | 90 | } |
91 | + } | ||
92 | + | ||
90 | }}> | 93 | }}> |
91 | { | 94 | { |
92 | (tipState=='取消提醒')? | 95 | (tipState=='取消提醒')? |
@@ -118,7 +121,9 @@ export default class ProductListView extends Component { | @@ -118,7 +121,9 @@ export default class ProductListView extends Component { | ||
118 | render() { | 121 | render() { |
119 | let { | 122 | let { |
120 | resource, | 123 | resource, |
124 | + tipMessage, | ||
121 | } = this.props; | 125 | } = this.props; |
126 | + this.tipMessage = tipMessage; | ||
122 | let backgroundWidth = width; | 127 | let backgroundWidth = width; |
123 | let backgroundHeight = 64 + 20 + resource.length * rowHeight; | 128 | let backgroundHeight = 64 + 20 + resource.length * rowHeight; |
124 | 129 |
@@ -18,7 +18,7 @@ import Immutable, {Map} from 'immutable'; | @@ -18,7 +18,7 @@ import Immutable, {Map} from 'immutable'; | ||
18 | import ProductListView from './ProductListView'; | 18 | import ProductListView from './ProductListView'; |
19 | import TimeListView from './TimeListView'; | 19 | import TimeListView from './TimeListView'; |
20 | import LoadingIndicator from '../../../common/components/LoadingIndicator'; | 20 | import LoadingIndicator from '../../../common/components/LoadingIndicator'; |
21 | -import Toast from 'react-native-smart-toast' | 21 | +import Toast from 'react-native-root-toast' |
22 | 22 | ||
23 | export default class Seckill extends Component { | 23 | export default class Seckill extends Component { |
24 | constructor(props) { | 24 | constructor(props) { |
@@ -31,6 +31,7 @@ export default class Seckill extends Component { | @@ -31,6 +31,7 @@ export default class Seckill extends Component { | ||
31 | sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2), | 31 | sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2), |
32 | }); | 32 | }); |
33 | this.isFetching = false; | 33 | this.isFetching = false; |
34 | + this.tipMessage = ''; | ||
34 | this.queryActivityInfo = Immutable.fromJS({}); | 35 | this.queryActivityInfo = Immutable.fromJS({}); |
35 | } | 36 | } |
36 | 37 | ||
@@ -52,29 +53,29 @@ export default class Seckill extends Component { | @@ -52,29 +53,29 @@ export default class Seckill extends Component { | ||
52 | componentWillReceiveProps(nextProps) { | 53 | componentWillReceiveProps(nextProps) { |
53 | if (nextProps.tipMessage && nextProps.tipMessage !== '') { | 54 | if (nextProps.tipMessage && nextProps.tipMessage !== '') { |
54 | this._showToast && this._showToast(nextProps.tipMessage); | 55 | this._showToast && this._showToast(nextProps.tipMessage); |
56 | + console.log(nextProps.tipMessage); | ||
55 | } | 57 | } |
56 | } | 58 | } |
57 | 59 | ||
58 | - _showToast(message){ | ||
59 | - this._toast && this._toast.show({ | ||
60 | - position: Toast.constants.gravity.center, | ||
61 | - duration: 255, | ||
62 | - children: message, | ||
63 | - animationEnd : () => { | ||
64 | - this._toast._toastAnimationToggle = setTimeout( | ||
65 | - () => { | ||
66 | - this._toast.hide({ | ||
67 | - duration: 0, | ||
68 | - animationEnd: () => { | ||
69 | - this.props.onClearTipMessage && this.props.onClearTipMessage(); | 60 | + _showToast = (message) => { |
61 | + if (this.toast) { | ||
62 | + return; | ||
70 | } | 63 | } |
71 | - }) | ||
72 | - }, | ||
73 | - 1000 | ||
74 | - ); | 64 | + this.toast = Toast.show(message, { |
65 | + duration: 3000, | ||
66 | + position: height / 2 - 60, | ||
67 | + shadow: false, | ||
68 | + animation: true, | ||
69 | + hideOnPress: true, | ||
70 | + onHidden: () => { | ||
71 | + if (this.toast) { | ||
72 | + this.toast.destroy(); | ||
73 | + this.toast = null; | ||
75 | } | 74 | } |
76 | - }) | 75 | + this.props.onClearTipMessage && this.props.onClearTipMessage(); |
77 | } | 76 | } |
77 | + }); | ||
78 | + }; | ||
78 | 79 | ||
79 | renderSectionHeader(sectionData, sectionID) { | 80 | renderSectionHeader(sectionData, sectionID) { |
80 | if (this.queryActivityInfo && this.queryActivityInfo.secKillProductVoList && this.queryActivityInfo.secKillProductVoList.size > 0) { | 81 | if (this.queryActivityInfo && this.queryActivityInfo.secKillProductVoList && this.queryActivityInfo.secKillProductVoList.size > 0) { |
@@ -112,6 +113,7 @@ export default class Seckill extends Component { | @@ -112,6 +113,7 @@ export default class Seckill extends Component { | ||
112 | resource={rowData} | 113 | resource={rowData} |
113 | onPressProductItem={this.props.onPressProductItem} | 114 | onPressProductItem={this.props.onPressProductItem} |
114 | onPressRemindBtn={this.props.onPressRemindBtn} | 115 | onPressRemindBtn={this.props.onPressRemindBtn} |
116 | + tipMessage={this.tipMessage} | ||
115 | /> | 117 | /> |
116 | ); | 118 | ); |
117 | } | 119 | } |
@@ -133,6 +135,7 @@ export default class Seckill extends Component { | @@ -133,6 +135,7 @@ export default class Seckill extends Component { | ||
133 | } = this.props; | 135 | } = this.props; |
134 | this.isFetching = isFetching; | 136 | this.isFetching = isFetching; |
135 | this.queryActivityInfo = queryActivityInfo; | 137 | this.queryActivityInfo = queryActivityInfo; |
138 | + this.tipMessage = tipMessage; | ||
136 | diff = localServerTimeDiff; | 139 | diff = localServerTimeDiff; |
137 | let dataSource = { | 140 | let dataSource = { |
138 | ActivityProductList: [queryProductList ? queryProductList : []], | 141 | ActivityProductList: [queryProductList ? queryProductList : []], |
@@ -207,11 +210,6 @@ export default class Seckill extends Component { | @@ -207,11 +210,6 @@ export default class Seckill extends Component { | ||
207 | isVisible={isFetching && !ptr} | 210 | isVisible={isFetching && !ptr} |
208 | /> | 211 | /> |
209 | 212 | ||
210 | - <Toast | ||
211 | - ref={ component => this._toast = component } | ||
212 | - marginTop={64}> | ||
213 | - </Toast> | ||
214 | - | ||
215 | </View> | 213 | </View> |
216 | ); | 214 | ); |
217 | } | 215 | } |
@@ -118,15 +118,13 @@ export default class SeckillTimeListView extends Component { | @@ -118,15 +118,13 @@ export default class SeckillTimeListView extends Component { | ||
118 | this.timer && clearInterval(this.timer); | 118 | this.timer && clearInterval(this.timer); |
119 | } | 119 | } |
120 | 120 | ||
121 | - // componentWillReceiveProps(nextProps) { | ||
122 | - // this.curFocusActivity = nextProps.curActivity; | ||
123 | - // if (this.curFocusActivity) { | ||
124 | - // this._scrollToFocusActivity(); | ||
125 | - // } | ||
126 | - // this._caculateTimerState(); | ||
127 | - // console.log('componentWillReceiveProps'); | ||
128 | - // | ||
129 | - // } | 121 | + componentWillReceiveProps(nextProps) { |
122 | + this.curFocusActivity = nextProps.curActivity; | ||
123 | + if (this.curFocusActivity) { | ||
124 | + this._scrollToFocusActivity(); | ||
125 | + } | ||
126 | + this._caculateTimerState(); | ||
127 | + } | ||
130 | 128 | ||
131 | _renderRow(rowData, sectionID, rowID) { | 129 | _renderRow(rowData, sectionID, rowID) { |
132 | rowData = rowData.toJS(); | 130 | rowData = rowData.toJS(); |
@@ -94,9 +94,6 @@ export default function seckillReducer(state=initialState, action) { | @@ -94,9 +94,6 @@ export default function seckillReducer(state=initialState, action) { | ||
94 | case SHOW_TIP_MESSAGE: { | 94 | case SHOW_TIP_MESSAGE: { |
95 | return state.set('tipMessage', Immutable.fromJS(action.payload)); | 95 | return state.set('tipMessage', Immutable.fromJS(action.payload)); |
96 | } | 96 | } |
97 | - case CLEAR_TIP_MESSAGE: { | ||
98 | - return state.set('tipMessage', ''); | ||
99 | - } | ||
100 | case UPDATE_SECKILL_PRODUCT_VO_LIST: { | 97 | case UPDATE_SECKILL_PRODUCT_VO_LIST: { |
101 | return state.setIn(['queryActivityInfo', 'secKillProductVoList'], Immutable.fromJS(action.payload.secKillProductVoList)) | 98 | return state.setIn(['queryActivityInfo', 'secKillProductVoList'], Immutable.fromJS(action.payload.secKillProductVoList)) |
102 | .set('curActivity', Immutable.fromJS(action.payload.curActivity)) | 99 | .set('curActivity', Immutable.fromJS(action.payload.curActivity)) |
@@ -20,9 +20,11 @@ | @@ -20,9 +20,11 @@ | ||
20 | "react-native-device-info": "0.9.5", | 20 | "react-native-device-info": "0.9.5", |
21 | "react-native-fabric": "0.2.2", | 21 | "react-native-fabric": "0.2.2", |
22 | "react-native-progress": "^3.0.1", | 22 | "react-native-progress": "^3.0.1", |
23 | + "react-native-root-toast": "^1.0.3", | ||
23 | "react-native-router-flux": "^3.32.0", | 24 | "react-native-router-flux": "^3.32.0", |
24 | "react-native-scrollable-mixin": "^1.0.1", | 25 | "react-native-scrollable-mixin": "^1.0.1", |
25 | "react-native-simple-store": "^1.1.0", | 26 | "react-native-simple-store": "^1.1.0", |
27 | + "react-native-smart-toast": "^1.1.1", | ||
26 | "react-native-swiper": "^1.4.11", | 28 | "react-native-swiper": "^1.4.11", |
27 | "react-redux": "^4.4.5", | 29 | "react-redux": "^4.4.5", |
28 | "react-static-container": "^1.0.1", | 30 | "react-static-container": "^1.0.1", |
@@ -32,7 +34,6 @@ | @@ -32,7 +34,6 @@ | ||
32 | "redux-thunk": "^2.0.1", | 34 | "redux-thunk": "^2.0.1", |
33 | "stacktrace-js": "^1.3.0", | 35 | "stacktrace-js": "^1.3.0", |
34 | "timeago.js": "^1.0.5", | 36 | "timeago.js": "^1.0.5", |
35 | - "yh_rncamera": "0.1.0", | ||
36 | - "react-native-smart-toast": "^1.1.1" | 37 | + "yh_rncamera": "0.1.0" |
37 | } | 38 | } |
38 | } | 39 | } |
-
Please register or login to post a comment