-
Notifications
You must be signed in to change notification settings - Fork 23
[jules] ux: Complete skeleton loading for HomeScreen groups #287
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import React from 'react'; | ||
| import { View, StyleSheet, FlatList } from 'react-native'; | ||
| import { Card } from 'react-native-paper'; | ||
| import Skeleton from '../ui/Skeleton'; | ||
|
|
||
| const GroupListSkeleton = () => { | ||
| // Create 6 dummy items to fill the screen | ||
| const dummyData = Array(6).fill(null); | ||
|
|
||
| const renderItem = () => ( | ||
| <Card style={styles.card}> | ||
| {/* Header Area (Avatar + Title) */} | ||
| <View style={styles.header}> | ||
| <Skeleton width={40} height={40} borderRadius={20} /> | ||
| <View style={styles.titleContainer}> | ||
| <Skeleton width="50%" height={20} borderRadius={4} /> | ||
| </View> | ||
| </View> | ||
|
|
||
| {/* Content Area (Status Text) */} | ||
| <View style={styles.content}> | ||
| <Skeleton width="75%" height={16} borderRadius={4} /> | ||
| </View> | ||
| </Card> | ||
| ); | ||
|
|
||
| return ( | ||
| <View style={styles.container} accessible={true} accessibilityLabel="Loading groups"> | ||
| <FlatList | ||
| data={dummyData} | ||
| renderItem={renderItem} | ||
| keyExtractor={(_, index) => index.toString()} | ||
| contentContainerStyle={styles.list} | ||
| scrollEnabled={false} | ||
| /> | ||
| </View> | ||
| ); | ||
| }; | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { | ||
| flex: 1, | ||
| }, | ||
| list: { | ||
| padding: 16, | ||
| }, | ||
| card: { | ||
| marginBottom: 16, | ||
| // Card has default elevation and background color from theme | ||
| }, | ||
| header: { | ||
| flexDirection: 'row', | ||
| alignItems: 'center', | ||
| padding: 16, // Match Card.Title padding | ||
| }, | ||
| titleContainer: { | ||
| marginLeft: 16, | ||
| flex: 1, | ||
| }, | ||
| content: { | ||
| paddingHorizontal: 16, | ||
| paddingBottom: 16, // Match Card.Content padding | ||
| }, | ||
| }); | ||
|
|
||
| export default GroupListSkeleton; | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,48 @@ | ||||||
| import React, { useEffect, useRef } from 'react'; | ||||||
| import { Animated, StyleSheet } from 'react-native'; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unused
🔧 Proposed fix-import { Animated, StyleSheet } from 'react-native';
+import { Animated } from 'react-native';📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| import { useTheme } from 'react-native-paper'; | ||||||
|
|
||||||
| const Skeleton = ({ width, height, borderRadius, style }) => { | ||||||
| const theme = useTheme(); | ||||||
| const opacity = useRef(new Animated.Value(0.3)).current; | ||||||
|
|
||||||
| useEffect(() => { | ||||||
| const animation = Animated.loop( | ||||||
| Animated.sequence([ | ||||||
| Animated.timing(opacity, { | ||||||
| toValue: 0.7, // Don't go to fully opaque so it looks like a placeholder | ||||||
| duration: 800, | ||||||
| useNativeDriver: true, | ||||||
| }), | ||||||
| Animated.timing(opacity, { | ||||||
| toValue: 0.3, | ||||||
| duration: 800, | ||||||
| useNativeDriver: true, | ||||||
| }), | ||||||
| ]) | ||||||
| ); | ||||||
|
|
||||||
| animation.start(); | ||||||
|
|
||||||
| return () => animation.stop(); | ||||||
| }, [opacity]); | ||||||
|
|
||||||
| return ( | ||||||
| <Animated.View | ||||||
| style={[ | ||||||
| { | ||||||
| width, | ||||||
| height, | ||||||
| borderRadius: borderRadius || 4, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The falsy OR operator means passing 🔧 Proposed fix- borderRadius: borderRadius || 4,
+ borderRadius: borderRadius ?? 4,📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| backgroundColor: theme.colors.surfaceVariant, // Adapts to light/dark mode | ||||||
| opacity, | ||||||
| }, | ||||||
| style, | ||||||
| ]} | ||||||
| accessibilityRole="progressbar" | ||||||
| accessibilityLabel="Loading..." | ||||||
| /> | ||||||
| ); | ||||||
| }; | ||||||
|
|
||||||
| export default Skeleton; | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Prefer a simple
mapoverFlatListfor this static, non-scrollable list.FlatListis designed for virtualized, scrollable lists. Here it's used withscrollEnabled={false}and a fixed item count of 6 — the virtualization machinery (scroll listeners, layout measurement passes, window sizing) runs entirely for nothing. Additionally,dummyDatais recreated on every render inside the component.♻️ Proposed refactor
🤖 Prompt for AI Agents