Skip to content

Commit a3c9028

Browse files
committed
skeleton ui implemented for home's header chips
1 parent 45442b8 commit a3c9028

2 files changed

Lines changed: 32 additions & 18 deletions

File tree

Component/Discover/ShowPlaylistofType.jsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { PlaylistItemWrapper } from "./PlaylistItemWrapper";
1414
import { CommonActions } from "@react-navigation/native";
1515
import { CacheManager } from '../../Utils/NavigationCacheManager';
1616
import { CACHE_TTL, CACHE_KEYS, generateCacheKey } from '../../Utils/CacheConfig';
17+
import { GridSkeleton } from "../Global/GridSkeleton";
1718

1819
// Add a utility function to truncate text
1920
const truncateText = (text, limit = 22) => {
@@ -30,7 +31,7 @@ export default function ShowPlaylistofType({ route }) {
3031
const currentRoute = useRoute();
3132
const limit = 30;
3233
const [Data, setData] = useState({});
33-
const [Loading, setLoading] = useState(false);
34+
const [Loading, setLoading] = useState(true);
3435
const [refreshing, setRefreshing] = useState(false);
3536
const [fetchError, setFetchError] = useState(null);
3637
const [source, setSource] = useState(null);
@@ -214,17 +215,9 @@ export default function ShowPlaylistofType({ route }) {
214215
<Heading text={(Searchtext || 'Popular Playlists').toUpperCase()} />
215216
</PaddingConatiner>
216217

217-
{/* Improved loading state */}
218+
{/* Improved loading state - Skeleton UI */}
218219
{Loading && (
219-
<View style={{
220-
flex: 1,
221-
justifyContent: 'center',
222-
alignItems: 'center',
223-
height: 300
224-
}}>
225-
<ActivityIndicator size="large" color="#1DB954" />
226-
<PlainText text={`Loading ${Searchtext || 'playlist'} data...`} style={{ marginTop: 10 }} />
227-
</View>
220+
<GridSkeleton count={8} showHeader={false} noScroll={true} />
228221
)}
229222

230223
{/* Error state */}

Component/Global/GridSkeleton.jsx

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ const { width: SCREEN_WIDTH } = Dimensions.get('window');
77
/**
88
* GridSkeleton - Skeleton UI for grid layouts (Albums, Playlists, etc.)
99
* Renders a 2-column grid of square cards
10+
* @param {number} count - Number of skeleton cards to show
11+
* @param {boolean} showHeader - Whether to show header skeleton
12+
* @param {boolean} noScroll - If true, renders without ScrollView wrapper (for use inside other scroll containers)
1013
*/
11-
export const GridSkeleton = ({ count = 6, showHeader = false }) => {
14+
export const GridSkeleton = ({ count = 6, showHeader = false, noScroll = false }) => {
1215
const { dark } = useTheme();
1316
const shimmerAnim = useRef(new Animated.Value(0)).current;
1417

@@ -70,12 +73,8 @@ export const GridSkeleton = ({ count = 6, showHeader = false }) => {
7073
</View>
7174
);
7275

73-
return (
74-
<ScrollView
75-
style={styles.container}
76-
showsVerticalScrollIndicator={false}
77-
contentContainerStyle={styles.contentContainer}
78-
>
76+
const content = (
77+
<>
7978
{showHeader && (
8079
<View style={styles.headerInfo}>
8180
<Animated.View
@@ -94,6 +93,24 @@ export const GridSkeleton = ({ count = 6, showHeader = false }) => {
9493
<GridCardSkeleton key={index} />
9594
))}
9695
</View>
96+
</>
97+
);
98+
99+
if (noScroll) {
100+
return (
101+
<View style={styles.noScrollContainer}>
102+
{content}
103+
</View>
104+
);
105+
}
106+
107+
return (
108+
<ScrollView
109+
style={styles.container}
110+
showsVerticalScrollIndicator={false}
111+
contentContainerStyle={styles.contentContainer}
112+
>
113+
{content}
97114
</ScrollView>
98115
);
99116
};
@@ -102,6 +119,10 @@ const styles = StyleSheet.create({
102119
container: {
103120
flex: 1,
104121
},
122+
noScrollContainer: {
123+
flex: 1,
124+
paddingHorizontal: 8,
125+
},
105126
contentContainer: {
106127
paddingBottom: 100,
107128
paddingHorizontal: 8,

0 commit comments

Comments
 (0)