add alert review bydaiqiang
Showing
7 changed files
with
112 additions
and
13 deletions
@@ -13,6 +13,7 @@ import { | @@ -13,6 +13,7 @@ import { | ||
13 | } from 'react-native'; | 13 | } from 'react-native'; |
14 | 14 | ||
15 | import {Map} from 'immutable'; | 15 | import {Map} from 'immutable'; |
16 | +import ReceiveGiftAlert from './ReceiveGiftAlert'; | ||
16 | 17 | ||
17 | export default class AssociatorGift extends Component { | 18 | export default class AssociatorGift extends Component { |
18 | constructor(props) { | 19 | constructor(props) { |
@@ -21,16 +22,17 @@ export default class AssociatorGift extends Component { | @@ -21,16 +22,17 @@ export default class AssociatorGift extends Component { | ||
21 | 22 | ||
22 | render() { | 23 | render() { |
23 | let { | 24 | let { |
24 | - demo, | 25 | + showGiftAlert, |
25 | } = this.props; | 26 | } = this.props; |
26 | 27 | ||
27 | return ( | 28 | return ( |
28 | <View style={styles.container}> | 29 | <View style={styles.container}> |
29 | - <Text>aaaaaaaaaaaaa</Text> | 30 | + <ReceiveGiftAlert showGiftAlert={showGiftAlert} hiddenGiftAlert={this.props.hiddenGiftAlert}/> |
30 | </View> | 31 | </View> |
31 | ); | 32 | ); |
32 | } | 33 | } |
33 | -} | 34 | +}; |
35 | + | ||
34 | let {width, height} = Dimensions.get('window'); | 36 | let {width, height} = Dimensions.get('window'); |
35 | let styles = StyleSheet.create({ | 37 | let styles = StyleSheet.create({ |
36 | container: { | 38 | container: { |
1 | +'use strict'; | ||
2 | + | ||
3 | +import React from 'react'; | ||
4 | +import ReactNative from 'react-native'; | ||
5 | +import Immutable, {Map} from 'immutable'; | ||
6 | + | ||
7 | +const { | ||
8 | + AppRegistry, | ||
9 | + StyleSheet, | ||
10 | + Text, | ||
11 | + View, | ||
12 | + Image, | ||
13 | + ListView, | ||
14 | + Dimensions, | ||
15 | + TouchableOpacity, | ||
16 | +} = ReactNative; | ||
17 | + | ||
18 | + | ||
19 | +export default class ReceiveGiftAlert extends React.Component { | ||
20 | + constructor(props) { | ||
21 | + super(props); | ||
22 | + } | ||
23 | + | ||
24 | + render() { | ||
25 | + console.log(this.props.showGiftAlert); | ||
26 | + if (!this.props.showGiftAlert) { | ||
27 | + return null; | ||
28 | + } | ||
29 | + | ||
30 | + return ( | ||
31 | + <View style={styles.modalStyle}> | ||
32 | + <TouchableOpacity activeOpacity={0.5} onPress={() => { | ||
33 | + this.props.hiddenGiftAlert && this.props.hiddenGiftAlert(); | ||
34 | + }}> | ||
35 | + <View style={styles.button}></View> | ||
36 | + </TouchableOpacity> | ||
37 | + | ||
38 | + </View> | ||
39 | + ); | ||
40 | + } | ||
41 | +}; | ||
42 | + | ||
43 | +let {width, height} = Dimensions.get('window'); | ||
44 | +let styles = StyleSheet.create({ | ||
45 | + container: { | ||
46 | + | ||
47 | + }, | ||
48 | + modalStyle: { | ||
49 | + position: "absolute", | ||
50 | + top: 0, | ||
51 | + left: 0, | ||
52 | + width: width, | ||
53 | + height: height, | ||
54 | + backgroundColor: 'yellow' | ||
55 | + }, | ||
56 | + | ||
57 | + button: { | ||
58 | + height: 100, | ||
59 | + width: 100, | ||
60 | + backgroundColor: 'blue', | ||
61 | + }, | ||
62 | + | ||
63 | +}); |
@@ -41,6 +41,8 @@ function mapDispatchToProps(dispatch) { | @@ -41,6 +41,8 @@ function mapDispatchToProps(dispatch) { | ||
41 | class AssociatorGiftContainer extends Component { | 41 | class AssociatorGiftContainer extends Component { |
42 | constructor(props) { | 42 | constructor(props) { |
43 | super(props); | 43 | super(props); |
44 | + this._displayGiftAlert = this._displayGiftAlert.bind(this); | ||
45 | + this._hiddenGiftAlert = this._hiddenGiftAlert.bind(this); | ||
44 | } | 46 | } |
45 | 47 | ||
46 | componentDidMount() { | 48 | componentDidMount() { |
@@ -51,14 +53,26 @@ class AssociatorGiftContainer extends Component { | @@ -51,14 +53,26 @@ class AssociatorGiftContainer extends Component { | ||
51 | 53 | ||
52 | } | 54 | } |
53 | 55 | ||
56 | + _displayGiftAlert(){ | ||
57 | + this.props.actions.displayGiftAlert(); | ||
58 | + } | ||
59 | + | ||
60 | + _hiddenGiftAlert(){ | ||
61 | + this.props.actions.hiddenGiftAlert(); | ||
62 | + } | ||
63 | + | ||
54 | render() { | 64 | render() { |
55 | 65 | ||
56 | let { | 66 | let { |
57 | - demo | ||
58 | - } = this.props.associatorGift; | 67 | + showGiftAlert, |
59 | 68 | ||
69 | + } = this.props.associatorGift; | ||
60 | return ( | 70 | return ( |
61 | - <AssociatorGift /> | 71 | + <AssociatorGift |
72 | + showGiftAlert={showGiftAlert} | ||
73 | + displayGiftAlert={this._displayGiftAlert} | ||
74 | + hiddenGiftAlert={this._hiddenGiftAlert} | ||
75 | + /> | ||
62 | ); | 76 | ); |
63 | } | 77 | } |
64 | } | 78 | } |
@@ -5,5 +5,20 @@ import CouponService from '../../services/AssociatorGiftService'; | @@ -5,5 +5,20 @@ import CouponService from '../../services/AssociatorGiftService'; | ||
5 | const Platform = require('Platform'); | 5 | const Platform = require('Platform'); |
6 | 6 | ||
7 | const { | 7 | const { |
8 | - SET_HOST, | 8 | + SHOWGIFTALERT, |
9 | + DISMISSGIFTALERT, | ||
9 | } = require('../../constants/actionTypes').default; | 10 | } = require('../../constants/actionTypes').default; |
11 | + | ||
12 | + | ||
13 | + | ||
14 | +export function displayGiftAlert() { | ||
15 | + return { | ||
16 | + type: SHOWGIFTALERT, | ||
17 | + } | ||
18 | +} | ||
19 | + | ||
20 | +export function hiddenGiftAlert() { | ||
21 | + return { | ||
22 | + type: DISMISSGIFTALERT, | ||
23 | + } | ||
24 | +} |
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | import {Record, List, Map} from 'immutable'; | 3 | import {Record, List, Map} from 'immutable'; |
4 | 4 | ||
5 | let InitialState = Record({ | 5 | let InitialState = Record({ |
6 | - demo: 1, | 6 | + showGiftAlert: false, |
7 | }); | 7 | }); |
8 | 8 | ||
9 | export default InitialState; | 9 | export default InitialState; |
@@ -4,15 +4,20 @@ import InitialState from './associatorGiftInitialState'; | @@ -4,15 +4,20 @@ import InitialState from './associatorGiftInitialState'; | ||
4 | import Immutable, {Map} from 'immutable'; | 4 | import Immutable, {Map} from 'immutable'; |
5 | 5 | ||
6 | const { | 6 | const { |
7 | - SET_HOST, | ||
8 | - | 7 | + SHOWGIFTALERT, |
8 | + DISMISSGIFTALERT, | ||
9 | } = require('../../constants/actionTypes').default; | 9 | } = require('../../constants/actionTypes').default; |
10 | 10 | ||
11 | const initialState = new InitialState; | 11 | const initialState = new InitialState; |
12 | 12 | ||
13 | export default function couponReducer(state=initialState, action) { | 13 | export default function couponReducer(state=initialState, action) { |
14 | switch(action.type) { | 14 | switch(action.type) { |
15 | - | 15 | + case SHOWGIFTALERT: { |
16 | + return state.set('showGiftAlert', true); | ||
17 | + } | ||
18 | + case DISMISSGIFTALERT: { | ||
19 | + return state.set('showGiftAlert', false); | ||
20 | + } | ||
16 | } | 21 | } |
17 | 22 | ||
18 | return state; | 23 | return state; |
-
Please register or login to post a comment