便于使用的RN搜索头组件 – react-native-search-header

weixin_38078058 2019-09-12 12:20:06
react-native-seach-header 基于MD模式的便于使用的React Native搜索头组件。 安装 $ npm install react-native-search-header –save 使用方法 To use search header you simply import the component factory function to create a renderable component: import SearchHeaderComponent from 'react-native-search-header'; const SearchHeaderView = SearchHeaderComponent(); 示例 你可以直接导入组件工厂函数来创建一个可渲染组件: import React, { Component } from 'react'; import { Dimensions, AppRegistry, StyleSheet, View, Text, Button, StatusBar } from 'react-native'; import SearchHeaderComponent from 'react-native-search-header'; const DEVICE_WIDTH = Dimensions.get(`window`).width; const SearchHeader = SearchHeaderComponent(); const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'flex-start', alignItems: 'center', backgroundColor: '#f5fcff' }, status: { zIndex: 10, elevation: 2, width: DEVICE_WIDTH, height: 21, backgroundColor: '#0097a7' }, header: { justifyContent: 'center', alignItems: 'center', width: DEVICE_WIDTH, height: 56, marginBottom: 6, backgroundColor: '#00bcd4' }, label: { flexGrow: 1, fontSize: 20, fontWeight: `600`, textAlign: `left`, marginVertical: 8, paddingVertical: 3, color: `#f5fcff`, backgroundColor: `transparent` }, button: { justifyContent: 'center', alignItems: 'center', width: 130, height: 40, marginTop: 40, borderRadius: 2, backgroundColor: `#ff5722` } }); export default class Demo extends Component { constructor ( props : Object, context : Object ) { super(props, context); } render () { return ( <View style = { styles.container }> <StatusBar barStyle = 'light-content' /> <View style = { styles.status }/> <View style = { styles.header }> <Text style = { styles.label }>Demo</Text> </View> <SearchHeader ref = {(searchHeader) => { this.searchHeader = searchHeader; }} statusHeightOffet = { 21 } /> <View style = { styles.button }> <Button title = 'Open Search' color = '#f5fcff' onPress = {() => this.searchHeader.show()} /> </View> </View> ); } } AppRegistry.registerComponent('Demo', () => Demo);
...全文
59 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧