Add placeholder for grid view
This commit is contained in:
@@ -161,3 +161,73 @@ export function VideoPostCard({
|
|||||||
</Link>
|
</Link>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function VideoPostCardPlaceholder() {
|
||||||
|
const t = useTheme()
|
||||||
|
const black = select(t.name, {
|
||||||
|
light: t.palette.black,
|
||||||
|
dark: t.atoms.bg_contrast_25.backgroundColor,
|
||||||
|
dim: `hsl(${BLUE_HUE}, 28%, 6%)`,
|
||||||
|
})
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={[a.flex_1]}>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.rounded_md,
|
||||||
|
a.overflow_hidden,
|
||||||
|
{
|
||||||
|
backgroundColor: black,
|
||||||
|
aspectRatio: 9 / 16,
|
||||||
|
},
|
||||||
|
]}>
|
||||||
|
<MediaInsetBorder />
|
||||||
|
</View>
|
||||||
|
<View style={[a.pr_xs, {paddingTop: 8, gap: 6}]}>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.w_full,
|
||||||
|
a.rounded_xs,
|
||||||
|
t.atoms.bg_contrast_50,
|
||||||
|
{
|
||||||
|
height: 14,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.w_full,
|
||||||
|
a.rounded_xs,
|
||||||
|
t.atoms.bg_contrast_50,
|
||||||
|
{
|
||||||
|
height: 14,
|
||||||
|
width: '70%',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<View style={[a.flex_row, a.gap_xs, a.align_center]}>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.rounded_full,
|
||||||
|
t.atoms.bg_contrast_50,
|
||||||
|
{
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.rounded_xs,
|
||||||
|
t.atoms.bg_contrast_25,
|
||||||
|
{
|
||||||
|
height: 12,
|
||||||
|
width: '75%',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,11 @@ import {AppBskyEmbedVideo} from '@atproto/api'
|
|||||||
|
|
||||||
import {FeedPostSliceItem} from '#/state/queries/post-feed'
|
import {FeedPostSliceItem} from '#/state/queries/post-feed'
|
||||||
import {atoms as a, useGutters} from '#/alf'
|
import {atoms as a, useGutters} from '#/alf'
|
||||||
import {SourceContext,VideoPostCard} from '#/components/VideoPostCard'
|
import {
|
||||||
|
SourceContext,
|
||||||
|
VideoPostCard,
|
||||||
|
VideoPostCardPlaceholder,
|
||||||
|
} from '#/components/VideoPostCard'
|
||||||
|
|
||||||
export function PostFeedVideoGridRow({
|
export function PostFeedVideoGridRow({
|
||||||
slices,
|
slices,
|
||||||
@@ -35,3 +39,15 @@ export function PostFeedVideoGridRow({
|
|||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function PostFeedVideoGridRowPlaceholder() {
|
||||||
|
const gutters = useGutters(['base', 'base', 0, 'base'])
|
||||||
|
return (
|
||||||
|
<View style={[gutters]}>
|
||||||
|
<View style={[a.flex_row, a.gap_sm]}>
|
||||||
|
<VideoPostCardPlaceholder />
|
||||||
|
<VideoPostCardPlaceholder />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -45,7 +45,10 @@ import {PostFeedLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder'
|
|||||||
import {LoadMoreRetryBtn} from '#/view/com/util/LoadMoreRetryBtn'
|
import {LoadMoreRetryBtn} from '#/view/com/util/LoadMoreRetryBtn'
|
||||||
import {useBreakpoints} from '#/alf'
|
import {useBreakpoints} from '#/alf'
|
||||||
import {ProgressGuide, SuggestedFollows} from '#/components/FeedInterstitials'
|
import {ProgressGuide, SuggestedFollows} from '#/components/FeedInterstitials'
|
||||||
import {PostFeedVideoGridRow} from '#/components/feeds/PostFeedVideoGridRow'
|
import {
|
||||||
|
PostFeedVideoGridRow,
|
||||||
|
PostFeedVideoGridRowPlaceholder,
|
||||||
|
} from '#/components/feeds/PostFeedVideoGridRow'
|
||||||
import {TrendingInterstitial} from '#/components/interstitials/Trending'
|
import {TrendingInterstitial} from '#/components/interstitials/Trending'
|
||||||
import {DiscoverFallbackHeader} from './DiscoverFallbackHeader'
|
import {DiscoverFallbackHeader} from './DiscoverFallbackHeader'
|
||||||
import {FeedShutdownMsg} from './FeedShutdownMsg'
|
import {FeedShutdownMsg} from './FeedShutdownMsg'
|
||||||
@@ -86,6 +89,10 @@ type FeedRow =
|
|||||||
indexInSlice: number
|
indexInSlice: number
|
||||||
showReplyTo: boolean
|
showReplyTo: boolean
|
||||||
}
|
}
|
||||||
|
| {
|
||||||
|
type: 'videoGridRowPlaceholder'
|
||||||
|
key: string
|
||||||
|
}
|
||||||
| {
|
| {
|
||||||
type: 'videoGridRow'
|
type: 'videoGridRow'
|
||||||
key: string
|
key: string
|
||||||
@@ -176,6 +183,7 @@ let PostFeed = ({
|
|||||||
const lastFetchRef = React.useRef<number>(Date.now())
|
const lastFetchRef = React.useRef<number>(Date.now())
|
||||||
const [feedType, feedUri, feedTab] = feed.split('|')
|
const [feedType, feedUri, feedTab] = feed.split('|')
|
||||||
const {gtMobile, gtTablet} = useBreakpoints()
|
const {gtMobile, gtTablet} = useBreakpoints()
|
||||||
|
const isVideoFeed = feedUri === VIDEO_FEED_URI
|
||||||
|
|
||||||
const opts = React.useMemo(
|
const opts = React.useMemo(
|
||||||
() => ({enabled, ignoreFilterFor}),
|
() => ({enabled, ignoreFilterFor}),
|
||||||
@@ -287,8 +295,6 @@ let PostFeed = ({
|
|||||||
feedKind = 'following'
|
feedKind = 'following'
|
||||||
} else if (feedUri === DISCOVER_FEED_URI) {
|
} else if (feedUri === DISCOVER_FEED_URI) {
|
||||||
feedKind = 'discover'
|
feedKind = 'discover'
|
||||||
} else if (feedUri === VIDEO_FEED_URI) {
|
|
||||||
feedKind = 'thevids'
|
|
||||||
} else if (
|
} else if (
|
||||||
feedType === 'author' &&
|
feedType === 'author' &&
|
||||||
(feedTab === 'posts_and_author_threads' ||
|
(feedTab === 'posts_and_author_threads' ||
|
||||||
@@ -318,7 +324,7 @@ let PostFeed = ({
|
|||||||
} else if (data) {
|
} else if (data) {
|
||||||
let sliceIndex = -1
|
let sliceIndex = -1
|
||||||
for (const page of data?.pages) {
|
for (const page of data?.pages) {
|
||||||
if (feedKind === 'thevids' && isNative) {
|
if (isVideoFeed && isNative) {
|
||||||
const rows: FeedPostSliceItem[][] = []
|
const rows: FeedPostSliceItem[][] = []
|
||||||
for (let i = 0; i < page.slices.length; i++) {
|
for (let i = 0; i < page.slices.length; i++) {
|
||||||
const slice = page.slices[i]
|
const slice = page.slices[i]
|
||||||
@@ -435,12 +441,19 @@ let PostFeed = ({
|
|||||||
key: 'loadMoreError',
|
key: 'loadMoreError',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (isVideoFeed) {
|
||||||
|
arr.push({
|
||||||
|
type: 'videoGridRowPlaceholder',
|
||||||
|
key: 'videoGridRowPlaceholder',
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
arr.push({
|
arr.push({
|
||||||
type: 'loading',
|
type: 'loading',
|
||||||
key: 'loading',
|
key: 'loading',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return arr
|
return arr
|
||||||
}, [
|
}, [
|
||||||
@@ -457,6 +470,7 @@ let PostFeed = ({
|
|||||||
trendingDisabled,
|
trendingDisabled,
|
||||||
gtTablet,
|
gtTablet,
|
||||||
gtMobile,
|
gtMobile,
|
||||||
|
isVideoFeed,
|
||||||
])
|
])
|
||||||
|
|
||||||
// events
|
// events
|
||||||
@@ -579,6 +593,14 @@ let PostFeed = ({
|
|||||||
)
|
)
|
||||||
} else if (row.type === 'sliceViewFullThread') {
|
} else if (row.type === 'sliceViewFullThread') {
|
||||||
return <ViewFullThread uri={row.uri} />
|
return <ViewFullThread uri={row.uri} />
|
||||||
|
} else if (row.type === 'videoGridRowPlaceholder') {
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<PostFeedVideoGridRowPlaceholder />
|
||||||
|
<PostFeedVideoGridRowPlaceholder />
|
||||||
|
<PostFeedVideoGridRowPlaceholder />
|
||||||
|
</View>
|
||||||
|
)
|
||||||
} else if (row.type === 'videoGridRow') {
|
} else if (row.type === 'videoGridRow') {
|
||||||
return (
|
return (
|
||||||
<PostFeedVideoGridRow
|
<PostFeedVideoGridRow
|
||||||
|
|||||||
Reference in New Issue
Block a user