Skip to content

Instantly share code, notes, and snippets.

@hgale
hgale / History.js
Created June 4, 2017 16:43
react native class gist
import React, { Component } from 'react'
import { StyleSheet, Text, View } from 'react-native';
export default class History extends Component {
render() {
return (
<View style={styles.container}>
<Text>History!</Text>
</View>
);
1 RCT_EXPORT_METHOD(startPostingLocationTo:(NSString *)url everyInterval:(NSInteger)interval) {
2 if (!url || url.length == 0 || interval <= 0) {
3 return;
4 }
5
6 self.url = [NSURL URLWithString:url];
7
8 double seconds = interval / 1000.0;
9
10 if (self.pollingTimer) {
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)
launchOptions {
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.pausesLocationUpdatesAutomatically = NO;
self.locationManager.allowsBackgroundLocationUpdates = YES;
self.locationManager.delegate=self;
self.locationManager.desiredAccuracy=kCLLocationAccuracyBest;
[self.locationManager requestAlwaysAuthorization];
return YES;
}
import BackgroundTimer from 'react-native-background-timer'
const intervalId = BackgroundTimer.setInterval(() => {
let now = new Date()
let data = JSON.stringify({'lat': 20, 'long': 20, 'time': now })
fetch('http://192.168.107.24:8080', {
method: 'POST',
headers: {
'Accept': 'application/json',
import pole from 'pole'
this.setState({
pollLocation: pole({interval:
LOCATION_POLL_FREQUENCY}, (
callback) => {
let now = new Date()
let data = JSON.stringify({'lat': 20,
'long': 20, 'time': now })
fetch('http://localhost:8080', {
import React from 'react'
import { Text, View, Button, Dimensions, Image, ScrollView } from 'react-native'
import { FlickrImages } from './FlickrImages'
import { BgView } from './Background'
import style from './Style'
class HomeScreen extends React.Component {
renderCells (data) {
import React from 'react'
import { Image, View } from 'react-native'
import bgImage from './assets/bg_transparent.png'
import style from './Style'
export const BaseView = (props) => {
return (
<View
{...props}
import React from 'react'
import { View, Image } from 'react-native'
import style from './Style'
const ImageRow = (props) => (
<View style={style.cellContainer}>
<Image style={style.imageContainer} source={{uri:props.uri}}/>
</View>
import React from 'react'
import { ListView } from 'react-native'
import { FlickrImages } from './FlickrImages'
import ImageRow from './ImageRow'
import { BgView } from './Background'
import style from './Style'
class HomeScreen extends React.Component {
constructor(props) {
import React from 'react'
import { ListView } from 'react-native'
import { FlickrImages } from './FlickrImages'
import ImageRow from './ImageRow'
import { BgView } from './Background'
import style from './Style'
class HomeScreen extends React.Component {
constructor(props) {