diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 0000000..992417a --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,13 @@ +{ + "permissions": { + "allow": [ + "Bash(npm install --save-dev babel-plugin-module-resolver)", + "Bash(cargo build)", + "Bash(npx expo install expo-camera)", + "Bash(npm install expo-camera)", + "Bash(npm install expo-camera --legacy-peer-deps)", + "Bash(ls /var/home/felipecn/DEV/MeowSpool/mobile/app/\\\\\\(app\\\\\\)/)", + "Bash(java -version)" + ] + } +} diff --git a/backend/agent.md b/backend/agent.md index 26eca40..afd0bbc 100644 --- a/backend/agent.md +++ b/backend/agent.md @@ -361,7 +361,7 @@ O backend implementa **last-write-wins com timestamp**: ## Geração de QR Code e Etiqueta SVG ### QR Code (`GET /filaments/:id/qrcode`) -- Gera QR Code com deep link: `meowspool://filaments/:id` +- Gera QR Code com deep link: `meowspool://filament/:id` (singular) - Retorna PNG (`image/png`) por padrão, ou SVG com `?format=svg` - Biblioteca: crate `qrcode` diff --git a/backend/bruno-routes/MewoSpool/Filaments/Get QR Code.yml b/backend/bruno-routes/MewoSpool/Filaments/Get QR Code.yml index e4ae7a4..0084da8 100644 --- a/backend/bruno-routes/MewoSpool/Filaments/Get QR Code.yml +++ b/backend/bruno-routes/MewoSpool/Filaments/Get QR Code.yml @@ -10,11 +10,6 @@ http: type: bearer token: "{{access_token}}" -runtime: - variables: - - name: filament_id - value: e1edc611-f020-4234-94e5-db5e1393dbf2 - settings: encodeUrl: true timeout: 0 diff --git a/backend/bruno-routes/MewoSpool/SpoolPresets/Update Spool Preset.yml b/backend/bruno-routes/MewoSpool/SpoolPresets/Update Spool Preset.yml index 1eea351..e9e1cae 100644 --- a/backend/bruno-routes/MewoSpool/SpoolPresets/Update Spool Preset.yml +++ b/backend/bruno-routes/MewoSpool/SpoolPresets/Update Spool Preset.yml @@ -10,8 +10,8 @@ http: type: json data: |- { - "name": "Carretel Customizado 350g", - "spool_weight_g": 350 + "name": "Elegoo (Papelão)", + "spool_weight_g": 156 } auth: type: bearer diff --git a/backend/bruno-routes/MewoSpool/environments/route.yml b/backend/bruno-routes/MewoSpool/environments/route.yml index 249b1ac..1c83c5d 100644 --- a/backend/bruno-routes/MewoSpool/environments/route.yml +++ b/backend/bruno-routes/MewoSpool/environments/route.yml @@ -5,6 +5,6 @@ variables: - secret: true name: refresh_token - name: preset_id - value: 0ffa808d-af09-4bc6-9a40-43df3a4c6dd0 + value: 38e439ba-0289-4bf0-9f4b-f9cb12991167 - name: filament_id - value: e1edc611-f020-4234-94e5-db5e1393dbf2 + value: 0b371f84-706a-4eaa-bff0-33556fa833b4 diff --git a/backend/src/adapters/inbound/spool_preset_handler.rs b/backend/src/adapters/inbound/spool_preset_handler.rs index 0d94670..46202b6 100644 --- a/backend/src/adapters/inbound/spool_preset_handler.rs +++ b/backend/src/adapters/inbound/spool_preset_handler.rs @@ -82,6 +82,15 @@ pub async fn create_preset_handler( Ok((StatusCode::CREATED, Json(SpoolPresetResponse::from(preset)))) } +pub async fn get_preset_handler( + State(state): State, + Extension(_user): Extension, + Path(id): Path, +) -> Result { + let preset = state.spool_preset_service.get_by_id(id).await?; + Ok(Json(SpoolPresetResponse::from(preset))) +} + pub async fn update_preset_handler( State(state): State, Extension(user): Extension, diff --git a/backend/src/application/filament_service.rs b/backend/src/application/filament_service.rs index 9941006..9047076 100644 --- a/backend/src/application/filament_service.rs +++ b/backend/src/application/filament_service.rs @@ -228,7 +228,7 @@ impl FilamentService { pub async fn generate_qrcode_png(&self, id: Uuid, user_id: Uuid) -> Result, AppError> { self.get(id, user_id).await?; - let deep_link = format!("meowspool://filaments/{id}"); + let deep_link = format!("meowspool://filament/{id}"); let code = qrcode::QrCode::new(deep_link.as_bytes()) .map_err(|e| AppError::Internal(anyhow::anyhow!("QR Code generation failed: {e}")))?; diff --git a/backend/src/application/spool_preset_service.rs b/backend/src/application/spool_preset_service.rs index 4bf996a..620d257 100644 --- a/backend/src/application/spool_preset_service.rs +++ b/backend/src/application/spool_preset_service.rs @@ -23,6 +23,10 @@ impl SpoolPresetService { self.repo.list_for_user(user_id).await } + pub async fn get_by_id(&self, id: Uuid) -> Result { + self.repo.find_by_id(id).await?.ok_or(AppError::NotFound) + } + pub async fn create( &self, user_id: Uuid, diff --git a/backend/src/router.rs b/backend/src/router.rs index 293cb78..f902e39 100644 --- a/backend/src/router.rs +++ b/backend/src/router.rs @@ -88,6 +88,7 @@ pub fn build(db: PgPool, config: Config) -> Router { // Spool Presets .route("/spool-presets", get(spool_preset_handler::list_presets_handler)) .route("/spool-presets", post(spool_preset_handler::create_preset_handler)) + .route("/spool-presets/:id", get(spool_preset_handler::get_preset_handler)) .route("/spool-presets/:id", put(spool_preset_handler::update_preset_handler)) .route("/spool-presets/:id", delete(spool_preset_handler::delete_preset_handler)) .route_layer(middleware::from_fn_with_state(state.clone(), auth_middleware)); diff --git a/mobile/.expo/types/router.d.ts b/mobile/.expo/types/router.d.ts index e652778..4c01455 100644 --- a/mobile/.expo/types/router.d.ts +++ b/mobile/.expo/types/router.d.ts @@ -6,9 +6,9 @@ export * from 'expo-router'; declare module 'expo-router' { export namespace ExpoRouter { export interface __routes { - hrefInputParams: { pathname: Router.RelativePathString, params?: Router.UnknownInputParams } | { pathname: Router.ExternalPathString, params?: Router.UnknownInputParams } | { pathname: `/_sitemap`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/add` | `/add`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/config` | `/config`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/home` | `/home`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/inventory` | `/inventory`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/profile` | `/profile`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}/config/presets/new` | `/config/presets/new`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}/inventory/filters` | `/inventory/filters`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}/inventory/new` | `/inventory/new`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/forgot-password` | `/forgot-password`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/login` | `/login`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/password-reset-done` | `/password-reset-done`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/register` | `/register`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/reset-password` | `/reset-password`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/verify-email` | `/verify-email`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}/config/presets/[id]/edit` | `/config/presets/[id]/edit`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(app)'}/filaments/[id]/label` | `/filaments/[id]/label`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(app)'}/filaments/[id]/qrcode` | `/filaments/[id]/qrcode`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(app)'}/inventory/[id]` | `/inventory/[id]`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(app)'}/inventory/[id]/edit` | `/inventory/[id]/edit`, params: Router.UnknownInputParams & { id: string | number; } }; - hrefOutputParams: { pathname: Router.RelativePathString, params?: Router.UnknownOutputParams } | { pathname: Router.ExternalPathString, params?: Router.UnknownOutputParams } | { pathname: `/_sitemap`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/add` | `/add`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/config` | `/config`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/home` | `/home`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/inventory` | `/inventory`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/profile` | `/profile`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}/config/presets/new` | `/config/presets/new`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}/inventory/filters` | `/inventory/filters`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}/inventory/new` | `/inventory/new`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(auth)'}/forgot-password` | `/forgot-password`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(auth)'}/login` | `/login`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(auth)'}/password-reset-done` | `/password-reset-done`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(auth)'}/register` | `/register`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(auth)'}/reset-password` | `/reset-password`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(auth)'}/verify-email` | `/verify-email`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}/config/presets/[id]/edit` | `/config/presets/[id]/edit`, params: Router.UnknownOutputParams & { id: string; } } | { pathname: `${'/(app)'}/filaments/[id]/label` | `/filaments/[id]/label`, params: Router.UnknownOutputParams & { id: string; } } | { pathname: `${'/(app)'}/filaments/[id]/qrcode` | `/filaments/[id]/qrcode`, params: Router.UnknownOutputParams & { id: string; } } | { pathname: `${'/(app)'}/inventory/[id]` | `/inventory/[id]`, params: Router.UnknownOutputParams & { id: string; } } | { pathname: `${'/(app)'}/inventory/[id]/edit` | `/inventory/[id]/edit`, params: Router.UnknownOutputParams & { id: string; } }; - href: Router.RelativePathString | Router.ExternalPathString | `/_sitemap${`?${string}` | `#${string}` | ''}` | `${'/(app)'}${'/(tabs)'}/add${`?${string}` | `#${string}` | ''}` | `/add${`?${string}` | `#${string}` | ''}` | `${'/(app)'}${'/(tabs)'}/config${`?${string}` | `#${string}` | ''}` | `/config${`?${string}` | `#${string}` | ''}` | `${'/(app)'}${'/(tabs)'}/home${`?${string}` | `#${string}` | ''}` | `/home${`?${string}` | `#${string}` | ''}` | `${'/(app)'}${'/(tabs)'}/inventory${`?${string}` | `#${string}` | ''}` | `/inventory${`?${string}` | `#${string}` | ''}` | `${'/(app)'}${'/(tabs)'}/profile${`?${string}` | `#${string}` | ''}` | `/profile${`?${string}` | `#${string}` | ''}` | `${'/(app)'}/config/presets/new${`?${string}` | `#${string}` | ''}` | `/config/presets/new${`?${string}` | `#${string}` | ''}` | `${'/(app)'}/inventory/filters${`?${string}` | `#${string}` | ''}` | `/inventory/filters${`?${string}` | `#${string}` | ''}` | `${'/(app)'}/inventory/new${`?${string}` | `#${string}` | ''}` | `/inventory/new${`?${string}` | `#${string}` | ''}` | `${'/(auth)'}/forgot-password${`?${string}` | `#${string}` | ''}` | `/forgot-password${`?${string}` | `#${string}` | ''}` | `${'/(auth)'}/login${`?${string}` | `#${string}` | ''}` | `/login${`?${string}` | `#${string}` | ''}` | `${'/(auth)'}/password-reset-done${`?${string}` | `#${string}` | ''}` | `/password-reset-done${`?${string}` | `#${string}` | ''}` | `${'/(auth)'}/register${`?${string}` | `#${string}` | ''}` | `/register${`?${string}` | `#${string}` | ''}` | `${'/(auth)'}/reset-password${`?${string}` | `#${string}` | ''}` | `/reset-password${`?${string}` | `#${string}` | ''}` | `${'/(auth)'}/verify-email${`?${string}` | `#${string}` | ''}` | `/verify-email${`?${string}` | `#${string}` | ''}` | { pathname: Router.RelativePathString, params?: Router.UnknownInputParams } | { pathname: Router.ExternalPathString, params?: Router.UnknownInputParams } | { pathname: `/_sitemap`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/add` | `/add`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/config` | `/config`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/home` | `/home`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/inventory` | `/inventory`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/profile` | `/profile`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}/config/presets/new` | `/config/presets/new`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}/inventory/filters` | `/inventory/filters`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}/inventory/new` | `/inventory/new`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/forgot-password` | `/forgot-password`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/login` | `/login`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/password-reset-done` | `/password-reset-done`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/register` | `/register`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/reset-password` | `/reset-password`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/verify-email` | `/verify-email`; params?: Router.UnknownInputParams; } | `${'/(app)'}/config/presets/${Router.SingleRoutePart}/edit${`?${string}` | `#${string}` | ''}` | `/config/presets/${Router.SingleRoutePart}/edit${`?${string}` | `#${string}` | ''}` | `${'/(app)'}/filaments/${Router.SingleRoutePart}/label${`?${string}` | `#${string}` | ''}` | `/filaments/${Router.SingleRoutePart}/label${`?${string}` | `#${string}` | ''}` | `${'/(app)'}/filaments/${Router.SingleRoutePart}/qrcode${`?${string}` | `#${string}` | ''}` | `/filaments/${Router.SingleRoutePart}/qrcode${`?${string}` | `#${string}` | ''}` | `${'/(app)'}/inventory/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | `/inventory/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | `${'/(app)'}/inventory/${Router.SingleRoutePart}/edit${`?${string}` | `#${string}` | ''}` | `/inventory/${Router.SingleRoutePart}/edit${`?${string}` | `#${string}` | ''}` | { pathname: `${'/(app)'}/config/presets/[id]/edit` | `/config/presets/[id]/edit`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(app)'}/filaments/[id]/label` | `/filaments/[id]/label`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(app)'}/filaments/[id]/qrcode` | `/filaments/[id]/qrcode`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(app)'}/inventory/[id]` | `/inventory/[id]`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(app)'}/inventory/[id]/edit` | `/inventory/[id]/edit`, params: Router.UnknownInputParams & { id: string | number; } }; + hrefInputParams: { pathname: Router.RelativePathString, params?: Router.UnknownInputParams } | { pathname: Router.ExternalPathString, params?: Router.UnknownInputParams } | { pathname: `/`; params?: Router.UnknownInputParams; } | { pathname: `/_sitemap`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}/scanner` | `/scanner`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/add` | `/add`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/config` | `/config`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/home` | `/home`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/inventory` | `/inventory`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/profile` | `/profile`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}/config/presets/new` | `/config/presets/new`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}/inventory/filters` | `/inventory/filters`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}/inventory/new` | `/inventory/new`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/forgot-password` | `/forgot-password`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/login` | `/login`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/password-reset-done` | `/password-reset-done`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/register` | `/register`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/reset-password` | `/reset-password`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/verify-email` | `/verify-email`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}/config/presets/[id]/edit` | `/config/presets/[id]/edit`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(app)'}/filaments/[id]/label` | `/filaments/[id]/label`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(app)'}/filaments/[id]/qrcode` | `/filaments/[id]/qrcode`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(app)'}/inventory/[id]` | `/inventory/[id]`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(app)'}/inventory/[id]/edit` | `/inventory/[id]/edit`, params: Router.UnknownInputParams & { id: string | number; } }; + hrefOutputParams: { pathname: Router.RelativePathString, params?: Router.UnknownOutputParams } | { pathname: Router.ExternalPathString, params?: Router.UnknownOutputParams } | { pathname: `/`; params?: Router.UnknownOutputParams; } | { pathname: `/_sitemap`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}/scanner` | `/scanner`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/add` | `/add`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/config` | `/config`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/home` | `/home`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/inventory` | `/inventory`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/profile` | `/profile`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}/config/presets/new` | `/config/presets/new`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}/inventory/filters` | `/inventory/filters`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}/inventory/new` | `/inventory/new`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(auth)'}/forgot-password` | `/forgot-password`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(auth)'}/login` | `/login`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(auth)'}/password-reset-done` | `/password-reset-done`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(auth)'}/register` | `/register`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(auth)'}/reset-password` | `/reset-password`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(auth)'}/verify-email` | `/verify-email`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(app)'}/config/presets/[id]/edit` | `/config/presets/[id]/edit`, params: Router.UnknownOutputParams & { id: string; } } | { pathname: `${'/(app)'}/filaments/[id]/label` | `/filaments/[id]/label`, params: Router.UnknownOutputParams & { id: string; } } | { pathname: `${'/(app)'}/filaments/[id]/qrcode` | `/filaments/[id]/qrcode`, params: Router.UnknownOutputParams & { id: string; } } | { pathname: `${'/(app)'}/inventory/[id]` | `/inventory/[id]`, params: Router.UnknownOutputParams & { id: string; } } | { pathname: `${'/(app)'}/inventory/[id]/edit` | `/inventory/[id]/edit`, params: Router.UnknownOutputParams & { id: string; } }; + href: Router.RelativePathString | Router.ExternalPathString | `/${`?${string}` | `#${string}` | ''}` | `/_sitemap${`?${string}` | `#${string}` | ''}` | `${'/(app)'}/scanner${`?${string}` | `#${string}` | ''}` | `/scanner${`?${string}` | `#${string}` | ''}` | `${'/(app)'}${'/(tabs)'}/add${`?${string}` | `#${string}` | ''}` | `/add${`?${string}` | `#${string}` | ''}` | `${'/(app)'}${'/(tabs)'}/config${`?${string}` | `#${string}` | ''}` | `/config${`?${string}` | `#${string}` | ''}` | `${'/(app)'}${'/(tabs)'}/home${`?${string}` | `#${string}` | ''}` | `/home${`?${string}` | `#${string}` | ''}` | `${'/(app)'}${'/(tabs)'}/inventory${`?${string}` | `#${string}` | ''}` | `/inventory${`?${string}` | `#${string}` | ''}` | `${'/(app)'}${'/(tabs)'}/profile${`?${string}` | `#${string}` | ''}` | `/profile${`?${string}` | `#${string}` | ''}` | `${'/(app)'}/config/presets/new${`?${string}` | `#${string}` | ''}` | `/config/presets/new${`?${string}` | `#${string}` | ''}` | `${'/(app)'}/inventory/filters${`?${string}` | `#${string}` | ''}` | `/inventory/filters${`?${string}` | `#${string}` | ''}` | `${'/(app)'}/inventory/new${`?${string}` | `#${string}` | ''}` | `/inventory/new${`?${string}` | `#${string}` | ''}` | `${'/(auth)'}/forgot-password${`?${string}` | `#${string}` | ''}` | `/forgot-password${`?${string}` | `#${string}` | ''}` | `${'/(auth)'}/login${`?${string}` | `#${string}` | ''}` | `/login${`?${string}` | `#${string}` | ''}` | `${'/(auth)'}/password-reset-done${`?${string}` | `#${string}` | ''}` | `/password-reset-done${`?${string}` | `#${string}` | ''}` | `${'/(auth)'}/register${`?${string}` | `#${string}` | ''}` | `/register${`?${string}` | `#${string}` | ''}` | `${'/(auth)'}/reset-password${`?${string}` | `#${string}` | ''}` | `/reset-password${`?${string}` | `#${string}` | ''}` | `${'/(auth)'}/verify-email${`?${string}` | `#${string}` | ''}` | `/verify-email${`?${string}` | `#${string}` | ''}` | { pathname: Router.RelativePathString, params?: Router.UnknownInputParams } | { pathname: Router.ExternalPathString, params?: Router.UnknownInputParams } | { pathname: `/`; params?: Router.UnknownInputParams; } | { pathname: `/_sitemap`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}/scanner` | `/scanner`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/add` | `/add`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/config` | `/config`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/home` | `/home`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/inventory` | `/inventory`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}${'/(tabs)'}/profile` | `/profile`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}/config/presets/new` | `/config/presets/new`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}/inventory/filters` | `/inventory/filters`; params?: Router.UnknownInputParams; } | { pathname: `${'/(app)'}/inventory/new` | `/inventory/new`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/forgot-password` | `/forgot-password`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/login` | `/login`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/password-reset-done` | `/password-reset-done`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/register` | `/register`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/reset-password` | `/reset-password`; params?: Router.UnknownInputParams; } | { pathname: `${'/(auth)'}/verify-email` | `/verify-email`; params?: Router.UnknownInputParams; } | `${'/(app)'}/config/presets/${Router.SingleRoutePart}/edit${`?${string}` | `#${string}` | ''}` | `/config/presets/${Router.SingleRoutePart}/edit${`?${string}` | `#${string}` | ''}` | `${'/(app)'}/filaments/${Router.SingleRoutePart}/label${`?${string}` | `#${string}` | ''}` | `/filaments/${Router.SingleRoutePart}/label${`?${string}` | `#${string}` | ''}` | `${'/(app)'}/filaments/${Router.SingleRoutePart}/qrcode${`?${string}` | `#${string}` | ''}` | `/filaments/${Router.SingleRoutePart}/qrcode${`?${string}` | `#${string}` | ''}` | `${'/(app)'}/inventory/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | `/inventory/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | `${'/(app)'}/inventory/${Router.SingleRoutePart}/edit${`?${string}` | `#${string}` | ''}` | `/inventory/${Router.SingleRoutePart}/edit${`?${string}` | `#${string}` | ''}` | { pathname: `${'/(app)'}/config/presets/[id]/edit` | `/config/presets/[id]/edit`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(app)'}/filaments/[id]/label` | `/filaments/[id]/label`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(app)'}/filaments/[id]/qrcode` | `/filaments/[id]/qrcode`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(app)'}/inventory/[id]` | `/inventory/[id]`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(app)'}/inventory/[id]/edit` | `/inventory/[id]/edit`, params: Router.UnknownInputParams & { id: string | number; } }; } } } diff --git a/mobile/.expo/web/cache/production/images/android-standard-square/android-standard-square-0cdc816a6283f077753f1c797eec3e0bbe29d1d1491e09ce6ddbccf87924040b-cover-#1E1B18/icon_96.png b/mobile/.expo/web/cache/production/images/android-standard-square/android-standard-square-0cdc816a6283f077753f1c797eec3e0bbe29d1d1491e09ce6ddbccf87924040b-cover-#1E1B18/icon_96.png new file mode 100644 index 0000000..e69de29 diff --git a/mobile/.mise.toml b/mobile/.mise.toml index 6a0493c..de20045 100644 --- a/mobile/.mise.toml +++ b/mobile/.mise.toml @@ -1,2 +1,3 @@ [tools] +java = "17" node = "22" diff --git a/mobile/agent.md b/mobile/agent.md index 450ed70..dc8a80e 100644 --- a/mobile/agent.md +++ b/mobile/agent.md @@ -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/` → `/(app)/inventory/` -- QR público: `meowspool.app/f/` (web) +- Filamento: `meowspool://filament/` → `/(app)/inventory/` (singular, alinhado com backend) +- O scanner (`scanner.tsx`) faz match via `/meowspool:\/\/filament\/([^/]+)/` e navega para `/(app)/inventory/` +- O QR Code de cada filamento exibe `meowspool://filament/` 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. diff --git a/mobile/android/.gitignore b/mobile/android/.gitignore new file mode 100644 index 0000000..8a6be07 --- /dev/null +++ b/mobile/android/.gitignore @@ -0,0 +1,16 @@ +# OSX +# +.DS_Store + +# Android/IntelliJ +# +build/ +.idea +.gradle +local.properties +*.iml +*.hprof +.cxx/ + +# Bundle artifacts +*.jsbundle diff --git a/mobile/android/app/build.gradle b/mobile/android/app/build.gradle new file mode 100644 index 0000000..b0e3a42 --- /dev/null +++ b/mobile/android/app/build.gradle @@ -0,0 +1,182 @@ +apply plugin: "com.android.application" +apply plugin: "org.jetbrains.kotlin.android" +apply plugin: "com.facebook.react" + +def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath() + +/** + * This is the configuration block to customize your React Native Android app. + * By default you don't need to apply any configuration, just uncomment the lines you need. + */ +react { + entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android", "absolute"].execute(null, rootDir).text.trim()) + reactNativeDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile() + hermesCommand = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc" + codegenDir = new File(["node", "--print", "require.resolve('@react-native/codegen/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile() + + enableBundleCompression = (findProperty('android.enableBundleCompression') ?: false).toBoolean() + // Use Expo CLI to bundle the app, this ensures the Metro config + // works correctly with Expo projects. + cliFile = new File(["node", "--print", "require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })"].execute(null, rootDir).text.trim()) + bundleCommand = "export:embed" + + /* Folders */ + // The root of your project, i.e. where "package.json" lives. Default is '../..' + // root = file("../../") + // The folder where the react-native NPM package is. Default is ../../node_modules/react-native + // reactNativeDir = file("../../node_modules/react-native") + // The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen + // codegenDir = file("../../node_modules/@react-native/codegen") + + /* Variants */ + // The list of variants to that are debuggable. For those we're going to + // skip the bundling of the JS bundle and the assets. By default is just 'debug'. + // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. + // debuggableVariants = ["liteDebug", "prodDebug"] + + /* Bundling */ + // A list containing the node command and its flags. Default is just 'node'. + // nodeExecutableAndArgs = ["node"] + + // + // The path to the CLI configuration file. Default is empty. + // bundleConfig = file(../rn-cli.config.js) + // + // The name of the generated asset file containing your JS bundle + // bundleAssetName = "MyApplication.android.bundle" + // + // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' + // entryFile = file("../js/MyApplication.android.js") + // + // A list of extra flags to pass to the 'bundle' commands. + // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle + // extraPackagerArgs = [] + + /* Hermes Commands */ + // The hermes compiler command to run. By default it is 'hermesc' + // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" + // + // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" + // hermesFlags = ["-O", "-output-source-map"] + + /* Autolinking */ + autolinkLibrariesWithApp() +} + +/** + * Set this to true in release builds to optimize the app using [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization). + */ +def enableMinifyInReleaseBuilds = (findProperty('android.enableMinifyInReleaseBuilds') ?: false).toBoolean() + +/** + * The preferred build flavor of JavaScriptCore (JSC) + * + * For example, to use the international variant, you can use: + * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` + * + * The international variant includes ICU i18n library and necessary data + * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that + * give correct results when using with locales other than en-US. Note that + * this variant is about 6MiB larger per architecture than default. + */ +def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+' + +android { + ndkVersion rootProject.ext.ndkVersion + + buildToolsVersion rootProject.ext.buildToolsVersion + compileSdk rootProject.ext.compileSdkVersion + + namespace "com.meowspool" + defaultConfig { + applicationId "com.meowspool" + minSdkVersion rootProject.ext.minSdkVersion + targetSdkVersion rootProject.ext.targetSdkVersion + versionCode 1 + versionName "1.0" + + buildConfigField "String", "REACT_NATIVE_RELEASE_LEVEL", "\"${findProperty('reactNativeReleaseLevel') ?: 'stable'}\"" + } + signingConfigs { + debug { + storeFile file('debug.keystore') + storePassword 'android' + keyAlias 'androiddebugkey' + keyPassword 'android' + } + } + buildTypes { + debug { + signingConfig signingConfigs.debug + } + release { + // Caution! In production, you need to generate your own keystore file. + // see https://reactnative.dev/docs/signed-apk-android. + signingConfig signingConfigs.debug + def enableShrinkResources = findProperty('android.enableShrinkResourcesInReleaseBuilds') ?: 'false' + shrinkResources enableShrinkResources.toBoolean() + minifyEnabled enableMinifyInReleaseBuilds + proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" + def enablePngCrunchInRelease = findProperty('android.enablePngCrunchInReleaseBuilds') ?: 'true' + crunchPngs enablePngCrunchInRelease.toBoolean() + } + } + packagingOptions { + jniLibs { + def enableLegacyPackaging = findProperty('expo.useLegacyPackaging') ?: 'false' + useLegacyPackaging enableLegacyPackaging.toBoolean() + } + } + androidResources { + ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~' + } +} + +// Apply static values from `gradle.properties` to the `android.packagingOptions` +// Accepts values in comma delimited lists, example: +// android.packagingOptions.pickFirsts=/LICENSE,**/picasa.ini +["pickFirsts", "excludes", "merges", "doNotStrip"].each { prop -> + // Split option: 'foo,bar' -> ['foo', 'bar'] + def options = (findProperty("android.packagingOptions.$prop") ?: "").split(","); + // Trim all elements in place. + for (i in 0.. 0) { + println "android.packagingOptions.$prop += $options ($options.length)" + // Ex: android.packagingOptions.pickFirsts += '**/SCCS/**' + options.each { + android.packagingOptions[prop] += it + } + } +} + +dependencies { + // The version of react-native is set by the React Native Gradle Plugin + implementation("com.facebook.react:react-android") + + def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true"; + def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true"; + def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true"; + + if (isGifEnabled) { + // For animated gif support + implementation("com.facebook.fresco:animated-gif:${expoLibs.versions.fresco.get()}") + } + + if (isWebpEnabled) { + // For webp support + implementation("com.facebook.fresco:webpsupport:${expoLibs.versions.fresco.get()}") + if (isWebpAnimatedEnabled) { + // Animated webp support + implementation("com.facebook.fresco:animated-webp:${expoLibs.versions.fresco.get()}") + } + } + + if (hermesEnabled.toBoolean()) { + implementation("com.facebook.react:hermes-android") + } else { + implementation jscFlavor + } +} diff --git a/mobile/android/app/debug.keystore b/mobile/android/app/debug.keystore new file mode 100644 index 0000000..364e105 Binary files /dev/null and b/mobile/android/app/debug.keystore differ diff --git a/mobile/android/app/proguard-rules.pro b/mobile/android/app/proguard-rules.pro new file mode 100644 index 0000000..551eb41 --- /dev/null +++ b/mobile/android/app/proguard-rules.pro @@ -0,0 +1,14 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# react-native-reanimated +-keep class com.swmansion.reanimated.** { *; } +-keep class com.facebook.react.turbomodule.** { *; } + +# Add any project specific keep options here: diff --git a/mobile/android/app/src/debug/AndroidManifest.xml b/mobile/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..3ec2507 --- /dev/null +++ b/mobile/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/mobile/android/app/src/debugOptimized/AndroidManifest.xml b/mobile/android/app/src/debugOptimized/AndroidManifest.xml new file mode 100644 index 0000000..3ec2507 --- /dev/null +++ b/mobile/android/app/src/debugOptimized/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/mobile/android/app/src/main/AndroidManifest.xml b/mobile/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..d321e54 --- /dev/null +++ b/mobile/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mobile/android/app/src/main/java/com/meowspool/app/MainActivity.kt b/mobile/android/app/src/main/java/com/meowspool/app/MainActivity.kt new file mode 100644 index 0000000..16a5dea --- /dev/null +++ b/mobile/android/app/src/main/java/com/meowspool/app/MainActivity.kt @@ -0,0 +1,64 @@ +package com.meowspool.app + +import android.os.Build +import android.os.Bundle + +import com.facebook.react.ReactActivity +import com.facebook.react.ReactActivityDelegate +import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled +import com.facebook.react.defaults.DefaultReactActivityDelegate + +import expo.modules.ReactActivityDelegateWrapper + +import com.meowspool.R +import com.meowspool.BuildConfig + +class MainActivity : ReactActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + // Set the theme to AppTheme BEFORE onCreate to support + // coloring the background, status bar, and navigation bar. + // This is required for expo-splash-screen. + setTheme(R.style.AppTheme); + super.onCreate(null) + } + + /** + * Returns the name of the main component registered from JavaScript. This is used to schedule + * rendering of the component. + */ + override fun getMainComponentName(): String = "main" + + /** + * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate] + * which allows you to enable New Architecture with a single boolean flags [fabricEnabled] + */ + override fun createReactActivityDelegate(): ReactActivityDelegate { + return ReactActivityDelegateWrapper( + this, + BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, + object : DefaultReactActivityDelegate( + this, + mainComponentName, + fabricEnabled + ){}) + } + + /** + * Align the back button behavior with Android S + * where moving root activities to background instead of finishing activities. + * @see onBackPressed + */ + override fun invokeDefaultOnBackPressed() { + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) { + if (!moveTaskToBack(false)) { + // For non-root activities, use the default implementation to finish them. + super.invokeDefaultOnBackPressed() + } + return + } + + // Use the default back button implementation on Android S + // because it's doing more than [Activity.moveTaskToBack] in fact. + super.invokeDefaultOnBackPressed() + } +} diff --git a/mobile/android/app/src/main/java/com/meowspool/app/MainApplication.kt b/mobile/android/app/src/main/java/com/meowspool/app/MainApplication.kt new file mode 100644 index 0000000..8d95743 --- /dev/null +++ b/mobile/android/app/src/main/java/com/meowspool/app/MainApplication.kt @@ -0,0 +1,58 @@ +package com.meowspool.app + +import android.app.Application +import android.content.res.Configuration + +import com.facebook.react.PackageList +import com.facebook.react.ReactApplication +import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative +import com.facebook.react.ReactNativeHost +import com.facebook.react.ReactPackage +import com.facebook.react.ReactHost +import com.facebook.react.common.ReleaseLevel +import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint +import com.facebook.react.defaults.DefaultReactNativeHost + +import expo.modules.ApplicationLifecycleDispatcher +import expo.modules.ReactNativeHostWrapper + +import com.meowspool.BuildConfig + +class MainApplication : Application(), ReactApplication { + + override val reactNativeHost: ReactNativeHost = ReactNativeHostWrapper( + this, + object : DefaultReactNativeHost(this) { + override fun getPackages(): List = + PackageList(this).packages.apply { + // Packages that cannot be autolinked yet can be added manually here, for example: + // add(MyReactNativePackage()) + } + + override fun getJSMainModuleName(): String = ".expo/.virtual-metro-entry" + + override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG + + override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED + } + ) + + override val reactHost: ReactHost + get() = ReactNativeHostWrapper.createReactHost(applicationContext, reactNativeHost) + + override fun onCreate() { + super.onCreate() + DefaultNewArchitectureEntryPoint.releaseLevel = try { + ReleaseLevel.valueOf(BuildConfig.REACT_NATIVE_RELEASE_LEVEL.uppercase()) + } catch (e: IllegalArgumentException) { + ReleaseLevel.STABLE + } + loadReactNative(this) + ApplicationLifecycleDispatcher.onApplicationCreate(this) + } + + override fun onConfigurationChanged(newConfig: Configuration) { + super.onConfigurationChanged(newConfig) + ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig) + } +} diff --git a/mobile/android/app/src/main/res/drawable-hdpi/splashscreen_logo.png b/mobile/android/app/src/main/res/drawable-hdpi/splashscreen_logo.png new file mode 100644 index 0000000..31df827 Binary files /dev/null and b/mobile/android/app/src/main/res/drawable-hdpi/splashscreen_logo.png differ diff --git a/mobile/android/app/src/main/res/drawable-mdpi/splashscreen_logo.png b/mobile/android/app/src/main/res/drawable-mdpi/splashscreen_logo.png new file mode 100644 index 0000000..ef243aa Binary files /dev/null and b/mobile/android/app/src/main/res/drawable-mdpi/splashscreen_logo.png differ diff --git a/mobile/android/app/src/main/res/drawable-xhdpi/splashscreen_logo.png b/mobile/android/app/src/main/res/drawable-xhdpi/splashscreen_logo.png new file mode 100644 index 0000000..e9d5474 Binary files /dev/null and b/mobile/android/app/src/main/res/drawable-xhdpi/splashscreen_logo.png differ diff --git a/mobile/android/app/src/main/res/drawable-xxhdpi/splashscreen_logo.png b/mobile/android/app/src/main/res/drawable-xxhdpi/splashscreen_logo.png new file mode 100644 index 0000000..d61da15 Binary files /dev/null and b/mobile/android/app/src/main/res/drawable-xxhdpi/splashscreen_logo.png differ diff --git a/mobile/android/app/src/main/res/drawable-xxxhdpi/splashscreen_logo.png b/mobile/android/app/src/main/res/drawable-xxxhdpi/splashscreen_logo.png new file mode 100644 index 0000000..4aeed11 Binary files /dev/null and b/mobile/android/app/src/main/res/drawable-xxxhdpi/splashscreen_logo.png differ diff --git a/mobile/android/app/src/main/res/drawable/ic_launcher_background.xml b/mobile/android/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..883b2a0 --- /dev/null +++ b/mobile/android/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/mobile/android/app/src/main/res/drawable/rn_edit_text_material.xml b/mobile/android/app/src/main/res/drawable/rn_edit_text_material.xml new file mode 100644 index 0000000..5c25e72 --- /dev/null +++ b/mobile/android/app/src/main/res/drawable/rn_edit_text_material.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + diff --git a/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..a2f5908 Binary files /dev/null and b/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b52399 Binary files /dev/null and b/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..ff10afd Binary files /dev/null and b/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..115a4c7 Binary files /dev/null and b/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..dcd3cd8 Binary files /dev/null and b/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..459ca60 Binary files /dev/null and b/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..8ca12fe Binary files /dev/null and b/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..8e19b41 Binary files /dev/null and b/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..b824ebd Binary files /dev/null and b/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..4c19a13 Binary files /dev/null and b/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/mobile/android/app/src/main/res/values/colors.xml b/mobile/android/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..21cc155 --- /dev/null +++ b/mobile/android/app/src/main/res/values/colors.xml @@ -0,0 +1,4 @@ + + + #FFFFFF + \ No newline at end of file diff --git a/mobile/android/app/src/main/res/values/strings.xml b/mobile/android/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..6805537 --- /dev/null +++ b/mobile/android/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + MeowSpool + diff --git a/mobile/android/app/src/main/res/values/styles.xml b/mobile/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..26f3404 --- /dev/null +++ b/mobile/android/app/src/main/res/values/styles.xml @@ -0,0 +1,8 @@ + + + + diff --git a/mobile/android/build.gradle b/mobile/android/build.gradle new file mode 100644 index 0000000..0554dd1 --- /dev/null +++ b/mobile/android/build.gradle @@ -0,0 +1,24 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + google() + mavenCentral() + } + dependencies { + classpath('com.android.tools.build:gradle') + classpath('com.facebook.react:react-native-gradle-plugin') + classpath('org.jetbrains.kotlin:kotlin-gradle-plugin') + } +} + +allprojects { + repositories { + google() + mavenCentral() + maven { url 'https://www.jitpack.io' } + } +} + +apply plugin: "expo-root-project" +apply plugin: "com.facebook.react.rootproject" diff --git a/mobile/android/gradle.properties b/mobile/android/gradle.properties new file mode 100644 index 0000000..b09dfd9 --- /dev/null +++ b/mobile/android/gradle.properties @@ -0,0 +1,62 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m +org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +org.gradle.parallel=true +org.gradle.caching=false + +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true + +# Enable AAPT2 PNG crunching +android.enablePngCrunchInReleaseBuilds=true + +# Use this property to specify which architecture you want to build. +# You can also override it from the CLI using +# ./gradlew -PreactNativeArchitectures=x86_64 +reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 + +# Use this property to enable support to the new architecture. +# This will allow you to use TurboModules and the Fabric render in +# your application. You should enable this flag either if you want +# to write custom TurboModules/Fabric components OR use libraries that +# are providing them. +newArchEnabled=true + +# Use this property to enable or disable the Hermes JS engine. +# If set to false, you will be using JSC instead. +hermesEnabled=true + +# Use this property to enable edge-to-edge display support. +# This allows your app to draw behind system bars for an immersive UI. +# Note: Only works with ReactActivity and should not be used with custom Activity. +edgeToEdgeEnabled=true + +# Enable GIF support in React Native images (~200 B increase) +expo.gif.enabled=true +# Enable webp support in React Native images (~85 KB increase) +expo.webp.enabled=true +# Enable animated webp support (~3.4 MB increase) +# Disabled by default because iOS doesn't support animated webp +expo.webp.animated=false + +# Enable network inspector +EX_DEV_CLIENT_NETWORK_INSPECTOR=true + +# Use legacy packaging to compress native libraries in the resulting APK. +expo.useLegacyPackaging=false diff --git a/mobile/android/gradle/wrapper/gradle-wrapper.jar b/mobile/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..1b33c55 Binary files /dev/null and b/mobile/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/mobile/android/gradle/wrapper/gradle-wrapper.properties b/mobile/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..d4081da --- /dev/null +++ b/mobile/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/mobile/android/gradlew b/mobile/android/gradlew new file mode 100755 index 0000000..7f94d3d --- /dev/null +++ b/mobile/android/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH="\\\"\\\"" + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/mobile/android/gradlew.bat b/mobile/android/gradlew.bat new file mode 100644 index 0000000..db3a6ac --- /dev/null +++ b/mobile/android/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH= + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/mobile/android/settings.gradle b/mobile/android/settings.gradle new file mode 100644 index 0000000..79970ab --- /dev/null +++ b/mobile/android/settings.gradle @@ -0,0 +1,39 @@ +pluginManagement { + def reactNativeGradlePlugin = new File( + providers.exec { + workingDir(rootDir) + commandLine("node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })") + }.standardOutput.asText.get().trim() + ).getParentFile().absolutePath + includeBuild(reactNativeGradlePlugin) + + def expoPluginsPath = new File( + providers.exec { + workingDir(rootDir) + commandLine("node", "--print", "require.resolve('expo-modules-autolinking/package.json', { paths: [require.resolve('expo/package.json')] })") + }.standardOutput.asText.get().trim(), + "../android/expo-gradle-plugin" + ).absolutePath + includeBuild(expoPluginsPath) +} + +plugins { + id("com.facebook.react.settings") + id("expo-autolinking-settings") +} + +extensions.configure(com.facebook.react.ReactSettingsExtension) { ex -> + if (System.getenv('EXPO_USE_COMMUNITY_AUTOLINKING') == '1') { + ex.autolinkLibrariesFromCommand() + } else { + ex.autolinkLibrariesFromCommand(expoAutolinking.rnConfigCommand) + } +} +expoAutolinking.useExpoModules() + +rootProject.name = 'MeowSpool' + +expoAutolinking.useExpoVersionCatalog() + +include ':app' +includeBuild(expoAutolinking.reactNativeGradlePlugin) diff --git a/mobile/app.json b/mobile/app.json index 141bdd6..08a9c47 100644 --- a/mobile/app.json +++ b/mobile/app.json @@ -29,7 +29,13 @@ "scheme": "meowspool", "plugins": [ "expo-router", - "expo-secure-store" + "expo-secure-store", + [ + "expo-camera", + { + "cameraPermission": "O MeowSpool precisa da câmera para escanear QR Codes de filamentos." + } + ] ], "experiments": { "typedRoutes": true diff --git a/mobile/app/(app)/(tabs)/_layout.tsx b/mobile/app/(app)/(tabs)/_layout.tsx index d9f7b4e..36978df 100644 --- a/mobile/app/(app)/(tabs)/_layout.tsx +++ b/mobile/app/(app)/(tabs)/_layout.tsx @@ -1,8 +1,11 @@ -import React from 'react'; -import { Tabs, Redirect } from 'expo-router'; +import React, { useEffect } from 'react'; +import { Tabs, Redirect, useRouter } from 'expo-router'; import { View, TouchableOpacity, StyleSheet } from 'react-native'; import { Ionicons } from '@expo/vector-icons'; import { useAuthStore } from '@store/authStore'; +import { useFilamentStore } from '@store/filamentStore'; +import { usePresetStore } from '@store/presetStore'; +import { listFilamentsUseCase, listPresetsUseCase } from '@infrastructure/container'; import { colors, radius, spacing } from '@shared/theme'; /** @@ -10,7 +13,27 @@ import { colors, radius, spacing } from '@shared/theme'; * 4 abas + FAB central: Início | Estoque | [+] | Config | Perfil */ export default function AppLayout(): React.ReactElement { - const { isAuthenticated } = useAuthStore(); + const { isAuthenticated, user } = useAuthStore(); + const router = useRouter(); + const { setFilaments, setLoading, setError } = useFilamentStore(); + const { setPresets } = usePresetStore(); + + useEffect(() => { + if (!user) return; + setLoading(true); + Promise.all([ + listFilamentsUseCase.execute(user.id), + listPresetsUseCase.execute(user.id), + ]).then(([filaments, presets]) => { + setFilaments(filaments); + setPresets(presets); + }).catch((err) => { + console.error('bootstrap error', err); + setError('Não foi possível carregar os dados.'); + }).finally(() => { + setLoading(false); + }); + }, [user, setFilaments, setPresets, setLoading, setError]); if (!isAuthenticated) { return ; @@ -54,7 +77,12 @@ export default function AppLayout(): React.ReactElement { ), tabBarButton: (props) => ( - + router.push('/(app)/inventory/new')} + /> ), }} /> diff --git a/mobile/app/(app)/(tabs)/add.tsx b/mobile/app/(app)/(tabs)/add.tsx index 49d8356..ee2a10b 100644 --- a/mobile/app/(app)/(tabs)/add.tsx +++ b/mobile/app/(app)/(tabs)/add.tsx @@ -1,17 +1,9 @@ import React from 'react'; -import { useRouter } from 'expo-router'; import { Screen } from '@presentation/components/layout/Screen'; /** - * Tab "add" — apenas redireciona para o formulário de novo filamento. - * O FAB central da tab bar chama esta rota. + * Tab "add" — tela placeholder; a navegação é interceptada pelo FAB no _layout. */ export default function AddTab(): React.ReactElement { - const router = useRouter(); - - React.useEffect(() => { - router.replace('/(app)/inventory/new'); - }, [router]); - return ; } diff --git a/mobile/app/(app)/(tabs)/home.tsx b/mobile/app/(app)/(tabs)/home.tsx index 61259e1..9aa740b 100644 --- a/mobile/app/(app)/(tabs)/home.tsx +++ b/mobile/app/(app)/(tabs)/home.tsx @@ -56,7 +56,7 @@ export default function HomeScreen(): React.ReactElement { router.push('/(app)/qrcode/scan')} + onPress={() => router.push('/(app)/scanner' as never)} > diff --git a/mobile/app/(app)/filaments/[id]/qrcode.tsx b/mobile/app/(app)/filaments/[id]/qrcode.tsx index 9b62341..633a441 100644 --- a/mobile/app/(app)/filaments/[id]/qrcode.tsx +++ b/mobile/app/(app)/filaments/[id]/qrcode.tsx @@ -5,6 +5,7 @@ import { import { useLocalSearchParams, useRouter } from 'expo-router'; import { Ionicons } from '@expo/vector-icons'; import { SafeAreaView } from 'react-native-safe-area-context'; +import QRCode from 'react-native-qrcode-svg'; import { useFilamentStore } from '@store/filamentStore'; import { colors, typography, spacing, radius } from '@shared/theme'; import { Button } from '@presentation/components/ui/Button'; @@ -23,19 +24,18 @@ export default function QRCodeScreen(): React.ReactElement { ? `${filament.brand.toLowerCase()}-${(filament.model ?? '').toLowerCase()}-${filament.colorHex.replace('#', '').toLowerCase()}`.replace(/\s+/g, '-') : 'desconhecido'; - const deepLink = `meowspool.app/f/${slug}`; + const deepLink = `meowspool://filament/${id}`; async function handleShare(): Promise { try { - await Share.share({ message: `meowspool://filament/${id}`, url: `https://${deepLink}` }); + await Share.share({ message: deepLink }); } catch { // cancelled } } async function handleCopyLink(): Promise { - // expo-clipboard not installed — show alert as placeholder - Alert.alert('Link copiado', deepLink); + Alert.alert('Link', deepLink); } if (!filament) { @@ -75,10 +75,12 @@ export default function QRCodeScreen(): React.ReactElement { {/* QR Code area */} - {/* Placeholder QR — real impl would use react-native-qrcode-svg */} - - - + Aponte a câmera para escanear @@ -149,12 +151,6 @@ const styles = StyleSheet.create({ borderRadius: radius.xl, padding: spacing[6], }, - qrPlaceholder: { - width: 200, - height: 200, - alignItems: 'center', - justifyContent: 'center', - }, qrHint: { fontFamily: typography.fontFamily.ui, fontSize: typography.fontSize.sm, diff --git a/mobile/app/(app)/inventory/new.tsx b/mobile/app/(app)/inventory/new.tsx index 110b47c..d40caf2 100644 --- a/mobile/app/(app)/inventory/new.tsx +++ b/mobile/app/(app)/inventory/new.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import { View, Text, ScrollView, TouchableOpacity, TextInput, StyleSheet, Alert, } from 'react-native'; @@ -10,6 +10,7 @@ import { Ionicons } from '@expo/vector-icons'; import { SafeAreaView } from 'react-native-safe-area-context'; import { usePresetStore } from '@store/presetStore'; import { useFilamentStore } from '@store/filamentStore'; +import { useAuthStore } from '@store/authStore'; import { Input } from '@presentation/components/ui/Input'; import { Button } from '@presentation/components/ui/Button'; import { Card } from '@presentation/components/ui/Card'; @@ -17,6 +18,7 @@ import { calcNetWeight } from '@domain/Filament'; import { colors, typography, spacing, radius } from '@shared/theme'; import { MATERIALS, type Material } from '@shared/constants'; import { formatWeight } from '@shared/utils/filament'; +import { createFilamentUseCase } from '@infrastructure/container'; const schema = z.object({ brand: z.string().min(1, 'Marca obrigatória'), @@ -39,6 +41,7 @@ export default function NewFilamentScreen(): React.ReactElement { const router = useRouter(); const { presets, systemPresets } = usePresetStore(); const { addFilament } = useFilamentStore(); + const { user } = useAuthStore(); const [selectedColor, setSelectedColor] = useState('#E05533'); const [hexInput, setHexInput] = useState('#E05533'); @@ -46,6 +49,13 @@ export default function NewFilamentScreen(): React.ReactElement { const [selectedPresetId, setSelectedPresetId] = useState(systemPresets[0]?.id ?? null); const [isLoading, setIsLoading] = useState(false); + // Quando os presets carregam (via layout), seleciona o primeiro sistema automaticamente + useEffect(() => { + if (selectedPresetId === null && presets.length > 0) { + setSelectedPresetId(presets.find((p) => p.isSystem)?.id ?? presets[0].id); + } + }, [presets, selectedPresetId]); + const { control, handleSubmit, watch, formState: { errors } } = useForm({ resolver: zodResolver(schema), defaultValues: { brand: '', model: '', totalWeightG: 0, tempHotendC: 210, tempBedC: 60, flowFactorPct: 100 }, @@ -63,12 +73,28 @@ export default function NewFilamentScreen(): React.ReactElement { Alert.alert('Atenção', 'Selecione um preset de carretel.'); return; } + if (!user) { + Alert.alert('Erro', 'Usuário não autenticado.'); + return; + } setIsLoading(true); try { - // TODO: CreateFilamentUseCase via container DI - console.log('create filament', { ...data, material: selectedMaterial, colorHex: selectedColor, spoolPresetId: selectedPresetId }); + const filament = await createFilamentUseCase.execute(user.id, { + material: selectedMaterial, + brand: data.brand, + model: data.model ?? null, + colorHex: selectedColor, + spoolPresetId: selectedPresetId, + totalWeightG: data.totalWeightG, + tempHotendC: data.tempHotendC ?? null, + tempBedC: data.tempBedC ?? null, + flowFactorPct: data.flowFactorPct ?? null, + notes: data.notes ?? null, + }); + addFilament(filament); router.back(); - } catch { + } catch (err) { + console.error('create filament error', err); Alert.alert('Erro', 'Não foi possível salvar o filamento.'); } finally { setIsLoading(false); diff --git a/mobile/app/(app)/scanner.tsx b/mobile/app/(app)/scanner.tsx new file mode 100644 index 0000000..5f69925 --- /dev/null +++ b/mobile/app/(app)/scanner.tsx @@ -0,0 +1,170 @@ +import React, { useRef } from 'react'; +import { View, Text, TouchableOpacity, StyleSheet } from 'react-native'; +import { useRouter } from 'expo-router'; +import { Ionicons } from '@expo/vector-icons'; +import { SafeAreaView } from 'react-native-safe-area-context'; +import { CameraView, useCameraPermissions } from 'expo-camera'; +import { colors, typography, spacing } from '@shared/theme'; + +/** + * Tela de scanner de QR Code + * Lê deeplinks meowspool://filament/ e navega para o filamento. + */ +export default function ScannerScreen(): React.ReactElement { + const router = useRouter(); + const [permission, requestPermission] = useCameraPermissions(); + const handledRef = useRef(false); + + function handleBarCodeScanned({ data }: { data: string }): void { + if (handledRef.current) return; + handledRef.current = true; + + const match = data.match(/meowspool:\/\/filament\/([^/]+)/); + if (match) { + router.replace(`/(app)/inventory/${match[1]}` as never); + } else { + // QR não reconhecido — libera para próximo scan + handledRef.current = false; + } + } + + if (!permission) { + return ( + + + Carregando câmera… + + + ); + } + + if (!permission.granted) { + return ( + + + + Permissão de câmera necessária + + Conceder permissão + + + + ); + } + + return ( + + {/* Header */} + + router.back()}> + + + Escanear QR Code + + + + {/* Camera */} + + + + {/* Viewfinder overlay */} + + + + + + + + + + + + + Aponte para o QR Code do filamento + + + + ); +} + +const CORNER = 24; +const CORNER_THICKNESS = 3; +const VIEWFINDER_SIZE = 240; + +const styles = StyleSheet.create({ + safe: { flex: 1, backgroundColor: colors.bgBase }, + center: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: spacing[4], paddingHorizontal: spacing[6] }, + message: { + fontFamily: typography.fontFamily.ui, + fontSize: typography.fontSize.base, + color: colors.textSecondary, + textAlign: 'center', + }, + permBtn: { + backgroundColor: colors.accent, + paddingHorizontal: spacing[5], + paddingVertical: spacing[3], + borderRadius: 8, + }, + permBtnText: { + fontFamily: typography.fontFamily.ui, + fontSize: typography.fontSize.base, + fontWeight: '600', + color: colors.bgBase, + }, + header: { + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'space-between', + paddingHorizontal: spacing[5], + paddingVertical: spacing[4], + }, + headerTitle: { + fontFamily: typography.fontFamily.ui, + fontSize: typography.fontSize.md, + fontWeight: '600', + color: colors.textPrimary, + }, + cameraWrapper: { + flex: 1, + }, + overlay: { + ...StyleSheet.absoluteFillObject, + alignItems: 'center', + justifyContent: 'center', + backgroundColor: 'rgba(0,0,0,0.55)', + }, + viewfinder: { + width: VIEWFINDER_SIZE, + height: VIEWFINDER_SIZE, + backgroundColor: 'transparent', + }, + corner: { + position: 'absolute', + width: CORNER, + height: CORNER, + borderColor: colors.accent, + }, + cornerTL: { top: 0, left: 0, borderTopWidth: CORNER_THICKNESS, borderLeftWidth: CORNER_THICKNESS }, + cornerTR: { top: 0, right: 0, borderTopWidth: CORNER_THICKNESS, borderRightWidth: CORNER_THICKNESS }, + cornerBL: { bottom: 0, left: 0, borderBottomWidth: CORNER_THICKNESS, borderLeftWidth: CORNER_THICKNESS }, + cornerBR: { bottom: 0, right: 0, borderBottomWidth: CORNER_THICKNESS, borderRightWidth: CORNER_THICKNESS }, + hint: { + paddingVertical: spacing[5], + paddingHorizontal: spacing[5], + alignItems: 'center', + borderTopWidth: 1, + borderTopColor: colors.border, + }, + hintText: { + fontFamily: typography.fontFamily.ui, + fontSize: typography.fontSize.sm, + color: colors.textSecondary, + }, +}); diff --git a/mobile/app/(auth)/forgot-password.tsx b/mobile/app/(auth)/forgot-password.tsx index e948d43..9affca9 100644 --- a/mobile/app/(auth)/forgot-password.tsx +++ b/mobile/app/(auth)/forgot-password.tsx @@ -9,6 +9,7 @@ import { Header } from '@presentation/components/layout/Header'; import { Input } from '@presentation/components/ui/Input'; import { Button } from '@presentation/components/ui/Button'; import { colors, typography, spacing } from '@shared/theme'; +import { forgotPasswordUseCase } from '@infrastructure/container'; const schema = z.object({ email: z.string().email('E-mail inválido'), @@ -31,8 +32,7 @@ export default function ForgotPasswordScreen(): React.ReactElement { async function onSubmit(data: FormData): Promise { setIsLoading(true); try { - // TODO: ForgotPasswordUseCase - console.log('forgot-password', data); + await forgotPasswordUseCase.execute(data.email); setSent(true); } catch { Alert.alert('Erro', 'Não foi possível enviar o e-mail.'); diff --git a/mobile/app/(auth)/login.tsx b/mobile/app/(auth)/login.tsx index d13f842..3f4ced2 100644 --- a/mobile/app/(auth)/login.tsx +++ b/mobile/app/(auth)/login.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { View, Text, Image, StyleSheet, TouchableOpacity, Alert } from 'react-native'; +import { View, Text, StyleSheet, TouchableOpacity, Alert } from 'react-native'; import { Link, useRouter } from 'expo-router'; import { useForm, Controller } from 'react-hook-form'; import { zodResolver } from '@hookform/resolvers/zod'; @@ -9,6 +9,8 @@ import { Screen } from '@presentation/components/layout/Screen'; import { Input } from '@presentation/components/ui/Input'; import { Button } from '@presentation/components/ui/Button'; import { colors, typography, spacing } from '@shared/theme'; +import { loginUseCase } from '@infrastructure/container'; +import { useAuthStore } from '@store/authStore'; const schema = z.object({ email: z.string().email('E-mail inválido'), @@ -23,6 +25,7 @@ type FormData = z.infer; */ export default function LoginScreen(): React.ReactElement { const router = useRouter(); + const setSession = useAuthStore((s) => s.setSession); const [isLoading, setIsLoading] = useState(false); const [isGoogleLoading, setIsGoogleLoading] = useState(false); @@ -34,10 +37,11 @@ export default function LoginScreen(): React.ReactElement { async function onSubmit(data: FormData): Promise { setIsLoading(true); try { - // TODO: injetar LoginUseCase via container de DI - console.log('login', data); + const session = await loginUseCase.execute(data); + await setSession(session); router.replace('/(app)/(tabs)/home'); } catch (err) { + console.error('login error', err); Alert.alert('Erro', 'E-mail ou senha incorretos.'); } finally { setIsLoading(false); diff --git a/mobile/app/(auth)/register.tsx b/mobile/app/(auth)/register.tsx index 224849c..c0e1853 100644 --- a/mobile/app/(auth)/register.tsx +++ b/mobile/app/(auth)/register.tsx @@ -10,6 +10,8 @@ import { Header } from '@presentation/components/layout/Header'; import { Input } from '@presentation/components/ui/Input'; import { Button } from '@presentation/components/ui/Button'; import { colors, typography, spacing } from '@shared/theme'; +import { registerUseCase } from '@infrastructure/container'; +import { useAuthStore } from '@store/authStore'; const schema = z.object({ email: z.string().email('E-mail inválido'), @@ -29,6 +31,7 @@ type FormData = z.infer; */ export default function RegisterScreen(): React.ReactElement { const router = useRouter(); + const setSession = useAuthStore((s) => s.setSession); const [isLoading, setIsLoading] = useState(false); const { control, handleSubmit, formState: { errors } } = useForm({ @@ -39,8 +42,8 @@ export default function RegisterScreen(): React.ReactElement { async function onSubmit(data: FormData): Promise { setIsLoading(true); try { - // TODO: injetar RegisterUseCase - console.log('register', data); + const session = await registerUseCase.execute({ email: data.email, password: data.password }); + await setSession(session); router.replace('/(auth)/verify-email'); } catch { Alert.alert('Erro', 'Não foi possível criar sua conta.'); diff --git a/mobile/app/_layout.tsx b/mobile/app/_layout.tsx index 5634a37..a1e0ca4 100644 --- a/mobile/app/_layout.tsx +++ b/mobile/app/_layout.tsx @@ -1,5 +1,5 @@ import React, { useEffect } from 'react'; -import { Stack } from 'expo-router'; +import { Stack, useRouter, useSegments } from 'expo-router'; import { StatusBar } from 'expo-status-bar'; import { useAuthStore } from '@store/authStore'; @@ -8,18 +8,31 @@ import { useAuthStore } from '@store/authStore'; * Carrega a sessão armazenada e controla o fluxo auth vs app. */ export default function RootLayout(): React.ReactElement | null { - const { loadStoredSession, isLoading } = useAuthStore(); + const { loadStoredSession, isLoading, isAuthenticated } = useAuthStore(); + const router = useRouter(); + const segments = useSegments(); useEffect(() => { loadStoredSession(); }, [loadStoredSession]); + useEffect(() => { + if (isLoading) return; + const inAuthGroup = segments[0] === '(auth)'; + if (isAuthenticated && inAuthGroup) { + router.replace('/(app)/(tabs)/home'); + } else if (!isAuthenticated && !inAuthGroup) { + router.replace('/(auth)/login'); + } + }, [isAuthenticated, isLoading, segments, router]); + if (isLoading) return null; return ( <> + diff --git a/mobile/app/index.tsx b/mobile/app/index.tsx new file mode 100644 index 0000000..11805fd --- /dev/null +++ b/mobile/app/index.tsx @@ -0,0 +1,5 @@ +import { Redirect } from 'expo-router'; + +export default function Index() { + return ; +} diff --git a/mobile/babel.config.js b/mobile/babel.config.js index 1908390..5c412c8 100644 --- a/mobile/babel.config.js +++ b/mobile/babel.config.js @@ -15,6 +15,7 @@ module.exports = function (api) { '@presentation': './src/presentation', '@store': './src/store', '@shared': './src/shared', + '@infrastructure': './src/infrastructure', }, }, ], diff --git a/mobile/package-lock.json b/mobile/package-lock.json index bd93dd7..c63352c 100644 --- a/mobile/package-lock.json +++ b/mobile/package-lock.json @@ -15,6 +15,7 @@ "@react-navigation/native-stack": "^7.14.5", "axios": "^1.7.7", "expo": "~54.0.0", + "expo-camera": "~17.0.10", "expo-constants": "~18.0.13", "expo-font": "~14.0.11", "expo-linking": "~8.0.11", @@ -42,6 +43,7 @@ "@types/react-native": "~0.73.0", "@typescript-eslint/eslint-plugin": "^7.0.0", "@typescript-eslint/parser": "^7.0.0", + "babel-plugin-module-resolver": "^5.0.2", "eslint": "^8.57.0", "eslint-plugin-react": "^7.34.0", "eslint-plugin-react-hooks": "^4.6.0", @@ -1398,6 +1400,22 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-transform-template-literals": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.27.1.tgz", + "integrity": "sha512-fBJKiV7F2DxZUkg5EtHKXQdbsbURW3DZKQUWphDum0uRP6eHGGa/He9mc0mypL680pb+e/lDIthRohlv8NCHkg==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-transform-typescript": { "version": "7.28.6", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.28.6.tgz", @@ -3852,7 +3870,7 @@ "version": "19.1.17", "resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.17.tgz", "integrity": "sha512-Qec1E3mhALmaspIrhWt9jkQMNdw6bReVu64mjvhbhq2NFPftLPVr+l1SZgmw/66WwBNpDh7ao5AT6gF5v41PFA==", - "dev": true, + "devOptional": true, "license": "MIT", "dependencies": { "csstype": "^3.0.2" @@ -4283,6 +4301,18 @@ "node": ">= 8" } }, + "node_modules/anymatch/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/arg": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", @@ -4568,6 +4598,121 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/babel-plugin-module-resolver": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/babel-plugin-module-resolver/-/babel-plugin-module-resolver-5.0.2.tgz", + "integrity": "sha512-9KtaCazHee2xc0ibfqsDeamwDps6FZNo5S0Q81dUqEuFzVwPhcT4J5jOqIVvgCA3Q/wO9hKYxN/Ds3tIsp5ygg==", + "dev": true, + "license": "MIT", + "dependencies": { + "find-babel-config": "^2.1.1", + "glob": "^9.3.3", + "pkg-up": "^3.1.0", + "reselect": "^4.1.7", + "resolve": "^1.22.8" + } + }, + "node_modules/babel-plugin-module-resolver/node_modules/glob": { + "version": "9.3.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-9.3.5.tgz", + "integrity": "sha512-e1LleDykUz2Iu+MTYdkSsuWX8lvAjAcs0Xef0lNIu0S2wOAzuTxCJtcd9S3cijlwYF18EsU3rzb8jPVobxDh9Q==", + "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "minimatch": "^8.0.2", + "minipass": "^4.2.4", + "path-scurry": "^1.6.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/babel-plugin-module-resolver/node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/babel-plugin-module-resolver/node_modules/minimatch": { + "version": "8.0.7", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-8.0.7.tgz", + "integrity": "sha512-V+1uQNdzybxa14e/p00HZnQNNcTjnRJjDxg2V8wtkjFctq4M7hXFws4oekyTP0Jebeq7QYtpFyOeBAjc88zvYg==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/babel-plugin-module-resolver/node_modules/minipass": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.8.tgz", + "integrity": "sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-module-resolver/node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.18" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/babel-plugin-module-resolver/node_modules/path-scurry/node_modules/minipass": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", + "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/babel-plugin-module-resolver/node_modules/resolve": { + "version": "1.22.11", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.11.tgz", + "integrity": "sha512-RfqAvLnMl313r7c9oclB1HhUEAezcpLjz95wFH4LVuhk9JF/r22qmVP9AMmOU4vMX7Q8pN8jwNg/CSpdFnMjTQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.16.1", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/babel-plugin-polyfill-corejs2": { "version": "0.4.16", "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.16.tgz", @@ -5448,7 +5593,7 @@ "version": "3.2.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", - "dev": true, + "devOptional": true, "license": "MIT" }, "node_modules/data-view-buffer": { @@ -6436,6 +6581,26 @@ "react-native": "*" } }, + "node_modules/expo-camera": { + "version": "17.0.10", + "resolved": "https://registry.npmjs.org/expo-camera/-/expo-camera-17.0.10.tgz", + "integrity": "sha512-w1RBw83mAGVk4BPPwNrCZyFop0VLiVSRE3c2V9onWbdFwonpRhzmB4drygG8YOUTl1H3wQvALJHyMPTbgsK1Jg==", + "license": "MIT", + "dependencies": { + "invariant": "^2.2.4" + }, + "peerDependencies": { + "expo": "*", + "react": "*", + "react-native": "*", + "react-native-web": "*" + }, + "peerDependenciesMeta": { + "react-native-web": { + "optional": true + } + } + }, "node_modules/expo-constants": { "version": "18.0.13", "resolved": "https://registry.npmjs.org/expo-constants/-/expo-constants-18.0.13.tgz", @@ -7050,6 +7215,16 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "license": "MIT" }, + "node_modules/find-babel-config": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/find-babel-config/-/find-babel-config-2.1.2.tgz", + "integrity": "sha512-ZfZp1rQyp4gyuxqt1ZqjFGVeVBvmpURMqdIWXbPRfB97Bf6BzdK/xSIbylEINzQ0kB5tlDQfn9HkNXXWsqTqLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "json5": "^2.2.3" + } + }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -8371,6 +8546,18 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/jest-util/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/jest-validate": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.7.0.tgz", @@ -9395,6 +9582,18 @@ "node": ">=8.6" } }, + "node_modules/micromatch/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", @@ -10095,12 +10294,12 @@ "license": "ISC" }, "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "license": "MIT", "engines": { - "node": ">=8.6" + "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/jonschlinkert" @@ -10115,6 +10314,85 @@ "node": ">= 6" } }, + "node_modules/pkg-up": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-3.1.0.tgz", + "integrity": "sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==", + "dev": true, + "license": "MIT", + "dependencies": { + "find-up": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-up/node_modules/find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/pkg-up/node_modules/locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/pkg-up/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pkg-up/node_modules/p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^2.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/pkg-up/node_modules/path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/plist": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/plist/-/plist-3.1.0.tgz", @@ -10548,6 +10826,26 @@ "ws": "^7" } }, + "node_modules/react-dom": { + "version": "19.2.4", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.4.tgz", + "integrity": "sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "scheduler": "^0.27.0" + }, + "peerDependencies": { + "react": "^19.2.4" + } + }, + "node_modules/react-dom/node_modules/scheduler": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz", + "integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==", + "license": "MIT", + "peer": true + }, "node_modules/react-fast-compare": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.2.tgz", @@ -10754,6 +11052,135 @@ "react-native": "*" } }, + "node_modules/react-native-worklets": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/react-native-worklets/-/react-native-worklets-0.7.4.tgz", + "integrity": "sha512-NYOdM1MwBb3n+AtMqy1tFy3Mn8DliQtd8sbzAVRf9Gc+uvQ0zRfxN7dS8ZzoyX7t6cyQL5THuGhlnX+iFlQTag==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/plugin-transform-arrow-functions": "7.27.1", + "@babel/plugin-transform-class-properties": "7.27.1", + "@babel/plugin-transform-classes": "7.28.4", + "@babel/plugin-transform-nullish-coalescing-operator": "7.27.1", + "@babel/plugin-transform-optional-chaining": "7.27.1", + "@babel/plugin-transform-shorthand-properties": "7.27.1", + "@babel/plugin-transform-template-literals": "7.27.1", + "@babel/plugin-transform-unicode-regex": "7.27.1", + "@babel/preset-typescript": "7.27.1", + "convert-source-map": "2.0.0", + "semver": "7.7.3" + }, + "peerDependencies": { + "@babel/core": "*", + "react": "*", + "react-native": "*" + } + }, + "node_modules/react-native-worklets/node_modules/@babel/plugin-transform-class-properties": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-properties/-/plugin-transform-class-properties-7.27.1.tgz", + "integrity": "sha512-D0VcalChDMtuRvJIu3U/fwWjf8ZMykz5iZsg77Nuj821vCKI3zCyRLwRdWbsuJ/uRwZhZ002QtCqIkwC/ZkvbA==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/helper-create-class-features-plugin": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/react-native-worklets/node_modules/@babel/plugin-transform-classes": { + "version": "7.28.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.28.4.tgz", + "integrity": "sha512-cFOlhIYPBv/iBoc+KS3M6et2XPtbT2HiCRfBXWtfpc9OAyostldxIf9YAYB6ypURBBbx+Qv6nyrLzASfJe+hBA==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.27.3", + "@babel/helper-compilation-targets": "^7.27.2", + "@babel/helper-globals": "^7.28.0", + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-replace-supers": "^7.27.1", + "@babel/traverse": "^7.28.4" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/react-native-worklets/node_modules/@babel/plugin-transform-nullish-coalescing-operator": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-nullish-coalescing-operator/-/plugin-transform-nullish-coalescing-operator-7.27.1.tgz", + "integrity": "sha512-aGZh6xMo6q9vq1JGcw58lZ1Z0+i0xB2x0XaauNIUXd6O1xXc3RwoWEBlsTQrY4KQ9Jf0s5rgD6SiNkaUdJegTA==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/react-native-worklets/node_modules/@babel/plugin-transform-optional-chaining": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.27.1.tgz", + "integrity": "sha512-BQmKPPIuc8EkZgNKsv0X4bPmOoayeu4F1YCwx2/CfmDSXDbp7GnzlUH+/ul5VGfRg1AoFPsrIThlEBj2xb4CAg==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/react-native-worklets/node_modules/@babel/preset-typescript": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.27.1.tgz", + "integrity": "sha512-l7WfQfX0WK4M0v2RudjuQK4u99BS6yLHYEmdtVPP7lKV013zr9DygFuWNlnbvQ9LR+LS0Egz/XAvGx5U9MX0fQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-validator-option": "^7.27.1", + "@babel/plugin-syntax-jsx": "^7.27.1", + "@babel/plugin-transform-modules-commonjs": "^7.27.1", + "@babel/plugin-transform-typescript": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/react-native-worklets/node_modules/semver": { + "version": "7.7.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", + "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", + "license": "ISC", + "peer": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/react-native/node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -11029,6 +11456,13 @@ "path-parse": "^1.0.5" } }, + "node_modules/reselect": { + "version": "4.1.8", + "resolved": "https://registry.npmjs.org/reselect/-/reselect-4.1.8.tgz", + "integrity": "sha512-ab9EmR80F/zQTMNeneUr4cv+jSwPJgIlvEmVwLerwrWVbpLlBuls9XHzIeTFy4cegU2NHBp3va0LKOzU5qFEYQ==", + "dev": true, + "license": "MIT" + }, "node_modules/resolve": { "version": "2.0.0-next.6", "resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.6.tgz", @@ -12141,18 +12575,6 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, - "node_modules/tinyglobby/node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/tmpl": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", diff --git a/mobile/package.json b/mobile/package.json index 2193de1..0623b66 100644 --- a/mobile/package.json +++ b/mobile/package.json @@ -4,8 +4,8 @@ "main": "expo-router/entry", "scripts": { "start": "expo start", - "android": "expo start --android", - "ios": "expo start --ios", + "android": "expo run:android", + "ios": "expo run:ios", "web": "expo start --web", "lint": "eslint src --ext .ts,.tsx", "type-check": "tsc --noEmit" @@ -18,6 +18,7 @@ "@react-navigation/native-stack": "^7.14.5", "axios": "^1.7.7", "expo": "~54.0.0", + "expo-camera": "~17.0.10", "expo-constants": "~18.0.13", "expo-font": "~14.0.11", "expo-linking": "~8.0.11", @@ -45,6 +46,7 @@ "@types/react-native": "~0.73.0", "@typescript-eslint/eslint-plugin": "^7.0.0", "@typescript-eslint/parser": "^7.0.0", + "babel-plugin-module-resolver": "^5.0.2", "eslint": "^8.57.0", "eslint-plugin-react": "^7.34.0", "eslint-plugin-react-hooks": "^4.6.0", diff --git a/mobile/src/adapters/remote/ApiAuthRepository.ts b/mobile/src/adapters/remote/ApiAuthRepository.ts index 2ad1b88..f257888 100644 --- a/mobile/src/adapters/remote/ApiAuthRepository.ts +++ b/mobile/src/adapters/remote/ApiAuthRepository.ts @@ -9,17 +9,17 @@ import type { AuthSession, LoginInput, RegisterInput, GoogleOAuthInput } from '@ export class ApiAuthRepository implements AuthRepository { async login(input: LoginInput): Promise { const { data } = await httpClient.post('/auth/login', input); - return this.mapSession(data); + return this.fetchSession(data.access_token as string, data.refresh_token as string); } async register(input: RegisterInput): Promise { const { data } = await httpClient.post('/auth/register', input); - return this.mapSession(data); + return this.fetchSession(data.access_token as string, data.refresh_token as string); } async loginWithGoogle(input: GoogleOAuthInput): Promise { const { data } = await httpClient.post('/auth/oauth/google', input); - return this.mapSession(data); + return this.fetchSession(data.access_token as string, data.refresh_token as string); } async refreshToken(refreshToken: string): Promise> { @@ -48,13 +48,15 @@ export class ApiAuthRepository implements AuthRepository { await httpClient.post('/auth/reset-password', { token, new_password: newPassword }); } - private mapSession(data: Record): AuthSession { - const user = data.user as Record; + private async fetchSession(accessToken: string, refreshToken: string): Promise { + const { data: user } = await httpClient.get('/users/me', { + headers: { Authorization: `Bearer ${accessToken}` }, + }); return { - accessToken: data.access_token as string, - refreshToken: data.refresh_token as string, + accessToken, + refreshToken, user: { - id: user.id as string, + id: String(user.id), email: user.email as string, name: (user.name as string | null) ?? null, googleId: (user.google_id as string | null) ?? null, diff --git a/mobile/src/infrastructure/container.ts b/mobile/src/infrastructure/container.ts new file mode 100644 index 0000000..d663fb4 --- /dev/null +++ b/mobile/src/infrastructure/container.ts @@ -0,0 +1,44 @@ +import { ApiAuthRepository } from '@adapters/remote/ApiAuthRepository'; +import { ApiFilamentRepository } from '@adapters/remote/ApiFilamentRepository'; +import { ApiSpoolPresetRepository } from '@adapters/remote/ApiSpoolPresetRepository'; +import { + LoginUseCase, + RegisterUseCase, + ForgotPasswordUseCase, + ResetPasswordUseCase, + LogoutUseCase, +} from '@application/auth/AuthUseCases'; +import { CreateFilamentUseCase } from '@application/filament/CreateFilamentUseCase'; +import { UpdateFilamentUseCase } from '@application/filament/UpdateFilamentUseCase'; +import { ListFilamentsUseCase } from '@application/filament/ListFilamentsUseCase'; +import { DeleteFilamentUseCase } from '@application/filament/DeleteFilamentUseCase'; +import { + ListPresetsUseCase, + CreatePresetUseCase, + UpdatePresetUseCase, + DeletePresetUseCase, +} from '@application/preset/PresetUseCases'; + +// Repositórios (singletons) +const authRepository = new ApiAuthRepository(); +const filamentRepository = new ApiFilamentRepository(); +const presetRepository = new ApiSpoolPresetRepository(); + +// Use cases de autenticação +export const loginUseCase = new LoginUseCase(authRepository); +export const registerUseCase = new RegisterUseCase(authRepository); +export const forgotPasswordUseCase = new ForgotPasswordUseCase(authRepository); +export const resetPasswordUseCase = new ResetPasswordUseCase(authRepository); +export const logoutUseCase = new LogoutUseCase(authRepository); + +// Use cases de filamento +export const createFilamentUseCase = new CreateFilamentUseCase(filamentRepository, presetRepository); +export const updateFilamentUseCase = new UpdateFilamentUseCase(filamentRepository, presetRepository); +export const listFilamentsUseCase = new ListFilamentsUseCase(filamentRepository); +export const deleteFilamentUseCase = new DeleteFilamentUseCase(filamentRepository); + +// Use cases de preset +export const listPresetsUseCase = new ListPresetsUseCase(presetRepository); +export const createPresetUseCase = new CreatePresetUseCase(presetRepository); +export const updatePresetUseCase = new UpdatePresetUseCase(presetRepository); +export const deletePresetUseCase = new DeletePresetUseCase(presetRepository); diff --git a/mobile/src/store/authStore.ts b/mobile/src/store/authStore.ts index d0dec0a..47532cb 100644 --- a/mobile/src/store/authStore.ts +++ b/mobile/src/store/authStore.ts @@ -1,7 +1,8 @@ import { create } from 'zustand'; import * as SecureStore from 'expo-secure-store'; +import axios from 'axios'; import type { User, AuthSession } from '@domain/User'; -import { SECURE_STORE_ACCESS_TOKEN, SECURE_STORE_REFRESH_TOKEN } from '@shared/constants'; +import { SECURE_STORE_ACCESS_TOKEN, SECURE_STORE_REFRESH_TOKEN, API_BASE_URL } from '@shared/constants'; interface AuthState { user: User | null; @@ -56,13 +57,26 @@ export const useAuthStore = create((set) => ({ set({ isLoading: true }); try { const accessToken = await SecureStore.getItemAsync(SECURE_STORE_ACCESS_TOKEN); + const refreshToken = await SecureStore.getItemAsync(SECURE_STORE_REFRESH_TOKEN); if (accessToken) { - // TODO: validar token com /api/v1/users/me e popular o user - set({ accessToken, isAuthenticated: true, isLoading: false }); + const { data } = await axios.get(`${API_BASE_URL}/users/me`, { + headers: { Authorization: `Bearer ${accessToken}` }, + }); + const user: User = { + id: String(data.id), + email: data.email as string, + name: (data.name as string | null) ?? null, + googleId: (data.google_id as string | null) ?? null, + createdAt: data.created_at as string, + }; + set({ user, accessToken, refreshToken, isAuthenticated: true, isLoading: false }); } else { set({ isLoading: false }); } } catch { + // Token inválido ou expirado — limpa a sessão + await SecureStore.deleteItemAsync(SECURE_STORE_ACCESS_TOKEN); + await SecureStore.deleteItemAsync(SECURE_STORE_REFRESH_TOKEN); set({ isLoading: false }); } }, diff --git a/mobile/tsconfig.json b/mobile/tsconfig.json index ecc5130..131fec5 100644 --- a/mobile/tsconfig.json +++ b/mobile/tsconfig.json @@ -38,6 +38,9 @@ ], "@shared/*": [ "src/shared/*" + ], + "@infrastructure/*": [ + "src/infrastructure/*" ] } },