Skip to content

Commit

Permalink
remove show animate logic
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Jan 20, 2025
1 parent 8894840 commit 9281ec0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 32 deletions.
5 changes: 0 additions & 5 deletions apps/mobile/src/modules/entry/ctx.ts

This file was deleted.

28 changes: 7 additions & 21 deletions apps/mobile/src/screens/(headless)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
import { Stack } from "expo-router"
import { useState } from "react"
import { useColorScheme } from "react-native"

import { SharedElementAnimationContextProvider } from "@/src/modules/entry/ctx"
import { getSystemBackgroundColor } from "@/src/theme/utils"

export default function HeadlessLayout() {
useColorScheme()
const systemBackgroundColor = getSystemBackgroundColor()
const [shouldAnimate, setShouldAnimate] = useState(true)
return (
<SharedElementAnimationContextProvider value={shouldAnimate}>
<Stack
screenOptions={{
contentStyle: { backgroundColor: systemBackgroundColor },
headerShown: false,
}}
screenListeners={{
transitionEnd: (e) => {
// disable shared element animation when navigating back to the start screen
const screenToStart = "index"

if (e.target?.startsWith(screenToStart)) {
setShouldAnimate(!e.data.closing)
}
},
}}
/>
</SharedElementAnimationContextProvider>
return (
<Stack
screenOptions={{
contentStyle: { backgroundColor: systemBackgroundColor },
headerShown: false,
}}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import PagerView from "react-native-pager-view"

import { ReAnimatedExpoImage } from "@/src/components/common/AnimatedComponents"
import HtmlWeb from "@/src/components/ui/typography/HtmlWeb"
import { useShouldAnimate } from "@/src/modules/entry/ctx"
import { useEntry } from "@/src/store/entry/hooks"

function Media({ media, shouldAnimate }: { media: any; shouldAnimate: boolean }) {
function Media({ media }: { media: any }) {
const isVideo = media.type === "video"
const imageUrl = isVideo ? media.preview_image_url : media.url
const videoUrl = media.url
Expand Down Expand Up @@ -44,7 +43,7 @@ function Media({ media, shouldAnimate }: { media: any; shouldAnimate: boolean })
aspectRatio: media?.height && media.width ? media.width / media.height : 9 / 16,
display: isVideo ? (status?.isLoaded ? "none" : "flex") : "flex",
}}
sharedTransitionTag={shouldAnimate && imageUrl ? `entry-image-${imageUrl}` : undefined}
sharedTransitionTag={imageUrl ? `entry-image-${imageUrl}` : undefined}
allowDownscaling={false}
/>
) : (
Expand Down Expand Up @@ -75,8 +74,6 @@ export default function EntryDetailPage() {
}),
)

const shouldAnimate = useShouldAnimate()

const [currentPageIndex, setCurrentPageIndex] = useState(0)
const [height, setHeight] = useState(0)

Expand All @@ -101,7 +98,7 @@ export default function EntryDetailPage() {
}}
>
{mediaList.map((media) => {
return <Media key={media.url} media={media} shouldAnimate={shouldAnimate} />
return <Media key={media.url} media={media} />
})}
</PagerView>
)}
Expand Down

0 comments on commit 9281ec0

Please sign in to comment.