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

Prize svg #32

Merged
merged 6 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
10 changes: 5 additions & 5 deletions Components/CurrentEventCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import CustomModal from "./CustomModal"; // Import the custom modal
// import AppLoading from "expo-app-loading";
import Colors from "../constants/Colors";

import {formatTime} from "../navigation/DayEvent";
import { formatTime } from "../navigation/DayEvent";

import EvilIcons from "@expo/vector-icons/EvilIcons";

Expand Down Expand Up @@ -52,9 +52,9 @@ const CurrentEventCard = ({
const start = new Date(startTime);
const end = new Date(endTime);

// console.log("CURRENT", currentTime);
// console.log("START", start);
// console.log("END", end);
// console.log("CURRENT", currentTime);
// console.log("START", start);
// console.log("END", end);
// Check if current time is within the event's duration
const isOngoing = currentTime >= start && currentTime <= end;

Expand All @@ -78,7 +78,7 @@ const CurrentEventCard = ({
</View>
<View style={styles.infoItem}>
<Image
source={require("../assets/token.png")}
source={require("../assets/pixel.png")}
style={styles.tokenImage}
></Image>
<Text style={styles.infoText}> x{points}</Text>
Expand Down
47 changes: 47 additions & 0 deletions Components/PrizeSVG.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from "react";
import { View, Text } from "react-native";
import { StyledText } from "./Text";

import Question1 from "../assets/SVGs/myRP/blue-question.svg";
import Question2 from "../assets/SVGs/myRP/purple-question.svg";
import Question3 from "../assets/SVGs/myRP/pink-question.svg";
import Button from "../assets/SVGs/myRP/button.svg";
import ToteBag from "../assets/SVGs/myRP/tote-bag.svg";
import Cap from "../assets/SVGs/myRP/cap.svg";

interface PrizeSVGProps {
prizeNum: number;
attendeePoints: number;
token: string;
}

const FoodWaveSVG: React.FC<PrizeSVGProps> = ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uh nit but this should be named PrizeSVG or smth right

prizeNum,
attendeePoints,
token,
}) => {
const size = 100;

const getSVG = () => {
if (token) {
// Map SVGs based on prizeNum and attendeePoints
const svgMap: { [key: number]: JSX.Element } = {
1: attendeePoints >= 20 ? <Button width={size} height={size}/> : <Question1 width={size} height={size}/>,
2: attendeePoints >= 35 ? <ToteBag width={size} height={size}/> : <Question2 width={size} height={size}/>,
3: attendeePoints >= 50 ? <Cap width={size} height={size}/> : <Question3 width={size} height={size}/>,
};
return svgMap[prizeNum] || <Text>No SVG available</Text>;
} else {
const svgMap: { [key: number]: JSX.Element } = {
1: <Question1 width={size} height={size}/>,
2: <Question2 width={size} height={size}/>,
3: <Question3 width={size} height={size}/>,
};
return svgMap[prizeNum] || <Text>No SVG available</Text>;
}
};

return getSVG();
};

export default FoodWaveSVG;
File renamed without changes
9 changes: 9 additions & 0 deletions assets/SVGs/myRP/button.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions assets/SVGs/myRP/cap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions assets/SVGs/myRP/diamond.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
9 changes: 9 additions & 0 deletions assets/SVGs/myRP/tote-bag.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/SVGs/question 1.png
Binary file not shown.
File renamed without changes
4 changes: 2 additions & 2 deletions components/EventCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const EventCard = ({ name, time, location, description, points }) => {
</View>
<View style={styles.infoItem}>
<Image
source={require("../assets/token.png")}
source={require("../assets/pixel.png")}
style={styles.tokenImage}
></Image>
<Text style={styles.infoText}> x{points}</Text>
Expand Down Expand Up @@ -123,7 +123,7 @@ const styles = StyleSheet.create({
fontWeight: "bold",
},
tokenImage: {
width: 20,
width: 20,
height: 20,
},
description: {
Expand Down
4 changes: 2 additions & 2 deletions components/EventModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const EventModal = ({ title, location, time, points, description }) => {
</View> */}
<View style={styles.infoItem}>
<Image
source={require("../assets/token.png")}
source={require("../assets/pixel.png")}
style={styles.tokenImage}
></Image>
<Text style={styles.infoText}> x{points}</Text>
Expand Down Expand Up @@ -69,7 +69,7 @@ const styles = StyleSheet.create({
paddingRight: 25,
color: "black",
fontFamily: "Kufam_700Bold",
paddingRight: 25
paddingRight: 25,
},
info: {
flexDirection: "row",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rp-mobile-2024",
"version": "1.3.1",
"version": "1.3.2",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
Expand Down
26 changes: 13 additions & 13 deletions screens/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ const Login: React.FC<LoginProps> = ({ navigation }) => {
}, [token, navigation]);

const handleLoginPress = () => {
WebBrowser.openAuthSessionAsync(
`${authUrl}?redirect_uri=${redirectURL}`,
redirectURL
)
.then((result) => {
if (result.type === "success") {
Linking.openURL(result.url);
}
})
.catch((err) => {
console.error("Failed to open URL:", err.message);
alert("Failed to open URL");
});
WebBrowser.openAuthSessionAsync(
`${authUrl}?redirect_uri=${redirectURL}`,
redirectURL
)
.then((result) => {
if (result.type === "success") {
Linking.openURL(result.url);
}
})
.catch((err) => {
console.error("Failed to open URL:", err.message);
alert("Failed to open URL");
});
};

return (
Expand Down
47 changes: 22 additions & 25 deletions screens/Shop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import {
} from "@expo-google-fonts/press-start-2p";
import AppLoading from "expo-app-loading";

import Question1 from "../assets/SVGs/question_1.svg"
import Question2 from "../assets/SVGs/purple-question_1.svg"
import Question3 from "../assets/SVGs/pink-question_1.svg"
import PrizeSVG from "../Components/PrizeSVG";

import VerticalProgressBar from '../Components/VerticalProgressBar';
import VerticalProgressBar from "../Components/VerticalProgressBar";
import { getPoints } from "../api/getPoints";

const Shop: React.FC = () => {
Expand All @@ -31,14 +29,14 @@ const Shop: React.FC = () => {
} catch (error) {
console.error("error fetching points for user:", error);
}
}
};
fetchUserPoints(); // Fetch points when component mounts
}, [token]); // Empty dependency array means this effect runs once on mount

if (!fontsLoaded) {
return <AppLoading />;
}

return (
<SafeAreaView style={styles.safeArea}>
<View style={styles.container}>
Expand All @@ -48,49 +46,48 @@ const Shop: React.FC = () => {
<View style={styles.pointsContainer}>
<Text style={styles.points}>Your Points:</Text>
<Image
source={require("../assets/token.png")}
source={require("../assets/pixel.png")}
style={styles.tokenImage}
/>
<Text style={styles.myPoints}>x{userPoints}</Text>
</View>
<View style={styles.photoContainer}>
<View style={styles.leftSide}>
<View style={styles.photoWithPoints}>
{/* <Image
source={{ uri: "https://via.placeholder.com/100" }}
style={styles.smallPhoto}
/> */}
<Question1 //might have to consolidate this into single component
width={100}
height={100}
<PrizeSVG
prizeNum={3}
attendeePoints={userPoints}
token={token}
/>
<Image
source={require("../assets/token.png")}
source={require("../assets/pixel.png")}
style={styles.tokenImage}
/>
<Text style={styles.points}>x{50}</Text>
</View>
<View style={styles.photoWithPoints}>
<Question2
width={100}
height={100}
<PrizeSVG
prizeNum={2}
attendeePoints={userPoints}
token={token}
/>
<Image
source={require("../assets/token.png")}
source={require("../assets/pixel.png")}
style={styles.tokenImage}
/>
<Text style={styles.points}>x{35}</Text>
</View>
<View style={styles.photoWithPoints}>
<Question3
width={100}
height={100}
<PrizeSVG
prizeNum={1}
attendeePoints={userPoints}
token={token}
/>
<Image
source={require("../assets/token.png")}
source={require("../assets/pixel.png")}
style={styles.tokenImage}
/>
<Text style={styles.points}>x{25}</Text>
<Text style={styles.points}>x{20}</Text>
</View>
</View>
<View style={styles.progressBarContainer}>
Expand Down Expand Up @@ -155,7 +152,7 @@ const styles = StyleSheet.create({
flexDirection: "row",
alignItems: "center",
marginBottom: 10,
// backgroundColor: 'red'
// backgroundColor: 'green'
},
smallPhoto: {
width: 100,
Expand Down
Loading
Loading