Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import {StyleSheet, View, TextInput, TouchableOpacity, Text, Image, FlatList, Dimensions} from 'react-native';
  3.  
  4.  
  5.  
  6. const data = [
  7. {id: 'a', value: 'A'},
  8. {id: 'b', value: 'B'},
  9. {id: 'c', value: 'C'},
  10. {id: 'd', value: 'D'},
  11. {id: 'e', value: 'E'},
  12. {id: 'f', value: 'F'},
  13. ];
  14. const numColumns = 3;
  15. const size = Dimensions.get('window').width/numColumns;
  16.  
  17. class App extends Component {
  18. constructor(props) {
  19. //constructor to set default state
  20. super(props);
  21. this.state = {
  22. keyword: '',
  23. };
  24. }
  25. render() {
  26. return (
  27. <View>
  28.  
  29. <View style={styles.searchInput}>
  30. <TouchableOpacity style={{padding:15,right:0,position:'absolute'}} onPress={()=>'tes'}>
  31.  
  32. </TouchableOpacity>
  33. <TextInput
  34. placeholder="Search..."
  35. style={{paddingRight:50}}
  36. onChangeText={keyword => this.setState({ keyword })}
  37. />
  38. </View>
  39. <View style={styles.con}>
  40. <Text style={styles.textC}>Test</Text>
  41. <FlatList
  42. data={data}
  43. renderItem={({item}) => (
  44. <View style={styles.itemContainer}>
  45. <Text style={styles.item}>{item.value}</Text>
  46. </View>
  47. )}
  48. keyExtractor={item => item.id}
  49. numColumns={numColumns} />
  50. </View>
  51. </View>
  52. );
  53. }
  54. }
  55.  
  56. const styles = StyleSheet.create({
  57. itemContainer: {
  58. width: size,
  59. height: size,
  60. },
  61. item: {
  62. flex: 1,
  63. margin: 3,
  64. backgroundColor: '#97ff49',
  65. },
  66. con: {
  67. flex: 1,
  68. //justifyContent: 'center',
  69. alignItems: 'center',
  70. marginTop: 15
  71. },
  72. searchInput: {
  73. borderWidth:0.8,
  74. borderColor: '#234q42',
  75. marginHorizontal:15,
  76. paddingHorizontal:15,
  77. marginTop:10,
  78. backgroundColor:'#fff',
  79. borderRadius:4,
  80. fontSize: 12,
  81. flexDirection:'row',
  82. },
  83. textC: {
  84. fontSize: 17,
  85. fontWeight: 'bold',
  86. marginTop: 5,
  87. marginBottom: 5,
  88. color: 'aee314'
  89. }
  90. });
  91.  
  92.  
  93. export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement