Skip to content

Instantly share code, notes, and snippets.

View gpeal's full-sized avatar

Gabriel Peal gpeal

View GitHub Profile
@gpeal
gpeal / Diamond.json
Created December 7, 2016 00:52
Lottie Samples
{"assets":[],"v":"4.3.1","ddd":0,"layers":[{"ddd":0,"ind":0,"ty":4,"nm":"Shape Layer 1","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":1,"y":0},"n":"0p833_0p833_1_0","t":16,"s":[20,6,0],"e":[20,31,0],"to":[0,0,0],"ti":[0,0,0]},{"t":30}]},"a":{"k":[0,0,0]},"s":{"k":[{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[1,1,1],"y":[0,0,1]},"n":["0p833_0p833_1_0","0p833_0p833_1_0","0p833_0p833_1_1"],"t":16,"s":[0,0,100],"e":[10,10,100]},{"t":24}]}},"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"k":[21.164,21.164]},"p":{"k":[0,0]},"nm":"Ellipse Path 1","closed":true},{"d":1,"ty":"el","s":{"k":[21.164,21.164]},"p":{"k":[0,0]},"nm":"Ellipse Path 1","closed":true},{"ty":"fl","fillEnabled":true,"c":{"k":[0,0.48,0.44,1]},"o":{"k":100},"nm":"Fill 1"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1"}],"bounds":{"l":-15,"t":-15,
@gpeal
gpeal / buildLayoutTree.js
Last active April 23, 2017 21:26
Airbnb React Native findOffscreenViews (written by Leland Richardson)
/* eslint-disable no-underscore-dangle, no-param-reassign, no-restricted-syntax */
import { UIManager, findNodeHandle } from 'react-native';
const name = fn => fn.displayName || fn.name || 'UnknownComponent';
const nodeName = (component) => name(component._currentElement.type);
const isHost = component => !!component._renderedChildren;
const isText = component => typeof component._stringText === 'string';
const { hasOwnProperty } = Object.prototype;
// This makes a node with all of the layout and react information we need
import React, { PureComponent } from 'react';
import BasicRow from 'airbnb-dls/lib/BasicRow';
interface Props {
thisisatestprop: string;
}
class TypeScriptScreen extends PureComponent<Props, {}> {
render() {
@gpeal
gpeal / React Native at Scale
Created November 14, 2017 08:34
CraftConf 2018 Talk - Gabriel Peal
For the past two years, Airbnb has been shipping React Native along side native code in their Android and iOS apps. Learn how they maintained a high quality bar, built a world class developer experience, and respected Android and iOS platform paradigms and architectures as they scaled from 0 to 300,000 lines of React Native code.
{"v":"5.1.9","fr":30,"ip":0,"op":120,"w":375,"h":375,"nm":"City_NoMattes","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Buildings 14 c","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[246.089,273.206,0],"ix":2},"a":{"a":0,"k":[245.839,534.206,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0,0,0],"y":[1,1,1]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,16.667]},"n":["0_1_0p167_0p167","0_1_0p167_0p167","0_1_0p167_16p667"],"t":21,"s":[0,0,100],"e":[100,100,100]},{"t":32}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0.634,0],[0,-0.635],[-0.634,0],[0,0.634]],"o":[[-0.634,0],[0,0.634],[0.634,0],[0,-0.635]],"v":[[16.086,168.355],[14.936,169.506],[16.086,170.656],[17.238,169.506]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.999999940162,0.999999940162,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","
basicRow {
id("settings")
title(R.string.settings)
subtitleText(R.string.settings_subtitle)
onClickListener { navigateTo(SETTINGS) }
}
override fun EpoxyController.buildModels() {
header {
id("marquee")
title(R.string.edit_profile)
}
inputRow {
id("first name")
title(R.string.first_name)
text(firstName)
onChange {
BasicRow.epoxyModel(
content: BasicRow.Content(
titleText: "Settings",
subtitleText: "Optional subtitle"),
style: .standard,
dataID: "settings",
selectionHandler: { [weak self] _, _, _ in
self?.navigate(to: .settings)
})
@gpeal
gpeal / MvRxFragment.kt
Created July 24, 2018 06:27
MvRxFragmentExtension
fun <S : MvRxState> MvRxViewModel<S>.subscribe(
shouldUpdate: ((S, S) -> Boolean)? = null,
observerScheduler: Scheduler = AndroidSchedulers.mainThread(),
subscriber: ((S) -> Unit)? = null
) = subscribe(this@MvRxFragment, shouldUpdate, observerScheduler, subscriber ?: { if (readyToInvalidate()) invalidate() })
override func itemModel(forDataID dataID: DemoDataID) -> EpoxyableModel? {
switch dataID {
case .header:
return DocumentMarquee.epoxyModel(
content: DocumentMarquee.Content(titleText: "Edit Profile"),
style: .standard,
dataID: DemoDataID.header)
case .inputRow:
return InputRow.epoxyModel(
content: InputRow.Content(