-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into rohan/admiring-tokens
- Loading branch information
Showing
400 changed files
with
7,104 additions
and
2,377 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { useCallback, useEffect, useRef } from 'react'; | ||
import { Animated } from 'react-native'; | ||
import { RefreshIcon } from 'src/icons/RefreshIcon'; | ||
|
||
import { IconContainer } from '~/components/IconContainer'; | ||
import { useToastActions } from '~/contexts/ToastContext'; | ||
import { contexts } from '~/shared/analytics/constants'; | ||
|
||
type AnimatedRefreshIconProps = { | ||
onSync: () => void; | ||
onRefresh: () => void; | ||
isSyncing: boolean; | ||
eventElementId: string; | ||
eventName: string; | ||
}; | ||
|
||
export function AnimatedRefreshIcon({ | ||
onSync, | ||
onRefresh, | ||
isSyncing, | ||
eventElementId, | ||
eventName, | ||
}: AnimatedRefreshIconProps) { | ||
const { pushToast } = useToastActions(); | ||
|
||
const handleSync = useCallback(async () => { | ||
if (isSyncing) return; | ||
|
||
await onSync(); | ||
onRefresh(); | ||
pushToast({ | ||
message: 'Successfully refreshed your collection', | ||
withoutNavbar: true, | ||
}); | ||
}, [isSyncing, onSync, onRefresh, pushToast]); | ||
|
||
const spinValue = useRef(new Animated.Value(0)).current; | ||
|
||
const spin = useCallback(() => { | ||
spinValue.setValue(0); | ||
Animated.timing(spinValue, { | ||
toValue: 1, | ||
duration: 1000, | ||
useNativeDriver: true, | ||
}).start(({ finished }) => { | ||
// Only repeat the animation if it completed (wasn't interrupted) and isSyncing is still true | ||
if (finished && isSyncing) { | ||
spin(); | ||
} | ||
}); | ||
}, [isSyncing, spinValue]); | ||
|
||
const spinAnimation = spinValue.interpolate({ | ||
inputRange: [0, 1], | ||
outputRange: ['0deg', '360deg'], | ||
}); | ||
|
||
useEffect(() => { | ||
if (isSyncing) { | ||
spin(); | ||
} else { | ||
spinValue.stopAnimation(); | ||
} | ||
}, [isSyncing, spin, spinValue]); | ||
|
||
return ( | ||
<IconContainer | ||
size="sm" | ||
onPress={handleSync} | ||
icon={ | ||
<Animated.View style={{ transform: [{ rotate: spinAnimation }] }}> | ||
<RefreshIcon /> | ||
</Animated.View> | ||
} | ||
eventElementId={eventElementId} | ||
eventName={eventName} | ||
eventContext={contexts.Posts} | ||
/> | ||
); | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import clsx from 'clsx'; | ||
import { View } from 'react-native'; | ||
|
||
import { GalleryElementTrackingProps } from '~/shared/contexts/AnalyticsContext'; | ||
|
||
import { GalleryTouchableOpacity } from './GalleryTouchableOpacity'; | ||
import { Typography } from './Typography'; | ||
|
||
type BottomSheetRowProps = { | ||
icon?: React.ReactNode; | ||
text: string; | ||
onPress: () => void; | ||
style?: React.ComponentProps<typeof GalleryTouchableOpacity>['style']; | ||
isConfirmationRow?: boolean; | ||
fontWeight?: 'Regular' | 'Bold'; | ||
rightIcon?: React.ReactNode; | ||
eventContext: GalleryElementTrackingProps['eventContext']; | ||
}; | ||
|
||
export function BottomSheetRow({ | ||
icon, | ||
text, | ||
onPress, | ||
style, | ||
isConfirmationRow, | ||
fontWeight = 'Regular', | ||
rightIcon, | ||
eventContext, | ||
}: BottomSheetRowProps) { | ||
return ( | ||
<GalleryTouchableOpacity | ||
onPress={onPress} | ||
eventElementId="Bottom Sheet Row" | ||
eventName="Bottom Sheet Row Press" | ||
eventContext={eventContext} | ||
properties={{ selection: text }} | ||
style={style} | ||
> | ||
<View className="bg-offWhite dark:bg-black-800 p-3 flex-row items-center"> | ||
{icon && <View className="mr-2">{icon}</View>} | ||
<Typography | ||
font={{ family: 'ABCDiatype', weight: fontWeight }} | ||
className={clsx( | ||
'text-sm', | ||
isConfirmationRow ? 'text-red' : 'text-black-900 dark:text-offWhite' | ||
)} | ||
> | ||
{text} | ||
</Typography> | ||
{rightIcon && <View className="ml-auto">{rightIcon}</View>} | ||
</View> | ||
</GalleryTouchableOpacity> | ||
); | ||
} |
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
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
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
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
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
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
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
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
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
Oops, something went wrong.