R&D on PIN setup for authentication flow.
Worked on managing local storage
This commit is contained in:
139
src/screen/Home.tsx
Normal file
139
src/screen/Home.tsx
Normal file
@@ -0,0 +1,139 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import {
|
||||
View,
|
||||
Text,
|
||||
StyleSheet,
|
||||
FlatList,
|
||||
TouchableOpacity,
|
||||
Image,
|
||||
SafeAreaView,
|
||||
ActivityIndicator,
|
||||
} from 'react-native';
|
||||
|
||||
interface Item {
|
||||
id: string;
|
||||
title: string;
|
||||
subtitle: string;
|
||||
image: string;
|
||||
}
|
||||
|
||||
const DATA: Item[] = [
|
||||
{
|
||||
id: '1',
|
||||
title: 'Food Delivery',
|
||||
subtitle: 'Fast & fresh food',
|
||||
image: 'https://via.placeholder.com/150',
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
title: 'Groceries',
|
||||
subtitle: 'Daily essentials',
|
||||
image: 'https://via.placeholder.com/150',
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
title: 'Medicines',
|
||||
subtitle: 'Health care items',
|
||||
image: 'https://via.placeholder.com/150',
|
||||
},
|
||||
];
|
||||
|
||||
const Home: React.FC = () => {
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [list, setList] = useState<Item[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
// Simulate API call
|
||||
setTimeout(() => {
|
||||
setList(DATA);
|
||||
setLoading(false);
|
||||
}, 1000);
|
||||
}, []);
|
||||
|
||||
const renderItem = ({ item }: { item: Item }) => (
|
||||
<TouchableOpacity style={styles.card} activeOpacity={0.8}>
|
||||
<Image source={{ uri: item.image }} style={styles.image} />
|
||||
<View style={styles.textContainer}>
|
||||
<Text style={styles.title}>{item.title}</Text>
|
||||
<Text style={styles.subtitle}>{item.subtitle}</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<View style={styles.loader}>
|
||||
<ActivityIndicator size="large" color="#000" />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<SafeAreaView style={styles.container}>
|
||||
<Text style={styles.header}>Home</Text>
|
||||
|
||||
<FlatList
|
||||
data={list}
|
||||
keyExtractor={(item) => item.id}
|
||||
renderItem={renderItem}
|
||||
contentContainerStyle={styles.list}
|
||||
showsVerticalScrollIndicator={false}
|
||||
/>
|
||||
</SafeAreaView>
|
||||
);
|
||||
};
|
||||
|
||||
export default Home;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: '#F5F5F5',
|
||||
},
|
||||
header: {
|
||||
fontSize: 22,
|
||||
fontWeight: '700',
|
||||
margin: 16,
|
||||
color: '#111',
|
||||
},
|
||||
list: {
|
||||
paddingHorizontal: 16,
|
||||
paddingBottom: 20,
|
||||
},
|
||||
card: {
|
||||
flexDirection: 'row',
|
||||
backgroundColor: '#FFF',
|
||||
borderRadius: 12,
|
||||
marginBottom: 12,
|
||||
padding: 12,
|
||||
alignItems: 'center',
|
||||
shadowColor: '#000',
|
||||
shadowOpacity: 0.1,
|
||||
shadowRadius: 6,
|
||||
elevation: 3,
|
||||
},
|
||||
image: {
|
||||
width: 60,
|
||||
height: 60,
|
||||
borderRadius: 10,
|
||||
marginRight: 12,
|
||||
},
|
||||
textContainer: {
|
||||
flex: 1,
|
||||
},
|
||||
title: {
|
||||
fontSize: 16,
|
||||
fontWeight: '600',
|
||||
color: '#000',
|
||||
},
|
||||
subtitle: {
|
||||
fontSize: 13,
|
||||
color: '#666',
|
||||
marginTop: 4,
|
||||
},
|
||||
loader: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user