import React, { useEffect, useState } from "react"; import { Text, View, StyleSheet, Dimensions, Image, FlatList, } from "react-native"; import { isLandscapeMode, isTablet } from "common/utils/DimensionUtils"; import images from "../../res/images"; import { ImageBackground } from "react-native"; import { renderTextOrImage } from "../utils/textOrImageUtils"; import dimens from "res/dimens"; type Props = { question: object; id: Number; }; //const HistoryScreen: React.FC = (props) => const QuestionComponent: React.FC = (props) => { const [isLandscape, setLandscape] = React.useState( isLandscapeMode() ? true : false ); useEffect(() => { // console.log("questions->", props.question); Dimensions.addEventListener("change", onChange); return () => { Dimensions.removeEventListener("change", onChange); }; }); const onChange = () => { if (Dimensions.get("window").width < Dimensions.get("window").height) { setLandscape(false); } else { setLandscape(true); } }; const renderQuestionCard = (item: object) => { switch (item.type) { case "match": return ( Which is the correct answer? {/* ITEM 1 */} {item.Question.item1 ? ( typeof item.Question.item1 == "string" ? ( {item.Question?.item1} ) : ( ) ) : null} {/* ITEM 2 */} {item.Question.item2 ? ( typeof item.Question.item2 == "string" ? ( {item.Question?.item2} ) : ( ) ) : null} {/* ITEM 3 */} {item.Question.item3 ? ( typeof item.Question.item3 == "string" ? ( {item.Question?.item3} ) : ( ) ) : null} {/* ITEM 4 */} {item.Question.item4 ? ( typeof item.Question.item4 == "string" ? ( {item.Question?.item4} ) : ( ) ) : null} ); case "quizitive": return ( {item.Question.attachment ? ( ) : null} {item.Question?.text} ); case "word": return ( {item.Question} ); } }; return ( Question {props.id} {props.question["#Correct"] ? ( ) : ( )} {renderQuestionCard(props.question)} {/* {props.question.Question.attachment ? ( ) : null} */} {/* {props.question.Question.item1} */} ); }; export default QuestionComponent; const styles = StyleSheet.create({ sectionText: { color: "#0076BB", fontSize: isTablet() ? 18 : 12, fontFamily: "Montserrat-SemiBold", fontWeight: "600", }, slideImageStyle: { alignSelf: "center", alignItems: "center", justifyContent: "center", resizeMode: "contain", }, sectionText2: { color: "#707070", fontSize: isTablet() ? 18 : 12, fontFamily: "Montserrat-Medium", fontWeight: "500", }, questionStyle: { color: "#707070", fontSize: isTablet() ? 20 : 14, fontFamily: "Montserrat-Medium", fontWeight: "500", }, sectionImage: { resizeMode: "cover", width: isTablet() ? 27 : 20, height: isTablet() ? 27 : 20, }, sectionImage2: { resizeMode: "cover", width: isTablet() ? 70 : 50, height: isTablet() ? 70 : 50, borderRadius: 10, }, title: { fontSize: isTablet() ? dimens.h6 : dimens.h8, textAlign: "center", }, });