import * as React from 'react';
import { View, Text, Button, Pressable, Linking } from 'react-native';
import { useTranslation } from 'react-i18next';
import { HelpScreenProps } from '../types';
import Snackbar from 'react-native-snackbar';
import { PRIVAcY_URL, WEB_APP_URL } from '../const/config';

export default function HelpScreen({ navigation, route }: HelpScreenProps) {

    const { context } = route.params;
    const { t } = useTranslation();

    const onGotoWebAppClick = () => {
        Linking.openURL(WEB_APP_URL).catch(()=>{
            Snackbar.show({text: t("InternalErrorOccurred")});
        })
    }

    const onGotoPrivacyClick = () => {
        Linking.openURL(PRIVAcY_URL).catch(()=>{
            Snackbar.show({text: t("InternalErrorOccurred")});
        })
    }

    return (
        <View style={{
            flex: 1,
            backgroundColor: context.themeManager.theme?.background,
            padding: 20,
            gap: 5,
            alignContent: "center",
            justifyContent: "center"
        }}>
            <Pressable onPress={onGotoWebAppClick}>
                <Text style={{ textAlign: "center", color: context.themeManager.theme.textColor }}>{t('WebApp')}</Text>
            </Pressable>
            <Pressable onPress={onGotoPrivacyClick}>
                <Text style={{ textAlign: "center", color: context.themeManager.theme.textColor }}>{t('Privacy')}</Text>
            </Pressable>
        </View>
    );
}