Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit f5e1417

Browse files
committed
feat: add expo-fast-image dependency and integrate FastImage component in DetailGiftScreen for optimized image loading
1 parent 60046c3 commit f5e1417

File tree

5 files changed

+63
-26
lines changed

5 files changed

+63
-26
lines changed

bun.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"dependencies": {
77
"@expo/vector-icons": "14.1.0",
88
"expo": "52.0.46",
9+
"expo-fast-image": "^1.1.3",
910
"expo-linking": "7.0.5",
1011
"expo-router": "4.0.20",
1112
"expo-splash-screen": "0.29.24",
@@ -729,6 +730,8 @@
729730

730731
"expo-constants": ["[email protected]", "", { "dependencies": { "@expo/config": "~10.0.11", "@expo/env": "~0.4.2" }, "peerDependencies": { "expo": "*", "react-native": "*" } }, "sha512-XfWRyQAf1yUNgWZ1TnE8pFBMqGmFP5Gb+SFSgszxDdOoheB/NI5D4p7q86kI2fvGyfTrxAe+D+74nZkfsGvUlg=="],
731732

733+
"expo-fast-image": ["[email protected]", "", {}, "sha512-dpHvUFJxImD+yDVJk3ubCMGSYgbewPfbsPMOpD/EP7PKDA4RurtkJZcUDF8T/0gxuxZMCldPgHup6np/hrK/MQ=="],
734+
732735
"expo-file-system": ["[email protected]", "", { "dependencies": { "web-streams-polyfill": "^3.3.2" }, "peerDependencies": { "expo": "*", "react-native": "*" } }, "sha512-HAkrd/mb8r+G3lJ9MzmGeuW2B+BxQR1joKfeCyY4deLl1zoZ48FrAWjgZjHK9aHUVhJ0ehzInu/NQtikKytaeg=="],
733736

734737
"expo-font": ["[email protected]", "", { "dependencies": { "fontfaceobserver": "^2.1.0" }, "peerDependencies": { "expo": "*", "react": "*" } }, "sha512-eAP5hyBgC8gafFtprsz0HMaB795qZfgJWqTmU0NfbSin1wUuVySFMEPMOrTkTgmazU73v4Cb4x7p86jY1XXYUw=="],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"dependencies": {
1111
"@expo/vector-icons": "14.1.0",
1212
"expo": "52.0.46",
13+
"expo-fast-image": "^1.1.3",
1314
"expo-linking": "7.0.5",
1415
"expo-router": "4.0.20",
1516
"expo-splash-screen": "0.29.24",

src/app/(gifts)/detail-gift.tsx

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { useLocalSearchParams, useRouter } from 'expo-router';
2-
import { Alert, Image, Pressable, StyleSheet, Text, View } from 'react-native';
3-
2+
import { Alert, Pressable, StyleSheet, Text, View } from 'react-native';
3+
import FastImage from 'expo-fast-image';
44
import { GiftIdea } from '@/models/GiftIdea';
55

66
const DetailGiftScreen = () => {
77
const router = useRouter();
8-
const { id, image, title, description, recipient, selectedDate } =
8+
const { id, image, title, description, price, recipient, selectedDate } =
99
useLocalSearchParams() as unknown as GiftIdea;
1010

1111
const handleEdit = () => {
@@ -16,6 +16,7 @@ const DetailGiftScreen = () => {
1616
image,
1717
title,
1818
description,
19+
price,
1920
recipient,
2021
selectedDate,
2122
},
@@ -39,20 +40,27 @@ const DetailGiftScreen = () => {
3940

4041
return (
4142
<View style={styles.container}>
42-
<Image source={{ uri: image }} style={styles.image} />
43+
<FastImage
44+
source={{ uri: image }}
45+
style={styles.image}
46+
cacheKey={id}
47+
contentFit="cover"
48+
/>
4349
<Text style={styles.title}>{title}</Text>
4450
<Text style={styles.description}>{description}</Text>
45-
<Text style={styles.recipient}>For: {recipient}</Text>
51+
<Text style={styles.price}>${price}</Text>
4652
<Text style={styles.date}>
47-
Event Date: {new Date(selectedDate).toLocaleDateString()}
53+
Happening on {new Date(selectedDate).toLocaleDateString()}
4854
</Text>
55+
<Text style={styles.recipient}>for {recipient}</Text>
56+
4957
<View style={styles.actions}>
50-
<Pressable style={styles.editButton} onPress={handleEdit}>
51-
<Text style={styles.buttonText}>Edit</Text>
52-
</Pressable>
5358
<Pressable style={styles.deleteButton} onPress={handleDelete}>
5459
<Text style={styles.buttonText}>Delete</Text>
5560
</Pressable>
61+
<Pressable style={styles.editButton} onPress={handleEdit}>
62+
<Text style={styles.buttonText}>Edit</Text>
63+
</Pressable>
5664
</View>
5765
</View>
5866
);
@@ -64,28 +72,30 @@ const styles = StyleSheet.create({
6472
backgroundColor: '#FFFFFF',
6573
padding: 16,
6674
},
67-
header: {
68-
fontSize: 20,
69-
fontWeight: 'bold',
70-
color: '#333333',
71-
marginBottom: 16,
72-
textAlign: 'center',
73-
},
7475
image: {
7576
width: '100%',
76-
height: 200,
77-
borderRadius: 12,
77+
height: 250,
78+
borderRadius: 16,
7879
marginBottom: 16,
80+
borderWidth: 1,
81+
borderColor: '#f0f0f0',
7982
},
8083
title: {
81-
fontSize: 24,
84+
fontSize: 25,
8285
fontWeight: 'bold',
8386
color: '#333333',
8487
marginBottom: 8,
8588
},
8689
description: {
8790
fontSize: 16,
8891
color: '#666666',
92+
lineHeight: 24,
93+
marginBottom: 8,
94+
},
95+
price: {
96+
fontSize: 18,
97+
fontWeight: 'bold',
98+
color: '#28a745',
8999
marginBottom: 8,
90100
},
91101
recipient: {
@@ -95,7 +105,7 @@ const styles = StyleSheet.create({
95105
},
96106
date: {
97107
fontSize: 16,
98-
color: '#666666',
108+
color: '#888888',
99109
marginBottom: 16,
100110
},
101111
actions: {
@@ -105,19 +115,29 @@ const styles = StyleSheet.create({
105115
},
106116
editButton: {
107117
flex: 1,
108-
backgroundColor: '#007BFF',
109-
padding: 12,
118+
backgroundColor: '#ffa200',
119+
paddingVertical: 14,
110120
borderRadius: 8,
111121
alignItems: 'center',
112-
marginRight: 8,
122+
marginLeft: 8,
123+
shadowColor: '#000',
124+
shadowOffset: { width: 0, height: 4 },
125+
shadowOpacity: 0.2,
126+
shadowRadius: 6,
127+
elevation: 5,
113128
},
114129
deleteButton: {
115130
flex: 1,
116131
backgroundColor: '#FF4D4F',
117-
padding: 12,
132+
paddingVertical: 14,
118133
borderRadius: 8,
119134
alignItems: 'center',
120-
marginLeft: 8,
135+
marginRight: 8,
136+
shadowColor: '#000',
137+
shadowOffset: { width: 0, height: 4 },
138+
shadowOpacity: 0.2,
139+
shadowRadius: 6,
140+
elevation: 5,
121141
},
122142
buttonText: {
123143
color: '#FFFFFF',

src/components/utils/GiftCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function GiftCard({
2323
const handlePress = () => {
2424
router.push({
2525
pathname: '/detail-gift',
26-
params: { id, image, title, description, recipient, selectedDate },
26+
params: { id, image, title, description, price, recipient, selectedDate },
2727
});
2828
};
2929

types/expo-fast-image.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
declare module 'expo-fast-image' {
2+
import { ImageProps } from 'react-native';
3+
4+
interface FastImageProps extends ImageProps {
5+
cacheKey?: string;
6+
placeholder?: any;
7+
contentFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
8+
}
9+
10+
const FastImage: React.FC<FastImageProps>;
11+
12+
export default FastImage;
13+
}

0 commit comments

Comments
 (0)