@@ -12,9 +12,9 @@ import {
1212 PanResponder ,
1313 Dimensions ,
1414} from "react-native" ;
15- import { Picker } from "@react-native-picker/picker" ;
1615import DateTimePickerModal from "react-native-modal-datetime-picker" ;
1716import { Ionicons } from "@expo/vector-icons" ;
17+ import { useActionSheet } from '@expo/react-native-action-sheet' ;
1818import { addTaskToList } from "../TaskList/types" ;
1919import { getCategories } from "../../services/taskService" ;
2020import dayjs from "dayjs" ;
@@ -50,12 +50,11 @@ const AddTask: React.FC<AddTaskProps> = ({
5050 allowCategorySelection = false ,
5151} ) => {
5252 const { t } = useTranslation ( ) ;
53+ const { showActionSheetWithOptions } = useActionSheet ( ) ;
5354 const [ categoriesOptions , setCategoriesOptions ] = useState <
5455 { label : string ; value : string } [ ]
5556 > ( [ ] ) ;
56- const [ localCategory , setLocalCategory ] = useState < string > (
57- categoryName || ""
58- ) ;
57+ const [ localCategory , setLocalCategory ] = useState < string > ( "" ) ;
5958 const [ categoryError , setCategoryError ] = useState < string > ( "" ) ;
6059 const [ priority , setPriority ] = useState < number > ( 1 ) ;
6160 const [ title , setTitle ] = useState ( "" ) ;
@@ -337,30 +336,44 @@ const AddTask: React.FC<AddTaskProps> = ({
337336 { allowCategorySelection && (
338337 < >
339338 < Text style = { styles . inputLabel } > Categoria *</ Text >
340- < View
339+ < TouchableOpacity
341340 style = { [
342- styles . dropdown ,
341+ styles . categoryButton ,
343342 categoryError ? styles . inputError : null ,
344343 ] }
344+ onPress = { ( ) => {
345+ const options = [
346+ ...categoriesOptions . map ( cat => cat . label ) ,
347+ 'Annulla'
348+ ] ;
349+ const cancelButtonIndex = options . length - 1 ;
350+
351+ showActionSheetWithOptions (
352+ {
353+ options,
354+ cancelButtonIndex,
355+ title : 'Seleziona categoria' ,
356+ message : 'Scegli una categoria per il task' ,
357+ } ,
358+ ( buttonIndex ) => {
359+ if ( buttonIndex !== cancelButtonIndex ) {
360+ setLocalCategory ( categoriesOptions [ buttonIndex ] . value ) ;
361+ setCategoryError ( "" ) ;
362+ }
363+ }
364+ ) ;
365+ } }
345366 >
346- < Picker
347- selectedValue = { localCategory }
348- onValueChange = { ( itemValue ) => {
349- setLocalCategory ( itemValue as string ) ;
350- if ( itemValue ) setCategoryError ( "" ) ;
351- } }
352- style = { styles . picker }
367+ < Text
368+ style = { [
369+ styles . categoryButtonText ,
370+ ! localCategory && styles . categoryPlaceholder
371+ ] }
353372 >
354- < Picker . Item label = "Seleziona categoria" value = "" />
355- { categoriesOptions . map ( ( option , index ) => (
356- < Picker . Item
357- key = { index }
358- label = { option . label }
359- value = { option . value }
360- />
361- ) ) }
362- </ Picker >
363- </ View >
373+ { localCategory || "Seleziona categoria" }
374+ </ Text >
375+ < Ionicons name = "chevron-down" size = { 20 } color = "#666666" />
376+ </ TouchableOpacity >
364377 { categoryError ? (
365378 < Text style = { styles . errorText } > { categoryError } </ Text >
366379 ) : null }
@@ -847,10 +860,14 @@ const styles = StyleSheet.create({
847860 fontSize : 17 ,
848861 fontFamily : "System" ,
849862 } ,
850- dropdown : {
863+ categoryButton : {
864+ flexDirection : "row" ,
865+ justifyContent : "space-between" ,
866+ alignItems : "center" ,
851867 borderWidth : 1.5 ,
852868 borderColor : "#e1e5e9" ,
853869 borderRadius : 16 ,
870+ padding : 16 ,
854871 marginBottom : 20 ,
855872 backgroundColor : "#ffffff" ,
856873 shadowColor : "#000" ,
@@ -862,9 +879,14 @@ const styles = StyleSheet.create({
862879 shadowRadius : 4 ,
863880 elevation : 1 ,
864881 } ,
865- picker : {
866- height : 50 ,
882+ categoryButtonText : {
883+ fontSize : 17 ,
867884 color : "#000000" ,
885+ fontFamily : "System" ,
886+ fontWeight : "400" ,
887+ } ,
888+ categoryPlaceholder : {
889+ color : "#999999" ,
868890 } ,
869891 disabledText : {
870892 color : "#ccc" ,
0 commit comments