import { FC, ReactNode } from "react"
import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native"
import React from "react"
import { Skin } from "../core/skin"
/*
Importing the correct stylesheet
*/
import styles from "./style/Skin.style"
import { useDispatch, useSelector } from "react-redux"
import { loginUser } from "../redux/features/currentUserSlice"
import { RootState } from "../redux/store"
export const SkinComponent :
/* Parameters :
* skin : Skin to be displayed
* state : Indicates from wich screen the component has been called
*/
FC<{skin: Skin, state: String}> =
({skin, state}) =>
{
const dispatch=useDispatch();
const currentUser = useSelector((state: RootState) => state.currentUserManager.currentUser);
/* 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
* From the profile (profile) : Name + Image, Pressable => Change the skin
*/
switch (state) {
case 'icon':
return (
)
case 'shop':
return(
Alert.alert("Achat du skin")} style={styles.imageWrapper}>
{skin.getSkinName()}
100€
)
case 'liste':
return(
{currentUser.setCurrentSkin(skin); dispatch(loginUser(currentUser))}} style={styles.imageWrapper}>
{skin.getSkinName()}
)
case 'profile':
return(
Alert.alert("Achat du skin")} style={styles.imageWrapperProfil}>
{skin.getSkinName()}
)
default:
return(
)
}
}