- 
                Notifications
    
You must be signed in to change notification settings  - Fork 311
 
project-react-native-app #304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,26 +1,21 @@ | ||
| import React from 'react'; | ||
| import styled from 'styled-components/native'; | ||
| 
     | 
||
| const Container = styled.View` | ||
| flex: 1; | ||
| background-color: papayawhip; | ||
| justify-content: center; | ||
| align-items: center; | ||
| `; | ||
| 
     | 
||
| const Title = styled.Text` | ||
| font-size: 24px; | ||
| color: palevioletred; | ||
| `; | ||
| import RandomQuote from './components/RandomQuote'; | ||
| 
     | 
||
| const App = () => { | ||
| return ( | ||
| <Container> | ||
| <Title>This is your cool app!</Title> | ||
| <Title>Go to App.js and start coding</Title> | ||
| <Title>💅💅💅</Title> | ||
| <RandomQuote /> | ||
| </Container> | ||
| ); | ||
| }; | ||
| 
     | 
||
| const Container = styled.View` | ||
| flex: 1; | ||
| background-color: #3d405b; | ||
| justify-content: center; | ||
| align-items: center; | ||
| `; | ||
| 
     | 
||
| export default App; | ||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import data from '../albums.json'; | ||
| import React, { useEffect, useState } from 'react'; | ||
| import { View, Text } from 'react-native'; | ||
| 
     | 
||
| const Albums = () => { | ||
| const [album, setAlbum] = useState({}); | ||
| console.log(data.items[2].name); | ||
| 
     | 
||
| const generateAlbum = () => { | ||
| fetch('../albums.json') | ||
| .then((res) => res.json()) | ||
| .then((data) => setAlbum(data)); | ||
| }; | ||
| 
     | 
||
| useEffect(() => { | ||
| generateAlbum(); | ||
| }); | ||
| 
     | 
||
| return ( | ||
| <View> | ||
| <Text>{JSON.stringify(data.items[2].name)} </Text> | ||
| </View> | ||
| ); | ||
| }; | ||
| 
     | 
||
| export default Albums; | ||
| 
         
      Comment on lines
    
      +1
     to 
      +26
    
   
  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might have missed this from the classes since we did not do the same project, but I can't see it imported somewhere so just wanted to comment in case it is not used :)  | 
||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import React, { useState, useEffect } from 'react'; | ||
| import { View, Text, TouchableOpacity, StyleSheet } from 'react-native'; | ||
| 
     | 
||
| const RandomQuote = () => { | ||
| const [quote, setQuote] = useState({}); | ||
| 
     | 
||
| const generateQuote = () => { | ||
| fetch('https://api.quotable.io/random') | ||
| .then((res) => res.json()) | ||
| .then((data) => setQuote(data)); | ||
| }; | ||
| 
     | 
||
| useEffect(() => { | ||
| generateQuote(); | ||
| }, []); | ||
| 
         
      Comment on lines
    
      +4
     to 
      +15
    
   
  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well doe with the fetch, it works perfectly on my phone! : D  | 
||
| 
     | 
||
| return ( | ||
| <View style={styles.container}> | ||
| <TouchableOpacity style={styles.btn} onPress={generateQuote}> | ||
| <Text style={styles.btnText}>New Quote</Text> | ||
| </TouchableOpacity> | ||
| <Text style={styles.quote}>"{quote.content}"</Text> | ||
| <Text style={styles.author}>{quote.author}</Text> | ||
| </View> | ||
| ); | ||
| }; | ||
| 
     | 
||
| 
         
      Comment on lines
    
      +17
     to 
      +27
    
   
  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great job implementing the Stylesheet object for styling the fetched quotes and author now that we had the opportunity to try it! ^__^  | 
||
| const styles = StyleSheet.create({ | ||
| container: { | ||
| padding: 30, | ||
| }, | ||
| btn: { | ||
| alignItems: 'center', | ||
| backgroundColor: '#81b29a', | ||
| paddingVertical: 20, | ||
| paddingHorizontal: 30, | ||
| marginBottom: 10, | ||
| alignSelf: 'center', | ||
| borderRadius: 3, | ||
| }, | ||
| btnText: { | ||
| color: '#f4f1de', | ||
| fontSize: 18, | ||
| textTransform: 'uppercase', | ||
| fontWeight: 'bold', | ||
| }, | ||
| quote: { | ||
| color: '#f4f1de', | ||
| fontSize: 24, | ||
| fontStyle: 'italic', | ||
| textAlign: 'center', | ||
| margin: 20, | ||
| lineHeight: 30, | ||
| }, | ||
| author: { | ||
| color: '#f4f1de', | ||
| textAlign: 'center', | ||
| fontSize: 18, | ||
| fontWeight: 'bold', | ||
| }, | ||
| }); | ||
| 
     | 
||
| export default RandomQuote; | ||
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice and clean approach in app.js with only RandomQuote :)