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.
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user