Skip to content

Commit 6393f36

Browse files
authored
Merge pull request #43652 from truph01/fix/43395-search-mobile-loading-indicator
Feat: Implement loading skeleton small screen width
2 parents c801580 + 5172df9 commit 6393f36

File tree

3 files changed

+103
-12
lines changed

3 files changed

+103
-12
lines changed

src/CONST.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,7 @@ const CONST = {
12501250
},
12511251
CENTRAL_PANE_ANIMATION_HEIGHT: 200,
12521252
LHN_SKELETON_VIEW_ITEM_HEIGHT: 64,
1253+
SEARCH_SKELETON_VIEW_ITEM_HEIGHT: 108,
12531254
EXPENSIFY_PARTNER_NAME: 'expensify.com',
12541255
EMAIL: {
12551256
ACCOUNTING: 'accounting@expensify.com',

src/components/Skeletons/ItemListSkeletonView.tsx

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, {useMemo, useState} from 'react';
22
import {View} from 'react-native';
3+
import type {StyleProp, ViewStyle} from 'react-native';
34
import SkeletonViewContentLoader from '@components/SkeletonViewContentLoader';
45
import useTheme from '@hooks/useTheme';
56
import useThemeStyles from '@hooks/useThemeStyles';
@@ -9,9 +10,11 @@ type ListItemSkeletonProps = {
910
shouldAnimate?: boolean;
1011
renderSkeletonItem: (args: {itemIndex: number}) => React.ReactNode;
1112
fixedNumItems?: number;
13+
itemViewStyle?: StyleProp<ViewStyle>;
14+
itemViewHeight?: number;
1215
};
1316

14-
function ItemListSkeletonView({shouldAnimate = true, renderSkeletonItem, fixedNumItems}: ListItemSkeletonProps) {
17+
function ItemListSkeletonView({shouldAnimate = true, renderSkeletonItem, fixedNumItems, itemViewStyle = {}, itemViewHeight = CONST.LHN_SKELETON_VIEW_ITEM_HEIGHT}: ListItemSkeletonProps) {
1518
const theme = useTheme();
1619
const themeStyles = useThemeStyles();
1720

@@ -20,20 +23,23 @@ function ItemListSkeletonView({shouldAnimate = true, renderSkeletonItem, fixedNu
2023
const items = [];
2124
for (let i = 0; i < numItems; i++) {
2225
items.push(
23-
<SkeletonViewContentLoader
26+
<View
2427
key={`skeletonViewItems${i}`}
25-
animate={shouldAnimate}
26-
height={CONST.LHN_SKELETON_VIEW_ITEM_HEIGHT}
27-
backgroundColor={theme.skeletonLHNIn}
28-
foregroundColor={theme.skeletonLHNOut}
29-
style={themeStyles.mr5}
28+
style={[themeStyles.mr5, itemViewStyle]}
3029
>
31-
{renderSkeletonItem({itemIndex: i})}
32-
</SkeletonViewContentLoader>,
30+
<SkeletonViewContentLoader
31+
animate={shouldAnimate}
32+
height={itemViewHeight}
33+
backgroundColor={theme.skeletonLHNIn}
34+
foregroundColor={theme.skeletonLHNOut}
35+
>
36+
{renderSkeletonItem({itemIndex: i})}
37+
</SkeletonViewContentLoader>
38+
</View>,
3339
);
3440
}
3541
return items;
36-
}, [numItems, shouldAnimate, theme, themeStyles, renderSkeletonItem]);
42+
}, [numItems, shouldAnimate, theme, themeStyles, renderSkeletonItem, itemViewHeight, itemViewStyle]);
3743

3844
return (
3945
<View
@@ -43,7 +49,7 @@ function ItemListSkeletonView({shouldAnimate = true, renderSkeletonItem, fixedNu
4349
return;
4450
}
4551

46-
const newNumItems = Math.ceil(event.nativeEvent.layout.height / CONST.LHN_SKELETON_VIEW_ITEM_HEIGHT);
52+
const newNumItems = Math.ceil(event.nativeEvent.layout.height / itemViewHeight);
4753
if (newNumItems === numItems) {
4854
return;
4955
}

src/components/Skeletons/TableListItemSkeleton.tsx

+85-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import React from 'react';
2-
import {Rect} from 'react-native-svg';
2+
import {Circle, Rect} from 'react-native-svg';
3+
import useThemeStyles from '@hooks/useThemeStyles';
4+
import useWindowDimensions from '@hooks/useWindowDimensions';
5+
import CONST from '@src/CONST';
36
import ItemListSkeletonView from './ItemListSkeletonView';
47

58
type TableListItemSkeletonProps = {
@@ -12,6 +15,87 @@ const shortBarWidth = '40';
1215
const longBarWidth = '120';
1316

1417
function TableListItemSkeleton({shouldAnimate = true, fixedNumItems}: TableListItemSkeletonProps) {
18+
const styles = useThemeStyles();
19+
const {windowWidth, isSmallScreenWidth} = useWindowDimensions();
20+
if (isSmallScreenWidth) {
21+
return (
22+
<ItemListSkeletonView
23+
itemViewHeight={CONST.SEARCH_SKELETON_VIEW_ITEM_HEIGHT}
24+
itemViewStyle={[styles.highlightBG, styles.mb3, styles.br3, styles.mr3, styles.ml3]}
25+
shouldAnimate={shouldAnimate}
26+
fixedNumItems={fixedNumItems}
27+
renderSkeletonItem={() => (
28+
<>
29+
<Circle
30+
cx={24}
31+
cy={26}
32+
r={8}
33+
/>
34+
35+
<Rect
36+
x={40}
37+
y={24}
38+
width={40}
39+
height={4}
40+
/>
41+
<Circle
42+
cx={96}
43+
cy={26}
44+
r={8}
45+
/>
46+
47+
<Rect
48+
x={112}
49+
y={24}
50+
width={40}
51+
height={4}
52+
/>
53+
<Rect
54+
x={windowWidth - 120}
55+
y={12}
56+
width={80}
57+
height={28}
58+
rx={14}
59+
ry={14}
60+
/>
61+
62+
<Rect
63+
x={16}
64+
y={56}
65+
width={36}
66+
height={40}
67+
rx={4}
68+
ry={4}
69+
/>
70+
<Rect
71+
x={64}
72+
y={65}
73+
width={124}
74+
height={8}
75+
/>
76+
<Rect
77+
x={64}
78+
y={79}
79+
width={60}
80+
height={8}
81+
/>
82+
<Rect
83+
x={windowWidth - 120}
84+
y={65}
85+
width={80}
86+
height={8}
87+
/>
88+
<Rect
89+
x={windowWidth - 100}
90+
y={79}
91+
width={60}
92+
height={8}
93+
/>
94+
</>
95+
)}
96+
/>
97+
);
98+
}
1599
return (
16100
<ItemListSkeletonView
17101
shouldAnimate={shouldAnimate}

0 commit comments

Comments
 (0)