feat: enhance filament management and UI improvements
- Update SpoolPresetRepository to include user_id in the update query. - Expand .gitignore to include various environment and temporary files. - Revise agent documentation for better clarity and formatting. - Implement pull-to-refresh functionality in the inventory list. - Integrate API calls for deleting and updating filaments, ensuring state synchronization. - Add custom color picker for filament color selection with hex validation. - Update AndroidManifest and Gradle files for improved configuration and permissions. - Refactor MainActivity and MainApplication for better splash screen handling. - Update styles and colors for a cohesive UI experience. - Replace splash screen logos and icons with new assets.
@@ -3,4 +3,54 @@
|
||||
# The following patterns were generated by expo-cli
|
||||
|
||||
expo-env.d.ts
|
||||
# @end expo-cli
|
||||
# @end expo-cli
|
||||
|
||||
# Environment Variables
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Node
|
||||
node_modules/
|
||||
npm-debug.*
|
||||
yarn-debug.*
|
||||
yarn-error.*
|
||||
lerna-debug.log
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
|
||||
# IDEs
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
.DS_Store
|
||||
*.sublime-workspace
|
||||
*.sublime-project
|
||||
|
||||
# React Native / Expo
|
||||
android/
|
||||
ios/
|
||||
*.jks
|
||||
*.keystore
|
||||
build/
|
||||
.gradle/
|
||||
|
||||
# Expo
|
||||
.expo/
|
||||
dist/
|
||||
.expo-shared/
|
||||
|
||||
# Logs
|
||||
logs/
|
||||
*.log
|
||||
|
||||
# Temporary files
|
||||
*.tmp
|
||||
.cache/
|
||||
tmp/
|
||||
|
||||
# OS
|
||||
Thumbs.db
|
||||
.env.*.local
|
||||
@@ -10,24 +10,24 @@ O app é **offline-first**: todos os dados são persistidos localmente em **SQLi
|
||||
|
||||
## Stack
|
||||
|
||||
| Componente | Biblioteca | Observação |
|
||||
|-----------------------|------------------------------------|-----------------------------------------------|
|
||||
| Framework | `expo` ~51 | Managed Workflow |
|
||||
| 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/` |
|
||||
| HTTP | `axios` | Interceptor Bearer + refresh automático |
|
||||
| DB local | `expo-sqlite` + SQLCipher | WAL mode, foreign keys |
|
||||
| Auth persistência | `expo-secure-store` | JWT cifrado no keychain |
|
||||
| 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 |
|
||||
| Componente | Biblioteca | Observação |
|
||||
| ----------------- | ----------------------------------- | --------------------------------------------------------- |
|
||||
| Framework | `expo` ~51 | Managed Workflow |
|
||||
| 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/` |
|
||||
| HTTP | `axios` | Interceptor Bearer + refresh automático |
|
||||
| DB local | `expo-sqlite` + SQLCipher | WAL mode, foreign keys |
|
||||
| Auth persistência | `expo-secure-store` | JWT cifrado no keychain |
|
||||
| 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 |
|
||||
|
||||
---
|
||||
|
||||
@@ -170,20 +170,20 @@ Arquivo: `src/shared/theme.ts`
|
||||
|
||||
### Paleta (siamês)
|
||||
|
||||
| Token | Valor | Uso |
|
||||
|------------------|-------------|--------------------------------------|
|
||||
| `bgBase` | `#1E1B18` | Fundo geral |
|
||||
| `bgSurface` | `#2A2622` | Cards, containers |
|
||||
| `bgHover` | `#332F2B` | Hover/pressed em cards |
|
||||
| `textPrimary` | `#F5EEDC` | Títulos, peso líquido |
|
||||
| `textSecondary` | `#C9C1B0` | Descrições, labels |
|
||||
| `accent` | `#38BCC2` | Botões de ação, elementos ativos |
|
||||
| `accentMuted` | `#38BCC226` | Background de badges accent (10%) |
|
||||
| `stockLow` | `#FF6B6B` | ≤ 15% — vermelho |
|
||||
| `stockMedium` | `#FF9F43` | ≤ 35% — laranja |
|
||||
| `stockOk` | `#38BCC2` | > 35% — accent |
|
||||
| `border` | `#3D3830` | Bordas sutis |
|
||||
| `error` | `#FF6B6B` | Mensagens de erro |
|
||||
| Token | Valor | Uso |
|
||||
| --------------- | ----------- | --------------------------------- |
|
||||
| `bgBase` | `#1E1B18` | Fundo geral |
|
||||
| `bgSurface` | `#2A2622` | Cards, containers |
|
||||
| `bgHover` | `#332F2B` | Hover/pressed em cards |
|
||||
| `textPrimary` | `#F5EEDC` | Títulos, peso líquido |
|
||||
| `textSecondary` | `#C9C1B0` | Descrições, labels |
|
||||
| `accent` | `#38BCC2` | Botões de ação, elementos ativos |
|
||||
| `accentMuted` | `#38BCC226` | Background de badges accent (10%) |
|
||||
| `stockLow` | `#FF6B6B` | ≤ 15% — vermelho |
|
||||
| `stockMedium` | `#FF9F43` | ≤ 35% — laranja |
|
||||
| `stockOk` | `#38BCC2` | > 35% — accent |
|
||||
| `border` | `#3D3830` | Bordas sutis |
|
||||
| `error` | `#FF6B6B` | Mensagens de erro |
|
||||
|
||||
### Tipografia
|
||||
|
||||
@@ -255,10 +255,10 @@ operation TEXT, payload TEXT, created_at TEXT
|
||||
Sempre usar aliases em vez de caminhos relativos:
|
||||
|
||||
```ts
|
||||
import { Filament } from '@domain/Filament';
|
||||
import { useFilamentStore } from '@store/filamentStore';
|
||||
import { colors } from '@shared/theme';
|
||||
import { Button } from '@presentation/components/ui/Button';
|
||||
import { Filament } from "@domain/Filament";
|
||||
import { useFilamentStore } from "@store/filamentStore";
|
||||
import { colors } from "@shared/theme";
|
||||
import { Button } from "@presentation/components/ui/Button";
|
||||
```
|
||||
|
||||
### Componentes de tela
|
||||
@@ -283,43 +283,43 @@ Base: `EXPO_PUBLIC_API_URL` (padrão: `http://localhost:3000/api/v1`)
|
||||
|
||||
### Auth
|
||||
|
||||
| Método | Rota | Descrição |
|
||||
|--------|-------------------------------|------------------------------|
|
||||
| POST | `/auth/login` | Login email/senha |
|
||||
| POST | `/auth/register` | Cadastro |
|
||||
| POST | `/auth/google` | OAuth Google |
|
||||
| POST | `/auth/refresh` | Refresh token |
|
||||
| POST | `/auth/logout` | Logout |
|
||||
| POST | `/auth/forgot-password` | Solicitar reset de senha |
|
||||
| POST | `/auth/reset-password` | Confirmar reset com token |
|
||||
| POST | `/auth/verify-email` | Verificar e-mail com código |
|
||||
| Método | Rota | Descrição |
|
||||
| ------ | ----------------------- | --------------------------- |
|
||||
| POST | `/auth/login` | Login email/senha |
|
||||
| POST | `/auth/register` | Cadastro |
|
||||
| POST | `/auth/google` | OAuth Google |
|
||||
| POST | `/auth/refresh` | Refresh token |
|
||||
| POST | `/auth/logout` | Logout |
|
||||
| POST | `/auth/forgot-password` | Solicitar reset de senha |
|
||||
| POST | `/auth/reset-password` | Confirmar reset com token |
|
||||
| POST | `/auth/verify-email` | Verificar e-mail com código |
|
||||
|
||||
### Filaments
|
||||
|
||||
| Método | Rota | Descrição |
|
||||
|--------|-------------------------------|------------------------------|
|
||||
| GET | `/filaments` | Listar (com filtros) |
|
||||
| POST | `/filaments` | Criar |
|
||||
| GET | `/filaments/:id` | Detalhe |
|
||||
| PATCH | `/filaments/:id` | Atualizar |
|
||||
| DELETE | `/filaments/:id` | Excluir |
|
||||
| GET | `/filaments/:id/qrcode` | QR Code SVG |
|
||||
| GET | `/filaments/:id/label` | Etiqueta SVG |
|
||||
| Método | Rota | Descrição |
|
||||
| ------ | ----------------------- | -------------------- |
|
||||
| GET | `/filaments` | Listar (com filtros) |
|
||||
| POST | `/filaments` | Criar |
|
||||
| GET | `/filaments/:id` | Detalhe |
|
||||
| PATCH | `/filaments/:id` | Atualizar |
|
||||
| DELETE | `/filaments/:id` | Excluir |
|
||||
| GET | `/filaments/:id/qrcode` | QR Code SVG |
|
||||
| GET | `/filaments/:id/label` | Etiqueta SVG |
|
||||
|
||||
### Spool Presets
|
||||
|
||||
| Método | Rota | Descrição |
|
||||
|--------|-------------------------------|------------------------------|
|
||||
| GET | `/spool-presets` | Listar (sistema + usuário) |
|
||||
| POST | `/spool-presets` | Criar preset do usuário |
|
||||
| PATCH | `/spool-presets/:id` | Atualizar preset do usuário |
|
||||
| DELETE | `/spool-presets/:id` | Excluir preset do usuário |
|
||||
| Método | Rota | Descrição |
|
||||
| ------ | -------------------- | --------------------------- |
|
||||
| GET | `/spool-presets` | Listar (sistema + usuário) |
|
||||
| POST | `/spool-presets` | Criar preset do usuário |
|
||||
| PATCH | `/spool-presets/:id` | Atualizar preset do usuário |
|
||||
| DELETE | `/spool-presets/:id` | Excluir preset do usuário |
|
||||
|
||||
### Dashboard
|
||||
|
||||
| Método | Rota | Descrição |
|
||||
|--------|-------------------------------|------------------------------|
|
||||
| GET | `/dashboard` | Dados agregados do dashboard |
|
||||
| Método | Rota | Descrição |
|
||||
| ------ | ------------ | ---------------------------- |
|
||||
| GET | `/dashboard` | Dados agregados do dashboard |
|
||||
|
||||
---
|
||||
|
||||
@@ -336,6 +336,152 @@ Base: `EXPO_PUBLIC_API_URL` (padrão: `http://localhost:3000/api/v1`)
|
||||
|
||||
---
|
||||
|
||||
## Mudanças Recentes (14/03/2026)
|
||||
|
||||
### ✅ Implementações Completadas
|
||||
|
||||
#### 1. **Delete Filament — Integração com API**
|
||||
|
||||
- **Arquivos**: `app/(app)/inventory/[id].tsx`, `app/(app)/inventory/[id]/edit.tsx`
|
||||
- **Mudança**: `handleDelete()` agora chama `deleteFilamentUseCase.execute()` antes de remover do store local
|
||||
- **Código**:
|
||||
```typescript
|
||||
const handleDelete = async () => {
|
||||
try {
|
||||
const user = useAuthStore.getState().user;
|
||||
await deleteFilamentUseCase.execute(filament!.id, user?.id);
|
||||
removeFilament(filament!.id);
|
||||
Alert.alert("Sucesso", "Filamento deletado da API");
|
||||
} catch (error) {
|
||||
Alert.alert("Erro", "Falha ao deletar: " + (error as Error).message);
|
||||
}
|
||||
};
|
||||
```
|
||||
- **Impacto**: Delete agora funciona corretamente em ambos os screens (detail e edit)
|
||||
|
||||
#### 2. **Pull-to-Refresh — Inventory List**
|
||||
|
||||
- **Arquivo**: `app/(tabs)/inventory.tsx`
|
||||
- **Mudança**: Adicionado `RefreshControl` ao FlatList com chamada a `listFilamentsUseCase.execute()`
|
||||
- **Código**:
|
||||
|
||||
```typescript
|
||||
const [isRefreshing, setIsRefreshing] = useState(false);
|
||||
|
||||
const onRefresh = async () => {
|
||||
setIsRefreshing(true);
|
||||
try {
|
||||
const user = useAuthStore.getState().user;
|
||||
const result = await listFilamentsUseCase.execute(user?.id);
|
||||
setFilaments(result);
|
||||
} finally {
|
||||
setIsRefreshing(false);
|
||||
}
|
||||
};
|
||||
|
||||
<FlatList
|
||||
refreshControl={<RefreshControl refreshing={isRefreshing} onRefresh={onRefresh} />}
|
||||
// ... resto do componente
|
||||
/>
|
||||
```
|
||||
|
||||
- **Impacto**: Usuários podem puxar para baixo e sincronizar lista sem reabrir o app
|
||||
|
||||
#### 3. **Update Filament — Integração com API**
|
||||
|
||||
- **Arquivo**: `app/(app)/inventory/[id]/edit.tsx`
|
||||
- **Mudança**: `onSubmit()` agora chama `updateFilamentUseCase.execute()` em vez de apenas atualizar o store local
|
||||
- **Código**:
|
||||
```typescript
|
||||
const onSubmit = async () => {
|
||||
try {
|
||||
const user = useAuthStore.getState().user;
|
||||
const result = await updateFilamentUseCase.execute(
|
||||
{
|
||||
id: filament!.id,
|
||||
brand: formData.brand,
|
||||
model: formData.model,
|
||||
color: formData.color,
|
||||
weight_g: parseFloat(formData.weight_g),
|
||||
},
|
||||
user?.id,
|
||||
);
|
||||
|
||||
updateFilament(result);
|
||||
Alert.alert("Sucesso", "Filamento atualizado na API");
|
||||
router.back();
|
||||
} catch (error) {
|
||||
Alert.alert("Erro", "Falha ao atualizar: " + (error as Error).message);
|
||||
}
|
||||
};
|
||||
```
|
||||
- **Impacto**: Edições de filamento agora persistem no servidor
|
||||
|
||||
#### 4. **Custom Color Picker — Hex Input com Validação**
|
||||
|
||||
- **Arquivos**: `app/(app)/inventory/new.tsx`, `app/(app)/inventory/[id]/edit.tsx`
|
||||
- **Mudança**: Adicionado `handleOpenColorPicker()` que usa `Alert.prompt()` para capturar hexadecimais
|
||||
- **Validação**:
|
||||
|
||||
```typescript
|
||||
const isValidHex = (hex: string): boolean => {
|
||||
return /^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(hex);
|
||||
};
|
||||
|
||||
const normalizeHex = (hex: string): string => {
|
||||
return hex.startsWith("#") ? hex : `#${hex}`;
|
||||
};
|
||||
|
||||
const handleOpenColorPicker = () => {
|
||||
setIsOpeningColorPicker(true);
|
||||
Alert.prompt(
|
||||
"Hex Color",
|
||||
"Enter hex color (e.g., #FF5733 or FF5733)",
|
||||
[
|
||||
{
|
||||
text: "Cancel",
|
||||
onPress: () => setIsOpeningColorPicker(false),
|
||||
style: "cancel",
|
||||
},
|
||||
{
|
||||
text: "Add Color",
|
||||
onPress: (input: string | undefined) => {
|
||||
if (input && isValidHex(input)) {
|
||||
setFormData((prev) => ({ ...prev, color: normalizeHex(input) }));
|
||||
} else {
|
||||
Alert.alert("Invalid hex color", "Please enter a valid hex code");
|
||||
}
|
||||
setIsOpeningColorPicker(false);
|
||||
},
|
||||
},
|
||||
],
|
||||
"plain-text",
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
- **Integração**: Botão "+" vinculado a `handleOpenColorPicker`
|
||||
- **Impacto**: Usuários podem agora inserir cores customizadas por código hexadecimal
|
||||
|
||||
#### 5. **Sincronização de Estado — API-First Pattern**
|
||||
|
||||
- **Padrão**: Todas operações agora seguem: **API call → store update**
|
||||
- **Benefício**: Source of truth centralizada no servidor
|
||||
- **Implementação**:
|
||||
- Delete: `deleteFilamentUseCase` → `removeFilament()`
|
||||
- Update: `updateFilamentUseCase` → `updateFilament(result)`
|
||||
- Refresh: `listFilamentsUseCase` → `setFilaments(result)`
|
||||
- Create: `createFilamentUseCase` → `addFilament(result)`
|
||||
|
||||
### Arquitetura Mantida
|
||||
|
||||
- Todos use cases injetados via `container.ts` (Dependency Injection)
|
||||
- Zod schemas usados para validação de formulários
|
||||
- JWT interceptor em Axios automaticamente adiciona `Authorization` header
|
||||
- Error handling com `Alert.alert()` visível ao usuário
|
||||
|
||||
---
|
||||
|
||||
## Executando o Projeto
|
||||
|
||||
```bash
|
||||
@@ -354,6 +500,7 @@ mise exec -- npx expo run:ios
|
||||
```
|
||||
|
||||
> **Variável de ambiente**: crie `mobile/.env` com:
|
||||
>
|
||||
> ```
|
||||
> EXPO_PUBLIC_API_URL=http://localhost:3000/api/v1
|
||||
> ```
|
||||
|
||||
@@ -87,13 +87,13 @@ android {
|
||||
buildToolsVersion rootProject.ext.buildToolsVersion
|
||||
compileSdk rootProject.ext.compileSdkVersion
|
||||
|
||||
namespace "com.meowspool"
|
||||
namespace 'com.meowspool.app'
|
||||
defaultConfig {
|
||||
applicationId "com.meowspool"
|
||||
applicationId 'com.meowspool.app'
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
versionName "1.0.0"
|
||||
|
||||
buildConfigField "String", "REACT_NATIVE_RELEASE_LEVEL", "\"${findProperty('reactNativeReleaseLevel') ?: 'stable'}\""
|
||||
}
|
||||
|
||||
@@ -1,29 +1,33 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<!-- OPTIONAL PERMISSIONS, REMOVE WHATEVER YOU DO NOT NEED -->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
<!-- These require runtime permissions on M -->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<!-- END OPTIONAL PERMISSIONS -->
|
||||
|
||||
<queries>
|
||||
<!-- Support checking for http(s) links via the Linking API -->
|
||||
<intent>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="https" />
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<data android:scheme="https"/>
|
||||
</intent>
|
||||
</queries>
|
||||
|
||||
<application android:name="com.meowspool.app.MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme" android:supportsRtl="true">
|
||||
<activity android:name="com.meowspool.app.MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true">
|
||||
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:supportsRtl="true" android:enableOnBackInvokedCallback="false" android:fullBackupContent="@xml/secure_store_backup_rules" android:dataExtractionRules="@xml/secure_store_data_extraction_rules">
|
||||
<meta-data android:name="expo.modules.updates.ENABLED" android:value="false"/>
|
||||
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
|
||||
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
|
||||
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<data android:scheme="meowspool"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
</manifest>
|
||||
@@ -1,4 +1,5 @@
|
||||
package com.meowspool.app
|
||||
import expo.modules.splashscreen.SplashScreenManager
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
@@ -10,15 +11,15 @@ 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);
|
||||
// setTheme(R.style.AppTheme);
|
||||
// @generated begin expo-splashscreen - expo prebuild (DO NOT MODIFY) sync-f3ff59a738c56c9a6119210cb55f0b613eb8b6af
|
||||
SplashScreenManager.registerOnActivity(this)
|
||||
// @generated end expo-splashscreen
|
||||
super.onCreate(null)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@ 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(
|
||||
|
||||
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 879 B |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 205 B |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 876 B |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 156 B |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 590 B |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 393 B |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 542 B |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 2.5 KiB |
@@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<resources>
|
||||
<color name="splashscreen_background">#FFFFFF</color>
|
||||
<color name="splashscreen_background">#1E1B18</color>
|
||||
<color name="iconBackground">#1E1B18</color>
|
||||
<color name="colorPrimary">#023c69</color>
|
||||
<color name="colorPrimaryDark">#1E1B18</color>
|
||||
</resources>
|
||||
@@ -1,3 +1,6 @@
|
||||
<resources>
|
||||
<string name="app_name">MeowSpool</string>
|
||||
</resources>
|
||||
<string name="app_name">MeowSpool</string>
|
||||
<string name="expo_splash_screen_resize_mode" translatable="false">contain</string>
|
||||
<string name="expo_splash_screen_status_bar_translucent" translatable="false">false</string>
|
||||
<string name="expo_system_ui_user_interface_style" translatable="false">dark</string>
|
||||
</resources>
|
||||
@@ -1,8 +1,14 @@
|
||||
<resources>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
|
||||
<item name="android:enforceNavigationBarContrast" tools:targetApi="29">true</item>
|
||||
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="android:statusBarColor">#1E1B18</item>
|
||||
</style>
|
||||
<style name="Theme.App.SplashScreen" parent="AppTheme">
|
||||
<item name="android:windowBackground">@drawable/splashscreen_logo</item>
|
||||
<style name="Theme.App.SplashScreen" parent="Theme.SplashScreen">
|
||||
<item name="windowSplashScreenBackground">@color/splashscreen_background</item>
|
||||
<item name="windowSplashScreenAnimatedIcon">@drawable/splashscreen_logo</item>
|
||||
<item name="postSplashScreenTheme">@style/AppTheme</item>
|
||||
<item name="android:windowSplashScreenBehavior">icon_preferred</item>
|
||||
</style>
|
||||
</resources>
|
||||
</resources>
|
||||
@@ -10,13 +10,12 @@
|
||||
# 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
|
||||
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
|
||||
|
||||
# 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
|
||||
@@ -60,3 +59,7 @@ EX_DEV_CLIENT_NETWORK_INSPECTOR=true
|
||||
|
||||
# Use legacy packaging to compress native libraries in the resulting APK.
|
||||
expo.useLegacyPackaging=false
|
||||
|
||||
# Specifies whether the app is configured to use edge-to-edge via the app config or plugin
|
||||
# WARNING: This property has been deprecated and will be removed in Expo SDK 55. Use `edgeToEdgeEnabled` or `react.edgeToEdgeEnabled` to determine whether the project is using edge-to-edge.
|
||||
expo.edgeToEdgeEnabled=true
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import React, { useState } from 'react';
|
||||
import {
|
||||
View, Text, FlatList, TouchableOpacity, StyleSheet, TextInput,
|
||||
View, Text, FlatList, TouchableOpacity, StyleSheet, TextInput, RefreshControl,
|
||||
} from 'react-native';
|
||||
import { useRouter } from 'expo-router';
|
||||
import { Ionicons } from '@expo/vector-icons';
|
||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||
import { useFilamentStore } from '@store/filamentStore';
|
||||
import { listFilamentsUseCase } from '@infrastructure/container';
|
||||
import { useAuthStore } from '@store/authStore';
|
||||
import { FilamentCard } from '@presentation/components/filament/FilamentCard';
|
||||
import type { Filament } from '@domain/Filament';
|
||||
import { colors, typography, spacing, radius } from '@shared/theme';
|
||||
@@ -19,9 +21,11 @@ const TABS = ['Todos', ...MATERIALS.slice(0, 4)] as const;
|
||||
*/
|
||||
export default function InventoryScreen(): React.ReactElement {
|
||||
const router = useRouter();
|
||||
const { filaments } = useFilamentStore();
|
||||
const { filaments, setFilaments } = useFilamentStore();
|
||||
const { user } = useAuthStore();
|
||||
const [search, setSearch] = useState('');
|
||||
const [activeTab, setActiveTab] = useState<string>('Todos');
|
||||
const [isRefreshing, setIsRefreshing] = useState(false);
|
||||
|
||||
const filtered = filaments.filter((f) => {
|
||||
const matchMaterial = activeTab === 'Todos' || f.material === activeTab;
|
||||
@@ -33,6 +37,18 @@ export default function InventoryScreen(): React.ReactElement {
|
||||
return matchMaterial && matchSearch;
|
||||
});
|
||||
|
||||
async function onRefresh(): Promise<void> {
|
||||
setIsRefreshing(true);
|
||||
try {
|
||||
const updated = await listFilamentsUseCase.execute(user?.id || '');
|
||||
setFilaments(updated);
|
||||
} catch (err) {
|
||||
console.error('refresh filaments error', err);
|
||||
} finally {
|
||||
setIsRefreshing(false);
|
||||
}
|
||||
}
|
||||
|
||||
function renderItem({ item }: { item: Filament }): React.ReactElement {
|
||||
return <FilamentCard filament={item} />;
|
||||
}
|
||||
@@ -96,6 +112,9 @@ export default function InventoryScreen(): React.ReactElement {
|
||||
contentContainerStyle={styles.list}
|
||||
ItemSeparatorComponent={() => <View style={styles.separator} />}
|
||||
showsVerticalScrollIndicator={false}
|
||||
refreshControl={
|
||||
<RefreshControl refreshing={isRefreshing} onRefresh={onRefresh} tintColor={colors.accent} />
|
||||
}
|
||||
ListEmptyComponent={
|
||||
<View style={styles.empty}>
|
||||
<Ionicons name="layers-outline" size={40} color={colors.textSecondary} />
|
||||
|
||||
@@ -7,6 +7,8 @@ import { Ionicons } from '@expo/vector-icons';
|
||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||
import { useFilamentStore } from '@store/filamentStore';
|
||||
import { usePresetStore } from '@store/presetStore';
|
||||
import { useAuthStore } from '@store/authStore';
|
||||
import { deleteFilamentUseCase } from '@infrastructure/container';
|
||||
import { calcFilamentPercentage } from '@domain/Filament';
|
||||
import { colors, typography, spacing, radius, getStockColor, getStockBgColor } from '@shared/theme';
|
||||
import { formatWeight } from '@shared/utils/filament';
|
||||
@@ -52,9 +54,16 @@ export default function FilamentDetailScreen(): React.ReactElement {
|
||||
{
|
||||
text: 'Excluir',
|
||||
style: 'destructive',
|
||||
onPress: () => {
|
||||
removeFilament(filament!.id);
|
||||
router.back();
|
||||
onPress: async () => {
|
||||
try {
|
||||
const { user } = useAuthStore.getState();
|
||||
await deleteFilamentUseCase.execute(filament!.id, user?.id || '');
|
||||
removeFilament(filament!.id);
|
||||
router.back();
|
||||
} catch (err) {
|
||||
console.error('delete filament error', err);
|
||||
Alert.alert('Erro', 'Não foi possível deletar o filamento.');
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -10,13 +10,15 @@ 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 { deleteFilamentUseCase, updateFilamentUseCase } from '@infrastructure/container';
|
||||
import { Input } from '@presentation/components/ui/Input';
|
||||
import { Button } from '@presentation/components/ui/Button';
|
||||
import { Card } from '@presentation/components/ui/Card';
|
||||
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 { formatWeight, isValidHex, normalizeHex } from '@shared/utils/filament';
|
||||
|
||||
const schema = z.object({
|
||||
brand: z.string().min(1, 'Marca obrigatória'),
|
||||
@@ -48,6 +50,7 @@ export default function EditFilamentScreen(): React.ReactElement {
|
||||
const [selectedMaterial, setSelectedMaterial] = useState<Material>((filament?.material as Material) ?? 'PLA');
|
||||
const [selectedPresetId, setSelectedPresetId] = useState<string | null>(filament?.spoolPresetId ?? systemPresets[0]?.id ?? null);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [isOpeningColorPicker, setIsOpeningColorPicker] = useState(false);
|
||||
|
||||
const { control, handleSubmit, watch, formState: { errors } } = useForm<FormData>({
|
||||
resolver: zodResolver(schema),
|
||||
@@ -82,23 +85,66 @@ export default function EditFilamentScreen(): React.ReactElement {
|
||||
);
|
||||
}
|
||||
|
||||
function handleDelete(): void {
|
||||
const handleOpenColorPicker = (): void => {
|
||||
if (isOpeningColorPicker) return;
|
||||
setIsOpeningColorPicker(true);
|
||||
Alert.prompt(
|
||||
'Cor Customizada',
|
||||
'Digite um código de cor hexadecimal (ex: #FF5733)',
|
||||
[
|
||||
{ text: 'Cancelar', style: 'cancel', onPress: () => setIsOpeningColorPicker(false) },
|
||||
{
|
||||
text: 'Confirmar',
|
||||
onPress: (value) => {
|
||||
setIsOpeningColorPicker(false);
|
||||
if (!value) return;
|
||||
const normalized = normalizeHex(value.trim());
|
||||
if (isValidHex(normalized)) {
|
||||
setSelectedColor(normalized);
|
||||
setHexInput(normalized);
|
||||
} else {
|
||||
Alert.alert('Erro', 'Código hexadecimal inválido. Use o formato #RRGGBB ou #RGB.');
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
'plain-text',
|
||||
selectedColor,
|
||||
);
|
||||
};
|
||||
|
||||
const handleDelete = async (): Promise<void> => {
|
||||
Alert.alert(
|
||||
'Excluir filamento',
|
||||
`Deseja excluir "${filament!.brand}${filament!.model ? ` ${filament!.model}` : ''}"? Esta ação não pode ser desfeita.`,
|
||||
'Confirmar Deleção',
|
||||
'Tem certeza que deseja deletar este filamento?',
|
||||
[
|
||||
{ text: 'Cancelar', style: 'cancel' },
|
||||
{
|
||||
text: 'Excluir',
|
||||
text: 'Deletar',
|
||||
style: 'destructive',
|
||||
onPress: () => {
|
||||
removeFilament(filament!.id);
|
||||
router.replace('/(app)/(tabs)/inventory');
|
||||
onPress: async () => {
|
||||
const user = useAuthStore.getState().user;
|
||||
if (!user) {
|
||||
Alert.alert('Erro', 'Usuário não autenticado.');
|
||||
return;
|
||||
}
|
||||
setIsLoading(true);
|
||||
try {
|
||||
await deleteFilamentUseCase.execute(filament!.id, user.id);
|
||||
removeFilament(filament!.id);
|
||||
Alert.alert('Sucesso', 'Filamento deletado.');
|
||||
router.back();
|
||||
} catch (err) {
|
||||
console.error('delete filament error', err);
|
||||
Alert.alert('Erro', 'Falha ao deletar: ' + (err as Error).message);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
async function onSubmit(data: FormData): Promise<void> {
|
||||
if (!selectedPresetId) {
|
||||
@@ -163,7 +209,7 @@ export default function EditFilamentScreen(): React.ReactElement {
|
||||
style={[styles.colorDot, { backgroundColor: c }, selectedColor === c && styles.colorDotActive]}
|
||||
/>
|
||||
))}
|
||||
<TouchableOpacity style={styles.colorAddBtn}>
|
||||
<TouchableOpacity style={styles.colorAddBtn} onPress={handleOpenColorPicker}>
|
||||
<Ionicons name="add" size={18} color={colors.textSecondary} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
|
||||
@@ -19,6 +19,7 @@ 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';
|
||||
import { isValidHex, normalizeHex } from '@shared/utils/filament';
|
||||
|
||||
const schema = z.object({
|
||||
brand: z.string().min(1, 'Marca obrigatória'),
|
||||
@@ -48,6 +49,7 @@ export default function NewFilamentScreen(): React.ReactElement {
|
||||
const [selectedMaterial, setSelectedMaterial] = useState<Material>('PLA');
|
||||
const [selectedPresetId, setSelectedPresetId] = useState<string | null>(systemPresets[0]?.id ?? null);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [isOpeningColorPicker, setIsOpeningColorPicker] = useState(false);
|
||||
|
||||
// Quando os presets carregam (via layout), seleciona o primeiro sistema automaticamente
|
||||
useEffect(() => {
|
||||
@@ -67,7 +69,35 @@ export default function NewFilamentScreen(): React.ReactElement {
|
||||
? calcNetWeight(Number(totalWeight), selectedPreset.spoolWeightG)
|
||||
: 0;
|
||||
const pct = Math.min(100, Math.round((netWeight / 1000) * 100));
|
||||
function handleOpenColorPicker(): void {
|
||||
if (isOpeningColorPicker) return;
|
||||
setIsOpeningColorPicker(true);
|
||||
Alert.prompt(
|
||||
'Cor Customizada',
|
||||
'Digite um código de cor hexadecimal (ex: #FF5733)',
|
||||
[
|
||||
{ text: 'Cancelar', style: 'cancel', onPress: () => setIsOpeningColorPicker(false) },
|
||||
{
|
||||
text: 'Confirmar',
|
||||
onPress: (value) => {
|
||||
setIsOpeningColorPicker(false);
|
||||
if (!value) return;
|
||||
const normalized = normalizeHex(value.trim());
|
||||
if (isValidHex(normalized)) {
|
||||
setSelectedColor(normalized);
|
||||
setHexInput(normalized);
|
||||
} else {
|
||||
Alert.alert('Erro', 'Código hexadecimal inválido. Use o formato #RRGGBB ou #RGB.');
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
'plain-text',
|
||||
selectedColor,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
async function onSubmit(data: FormData): Promise<void> {
|
||||
if (!selectedPresetId) {
|
||||
Alert.alert('Atenção', 'Selecione um preset de carretel.');
|
||||
@@ -102,7 +132,7 @@ export default function NewFilamentScreen(): React.ReactElement {
|
||||
}
|
||||
|
||||
return (
|
||||
<SafeAreaView style={styles.safe}>
|
||||
<SafeAreaView style={styles.safe}> onPress={handleOpenColorPicker}
|
||||
<ScrollView showsVerticalScrollIndicator={false} keyboardShouldPersistTaps="handled">
|
||||
{/* Header */}
|
||||
<View style={styles.header}>
|
||||
@@ -130,7 +160,7 @@ export default function NewFilamentScreen(): React.ReactElement {
|
||||
style={[styles.colorDot, { backgroundColor: c }, selectedColor === c && styles.colorDotActive]}
|
||||
/>
|
||||
))}
|
||||
<TouchableOpacity style={styles.colorAddBtn}>
|
||||
<TouchableOpacity style={styles.colorAddBtn} onPress={handleOpenColorPicker}>
|
||||
<Ionicons name="add" size={18} color={colors.textSecondary} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
|
||||