From 2da07a8d0100ad1f9c19323363d7f1e456cf538b Mon Sep 17 00:00:00 2001 From: thislight Date: Fri, 27 Dec 2024 21:40:39 +0800 Subject: [PATCH 1/6] Settings: correct safe area emu hot reload --- src/settings/Settings.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index f783e7a..645c98f 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -141,11 +141,16 @@ function setupSafeAreaEmulation(name: string) { } } +const $$SAFE_AREA_EMU = "$$SAFE_AREA_EMU"; + if (import.meta.hot) { - import.meta.hot.accept((mod) => { - if (!mod) return; + import.meta.hot.on("vite:beforeUpdate", () => { + import.meta.hot!.data[$$SAFE_AREA_EMU] = screenOrientationCallback; + }); + + import.meta.hot.on("vite:afterUpdate", () => { + screenOrientationCallback = import.meta.hot?.data?.[$$SAFE_AREA_EMU]; if (screenOrientationCallback) { - mod["screenOrientationCallback"] = screenOrientationCallback; setTimeout(screenOrientationCallback, 0); } }); From 81b5fe145048e3ee3cce23aa86a22b1517473b12 Mon Sep 17 00:00:00 2001 From: thislight Date: Fri, 27 Dec 2024 21:56:32 +0800 Subject: [PATCH 2/6] Settings: add clear cache option --- src/masto/base.ts | 4 +++- src/settings/Settings.tsx | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/masto/base.ts b/src/masto/base.ts index 823fad7..a0bc4ee 100644 --- a/src/masto/base.ts +++ b/src/masto/base.ts @@ -1,6 +1,8 @@ import { createCacheBucket } from "~platform/cache"; -export const cacheBucket = /* @__PURE__ */ createCacheBucket("mastodon"); +export const CACHE_BUCKET_NAME = "mastodon" + +export const cacheBucket = /* @__PURE__ */ createCacheBucket(CACHE_BUCKET_NAME); export function toSmallCamelCase(object: T) :T { if (!object || typeof object !== "object") { diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index 645c98f..0153c7c 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -18,6 +18,7 @@ import { import { Animation as AnimationIcon, Close as CloseIcon, + DeleteForever, Logout, Public as PublicIcon, Refresh as RefreshIcon, @@ -275,6 +276,17 @@ const Settings: Component = () => { +
  • + Storage + + + + + + Clear cache... + + +
  • {t("This Application")} From 4df609f1f55f7889dbc304c82bb73dbee2d4ed3a Mon Sep 17 00:00:00 2001 From: thislight Date: Fri, 27 Dec 2024 22:24:19 +0800 Subject: [PATCH 3/6] Settings: use AppTopBar --- src/settings/Language.tsx | 18 +++++++----------- src/settings/Motions.tsx | 12 ++++-------- src/settings/Region.tsx | 20 ++++++++------------ src/settings/Settings.tsx | 18 +++++++----------- 4 files changed, 26 insertions(+), 42 deletions(-) diff --git a/src/settings/Language.tsx b/src/settings/Language.tsx index b76495f..4a72cb1 100644 --- a/src/settings/Language.tsx +++ b/src/settings/Language.tsx @@ -25,6 +25,7 @@ import type { Template } from "@solid-primitives/i18n"; import { useStore } from "@nanostores/solid"; import { $settings } from "./stores"; import { useNavigator } from "~platform/StackedRouter"; +import AppTopBar from "~material/AppTopBar"; const ChooseLang: Component = () => { const { pop } = useNavigator(); @@ -54,17 +55,12 @@ const ChooseLang: Component = () => { return ( - - - - - {t("Choose Language")} - - + + + + + {t("Choose Language")} + } > { const {pop} = useNavigator(); @@ -31,17 +32,12 @@ const Motions: Component = () => { return ( - - + + {t("motions")} - - + } > { - const {pop} = useNavigator(); + const { pop } = useNavigator(); const [t] = createTranslator( () => import("./i18n/generic.json"), (code) => @@ -49,17 +50,12 @@ const ChooseRegion: Component = () => { return ( - - - - - {t("Choose Region")} - - + + + + + {t("Choose Region")} + } > { return ( - - - - - {t("Settings")} - - + + + + + {t("Settings")} + } > From 8d04874bce75f79f831db7d36eef03a5976d31dc Mon Sep 17 00:00:00 2001 From: thislight Date: Fri, 27 Dec 2024 22:24:46 +0800 Subject: [PATCH 4/6] AppTopBar: minor change to the text justify --- src/material/AppTopBar.css | 16 +++++++++++++++- src/material/AppTopBar.tsx | 1 - 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/material/AppTopBar.css b/src/material/AppTopBar.css index de3426d..cf692eb 100644 --- a/src/material/AppTopBar.css +++ b/src/material/AppTopBar.css @@ -1,6 +1,20 @@ .AppTopBar { - & > .toolbar { + & > .MuiToolbar-root { padding-top: var(--safe-area-inset-top, 0px); gap: 8px; + + & > button:first-child, & > .MuiButtonBase-root:first-child { + margin-left: -0.15em; + } + + & > button:last-child, & > .MuiButtonBase-root:last-child { + margin-right: -0.15em; + } + + & > .title { + margin-top: -0.2ch; + } } } + + diff --git a/src/material/AppTopBar.tsx b/src/material/AppTopBar.tsx index a9ad382..a75c7c3 100644 --- a/src/material/AppTopBar.tsx +++ b/src/material/AppTopBar.tsx @@ -20,7 +20,6 @@ const AppTopBar: ParentComponent<{ > windowSize.height ? "dense" : "regular"} - class="toolbar" sx={{ paddingTop: "var(--safe-area-inset-top, 0px)" }} > {props.children} From 59c7a5c588a2aff218502d4ebf91ae5b7a90f426 Mon Sep 17 00:00:00 2001 From: thislight Date: Fri, 27 Dec 2024 22:36:35 +0800 Subject: [PATCH 5/6] Home: use AppTopBar --- src/timelines/Home.tsx | 63 +++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/src/timelines/Home.tsx b/src/timelines/Home.tsx index 99e4fd1..5b413ce 100644 --- a/src/timelines/Home.tsx +++ b/src/timelines/Home.tsx @@ -31,6 +31,7 @@ import { createSingluarItemSelection, default as ItemSelectionProvider, } from "./toots/ItemSelectionProvider"; +import AppTopBar from "~material/AppTopBar"; const Home: ParentComponent = (props) => { let panelList: HTMLDivElement; @@ -165,40 +166,34 @@ const Home: ParentComponent = (props) => { <> - - - - Home - - - Trending - - - Public - - - - - $settings.setKey( - "prefetchTootsDisabled", - !$settings.get().prefetchTootsDisabled, - ) - } - > - Prefetch Toots - - - - - - - + + + + Home + + + Trending + + + Public + + + + + $settings.setKey( + "prefetchTootsDisabled", + !$settings.get().prefetchTootsDisabled, + ) + } + > + Prefetch Toots + + + + + + } > From d7e13584950501440517b33e8dd254110f08016a Mon Sep 17 00:00:00 2001 From: thislight Date: Fri, 27 Dec 2024 22:42:20 +0800 Subject: [PATCH 6/6] AppTopBar: add dark status bar --- src/material/AppTopBar.css | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/material/AppTopBar.css b/src/material/AppTopBar.css index cf692eb..a79321c 100644 --- a/src/material/AppTopBar.css +++ b/src/material/AppTopBar.css @@ -1,20 +1,31 @@ .AppTopBar { - & > .MuiToolbar-root { + &::before { + contain: strict; + content: ""; + position: absolute; + top: 0; + left: 0; + right: 0; + height: var(--safe-area-inset-top, 0); + background-color: rgba(0, 0, 0, 0.2); + } + + &>.MuiToolbar-root { padding-top: var(--safe-area-inset-top, 0px); gap: 8px; - & > button:first-child, & > .MuiButtonBase-root:first-child { + &>button:first-child, + &>.MuiButtonBase-root:first-child { margin-left: -0.15em; } - & > button:last-child, & > .MuiButtonBase-root:last-child { + &>button:last-child, + &>.MuiButtonBase-root:last-child { margin-right: -0.15em; } - & > .title { + &>.title { margin-top: -0.2ch; } } -} - - +} \ No newline at end of file