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 { useSafeAreaInsets } from 'react-native-safe-area-context' | |
import { useCallback, useLayoutEffect, useMemo, useReducer, useRef, useState } from 'react' | |
import { ActivityIndicator, Keyboard, Platform, Text, View, TextInput, useWindowDimensions } from 'react-native' | |
import Animated from 'react-native-reanimated' | |
const SearchBar = () => { | |
const inset = useSafeAreaInsets() | |
const [isFocused, toggle] = useReducer((s) => !s, false) | |
const ref = useRef<View>(null) | |
const rect = useRef({ width: 0, height: 0, x: 0, y: 0 }) |
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 { Stack } from 'expo-router'; | |
import { StyleSheet, Text, View, useWindowDimensions } from 'react-native'; | |
import Animated, { | |
Extrapolation, | |
interpolate, | |
useAnimatedRef, | |
useAnimatedStyle, | |
useScrollViewOffset, | |
} from 'react-native-reanimated'; | |
import { useSafeAreaInsets } from 'react-native-safe-area-context'; |
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
export const LazyScrollView = forwardRef(function LazyScrollView( | |
props: LazyScrollViewProps, | |
ref: ForwardedRef<FlashList<unknown[]>>, | |
): JSX.Element { | |
const {children, estimatedScrollViewSize, estimatedItemSize} = | |
props; | |
const data = isArray(children) ? children : Children.toArray(children); | |
// No specific reason for 2000, just a big number. Roughly 2x the screen size |
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 { useQueryClient } from "@tanstack/react-query"; | |
export default function useOptimisticUpdate() { | |
const queryClient = useQueryClient(); | |
return useCallback( | |
async (queryKey, updater) => { | |
await queryClient.cancelQueries({ queryKey }); |
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 Breakpoints from './Breakpoints'; | |
import { css, cx } from '@emotion/css'; | |
import { HTMLAttributes, forwardRef } from 'react'; | |
export type StackProps = { | |
adaptive?: true; | |
alignCenter?: true; | |
center?: true; | |
children?: React.ReactNode; | |
className?: 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 { FlashList, FlashListProps } from "@shopify/flash-list"; | |
import React, { forwardRef, ReactElement } from "react"; | |
type ListProps<T> = Omit<FlashListProps<T>, "children"> & { as?: "list" }; | |
type ScrollViewProps<T> = Omit< | |
FlashListProps<T>, | |
"children" | "data" | "renderItem" | |
> & { | |
as?: "scroll-view"; | |
children: React.ReactNode | React.ReactNode[]; |
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
{ | |
"explorer.fileNesting.enabled": true, | |
"explorer.fileNesting.patterns": { | |
"*.js": "${capture}.js.map, ${capture}.d.ts, ${capture}.d.ts.map", | |
"*.ts": "$(capture).test.ts, $(capture).test.tsx, $(capture).test.node.ts, $(capture).test.node.tsx, $(capture).test.native.ts, $(capture).test.native.tsx, $(capture).test.ios.ts, $(capture).test.ios.tsx, $(capture).test.web.ts, $(capture).test.web.tsx, $(capture).test.android.ts, $(capture).test.android.tsx, ${capture}.native.tsx, ${capture}.ios.tsx, ${capture}.android.tsx, ${capture}.web.tsx, ${capture}.native.ts, ${capture}.ios.ts, ${capture}.android.ts, ${capture}.web.ts, ${capture}.native.js, ${capture}.ios.js, ${capture}.android.js, ${capture}.web.js, ${capture}.native.jsx, ${capture}.ios.jsx, ${capture}.android.jsx, ${capture}.web.jsx", | |
"*.tsx": "$(capture).test.ts, $(capture).test.tsx, $(capture).test.node.ts, $(capture).test.node.tsx, $(capture).test.native.ts, $(capture).test.native.tsx, $(capture).test.ios.ts, $(capture).test.ios.tsx, $(captur |
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
function Favorite({ | |
postId = null, | |
isLiked: _isLiked = false, | |
numberOfLikes: _numberOfLikes = 0, | |
}) { | |
const [isLiked, setIsLiked] = React.useState(_isLiked); | |
const [numberOfLikes, setNumberOfLikes] = React.useState(_numberOfLikes ?? 0); | |
const likeDebounceRef = React.useRef(); | |
const lastIsLikedStateRef = React.useRef(_isLiked); |
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 UIKit | |
import SwiftUI | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let box = UIView() | |
box.frame = CGRect(x: (view.bounds.width / 2.0) - 100.0, y: 0.0, width: 100.0, height: 100.0) | |
box.backgroundColor = .systemGreen |
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: screenHeight, width: screenWidth } = Dimensions.get('window'); | |
const EACH_HEIGHT_UNIT = screenHeight / 100 | |
const EACH_WIDTH_UNIT = screenWidth / 100 | |
/** | |
* device height percentage | |
*/ |
NewerOlder