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.

The Café fragment is the heart of the ordering experience in La Casa del Bordadito. The dedicated Café tab (FragmentCafe) attaches a real-time Firestore snapshot listener filtered to isActive = true, so the menu always reflects what is actually available at the café today. Each item can be viewed either as a compact card in a two-column grid or as a detailed row in a scrollable list, and a toggle button lets you switch between those modes at any time.

Cafe data model

Every document in the cafes Firestore collection maps to the following Kotlin data class:
data class Cafe(
    var id: String = "",
    var nombre: String = "",
    var descripcion: String = "",
    var imagenUrl: String = "",
    var categoria: String = "",
    var tamano: Map<String, Double> = mapOf(),

    @get:PropertyName("isActive")
    @set:PropertyName("isActive")
    var isActive: Boolean = false
)
FieldTypeDescription
idStringFirestore document ID, assigned after fetch
nombreStringDisplay name of the item
descripcionStringShort description shown in list view
imagenUrlStringRemote image URL loaded via Coil
categoriaStringCategory label (e.g. “Bebida caliente”)
tamanoMap<String, Double>Size name → price in MXN
isActiveBooleanVisibility flag; only true items appear in the menu

Sample Firestore document

{
  "nombre": "Café de Olla",
  "descripcion": "Café tradicional mexicano con canela y piloncillo.",
  "imagenUrl": "https://firebasestorage.googleapis.com/.../cafe_de_olla.jpg",
  "categoria": "Bebida caliente",
  "tamano": {
    "Pequeño": 35.0,
    "Mediano": 45.0,
    "Grande": 55.0
  },
  "isActive": true
}

View modes

The fragment ships two adapters that are swapped live by a MaterialButtonToggleGroup:

Grid view

Powered by CafeInicioAdapter with a two-column GridLayoutManager. Each card shows the item image, name, and a quick add-to-cart button (btnAddCafe). Tapping the card itself opens DetalleCafeActivity.

List view

Powered by CafeAdapter with a LinearLayoutManager. Each row shows the image, name, and full description. Tapping the row opens DetalleCafeActivity.
The default view when the fragment opens is grid.

Filtering active items

Both fragments load only items where isActive equals true. The dedicated Café tab (FragmentCafe) uses a snapshot listener for live updates:
db.collection("cafes")
    .whereEqualTo("isActive", true)
    .addSnapshotListener { snapshot, error -> ... }
This means any change an admin makes to an item’s isActive flag is reflected on the customer’s screen in FragmentCafe without a manual refresh. The home screen (FragmentInicio) performs a one-time .get() fetch on load instead and will reflect admin changes on the next visit.

Quick add from the home screen

FragmentInicio also uses CafeInicioAdapter in its café section. Tapping the + button on any card from the home screen calls anadirAlCarrito, which picks the first size in the tamano map as the default and writes a CarritoItem to carritos/{uid}/items in Firestore immediately — no need to visit DetalleCafeActivity first.

Size selection in the detail screen

Opening an item navigates to DetalleCafeActivity, which loads the full Cafe document from Firestore using the cafeId passed as an intent extra. The tamano map is iterated to build a RadioGroup where each RadioButton stores a Pair<String, Double> (size name, price) as its tag:
for ((tamano, precio) in cafe.tamano) {
    val radio = RadioButton(this)
    radio.text = "$tamano - $precio MXN"
    radio.tag = Pair(tamano, precio)
    radioPrecios.addView(radio)
}
The customer selects a size, then taps Agregar. The app constructs a CarritoItem with the chosen tamano and precio, writes it to carritos/{uid}/items/{cafeId}_{tamano}, and navigates straight to CarritoActivity.
Items with isActive = false are hidden from all customer-facing views — the menu query and the home screen quick-add grid both filter them out. The documents remain in Firestore so an admin can reactivate them at any time without re-entering the data.

Build docs developers (and LLMs) love