|
1 |
| -import { useState, type FC, useRef } from "react"; |
| 1 | +import { useState, type FC, useRef, useEffect } from "react"; |
2 | 2 | import { useTranslation } from "react-i18next";
|
3 | 3 | import { Dimensions, InteractionManager, StyleSheet, View } from "react-native";
|
| 4 | +import { TouchableWithoutFeedback } from "react-native-gesture-handler"; |
4 | 5 | import type Animated from "react-native-reanimated";
|
5 | 6 | import { SafeAreaView } from "react-native-safe-area-context";
|
6 | 7 |
|
@@ -30,6 +31,7 @@ export const CreateShotsPage: FC<NativeStackScreenProps<RootStackParamList, "Cre
|
30 | 31 | const [assets, setAssets] = useState(route.params.assets);
|
31 | 32 | const [title, setTitle] = useState("");
|
32 | 33 | const [content, setContent] = useState("");
|
| 34 | + const [postEnabled, setPostEnabled] = useState(false); |
33 | 35 | const characterId = useCharacterId();
|
34 | 36 | const { pickImages } = usePickImages();
|
35 | 37 | const { addPostTask } = usePostIndicatorStore();
|
@@ -75,6 +77,10 @@ export const CreateShotsPage: FC<NativeStackScreenProps<RootStackParamList, "Cre
|
75 | 77 | });
|
76 | 78 | };
|
77 | 79 |
|
| 80 | + useEffect(() => { |
| 81 | + setPostEnabled(assets.length > 0 && title.length > 0 && content.length > 0); |
| 82 | + }, [assets, title, content]); |
| 83 | + |
78 | 84 | return (
|
79 | 85 | <YStack flex={1}>
|
80 | 86 | <ScrollView
|
@@ -105,15 +111,9 @@ export const CreateShotsPage: FC<NativeStackScreenProps<RootStackParamList, "Cre
|
105 | 111 | contentFit="cover"
|
106 | 112 | source={{ uri: asset.uri }}
|
107 | 113 | />
|
108 |
| - { |
109 |
| - assets.length > 1 && ( |
110 |
| - <Stack position="absolute" right="$2" bottom="$2" onPress={() => { |
111 |
| - handleRemoveImage(index); |
112 |
| - }}> |
113 |
| - <Trash color="white"/> |
114 |
| - </Stack> |
115 |
| - ) |
116 |
| - } |
| 114 | + <TouchableWithoutFeedback containerStyle={{ position: "absolute", right: 6, bottom: 6 }} onPress={() => handleRemoveImage(index)}> |
| 115 | + <Trash color="white"/> |
| 116 | + </TouchableWithoutFeedback> |
117 | 117 | </Stack>
|
118 | 118 | );
|
119 | 119 | })
|
@@ -170,8 +170,18 @@ export const CreateShotsPage: FC<NativeStackScreenProps<RootStackParamList, "Cre
|
170 | 170 | </ScrollView>
|
171 | 171 |
|
172 | 172 | <XStack width={"100%"} position="absolute" bottom={0} paddingBottom={"$2"}>
|
173 |
| - <SafeAreaView edges={["bottom"]} style={{ flex: 1 }}> |
174 |
| - <Button onPress={handleOnPost} size={"$5"} fontSize={"$7"}>{i18n.t("Post")}</Button> |
| 173 | + <SafeAreaView edges={["bottom"]} style={{ flex: 1 }} > |
| 174 | + <Button |
| 175 | + backgroundColor={postEnabled ? "$primary" : undefined} |
| 176 | + onPress={handleOnPost} |
| 177 | + disabled={!postEnabled} |
| 178 | + size={"$5"} |
| 179 | + width={"95%"} |
| 180 | + fontSize={"$7"} |
| 181 | + alignSelf="center" |
| 182 | + > |
| 183 | + {i18n.t("Post")} |
| 184 | + </Button> |
175 | 185 | </SafeAreaView>
|
176 | 186 | </XStack>
|
177 | 187 | </YStack>
|
|
0 commit comments