Skip to content

Commit 675318d

Browse files
authored
Merge pull request #27 from MyTaskly/fix-picker-ios-category
fix-picker-ios-category
2 parents 3578293 + 5167346 commit 675318d

5 files changed

Lines changed: 95 additions & 35 deletions

File tree

.claude/settings.local.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,15 @@
7979
"mcp__revenuecat__list-offerings",
8080
"mcp__revenuecat__get-product",
8181
"mcp__revenuecat__get-product-store-state",
82-
"Bash(git reset *)"
82+
"Bash(git reset *)",
83+
"Bash(but branch *)",
84+
"Bash(but commit *)",
85+
"Bash(but stage *)",
86+
"Bash(but diff *)",
87+
"Bash(but log *)",
88+
"Bash(but *)",
89+
"Bash(git restore *)",
90+
"Bash(npx skills *)"
8391
],
8492
"deny": [],
8593
"defaultMode": "acceptEdits"

package-lock.json

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
},
2222
"dependencies": {
2323
"@expo-google-fonts/inter": "^0.4.2",
24+
"@expo/react-native-action-sheet": "^4.1.1",
2425
"@expo/vector-icons": "^14.0.2",
2526
"@flyerhq/react-native-chat-ui": "^1.4.3",
2627
"@openspacelabs/react-native-zoomable-view": "^2.3.1",

src/components/Task/AddTask.tsx

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import {
1212
PanResponder,
1313
Dimensions,
1414
} from "react-native";
15-
import { Picker } from "@react-native-picker/picker";
1615
import DateTimePickerModal from "react-native-modal-datetime-picker";
1716
import { Ionicons } from "@expo/vector-icons";
17+
import { useActionSheet } from '@expo/react-native-action-sheet';
1818
import { addTaskToList } from "../TaskList/types";
1919
import { getCategories } from "../../services/taskService";
2020
import 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",

src/navigation/index.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
99
import { AppState, BackHandler, Linking } from "react-native";
1010
import { GestureHandlerRootView } from "react-native-gesture-handler";
1111
import { Ionicons } from "@expo/vector-icons";
12+
import { ActionSheetProvider } from '@expo/react-native-action-sheet';
1213
import {
1314
initAnalytics,
1415
trackScreenView,
@@ -588,14 +589,16 @@ export default function Navigation() {
588589

589590
return (
590591
<GestureHandlerRootView style={{ flex: 1 }} onLayout={onLayoutRootView}>
591-
<LanguageProvider>
592-
<TutorialProvider>
593-
<NavigationContainer>
594-
<AppStack />
595-
</NavigationContainer>
596-
<TutorialOnboardingWrapper />
597-
</TutorialProvider>
598-
</LanguageProvider>
592+
<ActionSheetProvider>
593+
<LanguageProvider>
594+
<TutorialProvider>
595+
<NavigationContainer>
596+
<AppStack />
597+
</NavigationContainer>
598+
<TutorialOnboardingWrapper />
599+
</TutorialProvider>
600+
</LanguageProvider>
601+
</ActionSheetProvider>
599602
</GestureHandlerRootView>
600603
);
601604
}

0 commit comments

Comments
 (0)