import 'package:flutter/material.dart';
import 'package:flutter_project/bars/app_bar';
import 'package:flutter_project/bars/bottom_bar';
import 'package:flutter_project/BloC/contenedores_event.dart';
import 'package:flutter_project/pages/noticias';
import 'package:flutter_project/pages/pregon';
import 'package:flutter_project/pages/embalses';
import 'package:flutter_project/widgets/background_widget.dart'; 

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: const CustomAppBar(), //Barra superior personalizada
      body: BackgroundWidget( //Widget fondo del fichero BackgroundWidget
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              InkWell(
                onTap: () { Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) => const NoticiasPage()),
                );},
                child: SizedBox( //Botón Noticias
                  width: 300.0,
                  child: Padding(
                    padding: const EdgeInsets.only(bottom: 20.0),
                    child: Container(
                      padding: const EdgeInsets.all(8.0),
                      decoration: BoxDecoration(
                        color: const 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,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ),
                  ),
                ),
              ),
              InkWell(
                onTap: () {
                  Navigator.push(
                    context,
                    MaterialPageRoute(builder: (context) => const Pregon()),
                  );
                },
                child: SizedBox(//Botón Pregón
                  width: 300.0,
                  child: Padding(
                    padding: const EdgeInsets.only(bottom: 20.0),
                    child: Container(
                      padding: const EdgeInsets.all(8.0),
                      decoration: BoxDecoration(
                        color: const Color.fromARGB(255, 78, 169, 6),
                        borderRadius: BorderRadius.circular(7.0),
                      ),
                      child: const Text(
                        'Pregón',
                        textAlign: TextAlign.center,
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 32.0,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ),
                  ),
                ),
              ),
              InkWell(
                onTap: () {
                  Navigator.push(
                    context,
                    MaterialPageRoute(builder: (context) => const EmbalsesPage()),
                  );
                },
                child: SizedBox( //Botón Embalses
                  width: 300.0,
                  child: Padding(
                    padding: const EdgeInsets.only(bottom: 20.0),
                    child: Container(
                      padding: const EdgeInsets.all(8.0),
                      decoration: BoxDecoration(
                        color: const Color.fromARGB(255, 78, 169, 6),
                        borderRadius: BorderRadius.circular(7.0),
                      ),
                      child: const Text(
                        'Embalses',
                        textAlign: TextAlign.center,
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 32.0,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ),
                  ),
                ),
              ),
              InkWell(
                onTap: () {
                  launchAemetURL();//Función a link externo
                },
                child: SizedBox(//Botón Tiempo
                  width: 300.0,
                  child: Padding(
                    padding: const EdgeInsets.only(bottom: 20.0),
                    child: Container(
                      padding: const EdgeInsets.all(8.0),
                      decoration: BoxDecoration(
                        color: const Color.fromARGB(255, 78, 169, 6),
                        borderRadius: BorderRadius.circular(7.0),
                      ),
                      child: const Text(
                        'Tiempo',
                        textAlign: TextAlign.center,
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 32.0,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
      bottomNavigationBar: const CustomBottomBar(),//Barra inferior personalizada
    );
  }
}
