// screens/moves/MoveFormScreen.tsx import React, { useState } from 'react'; import { Button, StyleSheet, TextInput, View } from 'react-native'; import { StackNavigationProp } from '@react-navigation/stack'; import { RootStackParamList } from "../../navigation/navigationTypes"; import { useDispatch } from 'react-redux'; import { createMove, updateMove } from '../../redux/actions/moveActions'; import { AppDispatch } from "../../redux/store"; import { Move } from "../../entities/Move"; import { RouteProp } from "@react-navigation/native"; import { MOVE_FORM } from "../../navigation/constants"; import { Picker } from "@react-native-community/picker"; import { ItemValue } from "@react-native-community/picker/typings/Picker"; import { MoveCategoryName } from "../../entities/MoveCategoryName"; import { TypeName } from "../../entities/TypeName"; type MoveFormScreenNavigationProp = StackNavigationProp; type MoveFormScreenRouteProp = RouteProp; type Props = { navigation: MoveFormScreenNavigationProp; route: MoveFormScreenRouteProp }; const MoveFormScreen = ({ navigation, route }: Props) => { const dispatch = useDispatch(); const [move, setMove] = useState(route.params?.move || { id: null, name: '', category: MoveCategoryName.PHYSICAL, power: 0, accuracy: 0, type: { name: TypeName.NORMAL, weakAgainst: [], effectiveAgainst: [], }, schemaVersion: 2 }); const handleSave = () => { if (route.params?.move) { (dispatch as AppDispatch)(updateMove(route.params.move.id!, move)); } else { (dispatch as AppDispatch)(createMove(move)); } navigation.goBack(); }; // TODO add labels and remove placeholders return ( setMove({ ...move, name: text })} placeholder="Name" style={styles.input} /> setMove({ ...move, category: itemValue as MoveCategoryName }) }> {Object.values(MoveCategoryName).map((value) => )} setMove({ ...move, power: Number(text) })} placeholder="Power" style={styles.input} keyboardType="numeric" /> setMove({ ...move, accuracy: Number(text) })} placeholder="Accuracy" style={styles.input} keyboardType="numeric" /> setMove({ ...move, type: { ...move.type, name: itemValue as TypeName } }) }> {Object.values(TypeName).map((value) => )} {/*TODO add weakAgainst and effectiveAgainst columns... Two pickers for that, and the ability to keep adding types in each column.. but user can't put the same type in each column or twice in a column*/}