import React from 'react'; import { TextInput, StyleSheet, View, TouchableOpacity , Dimensions, Alert, ImageBackground, } from 'react-native'; import { RadioButton, Text, ActivityIndicator } from 'react-native-paper'; import 'react-native-vector-icons'; import 'react-native-get-random-values'; import { Controller, useForm } from 'react-hook-form'; import { useRegistrationFormState } from '../contexts/RegisterContext'; const RegisterMeasurements = ({navigation}) => { const { dispatch, state: { height, weight, sagitta, isSubmitLoading } } = useRegistrationFormState(); const { control, handleSubmit, formState: {errors} } = useForm({ mode: 'all' }); const goBack = (formData) => { dispatch({ type: "HEIGHT_CHANGE", payload: formData.height }) dispatch({ type: "WEIGHT_CHANGE", payload: formData.weight }) navigation.navigate("Credentials"); } const toggleSagitta = (value) => { dispatch({ type: "SAGITTA_CHANGE", payload: value }) } const register = async (formData) => { dispatch({ type: "HEIGHT_CHANGE", payload: formData.height }) dispatch({ type: "WEIGHT_CHANGE", payload: formData.weight }) navigation.navigate("RegisterImage"); } return ( Will you be using a sagitta? {toggleSagitta(false)}} /> No {toggleSagitta(true)}} /> Yes { sagitta ? We'll also need some body measurements. ( onChange(value)} > )} name="height" rules={{ required: true, pattern: { value: /^[0-9]*$/i }}} /> {errors.height?.type === "required" && Height is required.} {errors.height?.type === "pattern" && Must be a number.} ( onChange(value)} /> )} rules={{ required: true, pattern: { value: /^[0-9]*$/i }}} name="weight"/> {errors.weight?.type === "required" && Weight is required.} {errors.weight?.type === "pattern" && Must be a number.} : null } Back Next ) } const styles = StyleSheet.create({ container: { backgroundColor: 'transparent', position: 'absolute', width: Dimensions.get('window').width, height: Dimensions.get('window').height, flex: 1, flexDirection: 'column', resizeMode: 'cover', }, brandContainer: { marginTop: 70, height: 120, marginLeft: 25, flexDirection: 'column', justifyContent: 'space-evenly' }, title: { fontFamily: 'RacingSansOne-Regular', color: 'white', fontSize: 20 }, sagittaCheck: { flexDirection: 'row', margin: 20 }, radioLabel: { marginTop: 7, marginRight: 20, color: 'white' }, subtitle: { fontFamily: 'RacingSansOne-Regular', color: 'white', fontSize: 15, marginHorizontal: 20, marginTop: 20 }, textContainer: { marginHorizontal: 20, marginBottom: 30, borderRadius: 50, }, textInput: { marginVertical: 7, paddingLeft: 30, borderRadius: 50, overflow: 'hidden', backgroundColor: 'white', height: 50 }, errorText: { alignSelf: 'flex-end', color: 'red', fontSize: 15 }, errorInput: { borderWidth: 2, borderColor: 'red' }, nextBtn: { marginHorizontal: 20, marginBottom: 100, borderRadius: 50, justifyContent: 'center', backgroundColor: '#df3f3f', margin: 5, height: 50, alignItems: 'center' }, backBtn: { marginHorizontal: 20, marginBottom: 10, borderRadius: 50, borderColor: 'white', borderWidth: 2, justifyContent: 'center', backgroundColor: 'transparent', margin: 5, height: 50, alignItems: 'center' }, }) export default RegisterMeasurements;