// @flow import * as React from 'react'; import type {cardList} from "../../components/Lists/CardList/CardList"; import CardList from "../../components/Lists/CardList/CardList"; import {Image, View} from "react-native"; import {Avatar, Card, Divider, List, TouchableRipple, withTheme} from "react-native-paper"; import type {CustomTheme} from "../../managers/ThemeManager"; import i18n from 'i18n-js'; import MaterialHeaderButtons, {Item} from "../../components/Overrides/CustomHeaderButton"; import {StackNavigationProp} from "@react-navigation/stack"; import {MASCOT_STYLE} from "../../components/Mascot/Mascot"; import MascotPopup from "../../components/Mascot/MascotPopup"; import AsyncStorageManager from "../../managers/AsyncStorageManager"; import ServicesManager, {SERVICES_CATEGORIES_KEY} from "../../managers/ServicesManager"; import CollapsibleFlatList from "../../components/Collapsible/CollapsibleFlatList"; type Props = { navigation: StackNavigationProp, theme: CustomTheme, } type State = { mascotDialogVisible: boolean, } export type listItem = { title: string, description: string, image: string | number, content: cardList, } class ServicesScreen extends React.Component { finalDataset: Array state = { mascotDialogVisible: AsyncStorageManager.getBool(AsyncStorageManager.PREFERENCES.servicesShowBanner.key), } constructor(props) { super(props); const services = new ServicesManager(props.navigation); this.finalDataset = services.getCategories([SERVICES_CATEGORIES_KEY.SPECIAL]) } componentDidMount() { this.props.navigation.setOptions({ headerRight: this.getAboutButton, }); } /** * Callback used when closing the banner. * This hides the banner and saves to preferences to prevent it from reopening */ onHideMascotDialog = () => { this.setState({mascotDialogVisible: false}); AsyncStorageManager.set(AsyncStorageManager.PREFERENCES.servicesShowBanner.key, false); }; getAboutButton = () => ; onAboutPress = () => this.props.navigation.navigate('amicale-contact'); /** * Gets the list title image for the list. * * If the source is a string, we are using an icon. * If the source is a number, we are using an internal image. * * @param props Props to pass to the component * @param source The source image to display. Can be a string for icons or a number for local images * @returns {*} */ getListTitleImage(props, source: string | number) { if (typeof source === "number") return else return } /** * A list item showing a list of available services for the current category * * @param item * @returns {*} */ renderItem = ({item}: { item: listItem }) => { return ( this.props.navigation.navigate("services-section", {data: item})} > this.getListTitleImage(props, item.image)} right={(props) => } /> ); }; keyExtractor = (item: listItem) => { return item.title; } render() { return ( } hasTab={true} /> ); } } export default withTheme(ServicesScreen);