From 8c5dfb2f2ce6a252fcba103f367449205e6b2d32 Mon Sep 17 00:00:00 2001 From: alguilhot Date: Fri, 21 Oct 2022 18:34:16 +0200 Subject: [PATCH] =?UTF-8?q?ADD:=20Sur=20SkinComponent:=20Ajout=20de=20la?= =?UTF-8?q?=20fonctionnalit=C3=A9=20de=20changement=20de=20skin=20Ajout=20?= =?UTF-8?q?d'un=20etat=20d=C3=A9fault?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bob_party/src/components/Skin.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bob_party/src/components/Skin.tsx b/bob_party/src/components/Skin.tsx index 3a20fff..2caf613 100644 --- a/bob_party/src/components/Skin.tsx +++ b/bob_party/src/components/Skin.tsx @@ -7,6 +7,8 @@ import { Skin } from "../core/skin" Importing the correct stylesheet */ import styles from "./style/Skin.style" +import { useDispatch } from "react-redux" +import { updateSkin } from "../redux/features/currentUserSlice" export const SkinComponent : /* Parameters : @@ -16,6 +18,8 @@ export const SkinComponent : FC<{skin: Skin, state: String}> = ({skin, state}) => { + const dispatch=useDispatch(); + /* The display of this component depends of the screen from where it has been called: * From the TopBar (icon) : Small image in a circle * From the shop (shop) : Image + Name + Price, Pressable => Buy the skin @@ -25,7 +29,7 @@ FC<{skin: Skin, state: String}> = case 'icon': return ( - + ) @@ -42,7 +46,7 @@ FC<{skin: Skin, state: String}> = ) case 'liste': return( - Alert.alert("Changement du skin")} style={styles.imageWrapper}> + dispatch(updateSkin(skin))} style={styles.imageWrapper}> {skin.getSkinName()} = ) default: - break; + return( + + ) } } \ No newline at end of file