feat: add iOS platform detection and improve dark theme contrast

This commit is contained in:
weishu
2025-12-17 18:48:44 +08:00
parent dc81620594
commit a6d088b51d
2 changed files with 14 additions and 1 deletions
+11 -1
View File
@@ -1,4 +1,4 @@
import { useEffect, useState, useSyncExternalStore } from 'react'
import { useSyncExternalStore } from 'react'
import { getTelegramWebApp } from './useTelegram'
type ColorScheme = 'light' | 'dark'
@@ -8,10 +8,20 @@ function getColorScheme(): ColorScheme {
return tg?.colorScheme === 'dark' ? 'dark' : 'light'
}
function isIOS(): boolean {
return /iPad|iPhone|iPod/.test(navigator.userAgent)
}
function applyTheme(scheme: ColorScheme): void {
document.documentElement.setAttribute('data-theme', scheme)
}
function applyPlatform(): void {
if (isIOS()) {
document.documentElement.classList.add('ios')
}
}
// External store for theme state
let currentScheme: ColorScheme = getColorScheme()
const listeners = new Set<() => void>()
+3
View File
@@ -37,6 +37,9 @@
}
[data-theme="dark"] {
/* Override secondary-bg for better contrast on iOS - matches happy-app surfaceHigh */
--app-secondary-bg: #2C2C2E;
--app-border: rgba(255, 255, 255, 0.1);
--app-divider: rgba(255, 255, 255, 0.08);
--app-subtle-bg: rgba(255, 255, 255, 0.05);