Last active
November 18, 2022 20:31
-
-
Save wesleyguirra/a7331143b841c0c415b8d60f977edbc2 to your computer and use it in GitHub Desktop.
[Code tutorial] - Building a chat app
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 {SafeAreaView, StyleSheet, Text} from 'react-native'; | |
import ChatItem from './ChatItem'; | |
const currentUser = 32; | |
const chatsMock = [ | |
{ | |
id: 1, | |
users: [ | |
{ | |
id: 32, | |
phone: '+5511999882323', | |
}, | |
{ | |
id: 99, | |
phone: '+5521991234321', | |
}, | |
], | |
messages: [ | |
{ | |
id: '-MLjvqRCEhOCF2MAFjng', | |
content: 'Oi, tudo bem?', | |
sent: '2020-11-09T22:16:40-04:00', | |
sentBy: '+5511999990000', | |
}, | |
], | |
}, | |
{ | |
id: 2, | |
users: [ | |
{ | |
id: 32, | |
phone: '+5511999882323', | |
}, | |
{ | |
id: 99, | |
phone: '+5532988882222', | |
}, | |
], | |
messages: [ | |
{ | |
id: '-MLjvqRCEhOCF2MAFjng', | |
content: 'E aquele conteúdo sobre como criar um chat?', | |
sent: '2020-11-09T22:16:40-04:00', | |
sentBy: '+5511999990000', | |
}, | |
], | |
}, | |
]; | |
const styles = StyleSheet.create({ | |
container: { | |
marginTop: 16, | |
marginHorizontal: 16, | |
}, | |
title: { | |
fontSize: 32, | |
fontWeight: '800', | |
marginTop: 32, | |
}, | |
}); | |
const Chats = () => { | |
return ( | |
<SafeAreaView style={styles.container}> | |
<Text style={styles.title}>Chats</Text> | |
{chatsMock.map((chat) => ( | |
<ChatItem chat={chat} currentUser={currentUser} /> | |
))} | |
</SafeAreaView> | |
); | |
}; | |
export default Chats; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment