import { createSignal, For, Show, type ParentComponent } from "solid-js"; import Scaffold from "../material/Scaffold.js"; import { AppBar, Divider, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemSecondaryAction, ListItemText, ListSubheader, NativeSelect, Switch, Toolbar, } from "@suid/material"; import { Close as CloseIcon, Logout, Public as PublicIcon, Refresh as RefreshIcon, Translate as TranslateIcon, } from "@suid/icons-material"; import { useNavigate } from "@solidjs/router"; import { Title } from "../material/typography.jsx"; import { css } from "solid-styled"; import { useSignedInProfiles } from "../masto/acct.js"; import { signOut, type Account } from "../accounts/stores.js"; import { format } from "date-fns"; import { useStore } from "@nanostores/solid"; import { $settings } from "./stores.js"; import { useRegisterSW } from "virtual:pwa-register/solid"; import { autoMatchLangTag, autoMatchRegion, createTranslator, SUPPORTED_LANGS, SUPPORTED_REGIONS, useDateFnLocale, } from "../platform/i18n.jsx"; import { type Template } from "@solid-primitives/i18n"; import BottomSheet from "../material/BottomSheet.jsx"; import ChooseLang from "./ChooseLang.jsx"; import ChooseRegion from "./ChooseRegion.jsx"; type Strings = { ["lang.auto"]: Template<{ detected: string }>; } & Record; const Settings: ParentComponent = () => { const [t] = createTranslator( (code) => import(`./i18n/${code}.json`) as Promise<{ default: Strings; }>, () => import(`./i18n/lang-names.json`), ); const navigate = useNavigate(); const settings$ = useStore($settings); const { needRefresh: [needRefresh], } = useRegisterSW(); const dateFnLocale = useDateFnLocale(); const [langPickerOpen, setLangPickerOpen] = createSignal(false); const [regionPickerOpen, setRegionPickerOpen] = createSignal(false); const [profiles] = useSignedInProfiles(); const doSignOut = (acct: Account) => { signOut((a) => a.site === acct.site && a.accessToken === acct.accessToken); }; css` ul { padding: 0; } .setting-list { padding-bottom: calc(var(--safe-area-inset-bottom, 0px) + 16px); } `; return ( {t("Settings")} } >
    • {t("Accounts")} {t("All Notifications")} {t("Sign in...")}
    {({ account: acct, inf }) => (
      {`@${inf?.username ?? "..."}@${new URL(acct.site).host}`} {t("Notifications")} {t("Sign out")}
    )}
  • {t("Reading")} $settings.setKey( "prefetchTootsDisabled", !settings$().prefetchTootsDisabled, ) } > {t("Prefetch Toots")}
  • {t("This Application")} {t("Language")} $settings.setKey("language", nval)} onClose={[setLangPickerOpen, false]} /> {t("Region")} $settings.setKey("region", nval)} onClose={[setRegionPickerOpen, false]} /> {t("About Tutu")} {needRefresh() ? t("updates.ready") : t("updates.no")} window.location.reload()} >
  • ); }; export default Settings;