From d2145f761d995c4959ea87ea9c47671ef432cb6a Mon Sep 17 00:00:00 2001 From: Antigravity Date: Fri, 29 May 2026 17:03:14 +0000 Subject: [PATCH] mobile: fix navigation (typed routes), extract C tokens to lib/theme.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - lib/theme.ts: C design tokens dans fichier dédié (plus d'import circulaire _layout) - app/_layout.tsx: importe C depuis @/lib/theme, ré-exporte pour compatibilité - Tous les écrans: import C depuis '@/lib/theme' au lieu de '../_layout' - Toutes les navigations: router.push({ pathname, params }) au lieu de template strings -> Fix réel du bug 'impossible d'ouvrir carnet/note' avec Expo Router v6 - package.json: expo-web-browser ajouté (pour Google OAuth étape suivante) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- memento-mobile/app/(auth)/login.tsx | 2 +- memento-mobile/app/(tabs)/_layout.tsx | 2 +- memento-mobile/app/(tabs)/home.tsx | 6 +++--- memento-mobile/app/(tabs)/notebooks.tsx | 4 ++-- memento-mobile/app/(tabs)/profile.tsx | 2 +- memento-mobile/app/(tabs)/search.tsx | 4 ++-- memento-mobile/app/_layout.tsx | 16 ++++------------ memento-mobile/app/note/[id].tsx | 2 +- memento-mobile/app/notebook/[id].tsx | 4 ++-- memento-mobile/lib/store.ts | 1 + memento-mobile/lib/theme.ts | 12 ++++++++++++ memento-mobile/package.json | 3 ++- 12 files changed, 32 insertions(+), 26 deletions(-) create mode 100644 memento-mobile/lib/theme.ts diff --git a/memento-mobile/app/(auth)/login.tsx b/memento-mobile/app/(auth)/login.tsx index 8d87ca2..c669340 100644 --- a/memento-mobile/app/(auth)/login.tsx +++ b/memento-mobile/app/(auth)/login.tsx @@ -5,7 +5,7 @@ import { Alert, StyleSheet, } from 'react-native' import { useAuthStore } from '@/lib/store' -import { C } from '../_layout' +import { C } from '@/lib/theme' export default function LoginScreen() { const [email, setEmail] = useState('') diff --git a/memento-mobile/app/(tabs)/_layout.tsx b/memento-mobile/app/(tabs)/_layout.tsx index 6fd8253..f36d1ff 100644 --- a/memento-mobile/app/(tabs)/_layout.tsx +++ b/memento-mobile/app/(tabs)/_layout.tsx @@ -1,6 +1,6 @@ import { Tabs } from 'expo-router' import { BookOpen, Search, Home, User } from 'lucide-react-native' -import { C } from '../_layout' +import { C } from '@/lib/theme' export default function TabsLayout() { return ( diff --git a/memento-mobile/app/(tabs)/home.tsx b/memento-mobile/app/(tabs)/home.tsx index ef7fc27..01c8a08 100644 --- a/memento-mobile/app/(tabs)/home.tsx +++ b/memento-mobile/app/(tabs)/home.tsx @@ -9,7 +9,7 @@ import { CalendarDays, Search, BookOpen, Clock, ChevronRight } from 'lucide-reac import { apiFetch } from '@/lib/api' import { ENDPOINTS } from '@/lib/config' import { useAuthStore } from '@/lib/store' -import { C } from '../_layout' +import { C } from '@/lib/theme' interface Note { id: string @@ -45,7 +45,7 @@ export default function HomeScreen() { const res = await apiFetch(ENDPOINTS.dailyNote) if (res.ok) { const data = await res.json() - router.push(`/note/${data.id}`) + router.push({ pathname: '/note/[id]', params: { id: data.id } }) } } @@ -107,7 +107,7 @@ export default function HomeScreen() { : recentNotes.map((note, i) => ( router.push(`/note/${note.id}`)} + onPress={() => router.push({ pathname: '/note/[id]', params: { id: note.id } })} style={[s.noteRow, i === recentNotes.length - 1 && { borderBottomWidth: 0 }]} activeOpacity={0.6} > diff --git a/memento-mobile/app/(tabs)/notebooks.tsx b/memento-mobile/app/(tabs)/notebooks.tsx index 16cd899..d5014fa 100644 --- a/memento-mobile/app/(tabs)/notebooks.tsx +++ b/memento-mobile/app/(tabs)/notebooks.tsx @@ -8,7 +8,7 @@ import { useRouter } from 'expo-router' import { ChevronRight, BookOpen, Folder } from 'lucide-react-native' import { apiFetch } from '@/lib/api' import { ENDPOINTS } from '@/lib/config' -import { C } from '../_layout' +import { C } from '@/lib/theme' interface Notebook { id: string @@ -72,7 +72,7 @@ export default function NotebooksScreen() { contentContainerStyle={s.list} refreshControl={ { setRefreshing(true); load() }} tintColor={C.brand} />} renderItem={({ item }) => ( - router.push(`/notebook/${item.id}`)} style={s.card} activeOpacity={0.7}> + router.push({ pathname: '/notebook/[id]', params: { id: item.id } })} style={s.card} activeOpacity={0.7}> diff --git a/memento-mobile/app/(tabs)/profile.tsx b/memento-mobile/app/(tabs)/profile.tsx index 104a97c..9bf46ca 100644 --- a/memento-mobile/app/(tabs)/profile.tsx +++ b/memento-mobile/app/(tabs)/profile.tsx @@ -2,7 +2,7 @@ import { View, Text, TouchableOpacity, ScrollView, Alert, StyleSheet } from 'rea import { SafeAreaView } from 'react-native-safe-area-context' import { LogOut, CreditCard, Globe } from 'lucide-react-native' import { useAuthStore } from '@/lib/store' -import { C } from '../_layout' +import { C } from '@/lib/theme' const TIER_LABELS: Record = { FREE: 'Gratuit', diff --git a/memento-mobile/app/(tabs)/search.tsx b/memento-mobile/app/(tabs)/search.tsx index ae3e2c3..1c92365 100644 --- a/memento-mobile/app/(tabs)/search.tsx +++ b/memento-mobile/app/(tabs)/search.tsx @@ -8,7 +8,7 @@ import { Search as SearchIcon, X } from 'lucide-react-native' import { useRouter } from 'expo-router' import { apiFetch } from '@/lib/api' import { ENDPOINTS } from '@/lib/config' -import { C } from '../_layout' +import { C } from '@/lib/theme' interface SearchResult { id: string @@ -67,7 +67,7 @@ export default function SearchScreen() { keyExtractor={(item) => item.id} contentContainerStyle={s.list} renderItem={({ item }) => ( - router.push(`/note/${item.id}`)} style={s.card}> + router.push({ pathname: '/note/[id]', params: { id: item.id } })} style={s.card}> {item.title || 'Sans titre'} {item.snippet && {item.snippet}} {item.notebookName && {item.notebookName}} diff --git a/memento-mobile/app/_layout.tsx b/memento-mobile/app/_layout.tsx index 6f6674f..b588547 100644 --- a/memento-mobile/app/_layout.tsx +++ b/memento-mobile/app/_layout.tsx @@ -4,6 +4,10 @@ import { SafeAreaProvider } from 'react-native-safe-area-context' import { StatusBar } from 'expo-status-bar' import { View, ActivityIndicator, StyleSheet } from 'react-native' import { useAuthStore } from '@/lib/store' +import { C } from '@/lib/theme' + +// Ré-exporter C pour la compatibilité avec les anciens imports +export { C } from '@/lib/theme' export default function RootLayout() { const { user, loading, restore } = useAuthStore() @@ -35,18 +39,6 @@ export default function RootLayout() { ) } -export const C = { - brand: '#A47148', - ink: '#1A1A18', - paper: '#FAFAF8', - concrete: '#8A8A82', - border: '#E8E6E0', - white: '#FFFFFF', - rose: '#e11d48', - roseBg: '#fff1f2', - roseBorder: '#fecdd3', -} - const s = StyleSheet.create({ loader: { flex: 1, alignItems: 'center', justifyContent: 'center', backgroundColor: C.paper }, }) diff --git a/memento-mobile/app/note/[id].tsx b/memento-mobile/app/note/[id].tsx index fc81aaf..59ad99c 100644 --- a/memento-mobile/app/note/[id].tsx +++ b/memento-mobile/app/note/[id].tsx @@ -9,7 +9,7 @@ import { ArrowLeft, Share2 } from 'lucide-react-native' import { WebView } from 'react-native-webview' import { apiFetch } from '@/lib/api' import { ENDPOINTS } from '@/lib/config' -import { C } from '../_layout' +import { C } from '@/lib/theme' interface Note { id: string diff --git a/memento-mobile/app/notebook/[id].tsx b/memento-mobile/app/notebook/[id].tsx index a3922e0..1001a71 100644 --- a/memento-mobile/app/notebook/[id].tsx +++ b/memento-mobile/app/notebook/[id].tsx @@ -7,7 +7,7 @@ import { useLocalSearchParams, useRouter } from 'expo-router' import { ArrowLeft } from 'lucide-react-native' import { apiFetch } from '@/lib/api' import { ENDPOINTS } from '@/lib/config' -import { C } from '../_layout' +import { C } from '@/lib/theme' interface Note { id: string @@ -56,7 +56,7 @@ export default function NotebookScreen() { contentContainerStyle={s.list} refreshControl={ { setRefreshing(true); load() }} tintColor={C.brand} />} renderItem={({ item }) => ( - router.push(`/note/${item.id}`)} style={s.card}> + router.push({ pathname: '/note/[id]', params: { id: item.id } })} style={s.card}> {item.title || 'Sans titre'} {new Date(item.updatedAt).toLocaleDateString('fr-FR', { day: 'numeric', month: 'short' })} diff --git a/memento-mobile/lib/store.ts b/memento-mobile/lib/store.ts index 9c58ea7..ec22f8b 100644 --- a/memento-mobile/lib/store.ts +++ b/memento-mobile/lib/store.ts @@ -13,6 +13,7 @@ interface AuthState { user: User | null loading: boolean login: (email: string, password: string) => Promise + loginWithToken: (token: string, user: User) => Promise logout: () => Promise restore: () => Promise } diff --git a/memento-mobile/lib/theme.ts b/memento-mobile/lib/theme.ts new file mode 100644 index 0000000..1587c2c --- /dev/null +++ b/memento-mobile/lib/theme.ts @@ -0,0 +1,12 @@ +// Design tokens partagés — ne pas importer depuis _layout pour éviter les circularités +export const C = { + brand: '#A47148', + ink: '#1A1A18', + paper: '#FAFAF8', + concrete: '#8A8A82', + border: '#E8E6E0', + white: '#FFFFFF', + rose: '#e11d48', + roseBg: '#fff1f2', + roseBorder: '#fecdd3', +} diff --git a/memento-mobile/package.json b/memento-mobile/package.json index a171e5b..f3f6a69 100644 --- a/memento-mobile/package.json +++ b/memento-mobile/package.json @@ -26,7 +26,8 @@ "react-native-screens": "~4.16.0", "react-native-svg": "15.12.0", "react-native-webview": "13.15.0", - "zustand": "^5.0.2" + "zustand": "^5.0.2", + "expo-web-browser": "~14.1.6" }, "devDependencies": { "@babel/core": "^7.25.2",