Skip to content

Commit 348fc18

Browse files
committed
style: Modify the button styles in the creating post page.
1 parent 4f83ee1 commit 348fc18

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

.changeset/eight-jeans-fly.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"xlog": patch
3+
---
4+
5+
style: Modify the button styles in the creating post page.

src/pages/CreateShots/index.tsx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { useState, type FC, useRef } from "react";
1+
import { useState, type FC, useRef, useEffect } from "react";
22
import { useTranslation } from "react-i18next";
33
import { Dimensions, InteractionManager, StyleSheet, View } from "react-native";
4+
import { TouchableWithoutFeedback } from "react-native-gesture-handler";
45
import type Animated from "react-native-reanimated";
56
import { SafeAreaView } from "react-native-safe-area-context";
67

@@ -30,6 +31,7 @@ export const CreateShotsPage: FC<NativeStackScreenProps<RootStackParamList, "Cre
3031
const [assets, setAssets] = useState(route.params.assets);
3132
const [title, setTitle] = useState("");
3233
const [content, setContent] = useState("");
34+
const [postEnabled, setPostEnabled] = useState(false);
3335
const characterId = useCharacterId();
3436
const { pickImages } = usePickImages();
3537
const { addPostTask } = usePostIndicatorStore();
@@ -75,6 +77,10 @@ export const CreateShotsPage: FC<NativeStackScreenProps<RootStackParamList, "Cre
7577
});
7678
};
7779

80+
useEffect(() => {
81+
setPostEnabled(assets.length > 0 && title.length > 0 && content.length > 0);
82+
}, [assets, title, content]);
83+
7884
return (
7985
<YStack flex={1}>
8086
<ScrollView
@@ -105,15 +111,9 @@ export const CreateShotsPage: FC<NativeStackScreenProps<RootStackParamList, "Cre
105111
contentFit="cover"
106112
source={{ uri: asset.uri }}
107113
/>
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>
117117
</Stack>
118118
);
119119
})
@@ -170,8 +170,18 @@ export const CreateShotsPage: FC<NativeStackScreenProps<RootStackParamList, "Cre
170170
</ScrollView>
171171

172172
<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>
175185
</SafeAreaView>
176186
</XStack>
177187
</YStack>

src/pages/TakePhoto/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export const TakePhotoPage: FC<NativeStackScreenProps<RootStackParamList, "TakeP
121121
>
122122
<ScrollView ref={scrollViewRef} horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={{ paddingHorizontal: itemGap }}>
123123
{
124-
pictures.map((picture, index) => {
124+
pictures.map((picture) => {
125125
return (
126126
<Stack
127127
justifyContent="space-between"

0 commit comments

Comments
 (0)