Skip to content

Commit 46f41de

Browse files
committed
chore: add heart icon
1 parent 144295a commit 46f41de

File tree

3 files changed

+43
-9
lines changed

3 files changed

+43
-9
lines changed

src/app/Scenes/InfiniteDiscovery/Components/InfiniteDiscoveryArtworkCard.tsx

+34-4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ import { useSaveArtworkToArtworkLists } from "app/Components/ArtworkLists/useSav
1515
import { GlobalStore } from "app/store/GlobalStore"
1616
import { Schema } from "app/utils/track"
1717
import { sizeToFit } from "app/utils/useSizeToFit"
18-
import { memo } from "react"
19-
import { LayoutAnimation, ViewStyle } from "react-native"
18+
import { memo, useEffect } from "react"
19+
import { ViewStyle } from "react-native"
2020
import Animated, {
21+
Easing,
2122
interpolate,
2223
useAnimatedStyle,
2324
useSharedValue,
25+
withDelay,
26+
withSequence,
2427
withTiming,
2528
} from "react-native-reanimated"
2629
import { graphql, useFragment } from "react-relay"
@@ -82,13 +85,23 @@ export const InfiniteDiscoveryArtworkCard: React.FC<InfiniteDiscoveryArtworkCard
8285
}
8386
})
8487

85-
useAnimatedStyle(() => {
88+
useEffect(() => {
8689
saveAnimationProgress.value = withTiming(isSavedProp ? 1 : 0, {
8790
duration: 300,
8891
})
89-
return {} // Required for ts
9092
}, [isSavedProp])
9193

94+
const savedArtworkAnimationStyles = useAnimatedStyle(() => {
95+
return {
96+
opacity: isSavedProp
97+
? withSequence(
98+
withTiming(1, { duration: 300, easing: Easing.linear }),
99+
withDelay(500, withTiming(0, { duration: 300, easing: Easing.linear }))
100+
)
101+
: 0,
102+
}
103+
})
104+
92105
if (!artwork) {
93106
return null
94107
}
@@ -114,6 +127,23 @@ export const InfiniteDiscoveryArtworkCard: React.FC<InfiniteDiscoveryArtworkCard
114127
/>
115128
</Flex>
116129
<Flex alignItems="center" minHeight={MAX_ARTWORK_HEIGHT} justifyContent="center">
130+
<Animated.View
131+
style={[
132+
{
133+
position: "absolute",
134+
width: "100%",
135+
height: "100%",
136+
backgroundColor: "rgba(255, 255, 255, 0.5)",
137+
justifyContent: "center",
138+
alignItems: "center",
139+
zIndex: 100,
140+
},
141+
savedArtworkAnimationStyles,
142+
]}
143+
>
144+
<HeartFillIcon height={64} width={64} fill="white100" />
145+
</Animated.View>
146+
117147
{!!src && <Image src={src} height={size.height} width={size.width} />}
118148
</Flex>
119149
<Flex flexDirection="row" justifyContent="space-between" p={1} mx={2}>

src/app/Scenes/InfiniteDiscovery/Components/InfiniteDiscoveryOnboarding.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export const InfiniteDiscoveryOnboarding: React.FC<InfiniteDiscoveryOnboardingPr
3838
shadowOpacity: 0.2,
3939
shadowOffset: { height: 0, width: 0 },
4040
}}
41+
// Only show the saved hint for the upper card - since the cards are reverted in the swiper,
42+
// the upper card index is the last in the array
4143
isSaved={i === artworks.length - 1 ? showSavedHint : false}
4244
/>
4345
))
@@ -59,11 +61,11 @@ export const InfiniteDiscoveryOnboarding: React.FC<InfiniteDiscoveryOnboardingPr
5961
}, [hasInteractedWithOnboarding])
6062

6163
const showOnboardingAnimation = () => {
62-
swiperRef.current?.swipeLeftThenRight(ONBOARDING_SWIPE_ANIMATION_DURATION)
64+
setShowSavedHint(true)
6365

6466
setTimeout(() => {
65-
setShowSavedHint(true)
66-
}, ONBOARDING_SWIPE_ANIMATION_DURATION + ONBOARDING_ANIMATION_DELAY)
67+
swiperRef.current?.swipeLeftThenRight(ONBOARDING_SWIPE_ANIMATION_DURATION)
68+
}, ONBOARDING_ANIMATION_DELAY + ONBOARDING_SAVED_HINT_DURATION)
6769

6870
setTimeout(
6971
() => {
@@ -80,8 +82,10 @@ export const InfiniteDiscoveryOnboarding: React.FC<InfiniteDiscoveryOnboardingPr
8082
return
8183
}
8284

85+
// Wait for a second before showing the animation
8386
setTimeout(() => {
8487
showOnboardingAnimation()
88+
// Show the animation every 5 seconds afterwards
8589
setInterval(() => {
8690
showOnboardingAnimation()
8791
}, 5000)

src/app/Scenes/InfiniteDiscovery/Components/Swiper/Swiper.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ export const Swiper = forwardRef<SwiperRefProps, SwiperProps>(
7373
const previousCards = usePrevious(cards)
7474

7575
useEffect(() => {
76-
if (previousCards && cards.length < previousCards.length) {
77-
setNumberExtraCardsAdded(previousCards.length - cards.length)
76+
if (previousCards && cards.length !== previousCards.length) {
77+
setNumberExtraCardsAdded(cards.length - previousCards.length)
7878
}
7979
}, [cards.length])
8080

0 commit comments

Comments
 (0)