Skip to content

Instantly share code, notes, and snippets.

@dereknelson
dereknelson / AppNavigator
Last active February 26, 2018 23:23
stack navigator issue
import React, { Component } from 'react';
import { AppState } from 'react-native';
import { addNavigationHelpers, NavigationActions } from 'react-navigation';
import { connect } from 'react-redux';
import { LoginScreen } from '../screens';
import Navigator from './Navigator';
import OnboardingStackNavigator from '../screens/auth/onboarding/BottomTabNavigator';
import { addListener } from '../redux/store';
@dereknelson
dereknelson / alphabetizedList.js
Created March 29, 2018 18:03
Alphabetized List implementation
import React, { Component, } from 'react';
import { View, Text, TouchableOpacity, FlatList, ListItem, Image, TextInput, Dimensions,
Animated, StyleSheet, SectionList, PanResponder, PixelRatio, ScrollView } from 'react-native';
import sectionListGetItemLayout from 'react-native-section-list-get-item-layout'
var { height, width } = Dimensions.get('window')
/* this component is re-used between displaying the friends/groups and being able to pick them in metoo posts, so there are a few different if statements that
@dereknelson
dereknelson / NotDumbImage.js
Last active July 11, 2019 21:36
Entirety of image caching
import React, { Component, PureComponent } from 'react';
import { connect } from 'react-redux';
import { View, ActivityIndicator, Image, Platform } from 'react-native';
import { FileSystem } from 'expo'
import md5 from 'js-md5';
const ios = Platform.OS == 'ios'
import { downloadImage, removeFromDownloading } from './NotDumbImageActions';
import { imgDownloadIsOld } from './cacheRedux';
@dereknelson
dereknelson / NavBar.js
Created May 9, 2018 00:34
Navigation Wrapper for screens
import React, { Component, PureComponent } from 'react';
import { View, Text, FlatList, TouchableOpacity, RefreshControl, Image, Alert, Dimensions, StyleSheet, Platform, Keyboard } from 'react-native';
import { SafeAreaView } from 'react-navigation'
import { connect } from 'react-redux'
import Colors from '../../../constants/Colors';
import BackIcon from 'react-native-vector-icons/Ionicons';
const ios = Platform.OS == 'ios'
@dereknelson
dereknelson / ViewRequisition.js
Created January 6, 2019 19:44
ViewRequisition help
import React, { Component } from 'react';
import { StyleSheet, ListView, AsyncStorage, Alert, FlatList } from "react-native";
import {
Container,
Body,
Content,
Header,
Left,
Right,
List,
@dereknelson
dereknelson / backgroundLocationTasks.js
Last active September 3, 2019 18:39
background location config
import { Permissions, Location, TaskManager, Notifications } from 'expo'
import axios from 'axios'
export const BACKGROUND_LOCATION_UPDATES_TASK = 'background-location-updates'
export const BACKGROUND_GEOFENCING_UPDATES_TASK = 'background-geofencing-updates'
const geofences = [] //I get this from the server, omitted for sake of clarity
const url = 'api.metoo.io'
TaskManager.defineTask(BACKGROUND_LOCATION_UPDATES_TASK, handleLocationUpdate)
TaskManager.defineTask(BACKGROUND_GEOFENCING_UPDATES_TASK, handleGeofencingUpdate)
@dereknelson
dereknelson / AppDelegate.m
Created April 17, 2019 18:22
AppDelegate
// Copyright 2015-present 650 Industries. All rights reserved.
#import "AppDelegate.h"
#import <React/RCTPushNotificationManager.h>
#import <RadarSDK/RadarSDK.h>
@implementation AppDelegate
// Put your app delegate methods here. Remember to also call methods from EXStandaloneAppDelegate superclass
// in order to keep Expo working. See example below.
@dereknelson
dereknelson / store.js
Created April 26, 2019 00:39
redux profiler
//...store logic
// profiler for redux actions
const userTiming = (store) => (next) => (action) => {
if (performance.mark === undefined) return next(action)
performance.mark(`${action.type}_start`);
const result = next(action);
performance.mark(`${action.type}_end`);
performance.measure(`${action.type}`,`${action.type}_start`,`${action.type}_end`,)
return result
{
"name": "convertnote",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"start": "nodemon --exec babel-node src/server.js",
"build": "babel src --out-dir dist",
"serve": "node dist/server.js"
},
@dereknelson
dereknelson / chat.js
Last active June 18, 2019 22:31
sendbird mounting
var sb = null;
export default class Chat extends Component {
constructor(props) {
super(props);
sb = SendBird.getInstance();
this.state = {
channel: props.channel, channelUrl: props.channelUrl, name: props.name, messageQuery: '', channel: '', name: '', messages: props.channel.messageList || [],
};
}