diff --git a/assets/logo-fondo-verde.png b/assets/logo-fondo-verde.png new file mode 100644 index 0000000..6daf7ed Binary files /dev/null and b/assets/logo-fondo-verde.png differ diff --git a/lib/BloC/contenedores_event.dart b/lib/BloC/contenedores_event.dart index 0edc2a5..7040038 100644 --- a/lib/BloC/contenedores_event.dart +++ b/lib/BloC/contenedores_event.dart @@ -37,12 +37,16 @@ Future> obtenerDatos(String url) async { } Future launchAemetURL() async { - const urlString = 'https://www.aemet.es/es/eltiempo/prediccion/municipios/caspe-id50074'; - final url = Uri.parse(urlString); + const urlString = 'https://www.aemet.es/es/eltiempo/prediccion/municipios/caspe-id50074'; + final url = Uri.parse(urlString); - if (await canLaunchUrl(url)) { - await launchUrl(url); - } else { - throw 'Could not launch $urlString'; - } + try { + if (await canLaunch(urlString)) { + await launch(urlString); + } else { + throw 'Could not launch $urlString'; + } + } catch (e) { + throw Exception('Error al lanzar la URL de Aemet: $e'); + } } \ No newline at end of file diff --git a/lib/pages/embalses b/lib/pages/embalses index 9090df0..dce9f46 100644 --- a/lib/pages/embalses +++ b/lib/pages/embalses @@ -110,7 +110,7 @@ List> embalsesData = []; padding: const EdgeInsets.only(bottom: 8.0), child: Container( decoration: BoxDecoration( - color: Colors.white, + color: Colors.white.withOpacity(0.5), borderRadius: BorderRadius.circular(10.0), ), child: Column( diff --git a/lib/pages/my_home_page.dart b/lib/pages/my_home_page.dart index 6760cd9..cbaf35d 100644 --- a/lib/pages/my_home_page.dart +++ b/lib/pages/my_home_page.dart @@ -20,7 +20,7 @@ class MyHomePage extends StatelessWidget { decoration: const BoxDecoration( image: DecorationImage( - image: AssetImage('assets/logo-fondo.png'), + image: AssetImage('assets/logo-fondo-verde.png'), fit: BoxFit.cover, ), @@ -35,21 +35,21 @@ class MyHomePage extends StatelessWidget { MaterialPageRoute(builder: (context) => const NoticiasPage()), );}, child: SizedBox( - width: 300.0, + width: 250.0, child: Padding( padding: const EdgeInsets.only(bottom: 20.0), child: Container( padding: const EdgeInsets.all(8.0), decoration: BoxDecoration( - color: Color.fromARGB(255, 43, 102, 150), + color: Color.fromARGB(255, 78, 169, 6), borderRadius: BorderRadius.circular(7.0), ), child: const Text( 'Noticias', textAlign: TextAlign.center, style: TextStyle( - color: Colors.white, - fontSize: 32.0, + color: Color.fromARGB(255, 255, 255, 255), + fontSize: 27.0, fontWeight: FontWeight.bold, ), ), @@ -65,13 +65,13 @@ class MyHomePage extends StatelessWidget { ); }, child: SizedBox( - width: 300.0, + width: 250.0, child: Padding( padding: const EdgeInsets.only(bottom: 20.0), child: Container( padding: const EdgeInsets.all(8.0), decoration: BoxDecoration( - color: Color.fromARGB(255, 43, 102, 150), + color: Color.fromARGB(255, 78, 169, 6), borderRadius: BorderRadius.circular(7.0), ), child: const Text( @@ -79,7 +79,7 @@ class MyHomePage extends StatelessWidget { textAlign: TextAlign.center, style: TextStyle( color: Colors.white, - fontSize: 32.0, + fontSize: 27.0, fontWeight: FontWeight.bold, ), ), @@ -95,13 +95,13 @@ class MyHomePage extends StatelessWidget { ); }, child: SizedBox( - width: 300.0, + width: 250.0, child: Padding( padding: const EdgeInsets.only(bottom: 20.0), child: Container( padding: const EdgeInsets.all(8.0), decoration: BoxDecoration( - color: Color.fromARGB(255, 43, 102, 150), + color: Color.fromARGB(255, 78, 169, 6), borderRadius: BorderRadius.circular(7.0), ), child: const Text( @@ -109,7 +109,7 @@ class MyHomePage extends StatelessWidget { textAlign: TextAlign.center, style: TextStyle( color: Colors.white, - fontSize: 32.0, + fontSize: 27.0, fontWeight: FontWeight.bold, ), ), @@ -122,13 +122,13 @@ class MyHomePage extends StatelessWidget { launchAemetURL(); }, child: SizedBox( - width: 300.0, + width: 250.0, child: Padding( padding: const EdgeInsets.only(bottom: 20.0), child: Container( padding: const EdgeInsets.all(8.0), decoration: BoxDecoration( - color: Color.fromARGB(255, 43, 102, 150), + color: Color.fromARGB(255, 78, 169, 6), borderRadius: BorderRadius.circular(7.0), ), child: const Text( @@ -136,7 +136,7 @@ class MyHomePage extends StatelessWidget { textAlign: TextAlign.center, style: TextStyle( color: Colors.white, - fontSize: 32.0, + fontSize: 27.0, fontWeight: FontWeight.bold, ), ), diff --git a/lib/pages/noticias b/lib/pages/noticias index 4535bfc..7bc0761 100644 --- a/lib/pages/noticias +++ b/lib/pages/noticias @@ -12,8 +12,7 @@ class NoticiasPage extends StatefulWidget { } class _NoticiasPageState extends State { - List noticiasData = []; - List titulos = []; + Map> noticiasPorTitulo = {}; @override void initState() { @@ -28,14 +27,44 @@ class _NoticiasPageState extends State { 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(); - }); + for (int i = 0; i < tituloElements.length; i++) { + String titulo = tituloElements[i].text.trim(); + String noticia = dataElements[i].text.trim(); + + if (!noticiasPorTitulo.containsKey(titulo)) { + noticiasPorTitulo[titulo] = []; + } + noticiasPorTitulo[titulo]?.add(noticia); + } + + setState(() {}); } else { - throw Exception('Failed to load noticias data'); + throw Exception('fallo al cargar noticias'); } } + //Función para desplegar noticias desde los contenedores + + /*Future obtenerDatosNoticias() async { + var linkElements = document.querySelectorAll('html > body > div > center > table > tbody > tr > td > div > center > table > tbody > tr > td > table > tbody > tr > td > a'); + String? link = linkElements[i].attributes['href']; + if (response.statusCode == 200) { + + for (int i = 0; i < tituloElements.length; i++) { + String titulo = tituloElements[i].text.trim(); + String noticia = dataElements[i].text.trim(); + + if (!noticiasPorTitulo.containsKey(titulo)) { + noticiasPorTitulo[titulo] = []; + } + noticiasPorTitulo[titulo]?.add(noticia); + } + + setState(() {}); + } else { + throw Exception('fallo al cargar noticias'); + } + }*/ + @override Widget build(BuildContext context) { @@ -49,30 +78,31 @@ class _NoticiasPageState extends State { fit: BoxFit.cover, ), ), - 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]), - ); - } - }, -), - + ListView.builder( + itemCount: noticiasPorTitulo.length, + itemBuilder: (context, index) { + String titulo = noticiasPorTitulo.keys.elementAt(index); + List? noticias = noticiasPorTitulo[titulo]; + return ExpansionTile( + title: Text( + titulo, + style: TextStyle(fontWeight: FontWeight.bold), + ), + children: noticias != null + ? noticias.map((noticia) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + noticia, + style: TextStyle(fontSize: 16.0), + ), + ); + }).toList() + : [], + ); + }, + ), ], ), bottomNavigationBar: const CustomBottomBar(), diff --git a/lib/pages/pregon b/lib/pages/pregon index fdfa0d7..6a4834f 100644 --- a/lib/pages/pregon +++ b/lib/pages/pregon @@ -77,23 +77,32 @@ Widget build(BuildContext context) { final hasMes = meses.any((mes) => datos[index].toLowerCase().contains(mes)); return Column( children: [ - if (hasMes) Divider(color: Colors.blue, thickness: 3.0), // Divider antes del párrafo + if (hasMes) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 10.0), // Add padding to the divider + child: Divider(color: Colors.blue, thickness: 3.0), // Divider antes del párrafo + ), hasText ? ListTile( title: Center( child: Text( datos[index], + textAlign: TextAlign.center, style: TextStyle( - color: hasMes ? Color.fromARGB(255, 0, 0, 0) : Color.fromARGB(255, 0, 0, 0), + color: hasMes ? Color.fromARGB(255, 0, 0, 0) : Color.fromARGB(255, 0, 0, 0), fontWeight : FontWeight.bold ), ), ), ) : SizedBox.shrink(), - if (hasMes) Divider(color: Colors.blue, thickness: 1.0), // Divider después del párrafo - ], - ); - }, + if (hasMes) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 100.0), // Add padding to the divider + child: Divider(color: Colors.blue, thickness: 1.0), // Divider después del párrafo + ), + ], + ); + }, shrinkWrap: true, // Ajusta el tamaño de ListView al contenido ), ), diff --git a/pubspec.yaml b/pubspec.yaml index b12c669..b410027 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -73,6 +73,7 @@ flutter: - assets/logo-fondo.png - assets/logo-sin-texto.png - assets/logo-sin-texto.svg + - assets/logo-fondo-verde.png # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see