first prototype of StackedRouter
This commit is contained in:
parent
607fa64c05
commit
0710aaf4f3
21 changed files with 442 additions and 109 deletions
|
@ -24,10 +24,10 @@ import { Title } from "../material/typography";
|
|||
import type { Template } from "@solid-primitives/i18n";
|
||||
import { useStore } from "@nanostores/solid";
|
||||
import { $settings } from "./stores";
|
||||
import { useNavigate } from "@solidjs/router";
|
||||
import { useNavigator } from "../platform/StackedRouter";
|
||||
|
||||
const ChooseLang: Component = () => {
|
||||
const navigate = useNavigate()
|
||||
const { pop } = useNavigator();
|
||||
const [t] = createTranslator(
|
||||
() => import("./i18n/lang-names.json"),
|
||||
(code) =>
|
||||
|
@ -37,9 +37,9 @@ const ChooseLang: Component = () => {
|
|||
};
|
||||
}>,
|
||||
);
|
||||
const settings = useStore($settings)
|
||||
const settings = useStore($settings);
|
||||
|
||||
const code = () => settings().language
|
||||
const code = () => settings().language;
|
||||
|
||||
const unsupportedLangCodes = createMemo(() => {
|
||||
return iso639_1.getAllCodes().filter((x) => !["zh", "en"].includes(x));
|
||||
|
@ -48,8 +48,8 @@ const ChooseLang: Component = () => {
|
|||
const matchedLangCode = createMemo(() => autoMatchLangTag());
|
||||
|
||||
const onCodeChange = (code?: string) => {
|
||||
$settings.setKey("language", code)
|
||||
}
|
||||
$settings.setKey("language", code);
|
||||
};
|
||||
|
||||
return (
|
||||
<Scaffold
|
||||
|
@ -59,7 +59,7 @@ const ChooseLang: Component = () => {
|
|||
variant="dense"
|
||||
sx={{ paddingTop: "var(--safe-area-inset-top, 0px)" }}
|
||||
>
|
||||
<IconButton color="inherit" onClick={[navigate, -1]} disableRipple>
|
||||
<IconButton color="inherit" onClick={[pop, 1]} disableRipple>
|
||||
<ArrowBack />
|
||||
</IconButton>
|
||||
<Title>{t("Choose Language")}</Title>
|
||||
|
@ -96,7 +96,10 @@ const ChooseLang: Component = () => {
|
|||
<ListItemText>{t(`lang.${c}`)}</ListItemText>
|
||||
<ListItemSecondaryAction>
|
||||
<Radio
|
||||
checked={code() === c || (code() === undefined && matchedLangCode() == c)}
|
||||
checked={
|
||||
code() === c ||
|
||||
(code() === undefined && matchedLangCode() == c)
|
||||
}
|
||||
/>
|
||||
</ListItemSecondaryAction>
|
||||
</ListItemButton>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue