mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-30 19:54:16 -04:00
Fix initial placeholders on mobile lists
This commit is contained in:
parent
1d6d27c0ee
commit
b4281188d4
@ -30,7 +30,7 @@ const emulateGap = (
|
|||||||
gap: number,
|
gap: number,
|
||||||
numColumns: number,
|
numColumns: number,
|
||||||
index: number,
|
index: number,
|
||||||
itemsCount: number
|
itemsCount: number,
|
||||||
): ViewStyle => {
|
): ViewStyle => {
|
||||||
let marginLeft = 0;
|
let marginLeft = 0;
|
||||||
let marginRight = 0;
|
let marginRight = 0;
|
||||||
@ -107,7 +107,7 @@ export const InfiniteFetchList = <Data, Props, _, Kind extends number | string>(
|
|||||||
const placeholders = [...Array(count === 0 ? numColumns : count)].map(
|
const placeholders = [...Array(count === 0 ? numColumns : count)].map(
|
||||||
(_, i) => ({ id: `gen${i}`, isLoading: true }) as Data,
|
(_, i) => ({ id: `gen${i}`, isLoading: true }) as Data,
|
||||||
);
|
);
|
||||||
const data = isFetching ? [...(items || []), ...placeholders] : items;
|
const data = isFetching || !items ? [...(items || []), ...placeholders] : items;
|
||||||
|
|
||||||
const List = nested ? (FlatList as unknown as typeof FlashList) : FlashList;
|
const List = nested ? (FlatList as unknown as typeof FlashList) : FlashList;
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ export const InfiniteFetchList = <Data, Props, _, Kind extends number | string>(
|
|||||||
renderItem={({ item, index }) => (
|
renderItem={({ item, index }) => (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
emulateGap(layout.layout, gap, numColumns, index, data?.length ?? 0),
|
emulateGap(layout.layout, gap, numColumns, index, data.length),
|
||||||
layout.layout === "horizontal" && {
|
layout.layout === "horizontal" && {
|
||||||
width:
|
width:
|
||||||
size * (getItemType && getItemSize ? getItemSize(getItemType(item, index)) : 1),
|
size * (getItemType && getItemSize ? getItemSize(getItemType(item, index)) : 1),
|
||||||
|
@ -33,7 +33,7 @@ export type Layout = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type WithLoading<Item> =
|
export type WithLoading<Item> =
|
||||||
| (Item & { isLoading?: false })
|
| (Item & { isLoading: false })
|
||||||
| (Partial<Item> & { isLoading: true });
|
| (Partial<Item> & { isLoading: true });
|
||||||
|
|
||||||
const isPage = <T = unknown,>(obj: unknown): obj is Page<T> =>
|
const isPage = <T = unknown,>(obj: unknown): obj is Page<T> =>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user