Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react native grid view

import React from 'react';
import { StyleSheet, View, Text } from 'react-native';
import { FlatGrid } from 'react-native-super-grid';

export default function Example() {
  const [items, setItems] = React.useState([
    { name: 'TURQUOISE', code: '#1abc9c' },
    { name: 'EMERALD', code: '#2ecc71' },
    { name: 'PETER RIVER', code: '#3498db' },
    { name: 'AMETHYST', code: '#9b59b6' },
    { name: 'WET ASPHALT', code: '#34495e' },
    { name: 'GREEN SEA', code: '#16a085' },
    { name: 'NEPHRITIS', code: '#27ae60' },
    { name: 'BELIZE HOLE', code: '#2980b9' },
    { name: 'WISTERIA', code: '#8e44ad' },
    { name: 'MIDNIGHT BLUE', code: '#2c3e50' },
    { name: 'SUN FLOWER', code: '#f1c40f' },
    { name: 'CARROT', code: '#e67e22' },
    { name: 'ALIZARIN', code: '#e74c3c' },
    { name: 'CLOUDS', code: '#ecf0f1' },
    { name: 'CONCRETE', code: '#95a5a6' },
    { name: 'ORANGE', code: '#f39c12' },
    { name: 'PUMPKIN', code: '#d35400' },
    { name: 'POMEGRANATE', code: '#c0392b' },
    { name: 'SILVER', code: '#bdc3c7' },
    { name: 'ASBESTOS', code: '#7f8c8d' },
  ]);

  return (
    <FlatGrid
      itemDimension={130}
      data={items}
      style={styles.gridView}
      // staticDimension={300}
      // fixed
      spacing={10}
      renderItem={({ item }) => (
        <View style={[styles.itemContainer, { backgroundColor: item.code }]}>
          <Text style={styles.itemName}>{item.name}</Text>
          <Text style={styles.itemCode}>{item.code}</Text>
        </View>
      )}
    />
  );
}

const styles = StyleSheet.create({
  gridView: {
    marginTop: 10,
    flex: 1,
  },
  itemContainer: {
    justifyContent: 'flex-end',
    borderRadius: 5,
    padding: 10,
    height: 150,
  },
  itemName: {
    fontSize: 16,
    color: '#fff',
    fontWeight: '600',
  },
  itemCode: {
    fontWeight: '600',
    fontSize: 12,
    color: '#fff',
  },
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery validator add method 
Javascript :: how to find duplicates in an array 
Javascript :: how to convert string to camel case in javascript 
Javascript :: stringify json javascript 
Javascript :: jqery first img src 
Javascript :: js retour à la ligne 
Javascript :: how to load link in new window using js 
Javascript :: moment js get french time 20:00:00 
Javascript :: what is node.js 
Javascript :: wait until something happens javascript 
Javascript :: pass multi variable in ajax 
Javascript :: javascript mouse over and mouse enter 
Javascript :: install react bootstrap 
Javascript :: react hooks componentdidmount 
Javascript :: two decimal places javascript 
Javascript :: javascript code for line break after comma 
Javascript :: not disabled jquery 
Javascript :: add image to ag-grid with react 
Javascript :: javascript size array 
Javascript :: Get the index of an Object in an Array in JavaScript 
Javascript :: convert an array to uppercase or lowercase js 
Javascript :: sort li elements with js 
Javascript :: check / unchecked a checkbox with jQuery 
Javascript :: what is json 
Javascript :: jquery add option if not exist 
Javascript :: sequelize array of strings 
Javascript :: javascript take picture from camera 
Javascript :: react app 
Javascript :: how to crash with js 
Javascript :: lodash swap array elements 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =