Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: basic masonry entry list and entry content view #2493

Merged
merged 19 commits into from
Jan 22, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove show animate logic
hyoban committed Jan 20, 2025
commit 9281ec0b7cba6582287a1193b99f825991e9cd40
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
@@ -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
@@ -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}
/>
) : (
@@ -75,8 +74,6 @@ export default function EntryDetailPage() {
}),
)

const shouldAnimate = useShouldAnimate()

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

@@ -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>
)}
Loading