// screens/moves/MoveFormScreen.tsx import React, { useState } from 'react'; import { Button, StyleSheet, Text, 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(); }; return ( Name: setMove({ ...move, name: text })} style={styles.input} /> Category: setMove({ ...move, category: itemValue as MoveCategoryName }) }> {Object.values(MoveCategoryName).map((value) => )} Power: setMove({ ...move, power: Number(text) })} style={styles.input} keyboardType="numeric" /> Accuracy: setMove({ ...move, accuracy: Number(text) })} style={styles.input} keyboardType="numeric" /> Type: setMove({ ...move, type: { ...move.type, name: itemValue as TypeName } }) }> {Object.values(TypeName).map((value) => )} {/*TODO add type.weakAgainst and type.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*/}