Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style Images + Remove Image Functionality #430

Merged
merged 10 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 37 additions & 16 deletions components/create/details.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import Tag from "@/components/global/tag";
import Beat from "@/components/global/beat";
import { View, Text, TextInput, Pressable } from "react-native";
import {
View,
Text,
TextInput,
Pressable,
ImageBackground,
} from "react-native";
import { useEffect, useState } from "react";
import { beat } from "@/types";
import { Image } from "expo-image";

Check warning on line 12 in components/create/details.tsx

View workflow job for this annotation

GitHub Actions / linting

'Image' is defined but never used
import * as Location from "expo-location";
import * as ImagePicker from "expo-image-picker";
import Icon from "../Icon";
import { useUser } from "@/hooks/useUser";
import { useDrops } from "@/hooks/useDrops";
import { router } from "expo-router";
import { ScrollView } from "react-native-gesture-handler";

const colors = [
"bg-beatdrop-tag-orange",
Expand Down Expand Up @@ -38,7 +45,7 @@
}: props) => {
const [tag, setTag] = useState("");
const [location, setLocation] = useState("");
const [error, setError] = useState("");

Check warning on line 48 in components/create/details.tsx

View workflow job for this annotation

GitHub Actions / linting

'error' is assigned a value but never used
const [loading, setLoading] = useState(false);
const [coordinates, setCoordinates] = useState({
longitude: 0.0,
Expand Down Expand Up @@ -122,6 +129,12 @@
setImages(allImages);
};

const handleRemoveImage = (selectedImage: ImagePicker.ImagePickerAsset) => {
const newImages = images.filter((image) => image.uri !== selectedImage.uri);

setImages(newImages);
};

return (
<View className="w-full">
<View className="p-3 h-full w-full gap-4">
Expand Down Expand Up @@ -183,26 +196,34 @@
<Tag text={tag} color={colors[index]} key={index} />
))}
</View>
<View className="flex flex-row flex-wrap gap-2 items-center">
<View className="flex flex-row flex-wrap gap-2 items-center justify-between">
<Icon size={28} name="Camera" />
<Pressable
onPress={handlePromptImage}
className="flex flex-row items-center gap-2"
className="flex flex-row items-center gap-2 rounded-full border border-[#EFEFEF]"
vraimondi04 marked this conversation as resolved.
Show resolved Hide resolved
>
<Text>Upload image + </Text>
<Text className="text-center text-xl px-24 py-2">
Upload Photos
</Text>
</Pressable>

{images.map((image) => {
return (
<Image
key={image.uri}
source={{ uri: image.uri }}
style={{ width: 40, height: 40, borderRadius: 8 }}
contentFit="cover"
alt="Selected Image"
/>
);
})}
</View>
<ScrollView horizontal>
{images.map((image) => (
<ImageBackground
className=" w-screen-2/5 h-2/3 mr-3 rounded-lg overflow-hidden"
key={image.uri}
source={image}
alt="Selected Image"
>
<Pressable
onPress={() => handleRemoveImage(image)}
className="absolute top-1 right-1 rounded-full bg-black"
>
<Icon size={28} name="Close_SM" color="white"></Icon>
</Pressable>
</ImageBackground>
))}
</ScrollView>
</View>

<Pressable
Expand Down
3 changes: 3 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ module.exports = {
},
},
},
width: {
"screen-2/5": "40vw",
},
},
},
plugins: [],
Expand Down