From 9a6a9c598d2c76afccc694f4b2ca9ec876070789 Mon Sep 17 00:00:00 2001 From: caxewsh Date: Sat, 9 Nov 2024 05:00:29 +0100 Subject: [PATCH 1/3] feat(gamescreen): add infoBloc, rebrand ui and refactor progressBar --- components/gamescreen/GameCard.jsx | 2 +- components/gamescreen/InfoBloc.jsx | 16 ++++++++++ components/gamescreen/ProgressBar.jsx | 6 +--- package.json | 2 +- screens/Gamescreen.js | 17 +++++++---- yarn.lock | 44 +++++++++++++-------------- 6 files changed, 52 insertions(+), 35 deletions(-) create mode 100644 components/gamescreen/InfoBloc.jsx diff --git a/components/gamescreen/GameCard.jsx b/components/gamescreen/GameCard.jsx index 71038b1..8300bb5 100644 --- a/components/gamescreen/GameCard.jsx +++ b/components/gamescreen/GameCard.jsx @@ -8,7 +8,7 @@ const GameCard = ({ isLoading, players, questions, currentQuestionIndex }) => { return ( {!isLoading && questions.length > 0 && players.length > 0 ? ( (() => { diff --git a/components/gamescreen/InfoBloc.jsx b/components/gamescreen/InfoBloc.jsx new file mode 100644 index 0000000..1a5176a --- /dev/null +++ b/components/gamescreen/InfoBloc.jsx @@ -0,0 +1,16 @@ +import React from "react"; +import { View, Text } from "react-native"; +import { InformationCircleIcon } from "react-native-heroicons/solid"; + +const InfoBloc = ({ info }) => { + return ( + + + + {info} + + + ); +}; + +export default InfoBloc; \ No newline at end of file diff --git a/components/gamescreen/ProgressBar.jsx b/components/gamescreen/ProgressBar.jsx index b1e0c30..4790295 100644 --- a/components/gamescreen/ProgressBar.jsx +++ b/components/gamescreen/ProgressBar.jsx @@ -5,12 +5,8 @@ import * as Progress from "react-native-progress"; const ProgressBar = ({ currentQuestionIndex, questions }) => { return ( - - Progression - { setIsLoading(true); try { - let { data: questionsData, error } = await supabase.from("questionsV3").select("Theme, Questions, severity"); + let { data: questionsData, error } = await supabase.from("questionsV4").select("Theme, Questions, severity, Instructions"); if (error) throw error; if (!Array.isArray(questionsData)) { @@ -37,21 +38,24 @@ export default function Gamescreen() { } const shuffledQuestions = shuffledArray(questionsData); - setQuestions(shuffledQuestions); + + // Limit the questions to 45 + const limitedQuestions = shuffledQuestions.slice(0, 45); + setQuestions(limitedQuestions); // Fetch players from AsyncStorage const playerData = await AsyncStorage.getItem("players"); let parsedPlayers = JSON.parse(playerData) || []; - + parsedPlayers = parsedPlayers.map(player => ({ ...player, score: player.score || 0 // Initialize score if not present })); - + if (!Array.isArray(parsedPlayers)) { throw new TypeError("Parsed players data is not an array"); } - + const shuffledPlayers = shuffledArray(parsedPlayers); setPlayers(shuffledPlayers); } catch (error) { @@ -86,7 +90,7 @@ export default function Gamescreen() { } if (currentQuestionIndex + 1 >= questions.length) { - // No more questions, navigate to Endscreen or reset for a new game + navigation.navigate("End", { players }); } else { // Increment index to move to the next question @@ -106,6 +110,7 @@ export default function Gamescreen() { + Date: Sat, 9 Nov 2024 18:52:23 +0100 Subject: [PATCH 2/3] bsr(gamescreen): revamp suggestionModal and delete duplicate render --- components/gamescreen/ProgressBar.jsx | 2 +- components/settingscreen/SuggestionModal.jsx | 6 +++--- screens/Gamescreen.js | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/components/gamescreen/ProgressBar.jsx b/components/gamescreen/ProgressBar.jsx index 4790295..e39d552 100644 --- a/components/gamescreen/ProgressBar.jsx +++ b/components/gamescreen/ProgressBar.jsx @@ -11,7 +11,7 @@ const ProgressBar = ({ currentQuestionIndex, questions }) => { progress={(currentQuestionIndex + 1) / questions.length} width={300} height={10} - color="#62C0CC" + color="#FFFFFF" /> ); diff --git a/components/settingscreen/SuggestionModal.jsx b/components/settingscreen/SuggestionModal.jsx index d1db5e7..aee32c3 100644 --- a/components/settingscreen/SuggestionModal.jsx +++ b/components/settingscreen/SuggestionModal.jsx @@ -26,7 +26,7 @@ const SuggestionModal = ({ showModal, setShowModal }) => { > {/* Modale centrée */} - + setShowModal(false)} className="self-end"> @@ -45,8 +45,8 @@ const SuggestionModal = ({ showModal, setShowModal }) => { onChangeText={handleChange} value={suggestion} /> - - Envoyer + + Envoyer diff --git a/screens/Gamescreen.js b/screens/Gamescreen.js index 1eb4729..c600bf3 100644 --- a/screens/Gamescreen.js +++ b/screens/Gamescreen.js @@ -90,7 +90,6 @@ export default function Gamescreen() { } if (currentQuestionIndex + 1 >= questions.length) { - navigation.navigate("End", { players }); } else { // Increment index to move to the next question From b177cd292babcf90ae43bf90d787d36065dd1bc8 Mon Sep 17 00:00:00 2001 From: caxewsh Date: Sun, 10 Nov 2024 01:23:11 +0100 Subject: [PATCH 3/3] bsr(suggestionModal): add accessibility label and loading state --- components/settingscreen/SuggestionModal.jsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/components/settingscreen/SuggestionModal.jsx b/components/settingscreen/SuggestionModal.jsx index aee32c3..77b110f 100644 --- a/components/settingscreen/SuggestionModal.jsx +++ b/components/settingscreen/SuggestionModal.jsx @@ -4,14 +4,16 @@ import { XCircleIcon } from "react-native-heroicons/solid"; const SuggestionModal = ({ showModal, setShowModal }) => { const [suggestion, setSuggestion] = React.useState(""); + const [isSubmitting, setIsSubmitting] = React.useState(false); const handleChange = (text) => { setSuggestion(text); }; const handleSubmit = () => { + setIsSubmitting(true); console.log("Submitted suggestion"); - setShowModal(false); // Fermer la modale après soumission + setShowModal(false); // Close the modal after submission }; return ( @@ -45,8 +47,11 @@ const SuggestionModal = ({ showModal, setShowModal }) => { onChangeText={handleChange} value={suggestion} /> - - Envoyer + + {isSubmitting ? "Envoi en cours..." : "Envoyer"}