Files
Momento/memento-mobile/app/_layout.tsx
Antigravity aeedb2846f
Some checks failed
CI / Lint, Unit Tests & Build (push) Failing after 1m21s
CI / Deploy production (on server) (push) Has been skipped
feat: App mobile Expo + API mobile dédiée
memento-mobile/ (Expo + React Native + expo-router):
- Auth: login email/password → Bearer token (expo-secure-store)
- Layout: guard auth → redirect /(auth)/login ou /(tabs)/home
- Tabs: Accueil, Carnets, Recherche, Profil
- Screens: login, home (recent notes + quick actions), notebooks list,
  note viewer (WebView HTML), search (texte), notebook detail, profile
- Design: tokens brand-accent (#A47148), ink, concrete, paper, border
- lib/config.ts: API_URL dev/prod configurable
- lib/api.ts: apiFetch avec Bearer token automatique
- lib/store.ts: Zustand auth store (login/logout/restore)

memento-note/ (API mobile dédiée):
- lib/mobile-auth.ts: createMobileToken / verifyMobileToken (HMAC-SHA256, 90j)
- POST /api/mobile/auth/login: email+password → token + user
- GET /api/mobile/auth/me: valider token, retourner profil
- GET /api/mobile/notebooks: liste carnets avec nb notes
- GET /api/mobile/notes: notes récentes (filtre par carnet optionnel)
- GET /api/mobile/notes/[id]: contenu complet d'une note
- GET /api/mobile/search: recherche fulltext titre+contenu

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-29 15:53:13 +00:00

42 lines
1.0 KiB
TypeScript

import { useEffect } from 'react'
import { Slot, useRouter, useSegments } from 'expo-router'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { StatusBar } from 'expo-status-bar'
import { View, ActivityIndicator } from 'react-native'
import { useAuthStore } from '@/lib/store'
export default function RootLayout() {
const { user, loading, restore } = useAuthStore()
const router = useRouter()
const segments = useSegments()
useEffect(() => {
restore()
}, [])
useEffect(() => {
if (loading) return
const inAuth = segments[0] === '(auth)'
if (!user && !inAuth) {
router.replace('/(auth)/login')
} else if (user && inAuth) {
router.replace('/(tabs)/home')
}
}, [user, loading, segments])
if (loading) {
return (
<View className="flex-1 items-center justify-center bg-paper">
<ActivityIndicator size="large" color="#A47148" />
</View>
)
}
return (
<SafeAreaProvider>
<StatusBar style="auto" />
<Slot />
</SafeAreaProvider>
)
}