diff --git a/lib/pages/embalses b/lib/pages/embalses index 11fce55..9090df0 100644 --- a/lib/pages/embalses +++ b/lib/pages/embalses @@ -13,6 +13,8 @@ class EmbalsesPage extends StatefulWidget { class _EmbalsesPageState extends State { List> embalsesData = []; + List descripciones = ['Cota (m)', 'Volumen (Hm3)', 'Entrada (l/s)', 'Salida (l/s)']; + @override void initState() { super.initState(); @@ -96,68 +98,69 @@ List> embalsesData = []; ), ), Padding( - padding: const EdgeInsets.all(8.0), - child: ListView.builder( - itemCount: embalsesData.length, - itemBuilder: (context, index) { - final embalseData = embalsesData[index]; - final nombreEmbalse = embalseData['nombre']; - final listaElementos = embalseData['elementos']; + padding: const EdgeInsets.all(8.0), + child: ListView.builder( + itemCount: embalsesData.length, + itemBuilder: (context, index) { + final embalseData = embalsesData[index]; + final nombreEmbalse = embalseData['nombre']; + final listaElementos = embalseData['elementos']; - return Padding( - padding: const EdgeInsets.only(bottom: 8.0), - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10.0), - ), - child: Column( - children: [ - Row( - children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - nombreEmbalse!, - style: TextStyle( - fontWeight: FontWeight.bold, - ), - ), + return Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10.0), ), - ), - ], - ), - Row( - children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: listaElementos.map((elemento) { - return Text( - elemento, - style: TextStyle( - fontWeight: FontWeight.normal, + child: Column( + children: [ + Row( + children: [ + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + nombreEmbalse!, + style: TextStyle( + fontWeight: FontWeight.bold, + ), + ), + ), ), - ); - }).toList(), - ), + ], + ), + Row( + children: [ + Expanded( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: List.generate( + listaElementos.length, + (index) => Text( + '${descripciones[index]}: ${listaElementos[index]}', + style: TextStyle( + fontWeight: FontWeight.normal, + ), + ), + ), + ), + ), + ), + ], + ), + ], ), ), - ], - ), - ], + ); + }, + ), ), - ), - ); - }, - ),), - ], -), - + ], + ), bottomNavigationBar: const CustomBottomBar(), ); } -} +} \ No newline at end of file diff --git a/lib/pages/noticias b/lib/pages/noticias index cfa55bb..4535bfc 100644 --- a/lib/pages/noticias +++ b/lib/pages/noticias @@ -13,6 +13,7 @@ class NoticiasPage extends StatefulWidget { class _NoticiasPageState extends State { List noticiasData = []; + List titulos = []; @override void initState() { @@ -25,9 +26,11 @@ class _NoticiasPageState extends State { if (response.statusCode == 200) { var document = htmlParser.parse(response.body); var dataElements = document.querySelectorAll('html > body > div > center > table > tbody > tr > td > div > center > table > tbody > tr > td > table > tbody > tr > td > font'); + var tituloElements = document.querySelectorAll('html > body > div > center > table > tbody > tr > td > div > center > table > tbody > tr > td > table > tbody > tr > td > b > a'); setState(() { noticiasData = dataElements.map((element) => element.text.trim()).toList(); + titulos = tituloElements.map((element) => element.text.trim()).toList(); }); } else { throw Exception('Failed to load noticias data'); @@ -46,17 +49,33 @@ class _NoticiasPageState extends State { fit: BoxFit.cover, ), ), - ListView.builder( - itemCount: noticiasData.length, - itemBuilder: (context, index) { - return ListTile( - title: Text(noticiasData[index]), - ); - }, + ListView.builder( + itemCount: noticiasData.length, + itemBuilder: (context, index) { + if (index < titulos.length) { + return Column( + children: [ + ListTile( + title: Text(titulos[index], style: TextStyle(fontWeight: FontWeight.bold)), + ), + ListTile( + title: Text(noticiasData[index]), ), + ], + ); + } else { + // Si el índice está fuera del rango de titulos, muestra un ListTile sin título + return ListTile( + subtitle: Text(noticiasData[index]), + ); + } + }, +), + + ], ), - bottomNavigationBar: const CustomBottomBar(), + bottomNavigationBar: const CustomBottomBar(), ); } }