/* -------------------------------------------------------------------------- */ /* Libraries */ /* -------------------------------------------------------------------------- */ import React from "react"; import { Langs } from "localization/i18n"; import { useTranslation } from "react-i18next"; /* -------------------------------------------------------------------------- */ /* Hooks */ /* -------------------------------------------------------------------------- */ import { useLangugeViewModel } from "localization/controller/langugeViewModel"; /* -------------------------------------------------------------------------- */ /* Components */ /* -------------------------------------------------------------------------- */ import Combox from "components/controls/Combox"; import Modal from "components/containers/modal/Modal"; /* -------------------------------------------------------------------------- */ /* Icons */ /* -------------------------------------------------------------------------- */ import classNames from "classnames"; /* -------------------------------------------------------------------------- */ /* Properties */ /* -------------------------------------------------------------------------- */ type Props = { isShown: boolean; onClose: VoidFunction; }; /* -------------------------------------------------------------------------- */ /* Language switcher */ /* -------------------------------------------------------------------------- */ function CheckIcon(props: React.SVGProps) { return ( ); } export default function LanguageSelector({ isShown, onClose }: Props) { const { t } = useTranslation(); const { selected, languages, switchLang } = useLangugeViewModel(); return ( {t("selectLanguage")} languages[key as Langs].nativeName} keyMaper={(key) => key} setSelected={switchLang} filterRule={(query, item) => { if (query === "") { return true; } return languages[item as Langs].nativeName .toLowerCase() .replace(/\s+/g, "") .includes(query.toLowerCase().replace(/\s+/g, "")); }} selected={selected} itemBuilder={({ selected, active }, item) => { return (
{languages[item as Langs].nativeName}
); }} />
); }