untitled

Pasted Nov 9, 2026, 4:11 AM1 file295 lines

Scan to open on your phone

Point a camera at the QR code - it opens this exact paste, no app needed.

https://codepastes.com/zzgs9b3r1n6k0407
untitled
package com.negocio.desinfectantes.ui.productos

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.foundation.verticalScroll
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.layout.imePadding

private val Navy = Color(0xFF101D35)
private val CardBlue = Color(0xFF1B2D4A)
private val AccentBlue = Color(0xFF2585F5)
private val SoftBlue = Color(0xFFA9BEDB)

@Composable
fun AgregarProductoScreen(
    onVolver: () -> Unit,
    onGuardar: (String, String, String) -> Unit
) {
    var nombre by remember { mutableStateOf("") }
    var tipo by remember { mutableStateOf("Desinfectante") }
    var aroma by remember { mutableStateOf("") }

    Column(
        modifier = Modifier
            .fillMaxSize()
            .background(Navy)
            .verticalScroll(rememberScrollState())
            .imePadding()
            .padding(20.dp),
        verticalArrangement = Arrangement.spacedBy(16.dp)
    ) {

        Text(
            text = "Agregar producto",
            color = Color.White,
            fontSize = 25.sp,
            fontWeight = FontWeight.Bold
        )

        Text(
            text = "Registra los datos básicos de tu producto.",
            color = SoftBlue,
            fontSize = 14.sp
        )

        OutlinedTextField(
            value = nombre,
            onValueChange = { nombre = it },
            modifier = Modifier.fillMaxWidth(),
            label = { Text("Nombre del producto") },
            placeholder = { Text("Ej. Desinfectante") },
            singleLine = true,
            colors = OutlinedTextFieldDefaults.colors(
                focusedTextColor = Color.White,
                unfocusedTextColor = Color.White,
                focusedBorderColor = AccentBlue,
                unfocusedBorderColor = SoftBlue,
                focusedLabelColor = AccentBlue,
                unfocusedLabelColor = SoftBlue
            )
        )

        Text(
            text = "Tipo de producto",
            color = Color.White,
            fontWeight = FontWeight.SemiBold
        )

        Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
            FilterChip(
                selected = tipo == "Desinfectante",
                onClick = { tipo = "Desinfectante" },
                label = { Text("Desinfectante") }
            )

            FilterChip(
                selected = tipo == "Otro",
                onClick = { tipo = "Otro" },
                label = { Text("Otro") }
            )
        }

        OutlinedTextField(
            value = aroma,
            onValueChange = { aroma = it },
            modifier = Modifier.fillMaxWidth(),
            label = { Text("Aroma") },
            placeholder = { Text("Ej. Canela, Musk, Lavanda") },
            singleLine = true,
            colors = OutlinedTextFieldDefaults.colors(
                focusedTextColor = Color.White,
                unfocusedTextColor = Color.White,
                focusedBorderColor = AccentBlue,
                unfocusedBorderColor = SoftBlue,
                focusedLabelColor = AccentBlue,
                unfocusedLabelColor = SoftBlue
            )
        )

        Spacer(modifier = Modifier.height(10.dp))

        Button(
            onClick = {
                if (nombre.isNotBlank() && aroma.isNotBlank()) {
                    onGuardar(nombre.trim(), tipo, aroma.trim())
                }
            },
            modifier = Modifier
                .fillMaxWidth()
                .height(54.dp),
            shape = RoundedCornerShape(14.dp),
            colors = ButtonDefaults.buttonColors(
                containerColor = AccentBlue
            ),
            enabled = nombre.isNotBlank() && aroma.isNotBlank()
        ) {
            Text("Guardar producto")
        }

        OutlinedButton(
            onClick = onVolver,
            modifier = Modifier
                .fillMaxWidth()
                .height(50.dp),
            shape = RoundedCornerShape(14.dp)
        ) {
            Text("Cancelar")
        }
    }
}



package com.negocio.desinfectantes.ui.productos

import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.Inventory2
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.ui.unit.dp

private val CardBlueForm = Color(0xFF1B2D4A)
private val AccentBlueForm = Color(0xFF2585F5)
private val SoftBlueForm = Color(0xFFA9BEDB)

@Composable
fun AgregarPresentacionScreen(
    nombreProducto: String,
    nombreAroma: String,
    onVolver: () -> Unit,
    onGuardar: (String, Int, Double) -> Unit
) {
    var nombre by remember { mutableStateOf("") }
    var contenido by remember { mutableStateOf("") }
    var precio by remember { mutableStateOf("") }

    val contenidoValido = contenido.toIntOrNull()?.let { it > 0 } == true
    val precioValido = precio.replace(",", ".").toDoubleOrNull()?.let { it >= 0 } == true

    Column(
        modifier = Modifier
            .fillMaxSize()
            .verticalScroll(rememberScrollState())
            .padding(20.dp)
    ) {
        Row(verticalAlignment = Alignment.CenterVertically) {
            IconButton(onClick = onVolver) {
                Icon(
                    Icons.Default.ArrowBack,
                    contentDescription = "Volver",
                    tint = SoftBlueForm
                )
            }

            Text(
                "Nueva presentación",
                color = Color.White,
                style = MaterialTheme.typography.headlineSmall
            )
        }

        Spacer(Modifier.height(12.dp))

        Text(
            "$nombreProducto · $nombreAroma",
            color = SoftBlueForm,
            style = MaterialTheme.typography.bodyMedium
        )

        Spacer(Modifier.height(24.dp))

        Card(
            modifier = Modifier.fillMaxWidth(),
            shape = RoundedCornerShape(18.dp),
            colors = CardDefaults.cardColors(containerColor = CardBlueForm)
        ) {
            Column(modifier = Modifier.padding(20.dp)) {
                Icon(
                    Icons.Default.Inventory2,
                    contentDescription = null,
                    tint = AccentBlueForm,
                    modifier = Modifier.size(32.dp)
                )

                Spacer(Modifier.height(12.dp))

                Text(
                    "Información de la presentación",
                    color = Color.White,
                    style = MaterialTheme.typography.titleMedium
                )

                Spacer(Modifier.height(20.dp))

                OutlinedTextField(
                    value = nombre,
                    onValueChange = { nombre = it },
                    modifier = Modifier.fillMaxWidth(),
                    label = { Text("Nombre") },
                    placeholder = { Text("Ej. Galón") },
                    singleLine = true,
                    shape = RoundedCornerShape(12.dp)
                )

                Spacer(Modifier.height(14.dp))

                OutlinedTextField(
                    value = contenido,
                    onValueChange = { contenido = it.filter { c -> c.isDigit() } },
                    modifier = Modifier.fillMaxWidth(),
                    label = { Text("Contenido en mililitros") },
                    placeholder = { Text("Ej. 3785") },
                    singleLine = true,
                    keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
                    shape = RoundedCornerShape(12.dp)
                )

                Spacer(Modifier.height(14.dp))

                OutlinedTextField(
                    value = precio,
                    onValueChange = {
                        precio = it.filter { c -> c.isDigit() || c == '.' || c == ',' }
                    },
                    modifier = Modifier.fillMaxWidth(),
                    label = { Text("Precio de venta") },
                    placeholder = { Text("Ej. 18000") },
                    singleLine = true,
                    keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Decimal),
                    shape = RoundedCornerShape(12.dp)
                )
            }
        }

        Spacer(Modifier.height(24.dp))

        Button(
            onClick = {
                val precioNumerico = precio.replace(",", ".").toDoubleOrNull()

                if (nombre.isNotBlank() && contenidoValido && precioNumerico != null) {
                    onGuardar(nombre.trim(), contenido.toInt(), precioNumerico)
                }
            },
            enabled = nombre.isNotBlank() && contenidoValido && precioValido,
            modifier = Modifier
                .fillMaxWidth()
                .height(54.dp),
            shape = RoundedCornerShape(14.dp),
            colors = ButtonDefaults.buttonColors(containerColor = AccentBlueForm)
        ) {
            Text("Guardar presentación")
        }
    }
}

9,847 chars · codepastes.com