Created
January 8, 2021 16:15
-
-
Save amandeepmittal/d045a23efa2713d54e0a7a73ea2cfd6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useRef } from 'react'; | |
import { | |
StyleSheet, | |
Text, | |
View, | |
TouchableOpacity, | |
ScrollView, | |
Image, | |
Dimensions | |
} from 'react-native'; | |
import { SharedElement } from 'react-navigation-shared-element'; | |
import { | |
SimpleLineIcons, | |
Feather, | |
MaterialCommunityIcons | |
} from '@expo/vector-icons'; | |
const { height } = Dimensions.get('window'); | |
const ITEM_HEIGHT = height * 0.5; | |
export default function Details({ navigation, route }) { | |
const { item } = route.params; | |
return ( | |
<View style={{ flex: 1 }}> | |
<View style={{ backgroundColor: '#0f0f0f' }}> | |
<SharedElement id={`item.${item.id}.image_url`}> | |
<Image | |
source={{ uri: item.image_url }} | |
style={{ | |
width: '100%', | |
height: ITEM_HEIGHT, | |
borderBottomLeftRadius: 20, | |
borderBottomRightRadius: 20 | |
}} | |
resizeMode='cover' | |
/> | |
</SharedElement> | |
<View | |
style={{ flexDirection: 'row', marginTop: 10, paddingHorizontal: 20 }} | |
> | |
<SharedElement id={`item.${item.id}.iconName`}> | |
<SimpleLineIcons size={40} color='white' name={item.iconName} /> | |
</SharedElement> | |
<View style={{ flexDirection: 'column', paddingLeft: 6 }}> | |
<SharedElement id={`item.${item.id}.title`}> | |
<Text | |
style={{ | |
color: 'white', | |
fontSize: 24, | |
fontWeight: 'bold', | |
lineHeight: 28 | |
}} | |
> | |
{item.title} | |
</Text> | |
</SharedElement> | |
<SharedElement id={`item.${item.id}.description`}> | |
<Text | |
style={{ | |
color: 'white', | |
fontSize: 16, | |
fontWeight: 'bold', | |
lineHeight: 18 | |
}} | |
> | |
{item.description} | |
</Text> | |
</SharedElement> | |
</View> | |
</View> | |
</View> | |
<ScrollView | |
indicatorStyle='white' | |
style={{ | |
paddingHorizontal: 20, | |
backgroundColor: '#0f0f0f' | |
}} | |
contentContainerStyle={{ paddingVertical: 20 }} | |
> | |
<Text | |
style={{ | |
fontSize: 18, | |
color: '#fff', | |
lineHeight: 24, | |
marginBottom: 4 | |
}} | |
> | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do | |
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad | |
minim veniam, quis nostrud exercitation ullamco laboris nisi ut | |
aliquip ex ea commodo consequat. Duis aute irure dolor in | |
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla | |
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in | |
culpa qui officia deserunt mollit anim id est laborum. | |
</Text> | |
<Text | |
style={{ | |
fontSize: 18, | |
color: '#fff', | |
lineHeight: 24, | |
marginBottom: 4 | |
}} | |
> | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do | |
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad | |
minim veniam, quis nostrud exercitation ullamco laboris nisi ut | |
aliquip ex ea commodo consequat. Duis aute irure dolor in | |
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla | |
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in | |
culpa qui officia deserunt mollit anim id est laborum. | |
</Text> | |
</ScrollView> | |
<View | |
style={{ | |
position: 'absolute', | |
top: 40, | |
right: 10 | |
}} | |
> | |
<TouchableOpacity onPress={() => navigation.goBack()}> | |
<MaterialCommunityIcons name='close' size={24} color='white' /> | |
</TouchableOpacity> | |
</View> | |
</View> | |
); | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1 | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { | |
ScrollView, | |
StyleSheet, | |
Text, | |
View, | |
TouchableOpacity, | |
Image, | |
Dimensions | |
} from 'react-native'; | |
import { SafeAreaView } from 'react-native-safe-area-context'; | |
import { StatusBar } from 'expo-status-bar'; | |
import { useNavigation } from '@react-navigation/native'; | |
import { SimpleLineIcons } from '@expo/vector-icons'; | |
import { SharedElement } from 'react-navigation-shared-element'; | |
const { width } = Dimensions.get('screen'); | |
const ITEM_WIDTH = width * 0.9; | |
const ITEM_HEIGHT = ITEM_WIDTH * 0.9; | |
import { data } from '../config/data'; | |
export default function Home({ navigation }) { | |
return ( | |
<View style={{ flex: 1, backgroundColor: '#0f0f0f' }}> | |
<StatusBar hidden /> | |
<View style={{ marginTop: 50, marginBottom: 20, paddingHorizontal: 20 }}> | |
<Text style={{ color: '#888', textTransform: 'uppercase' }}> | |
Friday 8 January | |
</Text> | |
<Text style={{ color: '#fff', fontSize: 32, fontWeight: '600' }}> | |
Today | |
</Text> | |
</View> | |
{/* Scrollable content */} | |
<View style={{ flex: 1, paddingBottom: 20 }}> | |
<ScrollView | |
indicatorStyle='white' | |
contentContainerStyle={{ alignItems: 'center' }} | |
> | |
{data.map(item => ( | |
<View key={item.id}> | |
<TouchableOpacity | |
style={{ marginBottom: 14 }} | |
activeOpacity={0.8} | |
onPress={() => navigation.navigate('Details', { item })} | |
> | |
<SharedElement id={`item.${item.id}.image_url`}> | |
<Image | |
style={{ | |
borderRadius: 14, | |
width: ITEM_WIDTH, | |
height: ITEM_HEIGHT | |
}} | |
source={{ uri: item.image_url }} | |
resizeMode='cover' | |
/> | |
</SharedElement> | |
<View | |
style={{ | |
position: 'absolute', | |
bottom: 20, | |
left: 10 | |
}} | |
> | |
<View style={{ flexDirection: 'row' }}> | |
<SharedElement id={`item.${item.id}.iconName`}> | |
<SimpleLineIcons | |
size={40} | |
color='white' | |
name={item.iconName} | |
/> | |
</SharedElement> | |
<View style={{ flexDirection: 'column', paddingLeft: 6 }}> | |
<SharedElement id={`item.${item.id}.title`}> | |
<Text | |
style={{ | |
color: 'white', | |
fontSize: 24, | |
fontWeight: 'bold', | |
lineHeight: 28 | |
}} | |
> | |
{item.title} | |
</Text> | |
</SharedElement> | |
<SharedElement id={`item.${item.id}.description`}> | |
<Text | |
style={{ | |
color: 'white', | |
fontSize: 16, | |
fontWeight: 'bold', | |
lineHeight: 18 | |
}} | |
> | |
{item.description} | |
</Text> | |
</SharedElement> | |
</View> | |
</View> | |
</View> | |
</TouchableOpacity> | |
</View> | |
))} | |
</ScrollView> | |
</View> | |
</View> | |
); | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
backgroundColor: '#0f0f0f' | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment