123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- /**
- * Created by zack on 2018/6/28.
- */
- import {
- View,
- Text,
- StyleSheet,
- TouchableOpacity,
- Image,
- TextInput,
- Keyboard
- } from 'react-native'
- import React, {Component} from 'react'
- import {NavigationBarHeight, TabBarHeight, ScreenDimensions} from '../../../utils/DimensionsTools'
-
- export default class CountryCodeItem extends Component {
- constructor(props) {
- super(props)
- this.state = {
- name: props.name,
- phoneCode: props.phoneCode,
- }
- }
-
- componentWillReceiveProps(props) {
- this.setState({
- name: props.name,
- phoneCode: props.phoneCode,
- })
- }
-
- shouldComponentUpdate(nextProps) {
- if (nextProps.name !== this.state.name || nextProps.phoneCode !== this.state.phoneCode) {
- return true
- }
-
- return false
- }
-
- render() {
- return(
- <TouchableOpacity onPress={() => {
- this.props.didSelectedItem()
- }} style={styles.View}>
- <Text style={styles.NameText}>{this.state.name}</Text>
- <Text style={styles.PhoneCodeText}>{this.state.phoneCode}</Text>
-
- <View style={{position: 'absolute', width: ScreenDimensions.width, height: 0.5, backgroundColor: '#efeff4', left: 0, bottom: 0}} />
- </TouchableOpacity>
- )
- }
- }
-
- const styles = StyleSheet.create({
- View: {
- width: ScreenDimensions.width,
- height:45,
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
- },
- NameText: {
- fontSize: 16,
- color: '#333333',
- marginLeft: 15,
- },
- PhoneCodeText: {
- fontSize: 16,
- color: '#333333',
- marginRight: 45,
- }
- })
|