about summary refs log tree commit diff
path: root/src/alf/util/useColorModeTheme.ts
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2024-05-30 14:39:36 +0300
committerGitHub <noreply@github.com>2024-05-30 12:39:36 +0100
commit3bdceac2fb0a835d1709ad4558c9dcc2dfee6f25 (patch)
tree32da762b6ee2f30f287acbab8b48984360409835 /src/alf/util/useColorModeTheme.ts
parent76f860dad2c55b17fcbd4caf4d4a9297261b64e3 (diff)
downloadvoidsky-3bdceac2fb0a835d1709ad4558c9dcc2dfee6f25.tar.zst
Composer - Use sheet presentation on iOS (#4278)
* use sheet presentation + tweak spacing

* line up elements + add hitslop to cancel

* fixing spacing on replies
Diffstat (limited to 'src/alf/util/useColorModeTheme.ts')
-rw-r--r--src/alf/util/useColorModeTheme.ts20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/alf/util/useColorModeTheme.ts b/src/alf/util/useColorModeTheme.ts
index 301c993dd..ce1558747 100644
--- a/src/alf/util/useColorModeTheme.ts
+++ b/src/alf/util/useColorModeTheme.ts
@@ -7,19 +7,21 @@ import {useThemePrefs} from 'state/shell'
 import {dark, dim, light, ThemeName} from '#/alf/themes'
 
 export function useColorModeTheme(): ThemeName {
-  const colorScheme = useColorScheme()
-  const {colorMode, darkTheme} = useThemePrefs()
+  const theme = useThemeName()
 
   React.useLayoutEffect(() => {
-    const theme = getThemeName(colorScheme, colorMode, darkTheme)
     updateDocument(theme)
     SystemUI.setBackgroundColorAsync(getBackgroundColor(theme))
-  }, [colorMode, colorScheme, darkTheme])
+  }, [theme])
+
+  return theme
+}
+
+export function useThemeName(): ThemeName {
+  const colorScheme = useColorScheme()
+  const {colorMode, darkTheme} = useThemePrefs()
 
-  return React.useMemo(
-    () => getThemeName(colorScheme, colorMode, darkTheme),
-    [colorScheme, colorMode, darkTheme],
-  )
+  return getThemeName(colorScheme, colorMode, darkTheme)
 }
 
 function getThemeName(
@@ -53,7 +55,7 @@ function updateDocument(theme: ThemeName) {
   }
 }
 
-function getBackgroundColor(theme: ThemeName): string {
+export function getBackgroundColor(theme: ThemeName): string {
   switch (theme) {
     case 'light':
       return light.atoms.bg.backgroundColor