From 19e32ec34867728e3871da83ef0160542aee8181 Mon Sep 17 00:00:00 2001 From: Alexis DRAI Date: Wed, 14 Jun 2023 18:06:34 +0200 Subject: [PATCH 1/2] :adhesive_bandage: Fix #18: Give title to Move forms --- screens/moves/MoveFormScreen.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/screens/moves/MoveFormScreen.tsx b/screens/moves/MoveFormScreen.tsx index 6a9e570..a99d10d 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); -- 2.36.3 From 1a330543d6c17a0c2027e2735c13730cc187bc45 Mon Sep 17 00:00:00 2001 From: Alexis DRAI Date: Wed, 14 Jun 2023 18:07:49 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=9B=82=20Fix=20#16:=20Validate=20numb?= =?UTF-8?q?er=20fields=20to=20prevent=20NaN=20issues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- screens/moves/MoveFormScreen.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/screens/moves/MoveFormScreen.tsx b/screens/moves/MoveFormScreen.tsx index a99d10d..576ffe6 100644 --- a/screens/moves/MoveFormScreen.tsx +++ b/screens/moves/MoveFormScreen.tsx @@ -102,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" /> -- 2.36.3