Skip to content

Commit

Permalink
adding pages
Browse files Browse the repository at this point in the history
Signed-off-by: Guilherme Banci <guibanci@gmail.com>
  • Loading branch information
gdeusdara committed Aug 30, 2021
1 parent 02550d4 commit 3fcbac3
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 0 deletions.
77 changes: 77 additions & 0 deletions src/pages/Page1/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React, {useState} from 'react';
import {Alert, Platform} from 'react-native';
import ScrollView from 'components/UI/ScrollView';
import Input from 'components/UI/Input';
import required from 'validators/required';
import phoneValidator from 'validators/phone';
import phoneMask from 'masks/phoneMask';
import Btn from 'components/UI/Btn';
import api from 'services/api';
import Text from 'components/UI/Text';
import {useDispatch} from 'react-redux';
import * as Actions from 'store/actions';
import theme from 'theme/theme';
import {Container} from './styles';

const Page1 = ({navigation}) => {
const dispatch = useDispatch();

const [phone, setPhone] = useState({
isValid: false,
value: '',
});

const [name, setName] = useState({
isValid: false,
value: '',
});

const formIsValid = () => {
return phone.isValid && name.isValid;
};

const onPress = async () => {
navigation.navigate('Page2')
// dispatch(Actions.enableLoader());
// const params = {}
// try {
// await api.post('/route/', params);
// } catch (error) {
// Alert.alert('Cartografia Social', 'Ocorreu um erro ao se conectar com o servidor');
// dispatch(Actions.disableLoader());
// }
};

return (
<ScrollView>
<Container>
<Text alignSelf="center" fontSize={theme.font.sizes.L} my={3}>
Texto exemplo
</Text>
<Input
label="Seu nome"
onChange={(value) => setName(value)}
value={name.value}
autoCapitalize="words"
rules={[required]}
/>
<Input
label="Número de telefone"
onChange={(value) => setPhone(value)}
value={phone.value}
inputMask={phoneMask}
keyboardType="numeric"
rules={[required, phoneValidator]}
/>
<Btn
disabled={!formIsValid()}
style={{marginVertical: 50}}
title="Próximo"
onPress={onPress}
/>
</Container>
</ScrollView>
);
};

export default Page1;
14 changes: 14 additions & 0 deletions src/pages/Page1/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import styled from 'styled-components/native';

export const Container = styled.View`
padding: 20px;
`;

export const FirstInput = styled.View`
flex-direction: row;
align-items: center;
`;

export const InputView = styled.View`
flex: 1;
`;
12 changes: 12 additions & 0 deletions src/pages/Page2/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import {View, Text} from 'components/UI';

const Page2 = () => {
return (
<View flex={1} alignItems="center" justifyContent="center">
<Text>Page 2</Text>
</View>
);
};

export default Page2;
14 changes: 14 additions & 0 deletions src/pages/Page2/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import styled from 'styled-components/native';

export const Container = styled.View`
padding: 20px;
`;

export const FirstInput = styled.View`
flex-direction: row;
align-items: center;
`;

export const InputView = styled.View`
flex: 1;
`;

0 comments on commit 3fcbac3

Please sign in to comment.