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>
This commit is contained in:
78
memento-mobile/app/notebook/[id].tsx
Normal file
78
memento-mobile/app/notebook/[id].tsx
Normal file
@@ -0,0 +1,78 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import {
|
||||
View, Text, FlatList, TouchableOpacity, ActivityIndicator, RefreshControl,
|
||||
} from 'react-native'
|
||||
import { SafeAreaView } from 'react-native-safe-area-context'
|
||||
import { useLocalSearchParams, useRouter } from 'expo-router'
|
||||
import { ArrowLeft } from 'lucide-react-native'
|
||||
import { apiFetch } from '@/lib/api'
|
||||
import { ENDPOINTS } from '@/lib/config'
|
||||
|
||||
interface Note {
|
||||
id: string
|
||||
title: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export default function NotebookScreen() {
|
||||
const { id } = useLocalSearchParams<{ id: string }>()
|
||||
const [notes, setNotes] = useState<Note[]>([])
|
||||
const [notebookName, setNotebookName] = useState('')
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
const router = useRouter()
|
||||
|
||||
const load = async () => {
|
||||
try {
|
||||
const res = await apiFetch(ENDPOINTS.notes(id))
|
||||
if (res.ok) {
|
||||
const data = await res.json()
|
||||
setNotes(data.notes ?? [])
|
||||
setNotebookName(data.notebookName ?? '')
|
||||
}
|
||||
} finally {
|
||||
setLoading(false)
|
||||
setRefreshing(false)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => { load() }, [id])
|
||||
|
||||
return (
|
||||
<SafeAreaView className="flex-1 bg-paper">
|
||||
<View className="flex-row items-center gap-3 px-4 py-3 border-b border-border">
|
||||
<TouchableOpacity onPress={() => router.back()} className="p-1">
|
||||
<ArrowLeft size={22} color="#1A1A18" />
|
||||
</TouchableOpacity>
|
||||
<Text className="text-[17px] font-semibold text-ink flex-1">{notebookName || 'Carnet'}</Text>
|
||||
</View>
|
||||
|
||||
{loading ? (
|
||||
<View className="flex-1 items-center justify-center">
|
||||
<ActivityIndicator color="#A47148" />
|
||||
</View>
|
||||
) : (
|
||||
<FlatList
|
||||
data={notes}
|
||||
keyExtractor={(item) => item.id}
|
||||
contentContainerClassName="px-5 pt-4 pb-8"
|
||||
refreshControl={<RefreshControl refreshing={refreshing} onRefresh={() => { setRefreshing(true); load() }} tintColor="#A47148" />}
|
||||
renderItem={({ item }) => (
|
||||
<TouchableOpacity
|
||||
onPress={() => router.push(`/note/${item.id}`)}
|
||||
className="bg-white border border-border rounded-2xl p-4 mb-2.5 active:opacity-70"
|
||||
>
|
||||
<Text className="text-[15px] font-semibold text-ink" numberOfLines={1}>
|
||||
{item.title || 'Sans titre'}
|
||||
</Text>
|
||||
<Text className="text-[12px] text-concrete mt-0.5">
|
||||
{new Date(item.updatedAt).toLocaleDateString('fr-FR', { day: 'numeric', month: 'short' })}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
ListEmptyComponent={<Text className="text-concrete text-center mt-12">Carnet vide.</Text>}
|
||||
/>
|
||||
)}
|
||||
</SafeAreaView>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user