import { WebView } from "@tarojs/components";
import Taro from "@tarojs/taro";
import { useRouter } from "@tarojs/taro";
import { useEffect } from "react";
import { useTranslation } from "react-i18next";


let useRoute,useNavigation;
if (process.env.TARO_ENV == 'rn') {
    useRoute = require("@react-navigation/native").useRoute
    useNavigation = require("@react-navigation/native").useNavigation
    // useNavigation = require("@react-navigation/native").useNavigation
}
export default function Page() {
    const { t } = useTranslation()

    let navigation;
    if (useNavigation) {
        navigation = useNavigation()
    }


    let router;
    if (process.env.TARO_ENV == 'weapp') {
        router = useRouter();
    }
    else {
        router = useRoute()
    }


    useEffect(() => {
        if (process.env.TARO_ENV == 'rn') {
            navigation.setOptions({ title: router.params.title ?? '' });
        }
        else {
            Taro.setNavigationBarTitle({
                title: router.params.title ?? ''
                // title:t('feature.track_time_duration.follow_wx_pub.title')
            })
        }
    }, [])

    return (
        <WebView style={{ display: 'flex', flex: 1 }} src={router.params.url as string} />
    )
}