From 2f4c31eb25ce961b77295bdfbbc4d1e0f999d46e Mon Sep 17 00:00:00 2001 From: whysman Date: Fri, 21 Feb 2025 13:58:19 -0500 Subject: [PATCH] Build.yaml, gitignore, app.json. Button anim. --- .gitea/workflows/build.yaml | 23 +++++++++---- .gitignore | 2 ++ app.json | 6 +++- app/StatusPage.tsx | 64 ++++++++++++++++++++++++------------- 4 files changed, 66 insertions(+), 29 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index de59eea..f4d8d70 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -17,11 +17,22 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: whereami - run: pwd + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' - - name: List workspace Directory - run: ls -l /workspace/ + - name: Install Dependencies + working-directory: ./pogdark-app + run: npm install - - name: Copy Files to hosting directory. - run: cp -Rf ./dist/* /data/pogdark + - name: Build + working-directory: ./pogdark-app + run: expo export --platform web + + - name: List Directory + run: | + ls -l . + ls -l ./pogdark/ + diff --git a/.gitignore b/.gitignore index 7fc1bdf..a1bee92 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,5 @@ yarn-error.* *.tsbuildinfo .idea + +.env* diff --git a/app.json b/app.json index e9d0c7a..b1010e2 100644 --- a/app.json +++ b/app.json @@ -20,7 +20,11 @@ "web": { "bundler": "metro", "output": "static", - "favicon": "./assets/images/favicon.png" + "favicon": "./assets/images/favicon.png", + "build": { + "output": "web-build", + "cacheDirectories": [] + } }, "plugins": [ "expo-router", diff --git a/app/StatusPage.tsx b/app/StatusPage.tsx index f816239..36205bc 100644 --- a/app/StatusPage.tsx +++ b/app/StatusPage.tsx @@ -103,33 +103,63 @@ const StatusPage: React.FC = ({ id, name, image, currentStatus, set ).start(); }; + const stopPulsing = (animationRef: Animated.Value) => { + animationRef.setValue(0); + animationRef.stopAnimation(); + }; + useEffect(() => { console.log("Updated status: ", currentStatus); if (currentStatus === "On the Way") { startPulsing(pulseAnimOnTheWay); } else { - pulseAnimOnTheWay.setValue(0); // Reset animation + stopPulsing(pulseAnimOnTheWay); } if (currentStatus === "Arrived") { startPulsing(pulseAnimArrived); } else { - pulseAnimArrived.setValue(0); // Reset animation + stopPulsing(pulseAnimArrived); } }, [currentStatus]); // Interpolated colors for pulsing effect - const pulseColorOnTheWay = pulseAnimOnTheWay.interpolate({ - inputRange: [0, 1], - outputRange: [theme.colors.secondary, theme.colors.primary], // From active color to normal color - }); - - const pulseColorArrived = pulseAnimArrived.interpolate({ + const getPulseColor = (animValue: Animated.Value) => animValue.interpolate({ inputRange: [0, 1], outputRange: [theme.colors.secondary, theme.colors.primary], }); + const pulseColorOnTheWay = getPulseColor(pulseAnimOnTheWay); + const pulseColorArrived = getPulseColor(pulseAnimArrived); + + // Function to handle status change + const handleStatusPress = async (status: string) => { + try { + if (currentStatus === status) { + // If pressed again, send "expired" status and clear currentStatus + console.log(`Expiring status: ${status}`); + const message: Message = { Id: id, Name: name, Image: image, Status: "expired", Timestamp: new Date().toISOString() }; + await axios.post(API_URL + "/set", message); + setStatus(""); // Reset status + } else { + // Otherwise, send the new status + console.log(`Setting status: ${status}`); + const message: Message = { Id: id, Name: name, Image: image, Status: status, Timestamp: new Date().toISOString() }; + await axios.post(API_URL + "/set", message); + setStatus(status); + } + } catch (error) { + console.error(`Error sending status '${status}':`, error); + } + }; + + // Determine the button label based on whether it's animating + const getButtonLabel = (status: string) => { + if (status === "On the Way") return currentStatus === "On the Way" ? "Traveling" : "On the way"; + if (status === "Arrived") return currentStatus === "Arrived" ? "At the dog park" : "Arrived"; + return status; + }; useEffect(() => { if (lastMessage?.data) { @@ -152,16 +182,6 @@ const StatusPage: React.FC = ({ id, name, image, currentStatus, set } }, [lastMessage, setStatus, id]); - const sendStatus = async (status: string) => { - try { - const message: Message = { Id: id, Name: name, Image: image, Status: status, Timestamp: new Date().toISOString() }; - await axios.post(API_URL + "/set", message); - setStatus(status) - } catch (error) { - console.error("Error sending status:", error); - } - }; - return ( @@ -211,25 +231,25 @@ const StatusPage: React.FC = ({ id, name, image, currentStatus, set