feat: implement authentication flow and session management
- Update RootLayout to handle authentication state and redirect users based on their auth status. - Create an Index component to redirect unauthenticated users to the login page. - Modify ApiAuthRepository to fetch user session data using access and refresh tokens. - Introduce a new container file to manage use case instances for authentication and filament operations. - Enhance authStore to validate tokens and fetch user data from the API. - Add babel-plugin-module-resolver for improved module imports. - Update package.json scripts for running the app on Android and iOS. - Add expo-camera dependency for camera functionalities. - Update tsconfig.json to include infrastructure path mapping.
This commit is contained in:
+25
-12
@@ -16,6 +16,7 @@ O app é **offline-first**: todos os dados são persistidos localmente em **SQLi
|
||||
| Navigation | `expo-router` ~3 | File-system routing |
|
||||
| Linguagem | TypeScript 5.x | strict mode |
|
||||
| Node Version | 22 LTS | Gerenciado via `mise` (`.mise.toml`) |
|
||||
| Java Version | 17 | Obrigatório para React Native 0.81 (Java 24 quebra CMake) |
|
||||
| UI | React Native + `@expo/vector-icons`| Ionicons |
|
||||
| Forms | `react-hook-form` + `zod` | Validação em runtime |
|
||||
| Estado global | `zustand` | Stores em `src/store/` |
|
||||
@@ -25,6 +26,8 @@ O app é **offline-first**: todos os dados são persistidos localmente em **SQLi
|
||||
| Safe Area | `react-native-safe-area-context` | |
|
||||
| Gesture Handler | `react-native-gesture-handler` | |
|
||||
| Animations | `react-native-reanimated` | |
|
||||
| QR Code render | `react-native-qrcode-svg` | Render de QR Code em tela |
|
||||
| Câmera / Scanner | `expo-camera` ~17 | ML Kit barcode scan; requer development build |
|
||||
|
||||
---
|
||||
|
||||
@@ -60,7 +63,7 @@ Nenhuma camada interna importa de camadas externas. Os `adapters` implementam os
|
||||
|
||||
```
|
||||
mobile/
|
||||
├── .mise.toml ← node 22 LTS
|
||||
├── .mise.toml ← node 22 LTS, java 17
|
||||
├── app.json ← Expo config, scheme "meowspool"
|
||||
├── babel.config.js ← module-resolver + reanimated
|
||||
├── tsconfig.json ← aliases @domain, @ports, @application,
|
||||
@@ -98,10 +101,11 @@ mobile/
|
||||
│ │ ├── new.tsx ← QM-0 Novo Preset
|
||||
│ │ └── [id]/
|
||||
│ │ └── edit.tsx ← 1KD-0 Editar Preset
|
||||
│ ├── scanner.tsx ← Scanner de QR Code (expo-camera ML Kit)
|
||||
│ └── filaments/
|
||||
│ └── [id]/
|
||||
│ ├── qrcode.tsx ← 1CF-0 Ver QR Code
|
||||
│ └── label.tsx ← 1FZ-0 Exportar Etiqueta SVG
|
||||
│ ├── qrcode.tsx ← Ver QR Code (react-native-qrcode-svg)
|
||||
│ └── label.tsx ← Exportar Etiqueta SVG
|
||||
│
|
||||
└── src/
|
||||
├── domain/
|
||||
@@ -202,8 +206,9 @@ Arquivo: `src/shared/theme.ts`
|
||||
### Deep links
|
||||
|
||||
- Scheme: `meowspool://`
|
||||
- Filamento: `meowspool://filament/<id>` → `/(app)/inventory/<id>`
|
||||
- QR público: `meowspool.app/f/<slug>` (web)
|
||||
- Filamento: `meowspool://filament/<id>` → `/(app)/inventory/<id>` (singular, alinhado com backend)
|
||||
- O scanner (`scanner.tsx`) faz match via `/meowspool:\/\/filament\/([^/]+)/` e navega para `/(app)/inventory/<id>`
|
||||
- O QR Code de cada filamento exibe `meowspool://filament/<id>` usando `react-native-qrcode-svg`
|
||||
|
||||
---
|
||||
|
||||
@@ -322,7 +327,8 @@ Base: `EXPO_PUBLIC_API_URL` (padrão: `http://localhost:3000/api/v1`)
|
||||
|
||||
- [ ] Instanciar e injetar repositórios concretos nos Use Cases (DI container simples ou Context)
|
||||
- [ ] Implementar sync background com `sync_queue` SQLite → API
|
||||
- [ ] Integrar `react-native-qrcode-svg` para render real do QR Code
|
||||
- [x] Integrar `react-native-qrcode-svg` para render real do QR Code
|
||||
- [x] Scanner de QR Code com `expo-camera` v17 (ML Kit) → `scanner.tsx`
|
||||
- [ ] Gerar SVG de etiqueta (integração com `/filaments/:id/label` do backend)
|
||||
- [ ] Expo Notifications para alertas de estoque baixo
|
||||
- [ ] Google OAuth com `expo-auth-session`
|
||||
@@ -334,20 +340,27 @@ Base: `EXPO_PUBLIC_API_URL` (padrão: `http://localhost:3000/api/v1`)
|
||||
|
||||
```bash
|
||||
# Instalar dependências (na pasta mobile/)
|
||||
mise install # garante Node 22
|
||||
mise install # garante Node 22 e Java 17
|
||||
npm install
|
||||
|
||||
# Iniciar servidor de desenvolvimento
|
||||
# Iniciar servidor de desenvolvimento (Expo Go — sem câmera ML Kit)
|
||||
npx expo start
|
||||
|
||||
# iOS
|
||||
npx expo run:ios
|
||||
# Build nativo Android (necessário para expo-camera ML Kit barcode scan)
|
||||
mise exec -- npx expo run:android
|
||||
|
||||
# Android
|
||||
npx expo run:android
|
||||
# Build nativo iOS
|
||||
mise exec -- npx expo run:ios
|
||||
```
|
||||
|
||||
> **Variável de ambiente**: crie `mobile/.env` com:
|
||||
> ```
|
||||
> EXPO_PUBLIC_API_URL=http://localhost:3000/api/v1
|
||||
> ```
|
||||
|
||||
> **Atenção ao build Android**: o projeto usa `namespace "com.meowspool"` no `build.gradle` mas
|
||||
> o código fonte fica em `com.meowspool.app`. Por isso `MainActivity.kt` e `MainApplication.kt`
|
||||
> importam explicitamente `com.meowspool.R` e `com.meowspool.BuildConfig`, e o `AndroidManifest.xml`
|
||||
> usa nomes totalmente qualificados (`com.meowspool.app.MainApplication`, `com.meowspool.app.MainActivity`).
|
||||
> Não usar nomes relativos (`.MainApplication`) no manifest — eles resolvem para `com.meowspool.*`
|
||||
> (sem `.app`), causando `ClassNotFoundException` em runtime.
|
||||
|
||||
Reference in New Issue
Block a user