Skip to content

Instantly share code, notes, and snippets.

View melihmucuk's full-sized avatar

Melih Mucuk melihmucuk

View GitHub Profile
@melihmucuk
melihmucuk / home.js
Created August 29, 2016 23:17
react native animate listview rows while scrolling
import React, { Component } from 'react';
import {
StyleSheet,
View,
Text,
ListView
} from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';
import * as Animatable from 'react-native-animatable';
renderPost: function(post) {
return (
<View style={styles.container}>
<Image
source={{uri: post.screenshot_url['300px']}}
style={styles.thumbnail}
/>
<View style={styles.rightContainer}>
<Text style={styles.title}>{post.name}</Text>
<Text style={styles.hunter}>{post.user.username}</Text>
render: function() {
if (!this.state.loaded) {
return this.renderLoadingView();
}
return (
<ListView
dataSource={this.state.dataSource}
renderRow={this.renderPost}
automaticallyAdjustContentInsets={false}
renderLoadingView: function() {
return (
<View style={styles.container}>
<Text>
Loading...
</Text>
</View>
);
}
componentDidMount: function() {
Api.getToken().then((response) => {
this.setState({
token: response.access_token,
});
}).then(()=>{
Api.getAllPosts(this.state.token,0).then((response)=> {
this.setState({
dataSource : this.state.dataSource.cloneWithRows(response.posts),
loaded : true
getInitialState: function() {
return {
token: '',
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2,
}),
loaded: false,
};
}
var React = require('react-native');
var Api = require('./App/api')
var {
AppRegistry,
StyleSheet,
Image,
ListView,
Text,
View,
'use strict';
var React = require('react-native');
var Api = require('./App/api')
var {
AppRegistry,
StyleSheet,
Image,
ListView,
@melihmucuk
melihmucuk / styles.js
Created July 5, 2015 22:35
React Native Listview Style
var styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#ecf0f1',
},
rightContainer: {
flex: 1,
@melihmucuk
melihmucuk / index.ios.js
Last active August 29, 2015 14:24
React Native View States
var PHReact = React.createClass({
getInitialState: function() {
console.log("initial state");
return {
token:"",
};
},
componentWillMount: function(){
console.log("component will mount");