mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-29 18:13:47 +00:00
fix: adapt referral network for Telegram MiniApp safe areas
- Extract useHeaderHeight() hook — single source of truth for header height across AppShell, ReferralNetwork, and TicketNotificationBell - Portal top offset now computed dynamically from TG safe area insets instead of hardcoded top-16 (fixes overlap with TG header bar) - Two-row mobile layout: title + selector on separate rows so dropdown gets full width on small screens - Add MOBILE_HEADER_HEIGHT_PX and DESKTOP_HEADER_HEIGHT_PX to constants - Fix TicketNotificationBell using hardcoded 45px for all platforms
This commit is contained in:
25
src/hooks/useHeaderHeight.ts
Normal file
25
src/hooks/useHeaderHeight.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { useTelegramSDK } from '@/hooks/useTelegramSDK';
|
||||
import { UI } from '@/config/constants';
|
||||
|
||||
/**
|
||||
* Computes the app header height in pixels, accounting for
|
||||
* Telegram MiniApp safe area insets in fullscreen mode.
|
||||
*
|
||||
* Desktop: 56px (h-14). Mobile: 64px (h-16) + safe area + TG header when fullscreen.
|
||||
*/
|
||||
export function useHeaderHeight(): { mobile: number; desktop: number } {
|
||||
const { isFullscreen, safeAreaInset, contentSafeAreaInset, platform, isMobile } =
|
||||
useTelegramSDK();
|
||||
const isMobileFullscreen = isFullscreen && isMobile;
|
||||
|
||||
const telegramHeaderHeight =
|
||||
platform === 'android' ? UI.TELEGRAM_HEADER_ANDROID_PX : UI.TELEGRAM_HEADER_IOS_PX;
|
||||
|
||||
const mobile = isMobileFullscreen
|
||||
? UI.MOBILE_HEADER_HEIGHT_PX +
|
||||
Math.max(safeAreaInset.top, contentSafeAreaInset.top) +
|
||||
telegramHeaderHeight
|
||||
: UI.MOBILE_HEADER_HEIGHT_PX;
|
||||
|
||||
return { mobile, desktop: UI.DESKTOP_HEADER_HEIGHT_PX };
|
||||
}
|
||||
Reference in New Issue
Block a user