|
| 1 | +# Header/Footer adaptation by page and device |
| 2 | + |
| 3 | +Yes - you can (and should) make header and footer behavior depend on both **route** and **runtime** (web, native, Telegram Mini App). |
| 4 | + |
| 5 | +This note describes a minimal, scalable pattern for this repository. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## 1) Goal |
| 10 | + |
| 11 | +Keep one global app shell, but allow each page group to define: |
| 12 | + |
| 13 | +- whether header is shown |
| 14 | +- whether footer is shown |
| 15 | +- which variant is used (full, compact, hidden) |
| 16 | +- device-specific behavior (web vs native vs TMA) |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## 2) Current baseline in this repo |
| 21 | + |
| 22 | +`app/_layout.tsx` currently always renders: |
| 23 | + |
| 24 | +- `GlobalLogoBarWithFallback` at top |
| 25 | +- page `<Stack />` in the middle |
| 26 | +- `GlobalBottomBarWeb` (web) or `GlobalBottomBar` (native/TMA) at bottom |
| 27 | + |
| 28 | +This is simple, but it means welcome/auth pages inherit the same bars as app pages. |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## 3) Recommended structure (minimal and clear) |
| 33 | + |
| 34 | +Use route-group layouts as shell boundaries: |
| 35 | + |
| 36 | +- `app/(auth)/_layout.tsx` -> auth shell (welcome/login flow) |
| 37 | +- `app/(app)/_layout.tsx` -> app shell (home/ai/settings/etc.) |
| 38 | + |
| 39 | +Then: |
| 40 | + |
| 41 | +1. Keep `app/_layout.tsx` for providers only (`TelegramProvider`, `AuthProvider`, theme setup). |
| 42 | +2. Move top/bottom bars out of root and into the group layout(s) that need them. |
| 43 | +3. In each group layout, select variants by device/platform. |
| 44 | + |
| 45 | +This keeps file structure small while preventing UI condition spaghetti in one file. |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +## 4) Adaptation matrix |
| 50 | + |
| 51 | +| Route group | Web | Native app | Telegram Mini App | |
| 52 | +|---|---|---|---| |
| 53 | +| `(auth)` | Header optional (brand only), footer hidden | Header optional, footer hidden | Header optional, footer hidden | |
| 54 | +| `(app)` | Full header + web footer/search | Full header + native footer/search | TMA-aware header + native footer/search | |
| 55 | + |
| 56 | +Notes: |
| 57 | + |
| 58 | +- Welcome screen is usually cleaner with no footer controls. |
| 59 | +- App pages should keep navigation/actions visible and consistent. |
| 60 | +- In TMA, preserve Telegram theme sync and avoid pre-theme flashes. |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +## 5) How to implement (practical) |
| 65 | + |
| 66 | +### A. Auth layout (`app/(auth)/_layout.tsx`) |
| 67 | + |
| 68 | +- Render a `Stack` with `headerShown: false`. |
| 69 | +- If needed, render a minimal top brand component only. |
| 70 | +- Do not mount bottom bar. |
| 71 | + |
| 72 | +### B. App layout (`app/(app)/_layout.tsx`) |
| 73 | + |
| 74 | +- Keep auth guard redirect to `/welcome`. |
| 75 | +- Render top bar + content + bottom bar. |
| 76 | +- Branch footer by `Platform.OS` (web/native), same as current root logic. |
| 77 | + |
| 78 | +### C. Optional per-page override |
| 79 | + |
| 80 | +If a specific page needs no bars (for example, fullscreen flow), add route metadata in code: |
| 81 | + |
| 82 | +- simple approach: maintain a tiny set of route names in group layout (`hiddenHeaderRoutes`, `hiddenFooterRoutes`) |
| 83 | +- cleaner later: create a `ScreenChromeContext` with `{ header: "full" | "compact" | "none", footer: ... }` |
| 84 | + |
| 85 | +Do not over-engineer before multiple special pages actually exist. |
| 86 | + |
| 87 | +--- |
| 88 | + |
| 89 | +## 6) Theme and color consistency rules |
| 90 | + |
| 91 | +1. All screens use `useColors()` (`background`, `primary`, `secondary`). |
| 92 | +2. Header/footer must read from the same theme source. |
| 93 | +3. Avoid hard-coded light/dark literals in page components. |
| 94 | +4. For TMA, keep `themeBgReady` guard behavior to prevent flash/mismatch. |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +## 7) Suggested near-term rollout |
| 99 | + |
| 100 | +1. Keep current providers in `app/_layout.tsx`. |
| 101 | +2. Move header/footer rendering from root to `app/(app)/_layout.tsx`. |
| 102 | +3. Keep `app/(auth)/_layout.tsx` minimal (no footer). |
| 103 | +4. Leave welcome blank now, but already under `(auth)` so future auth UI is isolated. |
| 104 | +5. Add one shared `PageContainer` helper later if repeated spacing/styling appears. |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## 8) One-line decision |
| 109 | + |
| 110 | +Use **group-based shell adaptation**: auth routes get a minimal chrome, app routes get full chrome, and device-specific variants are selected inside each group layout using the same `useColors()` theme contract. |
| 111 | + |
0 commit comments