diff --git a/assets/Swipe_Icon.png b/assets/Swipe_Icon.png new file mode 100644 index 0000000..c6dc151 Binary files /dev/null and b/assets/Swipe_Icon.png differ diff --git a/src/index.css b/src/index.css index bd6213e..0e7519f 100644 --- a/src/index.css +++ b/src/index.css @@ -1,3 +1,27 @@ @tailwind base; @tailwind components; -@tailwind utilities; \ No newline at end of file +@tailwind utilities; + + +/* Animação do icon de swipe */ + +.dont_swipe{ + animation: none; +} +.swipe_anime{ + animation-name: swipe_icon_animation; + animation-duration: 2.5s; + animation-timing-function:ease-in-out; +} + +@keyframes swipe_icon_animation{ + 0% {transform: rotate(50deg)} + 25% {transform: rotate(0deg)} + 50% {transform: rotate(50deg)} + 75% {transform: rotate(0deg)} + 100% {transform: rotate(50deg)} + 125% {transform: rotate(0deg)} +} + + + diff --git a/src/pages/WelcomePage.js b/src/pages/WelcomePage.js index aa06909..725d97e 100644 --- a/src/pages/WelcomePage.js +++ b/src/pages/WelcomePage.js @@ -1,65 +1,96 @@ -import React, { useState } from "react"; -import { View, Text, Image, PanResponder } from "react-native"; -import { FontAwesome } from "@expo/vector-icons"; +import React, { useState, useRef } from "react"; +import { + View, + Text, + Image, + Animated, + FlatList, + Dimensions, +} from "react-native"; -export default function WelcomePage({ navigation }) { - const [currentStep, setCurrentStep] = useState(0); - - const steps = [ - { text: "Olá! Bem-vindo ao LUMICHECK!", image: require("../../assets/Lumi.png") }, - { text: "Eu sou a Lumi. É um prazer poder conhecer-te!", image: require("../../assets/Lumi.png") }, - { text: "Vamos começar?", image: require("../../assets/Lumi.png") }, - ]; +const { width: SCREEN_WIDTH } = Dimensions.get("window"); - const handleNextStep = () => { - if (currentStep < steps.length - 1) { - setCurrentStep(currentStep + 1); - } else { - navigation.replace("Login"); - } - }; +export default function WelcomePage({ navigation }) { + const [currentStep, setCurrentStep] = useState(0); - // Configuração do PanResponder para capturar gestos - const panResponder = PanResponder.create({ - onMoveShouldSetPanResponder: (_, gestureState) => { - // Detecta se o movimento horizontal é significativo - return Math.abs(gestureState.dx) > 20 && Math.abs(gestureState.dy) < 20; - }, - onPanResponderRelease: (_, gestureState) => { - if (gestureState.dx < -50) { - // Movimento de deslizar para a esquerda - navigation.replace("HomeTabs"); - } - }, - }); + const steps = [ + { id: 0, text: "Olá! Bem-vindo ao LUMICHECK!" }, + { id: 1, text: "Eu sou a Lumi. É um prazer poder conhecer-te!" }, + { id: 2, text: "Vamos começar?" }, + { id: 3, text: " " }, + ]; - return ( - - {/* Texto principal */} - {steps[currentStep].text} + const flatListRef = useRef(null); - {/* Imagem */} - + const handleScroll = (event) => { + const offsetX = event.nativeEvent.contentOffset.x; + const currentIndex = Math.round(offsetX / SCREEN_WIDTH); + setCurrentStep(currentIndex); + if (currentStep === steps.length - 1) { + navigation.replace("Login"); + } + }; - {/* Barra de progresso */} - - {[...Array(steps.length + 1)].map((_, index) => ( - - ))} + return ( + + {/* Texto principal */} + + ( + + + + {item.text} + + + {/* Imagem */} + + + + )} + horizontal + showsHorizontalScrollIndicator={false} + pagingEnabled + onScroll={handleScroll} + keyExtractor={(item) => item.id.toString()} + scrollEventThrottle={16} // Optimize scroll updates + /> + - {/* Texto fixo indicando para deslizar */} - - Desliza - - + {/* Barra de progresso */} + + + {steps.map((_, index) => ( + + ))} + + + {/* Texto fixo indicando para deslizar */} + + + Desliza - ); + + + ); }