View useGetFirstTime.js
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]); |
View setupJest.js
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'); |
View AnimatedScrollHeader.tsx
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, |
View useFocusStatusBar.tsx
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( |
View useAnimatedStatusBar.ts
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'; |
View Fonts.ts
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, |
View useScrollHandler.ts
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; | |
}); |
View useRenderItem.tsx
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, {ComponentType} from 'react'; | |
import {ListRenderItem} from 'react-native'; | |
import {useCallback} from 'use-memo-one'; | |
type BaseProps<ItemType> = { | |
item: ItemType; | |
}; | |
const useRenderItem = <ItemType, P extends BaseProps<ItemType>>( | |
RenderItem: ComponentType<P>, |
View phone-validation.ts
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'); | |
} |
View pixel.ts
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 {Dimensions} from 'react-native'; | |
const {height: SCREEN_HEIGHT, width: SCREEN_WIDTH} = Dimensions.get('window'); | |
const designSize = {width: 390, height: 844}; | |
const CURRENT_RESOLUTION = Math.sqrt( | |
SCREEN_HEIGHT * SCREEN_HEIGHT + SCREEN_WIDTH * SCREEN_WIDTH, | |
); | |
const DESIGN_RESOLUTION = Math.sqrt( | |
designSize.height * designSize.height + designSize.width * designSize.width, |
NewerOlder