Skip to content
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

Techy API React Native #309

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,48 @@
import React from 'react';
import styled from 'styled-components/native';
import TechyApi from './components/TechyApi';
import { ImageBackground } from 'react-native';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could remove this line, since it's not used.


const Container = styled.View`
flex: 1;
background-color: papayawhip;
justify-content: center;
align-items: center;
`;
margin-top: 20px;
`;

const Title = styled.Text`
font-size: 24px;
color: palevioletred;
font-size: 20px;
color: darkgreen;
`;

const ContainerText = styled.View`
flex: 1;
justify-content: center;
align-items: center;
width: 80%;
padding-left: 20px;
padding-right: 20px;
padding-top: 20px;
`;

const Technician = styled.Image`
width: 40%;
height: 40%;
background: black;
margin-top: 20px;
padding: 10px;
`;

const App = () => {
return (
<Container>
<Title>This is your cool app!</Title>
<Title>Go to App.js and start coding</Title>
<Title>💅💅💅</Title>
<Technician source={require('./assets/technicians-at-work.jpg')} />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great that you made it work!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😊

<ContainerText>
<Title>Want to sound like you know what you are talking about?
Try these techy expressions:
👩‍💻👩‍💻👩‍💻</Title>
</ContainerText>
<TechyApi/>
</Container>
);
};
Expand Down
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}
},
"web": {
"favicon": "./assets/favicon.png"
"favicon": "./assets/favicon.png"
}
}
}
Binary file modified assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/technicians-at-work.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions components/TechyApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React, { useState, useEffect } from 'react';
import { View, Text, TouchableOpacity } from 'react-native';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View and TouchableOpacity are not used, so it's better to remove them here (you don't have to import them when they are styled with styled-components).

import styled from 'styled-components/native';

const TechyApi = () => {
const [techwords, setTechwords] = useState({})

const generateTechWords = () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice API, I should try to learn some sentences ;)

fetch('https://techy-api.vercel.app/api/json')
.then(response => response.json())
.then((data) => setTechwords(data))
}

const Container = styled.View`
flex: 1;
justify-content: center;
align-items: center;
margin: 20px;
width: 80%;
padding-left: 20px;
padding-right: 20px;
`;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's just github that does that, but it seems that the indentation isn't right in some places, like here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its Github for sure, it doesn´t look like this in VSC :)


const Quote = styled.Text`
font-size: 15px;
color: black;
font-style: italic;
`;

const APIButton= styled.TouchableOpacity`
font-weight: 700;
width: 40%;
background-color: green;
margin-top: 20px;
border-radius: 10px;
border: 2px solid darkgreen;
padding; 5px;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your padding isn't applied here because you have a semi-colon instead of a colon, should be padding: 5px;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It´s the little things...right 😊

color: white;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property has no effect (you text on the button remains black), since you are trying to set a font color to a container. Try to apply this to Text inside of the container instead.

`;


useEffect(() => {
generateTechWords();
}, []);

return (
<Container>
<Quote>
{techwords.message}</Quote>
<APIButton onPress={generateTechWords}>
<Text>New sentence</Text>
</APIButton>
</Container>
)
}

export default TechyApi;
Loading