import React, { useEffect } from "react"; import { ActivityIndicator, Alert, DeviceEventEmitter, Dimensions, Image, Modal, NativeModules, Platform, StatusBar, StyleSheet, Text, TouchableOpacity, View, } from "react-native"; import colors from "../../res/colors"; import AsyncStorage from "@react-native-community/async-storage"; import { heightPercentageToDP as hp, widthPercentageToDP, widthPercentageToDP as wp, } from "react-native-responsive-screen"; import { NavigationContext, NavigationEvents, NavigationScreenProps, withNavigationFocus, } from "react-navigation"; import { heightToDP, isLandscapeMode, isTablet, minSubtitle3, } from "common/utils/DimensionUtils"; import { FolderpropContext } from "../utils/FolderInfoContext"; import images from "res/images"; import { NavParams } from "../Enums"; import palette from "res/palette"; import strings from "res/strings"; import Input from "./Input"; import FIcons from "react-native-vector-icons/Feather"; import { ROUTES } from "../routes/RouteConst"; import { Icon } from "react-native-elements"; interface Props { navigation: typeof NavigationContext; data: Object; onLeftPress: () => void; onChangeText: (text: string) => void; value: string; title: string; } const SearchableHeader: React.FC = (props) => { const [isLandscape, setLandscape] = React.useState( isLandscapeMode() ? true : false ); useEffect(() => { 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); } }; return ( {(value) => { return ( {/* {console.log('Hi!'+ JSON.stringify(props.navigation.state))} */} {/* top half */} {/* */} {props.navigation.state.routeName == "QuizResult" ? ( ) : ( )} {props.navigation.state.routeName == "History" ? "Assignment History" : props.navigation.state.routeName == "Assignments" ? "Assignment" : "Result"} {props.navigation.state.routeName != "QuizResult" ? ( {props.navigation.state.routeName == "Assignments" ? ( props.navigation.navigate(ROUTES.HISTORY)} > ) : null} ) : ( )} {/* bottom half */} {/* {"navTitle"} */} ); }} ); }; export default SearchableHeader; const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: colors.renderBGColor, justifyContent: "center", alignItems: "center", }, textStyle: { fontFamily: "Montserrat-Bold", fontSize: minSubtitle3(hp(2.5)), color: colors.darkerText, paddingTop: hp(0.5), paddingBottom: hp(0.5), marginLeft: wp(3.75), textAlignVertical: "center", fontWeight: "500", }, leftNavTitle: { // marginTop: CommonHeader.getLeftTextSize() / 3, justifyContent: "center", color: colors.home.white, fontWeight: "400", // textAlign: "left", // textAlignVertical: "center", // fontSize: isLandscape ? hp(3.5) : wp(3.5), fontFamily: "Montserrat-Regular", }, navtitle: { color: colors.darkerText, // fontSize: isLandscape ? hp(3.5) : wp(3.5), fontFamily: "Montserrat-Regular", alignSelf: "center", }, });