@ -1,19 +1,19 @@
// screens/moves/MoveFormScreen.tsx
// screens/moves/MoveFormScreen.tsx
import React , { useState } from 'react' ;
import React , { useState } from 'react' ;
import { Button , StyleSheet , Text Input, View } from 'react-native' ;
import { Button , StyleSheet , Text , Text Input, View } from 'react-native' ;
import { StackNavigationProp } from '@react-navigation/stack' ;
import { StackNavigationProp } from '@react-navigation/stack' ;
import { RootStackParamList } from "../../navigation/navigationTypes" ;
import { RootStackParamList } from "../../navigation/navigationTypes" ;
import { useDispatch } from 'react-redux' ;
import { useDispatch } from 'react-redux' ;
import { createMove , updateMove } from '../../redux/actions/moveActions' ;
import { createMove , updateMove } from '../../redux/actions/moveActions' ;
import { AppDispatch } from "../../redux/store" ;
import { AppDispatch } from "../../redux/store" ;
import { Move } from "../../entities/Move" ;
import { Move } from "../../entities/Move" ;
import { RouteProp } from "@react-navigation/native" ;
import { RouteProp } from "@react-navigation/native" ;
import { MOVE_FORM } from "../../navigation/constants" ;
import { MOVE_FORM } from "../../navigation/constants" ;
import { Picker } from "@react-native-community/picker" ;
import { Picker } from "@react-native-community/picker" ;
import { ItemValue } from "@react-native-community/picker/typings/Picker" ;
import { ItemValue } from "@react-native-community/picker/typings/Picker" ;
import { MoveCategoryName } from "../../entities/MoveCategoryName" ;
import { MoveCategoryName } from "../../entities/MoveCategoryName" ;
import { TypeName } from "../../entities/TypeName" ;
import { TypeName } from "../../entities/TypeName" ;
type MoveFormScreenNavigationProp = StackNavigationProp < RootStackParamList , typeof MOVE_FORM > ;
type MoveFormScreenNavigationProp = StackNavigationProp < RootStackParamList , typeof MOVE_FORM > ;
type MoveFormScreenRouteProp = RouteProp < RootStackParamList , typeof MOVE_FORM > ;
type MoveFormScreenRouteProp = RouteProp < RootStackParamList , typeof MOVE_FORM > ;
@ -49,17 +49,18 @@ const MoveFormScreen = ({ navigation, route }: Props) => {
navigation . goBack ( ) ;
navigation . goBack ( ) ;
} ;
} ;
// TODO add labels and remove placeholders
return (
return (
< View style = { styles . container } >
< View style = { styles . container } >
< Text > Name : < / Text >
< TextInput
< TextInput
value = { move . name }
value = { move . name }
onChangeText = { ( text ) = > setMove ( { . . . move , name : text } ) }
onChangeText = { ( text ) = > setMove ( { . . . move , name : text } ) }
placeholder = "Name"
style = { styles . input }
style = { styles . input }
/ >
/ >
< Text > Category : < / Text >
< Picker
< Picker
selectedValue = { move . category }
selectedValue = { move . category }
style = { styles . input }
onValueChange = { ( itemValue : ItemValue ) = >
onValueChange = { ( itemValue : ItemValue ) = >
setMove ( { . . . move , category : itemValue as MoveCategoryName } )
setMove ( { . . . move , category : itemValue as MoveCategoryName } )
} >
} >
@ -67,22 +68,24 @@ const MoveFormScreen = ({ navigation, route }: Props) => {
< Picker.Item key = { value } label = { value } value = { value } / >
< Picker.Item key = { value } label = { value } value = { value } / >
) }
) }
< / Picker >
< / Picker >
< Text > Power : < / Text >
< TextInput
< TextInput
value = { move . power . toString ( ) }
value = { move . power . toString ( ) }
onChangeText = { ( text ) = > setMove ( { . . . move , power : Number ( text ) } ) }
onChangeText = { ( text ) = > setMove ( { . . . move , power : Number ( text ) } ) }
placeholder = "Power"
style = { styles . input }
style = { styles . input }
keyboardType = "numeric"
keyboardType = "numeric"
/ >
/ >
< Text > Accuracy : < / Text >
< TextInput
< TextInput
value = { move . accuracy . toString ( ) }
value = { move . accuracy . toString ( ) }
onChangeText = { ( text ) = > setMove ( { . . . move , accuracy : Number ( text ) } ) }
onChangeText = { ( text ) = > setMove ( { . . . move , accuracy : Number ( text ) } ) }
placeholder = "Accuracy"
style = { styles . input }
style = { styles . input }
keyboardType = "numeric"
keyboardType = "numeric"
/ >
/ >
< Text > Type : < / Text >
< Picker
< Picker
selectedValue = { move . type . name }
selectedValue = { move . type . name }
style = { styles . input }
onValueChange = { ( itemValue : ItemValue ) = >
onValueChange = { ( itemValue : ItemValue ) = >
setMove ( { . . . move , type : { . . . move . type , name : itemValue as TypeName } } )
setMove ( { . . . move , type : { . . . move . type , name : itemValue as TypeName } } )
} >
} >
@ -90,13 +93,12 @@ const MoveFormScreen = ({ navigation, route }: Props) => {
< Picker.Item key = { value } label = { value } value = { value } / >
< Picker.Item key = { value } label = { value } value = { value } / >
) }
) }
< / Picker >
< / Picker >
{ /*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*/}
{ /*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*/}
< Button title = "Save" onPress = { handleSave } / >
< Button title = "Save" onPress = { handleSave } / >
< / View >
< / View >
) ;
) ;
} ;
} ;
// TODO improve styles a bit
const styles = StyleSheet . create ( {
const styles = StyleSheet . create ( {
container : {
container : {
flex : 1 ,
flex : 1 ,