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:
Fringg
2026-03-20 04:23:45 +03:00
parent 2780898d1c
commit 33486a09d0
5 changed files with 47 additions and 26 deletions

View 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 };
}