Unverified Commit c1ac08d1 authored by yannickjacqueline's avatar yannickjacqueline Committed by GitHub
Browse files

fix(carto): correction du picker pour le nombre d'enfants (#740)

parent 990914e9
import { Picker } from "@react-native-community/picker";
import { Picker, PickerIOS } from "@react-native-community/picker";
import { range } from "lodash";
import * as React from "react";
import { useState } from "react";
import { StyleSheet, View } from "react-native";
import { Colors, FontWeight, Labels, Margins } from "../../constants";
import { PLATFORM_IS_IOS } from "../../constants/platform.constants";
import { CommonText } from "..";
interface Props {
......@@ -15,7 +16,7 @@ const CustomNumberOfChildrenPicker: React.FC<Props> = ({
updateNumberOfChildren,
}) => {
const INITIAL_NUMBER_OF_CHILDREN = 1;
const MAX_NUMBER_OF_CHILDREN = 3;
const MAX_NUMBER_OF_CHILDREN = 4;
const [numberOfChildren, setNumberOfChildren] = useState(
INITIAL_NUMBER_OF_CHILDREN
);
......@@ -25,36 +26,51 @@ const CustomNumberOfChildrenPicker: React.FC<Props> = ({
<CommonText style={styles.textStyle}>
{Labels.epdsSurvey.beContacted.numberOfChildren}
</CommonText>
<Picker
selectedValue={numberOfChildren}
style={styles.pickerStyle}
onValueChange={(itemValue) => {
setNumberOfChildren(Number(itemValue));
updateNumberOfChildren(Number(itemValue));
}}
>
{range(INITIAL_NUMBER_OF_CHILDREN, MAX_NUMBER_OF_CHILDREN).map(
(value) => (
<Picker.Item key={value} label={String(value)} value={value} />
)
)}
</Picker>
{PLATFORM_IS_IOS ? (
<PickerIOS
selectedValue={numberOfChildren}
style={styles.pickerStyle}
onValueChange={(itemValue) => {
setNumberOfChildren(Number(itemValue));
updateNumberOfChildren(Number(itemValue));
}}
>
{range(INITIAL_NUMBER_OF_CHILDREN, MAX_NUMBER_OF_CHILDREN).map(
(value) => (
<PickerIOS.Item key={value} label={String(value)} value={value} />
)
)}
</PickerIOS>
) : (
<Picker
selectedValue={numberOfChildren}
style={styles.pickerStyle}
onValueChange={(itemValue) => {
setNumberOfChildren(Number(itemValue));
updateNumberOfChildren(Number(itemValue));
}}
>
{range(INITIAL_NUMBER_OF_CHILDREN, MAX_NUMBER_OF_CHILDREN).map(
(value) => (
<Picker.Item key={value} label={String(value)} value={value} />
)
)}
</Picker>
)}
</View>
);
};
const styles = StyleSheet.create({
pickerStyle: {
height: 30,
width: 100,
},
rowView: {
alignItems: "center",
flexDirection: "row",
justifyContent: "space-between",
marginVertical: Margins.default,
},
textStyle: {
alignSelf: "center",
color: Colors.primaryBlue,
fontWeight: FontWeight.bold,
marginRight: Margins.default,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment