aboutsummaryrefslogtreecommitdiff
path: root/src/app/register.tsx
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-08-14 18:06:35 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-08-14 18:06:35 +0000
commit2c2dfba45357bbd205a59145ae55a2779c911ae0 (patch)
tree0736b848aed56ec2da3c2489c49da0519447703d /src/app/register.tsx
downloadyaba-2c2dfba45357bbd205a59145ae55a2779c911ae0.tar.gz
yaba-2c2dfba45357bbd205a59145ae55a2779c911ae0.zip
remake
Signed-off-by: Lucas Faria Mendes <lucas.fariamo08@gmail.com>
Diffstat (limited to 'src/app/register.tsx')
-rw-r--r--src/app/register.tsx142
1 files changed, 142 insertions, 0 deletions
diff --git a/src/app/register.tsx b/src/app/register.tsx
new file mode 100644
index 0000000..aac588d
--- /dev/null
+++ b/src/app/register.tsx
@@ -0,0 +1,142 @@
+import React, { useState } from 'react';
+import { View, StyleSheet, Text, KeyboardAvoidingView, Platform, Alert, ScrollView } from 'react-native';
+import { Link, useRouter } from 'expo-router';
+import { useSafeAreaInsets } from 'react-native-safe-area-context';
+import Animated, { FadeInDown, FadeInUp } from 'react-native-reanimated';
+import * as LocalAuthentication from 'expo-local-authentication';
+import * as SecureStore from 'expo-secure-store';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { Colors, Spacing, Typography } from '@/constants/theme';
+import { useAuth } from '@/contexts/AuthContext';
+
+export default function RegisterScreen() {
+ const insets = useSafeAreaInsets();
+ const router = useRouter();
+ const { register } = useAuth();
+
+ const [name, setName] = useState('');
+ const [email, setEmail] = useState('');
+ const [password, setPassword] = useState('');
+ const [isLoading, setIsLoading] = useState(false);
+
+ async function handleRegister() {
+ if (!name || !email || !password) {
+ Alert.alert('Erro', 'Preencha todos os campos.');
+ return;
+ }
+ try {
+ setIsLoading(true);
+ await register({ name: name.trim(), email: email.trim(), password });
+
+ const hasHardware = await LocalAuthentication.hasHardwareAsync();
+ const isEnrolled = await LocalAuthentication.isEnrolledAsync();
+
+ if (hasHardware && isEnrolled) {
+ router.replace('/biometrics');
+ } else {
+ router.replace('/');
+ }
+ } catch (err: any) {
+ Alert.alert('Erro no cadastro', 'Verifique seus dados.');
+ setIsLoading(false);
+ }
+ }
+
+ return (
+ <KeyboardAvoidingView style={styles.container} behavior={Platform.OS === 'ios' ? 'padding' : undefined}>
+ <ScrollView contentContainerStyle={[styles.content, { paddingTop: insets.top + Spacing.xl }]}>
+ <Animated.View entering={FadeInUp.duration(600)} style={styles.header}>
+ <Text style={styles.title}>Criar Conta</Text>
+ <Text style={styles.subtitle}>Junte-se ao YABA e organize sua vida financeira.</Text>
+ </Animated.View>
+
+ <Animated.View entering={FadeInDown.delay(200).duration(600)} style={styles.form}>
+ <Input
+ id="register-name"
+ label="Nome"
+ placeholder="Como quer ser chamado?"
+ value={name}
+ onChangeText={setName}
+ />
+ <Input
+ id="register-email"
+ label="E-mail"
+ placeholder="seu@email.com"
+ value={email}
+ onChangeText={setEmail}
+ keyboardType="email-address"
+ autoCapitalize="none"
+ />
+ <Input
+ id="register-password"
+ label="Senha"
+ placeholder="No mínimo 6 caracteres"
+ value={password}
+ onChangeText={setPassword}
+ secureTextEntry
+ />
+
+ <Button
+ id="register-button"
+ label="Cadastrar"
+ fullWidth
+ onPress={handleRegister}
+ loading={isLoading}
+ disabled={isLoading}
+ />
+
+ <View style={styles.footer}>
+ <Text style={styles.footerText}>Já tem uma conta? </Text>
+ <Link href="/login" asChild>
+ <Text style={styles.linkText}>Faça login</Text>
+ </Link>
+ </View>
+ </Animated.View>
+ </ScrollView>
+ </KeyboardAvoidingView>
+ );
+}
+
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: Colors.background,
+ },
+ content: {
+ flexGrow: 1,
+ padding: Spacing.xl,
+ justifyContent: 'center',
+ },
+ header: {
+ alignItems: 'center',
+ marginBottom: Spacing.xl,
+ },
+ title: {
+ ...Typography.h1,
+ color: Colors.textPrimary,
+ },
+ subtitle: {
+ ...Typography.body,
+ color: Colors.textSecondary,
+ marginTop: Spacing.xs,
+ textAlign: 'center',
+ },
+ form: {
+ gap: Spacing.lg,
+ },
+ footer: {
+ flexDirection: 'row',
+ justifyContent: 'center',
+ marginTop: Spacing.xl,
+ },
+ footerText: {
+ ...Typography.body,
+ color: Colors.textSecondary,
+ },
+ linkText: {
+ ...Typography.body,
+ color: Colors.primaryLight,
+ fontFamily: 'DMSans_700Bold',
+ },
+});