Skip to content

Commit 765f37b

Browse files
author
Petr Konecny
committed
fix: improved first example design
1 parent 1933a4e commit 765f37b

File tree

4 files changed

+4347
-1552
lines changed

4 files changed

+4347
-1552
lines changed

example/app/(tabs)/index.tsx

Lines changed: 55 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,66 @@
11
import { ThemedText } from '@/components/ThemedText'
22
import { ThemedView } from '@/components/ThemedView'
33
import { AutoCarousel } from '@strv/react-native-hero-carousel'
4-
import { SafeAreaView } from 'react-native'
4+
import { SafeAreaView, StyleSheet, Dimensions } from 'react-native'
5+
import { Image } from 'expo-image'
6+
import { LinearGradient } from 'expo-linear-gradient'
7+
8+
const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get('window')
9+
10+
const getRandomImageUrl = () => {
11+
return `https://picsum.photos/${SCREEN_WIDTH}/${SCREEN_HEIGHT}?random=${Math.floor(Math.random() * 1000)}`
12+
}
13+
14+
const images = Array.from({ length: 5 }, getRandomImageUrl)
15+
516
export default function HomeScreen() {
617
return (
7-
<SafeAreaView style={{ flex: 1 }}>
8-
<ThemedView style={{ flex: 1 }}>
18+
<SafeAreaView style={styles.container}>
19+
<ThemedView style={styles.container}>
920
<AutoCarousel>
10-
<ThemedView
11-
style={{
12-
flex: 1,
13-
backgroundColor: 'red',
14-
maxHeight: 200,
15-
alignItems: 'center',
16-
justifyContent: 'center',
17-
}}
18-
>
19-
<ThemedText type="title">Slide 1</ThemedText>
20-
</ThemedView>
21-
<ThemedView
22-
style={{
23-
flex: 1,
24-
backgroundColor: 'blue',
25-
maxHeight: 200,
26-
alignItems: 'center',
27-
justifyContent: 'center',
28-
}}
29-
>
30-
<ThemedText type="title">Slide 2</ThemedText>
31-
</ThemedView>
32-
<ThemedView
33-
style={{
34-
flex: 1,
35-
backgroundColor: 'green',
36-
maxHeight: 200,
37-
alignItems: 'center',
38-
justifyContent: 'center',
39-
}}
40-
>
41-
<ThemedText type="title">Slide 3</ThemedText>
42-
</ThemedView>
21+
{images.map((image, index) => (
22+
<ThemedView key={index} style={styles.slide}>
23+
<Image source={{ uri: image }} style={styles.image} contentFit="cover" />
24+
<LinearGradient colors={['transparent', 'rgba(0,0,0,0.8)']} style={styles.gradient}>
25+
<ThemedText style={styles.title}>Slide {index + 1}</ThemedText>
26+
</LinearGradient>
27+
</ThemedView>
28+
))}
4329
</AutoCarousel>
4430
</ThemedView>
4531
</SafeAreaView>
4632
)
4733
}
34+
35+
const styles = StyleSheet.create({
36+
container: {
37+
flex: 1,
38+
},
39+
slide: {
40+
flex: 1,
41+
width: SCREEN_WIDTH,
42+
height: SCREEN_HEIGHT * 0.7,
43+
},
44+
image: {
45+
width: '100%',
46+
height: '100%',
47+
},
48+
gradient: {
49+
position: 'absolute',
50+
bottom: 0,
51+
left: 0,
52+
right: 0,
53+
height: '50%',
54+
justifyContent: 'flex-end',
55+
padding: 20,
56+
},
57+
title: {
58+
fontSize: 32,
59+
bottom: 100,
60+
left: 20,
61+
position: 'absolute',
62+
lineHeight: 32,
63+
fontWeight: 'bold',
64+
color: 'white',
65+
},
66+
})

example/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"expo-font": "~13.3.1",
2121
"expo-haptics": "~14.1.4",
2222
"expo-image": "~2.1.7",
23+
"expo-linear-gradient": "^14.1.4",
2324
"expo-linking": "~7.1.5",
2425
"expo-router": "~5.0.6",
2526
"expo-splash-screen": "~0.30.8",
@@ -40,9 +41,9 @@
4041
"devDependencies": {
4142
"@babel/core": "^7.25.2",
4243
"@types/react": "~19.0.10",
43-
"typescript": "~5.8.3",
4444
"eslint": "^9.25.0",
45-
"eslint-config-expo": "~9.2.0"
45+
"eslint-config-expo": "~9.2.0",
46+
"typescript": "~5.8.3"
4647
},
4748
"private": true
4849
}

0 commit comments

Comments
 (0)