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
// Animated Scroll Header Context | |
// imports react and Animated | |
import React, {createContext, useContext} from 'react'; | |
import {clamp} from 'react-native-redash'; | |
import {NativeScrollEvent, NativeSyntheticEvent, ViewStyle} from 'react-native'; | |
import Animated, { | |
Extrapolate, | |
interpolate, | |
useAnimatedScrollHandler, | |
useAnimatedStyle, |
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, { useCallback } from "react"; | |
import { ListRenderItem } from "react-native"; | |
type BaseProps<T extends unknown> = { | |
item: T; | |
}; | |
type UseRenderItemProps<T, P extends BaseProps<T>> = { | |
Component: React.ComponentType<P>; | |
componentProps: Omit<P, "item">; |
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, { useMemo } from "react"; | |
import { | |
ScrollView, | |
ScrollViewProps, | |
StyleSheet, | |
View, | |
ViewProps, | |
} from "react-native"; | |
type BaseProps<T> = T extends "scroll" |
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 { useCallback, useLayoutEffect, useState } from "react"; | |
import { useAsyncStorage } from "@react-native-async-storage/async-storage"; | |
const useGetFirstTime = () => { | |
const [firstTime, setFirstTime] = useState(false); | |
const { getItem, setItem } = useAsyncStorage("FirstTime"); | |
const readItemFromStorage = useCallback(async () => { | |
const item = await getItem(); | |
setFirstTime(!item); | |
}, [getItem]); |
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-native-gesture-handler/jestSetup'; | |
import mockAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock'; | |
require('react-native-reanimated/lib/reanimated2/jestUtils').setUpTests(); | |
jest.useFakeTimers(); | |
jest.mock('react-native-reanimated', () => { | |
const Reanimated = require('react-native-reanimated/mock'); |
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 {useCallback} from 'react'; | |
import {useFocusEffect} from '@react-navigation/native'; | |
import {ColorValue, StatusBar, StatusBarStyle, Platform} from 'react-native'; | |
const useFocusStatusBar = ( | |
barStyle: StatusBarStyle = 'dark-content', | |
translucent: boolean = true, | |
backgroundColor: ColorValue = 'transparent', | |
): void => { | |
useFocusEffect( |
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 {StatusBar} from 'react-native'; | |
import {useCallback} from 'use-memo-one'; | |
import {useFocusEffect} from '@react-navigation/native'; | |
import Animated, {runOnJS, useDerivedValue} from 'react-native-reanimated'; | |
const updateStatusBarStyle = ( | |
shared: Animated.SharedValue<number>, | |
maxNo: number, | |
) => { | |
'worklet'; |
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 {Platform, StyleSheet, TextStyle} from 'react-native'; | |
import {getDesignSize} from '@utils'; | |
type Weight = '700' | '600' | '500' | '400'; | |
const fonts = new Map<Weight, string>([ | |
['700' as const, Platform.select({default: '700' as const, android: 'Bold'})], | |
[ | |
'500' as const, |
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 { | |
useSharedValue, | |
useAnimatedScrollHandler, | |
} from 'react-native-reanimated'; | |
const useScrollHandler = () => { | |
const scrollY = useSharedValue(0); | |
const onScroll = useAnimatedScrollHandler(event => { | |
scrollY.value = event.contentOffset.y; | |
}); |
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 {PhoneNumberUtil} from 'google-libphonenumber'; | |
export const isPhoneNumber = (number?: string) => { | |
try { | |
if (!number) { | |
throw new Error('Phone number is required'); | |
} | |
if (number.length < 4) { | |
throw new Error('Phone number is too short'); | |
} |
NewerOlder