From 1d907e7b488cdc677ddb6bfa77c5351a8256da40 Mon Sep 17 00:00:00 2001 From: Alexis Drai Date: Wed, 14 Jun 2023 18:09:25 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20=F0=9F=92=84=20=F0=9F=9B=82=20Fi?= =?UTF-8?q?x=20Move=20Form=20Screen=20(#20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexis DRAI Reviewed-on: https://codefirst.iut.uca.fr/git/alexis.drai/pokemong_app/pulls/20 --- screens/moves/MoveFormScreen.tsx | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/screens/moves/MoveFormScreen.tsx b/screens/moves/MoveFormScreen.tsx index 6a9e570..576ffe6 100644 --- a/screens/moves/MoveFormScreen.tsx +++ b/screens/moves/MoveFormScreen.tsx @@ -1,6 +1,6 @@ // screens/moves/MoveFormScreen.tsx -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { Button, StyleSheet, Text, TextInput } from 'react-native'; import { StackNavigationProp } from '@react-navigation/stack'; import { RootStackParamList } from "../../navigation/navigationTypes"; @@ -44,6 +44,12 @@ const MoveFormScreen = ({ navigation, route }: Props) => { schemaVersion: 2 }); + useEffect(() => { + navigation.setOptions({ + title: route.params?.move ? route.params.move.name : 'New move', + }); + }, [navigation, route.params?.move]); + const [selectedWeakAgainst, setSelectedWeakAgainst] = useState(move.type.weakAgainst); const [selectedEffectiveAgainst, setSelectedEffectiveAgainst] = useState(move.type.effectiveAgainst); @@ -96,14 +102,22 @@ const MoveFormScreen = ({ navigation, route }: Props) => { Power: setMove({ ...move, power: Number(text) })} + onChangeText={(text) => { + if (!isNaN(Number(text))) { + setMove({ ...move, power: Number(text) }); + } + }} style={styles.input} keyboardType="numeric" /> Accuracy: setMove({ ...move, accuracy: Number(text) })} + onChangeText={(text) => { + if (!isNaN(Number(text))) { + setMove({ ...move, accuracy: Number(text) }); + } + }} style={styles.input} keyboardType="numeric" />