This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Text } from 'react-native'; | |
const disableFontScaling = () => { | |
Text.defaultProps = Text.defaultProps || {}; | |
Text.defaultProps.allowFontScaling = false; | |
}; | |
export default disableFontScaling; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Color from 'color'; | |
export default (color, alpha) => Color(color).alpha(alpha).string(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numeral from 'numeral'; | |
/** | |
* This function formats a Number into a USD currency | |
* | |
* @param {number} amount - A number (or string that can be cast as a number) | |
* @param {boolean} includeCents - Set to true to include cents in the result | |
* @return {string} A string formatted in USD currency | |
* | |
* @example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mixHexColors = (color1, color2, weight = 50) => { | |
function d2h(d) { return d.toString(16); } // convert a decimal value to hex | |
function h2d(h) { return parseInt(h, 16); } // convert a hex value to decimal | |
let color = '#'; | |
for (let i = 0; i <= 5; i += 2) { // loop through each of the 3 hex pairs—red, green, and blue | |
const v1 = h2d(color1.replace('#', '').substr(i, 2)); // extract the current pairs | |
const v2 = h2d(color2.replace('#', '').substr(i, 2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const small = '(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|v[.]?|via|vs[.]?)'; | |
const punctuation = '([!"#$%&\'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]*)'; | |
const titleCase = (title) => { | |
const parts = []; | |
const split = /[:.;?!] |(?: |^)["Ò]/g; | |
let index = 0; | |
/* eslint-disable no-constant-condition */ | |
while (true) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useRef, useState } from 'react'; | |
import { RefreshControl } from 'react-native'; | |
const useRefreshControl = (refreshesRequested = 1) => { | |
const refreshesCompleted = useRef(0); | |
const [isRefreshing, setIsRefreshing] = useState(false); | |
const handleRefreshStart = () => { | |
refreshesCompleted.current = 0; | |
setIsRefreshing(true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { compose, lifecycle, withProps, withPropsOnChange, withStateHandlers } from 'recompose'; | |
export default compose( | |
withProps(() => ({ | |
measureRef: React.createRef(), | |
})), | |
withPropsOnChange(['measureRef'], ({ measureRef }) => ({ | |
elementToMeasure: { | |
ref: measureRef, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useContext, useRef } from 'react'; | |
import { KeyboardAvoidingView, StatusBar, StyleSheet, View } from 'react-native'; | |
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'; | |
import { SafeAreaView } from 'react-navigation'; | |
import withMeasurements from '../utilities/withMeasurements'; | |
import { utils } from '../theme'; | |
import ActivityIndicator from './ActivityIndicator'; | |
export const ScreenViewContext = React.createContext({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Input } from 'react-native-elements'; | |
import { Field } from 'formik'; | |
import { utils } from '../theme'; | |
import MoneyInput from './MoneyInput'; | |
import PickerSelect from './PickerSelect'; | |
import Text from './Text'; | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useRef } from 'react'; | |
import { Animated } from 'react-native'; | |
// A hook for using react-native's Animated.Value | |
// Example usages: | |
// | |
// const animatedValue = useAnimatedValue(props.value) | |
// | |
// const animatedValue = useAnimatedValue(props.value, { method: 'spring' }) | |
// |