Skip to content

Instantly share code, notes, and snippets.

View mariodev12's full-sized avatar

Mario mariodev12

View GitHub Profile
@mariodev12
mariodev12 / README-Template.md
Created February 5, 2017 21:40 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
@mariodev12
mariodev12 / App.js
Created February 10, 2017 08:26
Search Bar with a ListView using an API
import React, {Component} from 'react'
import {
Text,
StyleSheet,
View,
ListView,
TouchableHighlight,
Dimensions,
Image,
Animated,
@mariodev12
mariodev12 / App.js
Last active February 10, 2017 15:29
import React, {Component} from 'react'
import { Text, InputText, View, StyleSheet, Dimensions } from 'react-native'
const {width, height} = Dimensions.get('window')
export default class App extends Component {
render(){
<View style={styles.container}>
<InputText
style={styles.inputText}
export default class App extends Component {
constructor(){
super()
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2})
this.state = {
dataSource: ds.cloneWithRows([]),
rawData: ''
}
}
<ListView
enableEmptySections={true}
renderRow={this.renderRow.bind(this)}
dataSource={this.state.dataSource}
/>
renderRow(rowData){
return (
<TouchableHighlight style={styles.containerCell}>
<View>
<View style={styles.footerContainer}>
<View style={styles.footerTextContainer}>
<Text style={styles.text}>{rowData.name}</Text>
<Text style={[styles.text, styles.textTitle]}>{rowData.number}</Text>
<Text style={[styles.text, styles.textBy]}>By {rowData.airdate}</Text>
</View>
filterSearch(text){
this.setState({text})
let newData = this.dataFilter(text, this.state.rawData);
this.setState({
dataSource: this.state.dataSource.cloneWithRows(newData),
isLoaded: true,
empty: false
})
}
<TextInput
style={styles.textInput}
onChangeText={(text) => this.filterSearch(text)}
value={this.state.text}
/>