ReactNative实现地址挑选器功能-创新互联
本文实例为大家分享了React Native地址挑选器的实现代码,供大家参考,具体内容如下

产品经理:“你明白吧,这里向右划可以出菜单,然后需要一个闪烁的动画,还有,我想这个tab可以拉下来,你懂吧?
设计师:“别废话,把你要抄的产品给我看下。”
…
接下来,我们仿一下别人家的地址挑选器

import React, { Component, PropTypes } from 'react';
import {
ViewPropTypes,
StyleSheet,
View,
TouchableOpacity,
TouchableNativeFeedback,
Platform,
Animated,
Text
} from 'react-native';
export default class SelectCityTabBar extends Component {
//属性声名
static propTypes = {
goToPage: PropTypes.func,
activeTab: PropTypes.number,
tabs: PropTypes.array,
backgroundColor: PropTypes.string,
activeTextColor: PropTypes.string,
inactiveTextColor: PropTypes.string,
textStyle: Text.propTypes.style,
tabStyle: ViewPropTypes.style,
renderTab: PropTypes.func,
underlineStyle: ViewPropTypes.style,
};
//默认属性
static defaultProps = {
activeTextColor: '#FA3D4F',
inactiveTextColor: 'black',
backgroundColor: null,
}
renderTab(name, page, isTabActive, onPressHandler) {
const { activeTextColor, inactiveTextColor, textStyle, } = this.props;
const textColor = isTabActive ? activeTextColor : inactiveTextColor;
const fontWeight = isTabActive ? 'bold' : 'normal';
const viewStyle = isTabActive ? [styles.tab, { borderBottomWidth: Constant.sizeDividerLarge, borderColor: Constant.colorPrimary }] : styles.tab;
if (Platform.OS !== 'ios') {
return onPressHandler(page)}
>
{name}
}
return onPressHandler(page)}
>
{name}
;
}
render() {
return (
{this.props.tabs.map((name, page) => {
const isTabActive = this.props.activeTab === page;
const renderTab = this.props.renderTab || this.renderTab;
return this.renderTab(name, page, isTabActive, this.props.goToPage);
})}
);
}
}
const styles = StyleSheet.create({
tab: {
alignItems: 'center',
justifyContent: 'center',
paddingBottom: 10,
marginLeft: 10,
},
tabs: {
height: 50,
flexDirection: 'row',
justifyContent: 'space-around',
borderWidth: 1,
borderTopWidth: 0,
borderLeftWidth: 0,
borderRightWidth: 0,
borderColor: '#ccc',
},
});
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网页标题:ReactNative实现地址挑选器功能-创新互联
标题链接:http://www.lzwzjz.cn/article/dipesd.html


咨询
建站咨询
