From 6d6d221c953a916cd12cd73ed7087a5f76da2d0c Mon Sep 17 00:00:00 2001 From: Ryland Date: Tue, 19 Sep 2023 22:39:28 -0700 Subject: [PATCH] home screen BG fix + lock scrren notification --- src/components/LockScreen/lockScreen.css | 20 ++++----- src/components/LockScreen/lockScreen.jsx | 57 ++++++++++-------------- src/components/homeScreen/homeScreen.jsx | 11 +++-- 3 files changed, 38 insertions(+), 50 deletions(-) diff --git a/src/components/LockScreen/lockScreen.css b/src/components/LockScreen/lockScreen.css index 5377722..64723dc 100644 --- a/src/components/LockScreen/lockScreen.css +++ b/src/components/LockScreen/lockScreen.css @@ -28,9 +28,9 @@ right: 0%; height: 100%; - max-height: 447px; + max-height: 455px; - margin-top: -2.5%; + margin-top: -4%; /* opacity: 8%; */ } @@ -59,9 +59,8 @@ .notificationAlert { position: absolute; - background-color: rgb(120, 120, 120); + background-color: rgba(59, 59, 59, 0.7); z-index: 12 !important; - opacity: 70% !important; width: 83%; height: 12.5%; @@ -74,11 +73,10 @@ .notificationTextTop { position: absolute; - color: rgb(23, 23, 23); + color: rgb(182, 182, 182); font-size: 1.2rem; - background-color: rgba(255, 0, 0, 0.5); /* 50% opacity red background */ - left: 29%; - top: 40%; + left: 35%; + top: 34%; text-shadow: none !important; } @@ -114,10 +112,10 @@ position: absolute; z-index: 0.5; width: 100%; - height: 23%; - top: 3%; + height: 22%; + top: 4.2%; background: rgb(0, 0, 0); - background: linear-gradient(0deg, rgb(32, 32, 32) 50%, rgb(57, 57, 57) 50%); + background: linear-gradient(0deg, rgb(32, 32, 32) 55%, rgb(57, 57, 57) 50%); border-bottom: 0.1px solid rgb(0, 0, 0); opacity: 65%; diff --git a/src/components/LockScreen/lockScreen.jsx b/src/components/LockScreen/lockScreen.jsx index fe511ef..67e159f 100644 --- a/src/components/LockScreen/lockScreen.jsx +++ b/src/components/LockScreen/lockScreen.jsx @@ -1,41 +1,37 @@ import React, { useState, useEffect } from 'react'; import './lockScreen.css'; - import SlideToUnlock from '../slideToUnlock/slideToUnlock'; import lockScreenBackground from '../../assets/imgs/lockScreenBackground.jpg'; import linkTreeImg from '../../assets/imgs/linkTree.png'; - -import { motion, AnimatePresence } from 'framer-motion'; - -let didInit = false; +import { motion } from 'framer-motion'; const LockScreen = () => { const [date, setDate] = useState(new Date()); - const [notification, setNotification] = useState(false); - - // Initialize notification after 2 seconds - if (!didInit) { - setTimeout(() => { - setNotification(true); - shownotification(); - }, 200); - } - - // Show notification and hide after 3.45 seconds - const shownotification = () => { - didInit = true; - setTimeout(() => { - setNotification(false); - }, 34500); - }; + const [notificationVisible, setNotificationVisible] = useState(false); + // Function to refresh the clock function refreshClock() { setDate(new Date()); } useEffect(() => { + // Show notification after 2 seconds + const notificationTimeout = setTimeout(() => { + setNotificationVisible(true); + }, 200); + + // Clean up the timeout when the component unmounts + return () => { + clearTimeout(notificationTimeout); + }; + }, []); + + useEffect(() => { + // Set up an interval to refresh the clock every second const timerId = setInterval(refreshClock, 1000); - return function cleanup() { + + return () => { + // Clean up the interval when the component unmounts clearInterval(timerId); }; }, []); @@ -46,7 +42,7 @@ const LockScreen = () => { minute: '2-digit', hour12: true, }) - .replace(/\s?[APap][Mm]\.?/, ''); // Removes AM/PM text + .replace(/\s?[APap][Mm]\.?/, ''); // Removes AM/PM text~ const formattedDate = date.toLocaleString('en-US', { weekday: 'long', @@ -85,11 +81,10 @@ const LockScreen = () => {
{formattedDate}
- {/* Render notification if notification state is true */} - {notification ? ( + {/* Render notification if notificationVisible is true */} + {notificationVisible && ( { transition={{ duration: 1.5, type: 'spring', - repeat: 1, - // repeatType: 'reverse', - // repeatDelay: 0.5, + repeat: 0, }} key='notification' target='_blank' @@ -113,11 +106,9 @@ const LockScreen = () => { src={linkTreeImg} alt='BadWeather' /> -
Bad Weather - EP
+
LinkTree
- ) : ( - '' )} ); diff --git a/src/components/homeScreen/homeScreen.jsx b/src/components/homeScreen/homeScreen.jsx index a64a656..7508ef1 100644 --- a/src/components/homeScreen/homeScreen.jsx +++ b/src/components/homeScreen/homeScreen.jsx @@ -13,18 +13,17 @@ import { MAINAPPS, FOOTERAPPS } from '../../assets/apps'; const HomeScreen = () => { return ( <> - - {/* Render apps */} + {/* Main apps */}
{MAINAPPS.map((app) => (