embalses listos y notificaciones con titulo. Faltan mejoras
This commit is contained in:
@ -13,6 +13,8 @@ class EmbalsesPage extends StatefulWidget {
|
|||||||
|
|
||||||
class _EmbalsesPageState extends State<EmbalsesPage> {
|
class _EmbalsesPageState extends State<EmbalsesPage> {
|
||||||
List<Map<String, dynamic>> embalsesData = [];
|
List<Map<String, dynamic>> embalsesData = [];
|
||||||
|
List<String> descripciones = ['Cota (m)', 'Volumen (Hm3)', 'Entrada (l/s)', 'Salida (l/s)'];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -96,67 +98,68 @@ List<Map<String, dynamic>> embalsesData = [];
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemCount: embalsesData.length,
|
itemCount: embalsesData.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final embalseData = embalsesData[index];
|
final embalseData = embalsesData[index];
|
||||||
final nombreEmbalse = embalseData['nombre'];
|
final nombreEmbalse = embalseData['nombre'];
|
||||||
final listaElementos = embalseData['elementos'];
|
final listaElementos = embalseData['elementos'];
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 8.0),
|
padding: const EdgeInsets.only(bottom: 8.0),
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(10.0),
|
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
child: Column(
|
||||||
],
|
children: [
|
||||||
),
|
Row(
|
||||||
Row(
|
children: [
|
||||||
children: [
|
Expanded(
|
||||||
Expanded(
|
child: Padding(
|
||||||
child: Padding(
|
padding: const EdgeInsets.all(8.0),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
child: Text(
|
||||||
child: Column(
|
nombreEmbalse!,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
style: TextStyle(
|
||||||
children: listaElementos.map<Widget>((elemento) {
|
fontWeight: FontWeight.bold,
|
||||||
return Text(
|
),
|
||||||
elemento,
|
),
|
||||||
style: TextStyle(
|
),
|
||||||
fontWeight: FontWeight.normal,
|
|
||||||
),
|
),
|
||||||
);
|
],
|
||||||
}).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(),
|
bottomNavigationBar: const CustomBottomBar(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ class NoticiasPage extends StatefulWidget {
|
|||||||
|
|
||||||
class _NoticiasPageState extends State<NoticiasPage> {
|
class _NoticiasPageState extends State<NoticiasPage> {
|
||||||
List<String> noticiasData = [];
|
List<String> noticiasData = [];
|
||||||
|
List<String> titulos = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -25,9 +26,11 @@ class _NoticiasPageState extends State<NoticiasPage> {
|
|||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
var document = htmlParser.parse(response.body);
|
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 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(() {
|
setState(() {
|
||||||
noticiasData = dataElements.map((element) => element.text.trim()).toList();
|
noticiasData = dataElements.map((element) => element.text.trim()).toList();
|
||||||
|
titulos = tituloElements.map((element) => element.text.trim()).toList();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
throw Exception('Failed to load noticias data');
|
throw Exception('Failed to load noticias data');
|
||||||
@ -46,17 +49,33 @@ class _NoticiasPageState extends State<NoticiasPage> {
|
|||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
ListView.builder(
|
ListView.builder(
|
||||||
itemCount: noticiasData.length,
|
itemCount: noticiasData.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return ListTile(
|
if (index < titulos.length) {
|
||||||
title: Text(noticiasData[index]),
|
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(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user