diff --git a/src/App.native.tsx b/src/App.native.tsx index 026f6079b1..a6ec93d313 100644 --- a/src/App.native.tsx +++ b/src/App.native.tsx @@ -16,7 +16,6 @@ import * as Sentry from '@sentry/react-native' import {Provider as HideBottomBarBorderProvider} from '#/lib/hooks/useHideBottomBarBorder' import {QueryProvider} from '#/lib/react-query' -import {s} from '#/lib/styles' import {ThemeProvider} from '#/lib/ThemeContext' import {Provider as TranslateOnDeviceProvider} from '#/lib/translation' import I18nProvider from '#/locale/i18nProvider' @@ -58,7 +57,7 @@ import {Provider as StarterPackProvider} from '#/state/shell/starter-pack' import {Provider as HiddenRepliesProvider} from '#/state/threadgate-hidden-replies' import {TestCtrls} from '#/view/com/testing/TestCtrls' import {Shell} from '#/view/shell' -import {ThemeProvider as Alf} from '#/alf' +import {atoms as a, ThemeProvider as Alf} from '#/alf' import {useColorModeTheme} from '#/alf/util/useColorModeTheme' import {Provider as ContextMenuProvider} from '#/components/ContextMenu' import {useStarterPackEntry} from '#/components/hooks/useStarterPackEntry' @@ -175,7 +174,7 @@ function InnerApp() { + style={a.h_full}> diff --git a/src/analytics/index.tsx b/src/analytics/index.tsx index 3d39f464cd..d6b1f55c81 100644 --- a/src/analytics/index.tsx +++ b/src/analytics/index.tsx @@ -110,6 +110,7 @@ const Context = createContext({ }, }, }) +Context.displayName = 'AnalyticsContext' /** * Ensures that deviceId is set and migrated from legacy storage. Handled on diff --git a/src/components/PostControls/BookmarkButton.tsx b/src/components/PostControls/BookmarkButton.tsx index 2e56d13f4f..ba6ad18ff8 100644 --- a/src/components/PostControls/BookmarkButton.tsx +++ b/src/components/PostControls/BookmarkButton.tsx @@ -136,6 +136,8 @@ export const BookmarkButton = memo(function BookmarkButton({ - + ) }) diff --git a/src/components/PostControls/PostControlButton.tsx b/src/components/PostControls/PostControlButton.tsx index 9a24eb9173..3ea85e2811 100644 --- a/src/components/PostControls/PostControlButton.tsx +++ b/src/components/PostControls/PostControlButton.tsx @@ -130,8 +130,11 @@ export function PostControlButtonText({style, ...props}: TextProps) { { const ax = useAnalytics() + const t = useTheme() const {t: l} = useLingui() const {openComposer} = useOpenComposer() const {feedDescriptor} = useFeedFeedbackContext() @@ -270,6 +271,8 @@ let PostControls = ({ requireAuth(() => onPressToggleLike())} label={ post.viewer?.like @@ -296,10 +299,14 @@ let PostControls = ({ hasBeenToggled={hasLikeIconBeenToggled} /> ( + + {formatPostStatCount(count)} + + )} /> diff --git a/src/lib/custom-animations/CountWheel.tsx b/src/lib/custom-animations/CountWheel.tsx index e2c206078c..698df0e49d 100644 --- a/src/lib/custom-animations/CountWheel.tsx +++ b/src/lib/custom-animations/CountWheel.tsx @@ -8,10 +8,7 @@ import Animated, { } from 'react-native-reanimated' import {decideShouldRoll} from '#/lib/custom-animations/util' -import {s} from '#/lib/styles' -import {Text} from '#/view/com/util/text/Text' -import {atoms as a, useTheme} from '#/alf' -import {useFormatPostStatCount} from '#/components/PostControls/util' +import {atoms as a} from '#/alf' const animationConfig = { duration: 400, @@ -87,89 +84,66 @@ function ExitingDown() { } export function CountWheel({ - likeCount, - big, - isLiked, + count, + isToggled, hasBeenToggled, + renderCount, }: { - likeCount: number - big?: boolean - isLiked: boolean + count: number + isToggled: boolean hasBeenToggled: boolean + renderCount: (props: {count: number}) => React.ReactNode }) { - const t = useTheme() const shouldAnimate = !useReducedMotion() && hasBeenToggled - const shouldRoll = decideShouldRoll(isLiked, likeCount) + const shouldRoll = decideShouldRoll(isToggled, count) // Incrementing the key will cause the `Animated.View` to re-render, with the newly selected entering/exiting // animation // The initial entering/exiting animations will get skipped, since these will happen on screen mounts and would // be unnecessary const [key, setKey] = useState(0) - const [prevCount, setPrevCount] = useState(likeCount) - const prevIsLiked = useRef(isLiked) - const formatPostStatCount = useFormatPostStatCount() - const formattedCount = formatPostStatCount(likeCount) - const formattedPrevCount = formatPostStatCount(prevCount) + const [prevCount, setPrevCount] = useState(count) + const prevIsToggled = useRef(isToggled) useEffect(() => { - if (isLiked === prevIsLiked.current) { + if (isToggled === prevIsToggled.current) { return } - const newPrevCount = isLiked ? likeCount - 1 : likeCount + 1 + const newPrevCount = isToggled ? count - 1 : count + 1 setKey(prev => prev + 1) setPrevCount(newPrevCount) - prevIsLiked.current = isLiked - }, [isLiked, likeCount]) + prevIsToggled.current = isToggled + }, [isToggled, count]) const enteringAnimation = shouldAnimate && shouldRoll - ? isLiked + ? isToggled ? EnteringUp : EnteringDown : undefined const exitingAnimation = shouldAnimate && shouldRoll - ? isLiked + ? isToggled ? ExitingUp : ExitingDown : undefined return ( - {likeCount > 0 ? ( + {count > 0 ? ( - - {formattedCount} - + {renderCount({count})} - {shouldAnimate && (likeCount > 1 || !isLiked) ? ( + {shouldAnimate && (count > 1 || !isToggled) ? ( - - {formattedPrevCount} - + {renderCount({count: prevCount})} ) : null} diff --git a/src/lib/custom-animations/CountWheel.web.tsx b/src/lib/custom-animations/CountWheel.web.tsx index c5ca71e9bd..446dab1dd8 100644 --- a/src/lib/custom-animations/CountWheel.web.tsx +++ b/src/lib/custom-animations/CountWheel.web.tsx @@ -3,10 +3,6 @@ import {View} from 'react-native' import {useReducedMotion} from 'react-native-reanimated' import {decideShouldRoll} from '#/lib/custom-animations/util' -import {s} from '#/lib/styles' -import {Text} from '#/view/com/util/text/Text' -import {atoms as a, useTheme} from '#/alf' -import {useFormatPostStatCount} from '#/components/PostControls/util' const animationConfig = { duration: 400, @@ -35,50 +31,46 @@ const exitingDownKeyframe = [ ] export function CountWheel({ - likeCount, - big, - isLiked, + count, + isToggled, hasBeenToggled, + renderCount, }: { - likeCount: number - big?: boolean - isLiked: boolean + count: number + isToggled: boolean hasBeenToggled: boolean + renderCount: (props: {count: number}) => React.ReactNode }) { - const t = useTheme() const shouldAnimate = !useReducedMotion() && hasBeenToggled - const shouldRoll = decideShouldRoll(isLiked, likeCount) + const shouldRoll = decideShouldRoll(isToggled, count) const countView = useRef(null) const prevCountView = useRef(null) - const [prevCount, setPrevCount] = useState(likeCount) - const prevIsLiked = useRef(isLiked) - const formatPostStatCount = useFormatPostStatCount() - const formattedCount = formatPostStatCount(likeCount) - const formattedPrevCount = formatPostStatCount(prevCount) + const [prevCount, setPrevCount] = useState(count) + const prevIsToggled = useRef(isToggled) useEffect(() => { - if (isLiked === prevIsLiked.current) { + if (isToggled === prevIsToggled.current) { return } - const newPrevCount = isLiked ? likeCount - 1 : likeCount + 1 + const newPrevCount = isToggled ? count - 1 : count + 1 if (shouldAnimate && shouldRoll) { countView.current?.animate?.( - isLiked ? enteringUpKeyframe : enteringDownKeyframe, + isToggled ? enteringUpKeyframe : enteringDownKeyframe, animationConfig, ) prevCountView.current?.animate?.( - isLiked ? exitingUpKeyframe : exitingDownKeyframe, + isToggled ? exitingUpKeyframe : exitingDownKeyframe, animationConfig, ) setPrevCount(newPrevCount) } - prevIsLiked.current = isLiked - }, [isLiked, likeCount, shouldAnimate, shouldRoll]) + prevIsToggled.current = isToggled + }, [isToggled, count, shouldAnimate, shouldRoll]) - if (likeCount < 1) { + if (count < 1) { return null } @@ -87,34 +79,15 @@ export function CountWheel({ - - {formattedCount} - + {renderCount({count})} - {shouldAnimate && (likeCount > 1 || !isLiked) ? ( + {shouldAnimate && (count > 1 || !isToggled) ? ( - - {formattedPrevCount} - + {renderCount({count: prevCount})} ) : null} diff --git a/src/lib/custom-animations/LikeIcon.tsx b/src/lib/custom-animations/LikeIcon.tsx index 025e96f4be..223f8e9f18 100644 --- a/src/lib/custom-animations/LikeIcon.tsx +++ b/src/lib/custom-animations/LikeIcon.tsx @@ -5,7 +5,6 @@ import Animated, { useReducedMotion, } from 'react-native-reanimated' -import {s} from '#/lib/styles' import {useTheme} from '#/alf' import { Heart2_Filled_Stroke2_Corner0_Rounded as HeartIconFilled, @@ -86,7 +85,7 @@ export function AnimatedLikeIcon({ {isLiked ? ( - + ) : ( - + ) : ( { diff --git a/src/view/com/modals/UserAddRemoveLists.tsx b/src/view/com/modals/UserAddRemoveLists.tsx index 0021418b5a..1648b0ff22 100644 --- a/src/view/com/modals/UserAddRemoveLists.tsx +++ b/src/view/com/modals/UserAddRemoveLists.tsx @@ -202,7 +202,7 @@ function ListItem({ {sanitizeDisplayName(list.name)} diff --git a/src/view/com/notifications/NotificationFeedItem.tsx b/src/view/com/notifications/NotificationFeedItem.tsx index d8f0abf8a5..79a8d746e8 100644 --- a/src/view/com/notifications/NotificationFeedItem.tsx +++ b/src/view/com/notifications/NotificationFeedItem.tsx @@ -272,7 +272,7 @@ let NotificationFeedItem = ({ diff --git a/src/view/com/util/LoadingPlaceholder.tsx b/src/view/com/util/LoadingPlaceholder.tsx index 3afba7f306..97b8587933 100644 --- a/src/view/com/util/LoadingPlaceholder.tsx +++ b/src/view/com/util/LoadingPlaceholder.tsx @@ -60,7 +60,7 @@ export function PostLoadingPlaceholder({ }, ]} /> - + @@ -238,7 +238,7 @@ export function FeedLoadingPlaceholder({ height={36} style={[styles.avatar, {borderRadius: 8}]} /> - + diff --git a/src/view/screens/Debug.tsx b/src/view/screens/Debug.tsx index 7e79b26ccd..bc31b586b3 100644 --- a/src/view/screens/Debug.tsx +++ b/src/view/screens/Debug.tsx @@ -174,7 +174,7 @@ function NotifsView() { } return ( - +