Skip to content

Commit 8b57507

Browse files
committed
Continuação mobile
1 parent 3ffa396 commit 8b57507

File tree

18 files changed

+5611
-1
lines changed

18 files changed

+5611
-1
lines changed

frontend/src/services/api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import axios from 'axios';
22

33
const api = axios.create({
4-
baseURL: "http://localhost:3333",
4+
baseURL: "http://10.0.0.40:3333",
55
});
66

77
export default api;

mobile/.expo-shared/assets.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"f9155ac790fd02fadcdeca367b02581c04a353aa6d5aa84409a59f6804c87acd": true,
3+
"89ed26367cdb9b771858e026f2eb95bfdb90e5ae943e716575327ec325f39c44": true
4+
}

mobile/.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
node_modules/**/*
2+
.expo/*
3+
npm-debug.*
4+
*.jks
5+
*.p8
6+
*.p12
7+
*.key
8+
*.mobileprovision
9+
*.orig.*
10+
web-build/
11+
web-report/
12+
13+
# macOS
14+
.DS_Store

mobile/App.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react';
2+
import Routes from './src/routes';
3+
4+
export default function App() {
5+
return <Routes />
6+
}
7+
8+

mobile/app.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"expo": {
3+
"name": "Blank Template",
4+
"slug": "mobile",
5+
"privacy": "public",
6+
"sdkVersion": "36.0.0",
7+
"platforms": [
8+
"ios",
9+
"android",
10+
"web"
11+
],
12+
"version": "1.0.0",
13+
"orientation": "portrait",
14+
"icon": "./assets/icon.png",
15+
"splash": {
16+
"image": "./assets/splash.png",
17+
"resizeMode": "contain",
18+
"backgroundColor": "#ffffff"
19+
},
20+
"updates": {
21+
"fallbackToCacheTimeout": 0
22+
},
23+
"assetBundlePatterns": [
24+
"**/*"
25+
],
26+
"ios": {
27+
"supportsTablet": true
28+
}
29+
}
30+
}

mobile/assets/icon.png

1.07 KB
Loading

mobile/assets/splash.png

7.01 KB
Loading

mobile/babel.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = function(api) {
2+
api.cache(true);
3+
return {
4+
presets: ['babel-preset-expo'],
5+
};
6+
};

mobile/package.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"main": "node_modules/expo/AppEntry.js",
3+
"scripts": {
4+
"start": "expo start",
5+
"android": "expo start --android",
6+
"ios": "expo start --ios",
7+
"web": "expo start --web",
8+
"eject": "expo eject"
9+
},
10+
"dependencies": {
11+
"@react-native-community/masked-view": "0.1.5",
12+
"axios": "^0.19.2",
13+
"expo": "~36.0.0",
14+
"react": "~16.9.0",
15+
"react-dom": "~16.9.0",
16+
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
17+
"react-native-gesture-handler": "~1.5.0",
18+
"react-native-reanimated": "~1.4.0",
19+
"react-native-safe-area-context": "0.6.0",
20+
"react-native-screens": "2.0.0-alpha.12",
21+
"react-native-web": "~0.11.7",
22+
"react-navigation": "^4.1.1"
23+
},
24+
"devDependencies": {
25+
"@babel/core": "^7.0.0",
26+
"babel-preset-expo": "~8.0.0"
27+
},
28+
"private": true
29+
}

mobile/src/assets/logo.png

4.68 KB
Loading

mobile/src/assets/logo@2x.png

9.61 KB
Loading

mobile/src/assets/logo@3x.png

15.2 KB
Loading

mobile/src/page/Book.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import React from 'react';
2+
import { View } from 'react-native';
3+
4+
export default function Book() {
5+
return <View></View>
6+
}

mobile/src/page/List.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React, { useState, useEffect } from 'react';
2+
import { View, AsyncStorage, Text } from 'react-native';
3+
4+
export default function List() {
5+
const [techs, setTechs] = useState([]);
6+
7+
useEffect(() => {
8+
AsyncStorage.getItem('techs').then(storagedTechs => {
9+
const techsArray = storagedTechs.split(',').map(tech => tech.trim());
10+
11+
setTechs(techsArray);
12+
})
13+
}, []);
14+
15+
16+
return <Text>{techs}</Text>
17+
}

mobile/src/page/Login.js

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import React, {useState, useEffect} from 'react';
2+
import { View, AsyncStorage, KeyboardAvoidingView, Platform, Image, Text, TextInput, StyleSheet, TouchableOpacity } from 'react-native';
3+
4+
import api from '../services/api';
5+
import logo from '../assets/logo.png';
6+
7+
8+
export default function Login({ navigation }) {
9+
const [email, setEmail] = useState('');
10+
const [techs, setTechs] = useState('');
11+
12+
useEffect(() => {
13+
AsyncStorage.getItem('user').then(user => {
14+
if(user){
15+
navigation.navigate('List');
16+
}
17+
})
18+
}, []);
19+
20+
async function handleSubmit(){
21+
const response = await api.post('/session',{
22+
email
23+
})
24+
const {_id} = response.data;
25+
26+
await AsyncStorage.setItem('user', _id);
27+
await AsyncStorage.setItem('techs', techs);
28+
29+
navigation.navigate('List');
30+
}
31+
32+
return (
33+
<KeyboardAvoidingView /*enabled={Platform.OS === 'ios'}*/ behavior="padding" style = {styles.contanier}>
34+
<Image source={logo} />
35+
<View style={styles.form}>
36+
<Text style={styles.label}>SEU E-MAIL *</Text>
37+
<TextInput
38+
style={styles.input}
39+
placeholder="Seu e-mail"
40+
placeholderTextColor="#999"
41+
keyboardType="email-address"
42+
autoCapitalize="none"
43+
autoCorrect={false}
44+
value={email}
45+
onChangeText = {setEmail}
46+
/>
47+
48+
49+
<Text style={styles.label}>TECNOLOGIAS *</Text>
50+
<TextInput
51+
style={styles.input}
52+
placeholder="Tecnologias de interesse"
53+
placeholderTextColor="#999"
54+
autoCapitalize="words"
55+
autoCorrect={false}
56+
onChangeText={setTechs}
57+
/>
58+
59+
<TouchableOpacity onPress={handleSubmit} style={styles.button}>
60+
<Text style={styles.buttonText}>Encontrar spots</Text>
61+
</TouchableOpacity>
62+
</View>
63+
</KeyboardAvoidingView>
64+
);
65+
}
66+
67+
const styles = StyleSheet.create({
68+
contanier :{
69+
flex: 1,
70+
justifyContent: 'center',
71+
alignItems: 'center',
72+
},
73+
74+
form: {
75+
alignSelf: 'stretch',
76+
paddingHorizontal: 30,
77+
marginTop: 30,
78+
},
79+
80+
label: {
81+
fontWeight: 'bold',
82+
color: '#444',
83+
marginBottom: 8,
84+
},
85+
86+
input:{
87+
borderWidth: 1,
88+
borderColor: '#ddd',
89+
paddingHorizontal: 20,
90+
fontSize: 16,
91+
color:'#444',
92+
height: 44,
93+
marginBottom: 20,
94+
borderRadius: 2,
95+
},
96+
97+
button:{
98+
borderRadius: 2,
99+
backgroundColor: '#f05a5b',
100+
justifyContent: 'center',
101+
alignItems: 'center',
102+
height:42,
103+
},
104+
105+
buttonText:{
106+
color: '#fff',
107+
fontWeight: 'bold',
108+
fontSize:16,
109+
},
110+
});
111+

mobile/src/routes.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { createAppContainer, createSwitchNavigator } from 'react-navigation';
2+
3+
import Login from './page/Login';
4+
import List from './page/List';
5+
import Book from './page/Book'
6+
7+
const Routes = createAppContainer(
8+
createSwitchNavigator({
9+
Login,
10+
List,
11+
Book
12+
})
13+
);
14+
15+
16+
export default Routes;

mobile/src/services/api.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import axios from 'axios';
2+
3+
const api = axios.create({
4+
baseURL: 'http://10.0.0.40:3333',
5+
});
6+
7+
export default api;

0 commit comments

Comments
 (0)