Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/AndresLopezCorrales/La-casa-del-bordadito/llms.txt

Use this file to discover all available pages before exploring further.

Embroidery patterns are the heart of the Bordado section. Each pattern defines a grid of colored cells that customers can fill in progressively. Admins upload new patterns, control which ones are visible to users, and remove outdated ones — all from the Admin tab in Cuenta. Patterns are stored in Firebase Realtime Database under the patrones node.

Data models

data class PatronBordado(
    var id: String = "",
    var nombre: String = "",
    var columnas: Int = 0,
    var filas: Int = 0,
    var urlImagen: String = "",
    var paleta: List<ColorPatron> = emptyList(),
    var matriz: List<List<Int>> = emptyList(),
    var porcentaje: Int = 0,
    var activo: Boolean = false
)

data class ColorPatron(var id: Int = 0, var hex: String = "", var nombre: String = "")
  • matriz — a 2-D array of integers with dimensions filas × columnas. Each integer is a color ID that maps to an entry in paleta. 0 means the cell is transparent/empty (uncolored background).
  • paleta — the list of ColorPatron objects that assigns a hex color code and a display name to each numeric ID used in matriz.
  • porcentaje — tracks the user’s completion percentage; it starts at 0 when uploaded.
  • activo — controls whether the pattern is visible in the Bordado section.

Uploading a new pattern

1

Prepare the JSON

Create a JSON representation of a PatronBordado object. The id field must be a unique string — it becomes the Realtime DB key for the node. Set activo to false initially so the pattern is not shown to customers until you are ready.
2

Open the upload dialog

In the Admin tab, tap the Agregar Bordado button. A dialog titled “Nuevo Patrón de Bordado” appears with a multiline text field labelled “Pega el código JSON aquí”.
3

Paste and submit

Paste the full JSON into the text field and tap Subir. The app parses the JSON with Gson, forces activo = false, and writes the object to patrones/{patron.id} in Realtime Database:
private fun subirPatronAFirebase(json: String) {
    try {
        val patron = Gson().fromJson(json, PatronBordado::class.java).apply { activo = false }
        FirebaseDatabase.getInstance().getReference("patrones").child(patron.id)
            .setValue(patron)
            .addOnSuccessListener {
                Toast.makeText(mContext, "¡Patrón ${patron.nombre} subido!", Toast.LENGTH_SHORT).show()
            }
    } catch (e: Exception) {
        Toast.makeText(mContext, "JSON Inválido", Toast.LENGTH_LONG).show()
    }
}
If the JSON is malformed, a “JSON Inválido” toast appears and nothing is written to the database. On success, a confirmation toast shows “¡Patrón <nombre> subido!”.

Sample pattern JSON

The following is a minimal 3×3 pattern to illustrate the structure:
{
  "id": "patron_001",
  "nombre": "Flor Pequeña",
  "columnas": 3,
  "filas": 3,
  "urlImagen": "https://firebasestorage.googleapis.com/v0/b/example/o/patron_001.png",
  "porcentaje": 0,
  "activo": false,
  "paleta": [
    { "id": 1, "hex": "#E63946", "nombre": "Rojo" },
    { "id": 2, "hex": "#2A9D8F", "nombre": "Verde" }
  ],
  "matriz": [
    [0, 1, 0],
    [1, 2, 1],
    [0, 1, 0]
  ]
}
In this example, color 1 (red) forms a cross shape and color 2 (green) marks the center. Cells with 0 are transparent.

Toggling pattern visibility

Each row in the admin patterns list has a toggle button. Tapping it inverts the activo flag in Realtime Database:
private fun togglePatronStatus(patron: PatronBordado) {
    val newStatus = !patron.activo
    FirebaseDatabase.getInstance().getReference("patrones").child(patron.id)
        .child("activo").setValue(newStatus)
}
  • activo = true — the pattern appears in the Bordado section for all customers.
  • activo = false — the pattern is hidden but remains in the database; no user progress is lost.
The adapter shows an Activo label in green or a Deshabilitado label in red to indicate the current state at a glance.

Deleting a pattern

Tap the delete icon on a pattern row. A confirmation dialog appears:
“¿Estás seguro de que deseas eliminar el patrón “Flor Pequeña”? Esta acción no se puede deshacer.”
Confirming calls removeValue() on the pattern’s Realtime DB node:
private fun eliminarPatron(patron: PatronBordado) {
    FirebaseDatabase.getInstance().getReference("patrones").child(patron.id)
        .removeValue()
}
Deleting a pattern is permanent — it removes the pattern node from Realtime Database immediately and cannot be undone. Note that user progress records (stored separately under the progreso node) are not automatically deleted alongside the pattern. If you only want to hide a pattern temporarily, deactivate it instead.

Pagination

The admin patterns list shows 5 patterns per page. The / buttons and the “Página X de Y” label work identically to the café menu pagination. The list is backed by a ValueEventListener on the patrones node, so new uploads and deletions appear instantly without a manual refresh.

Build docs developers (and LLMs) love