296 lines
12 KiB
Dart
296 lines
12 KiB
Dart
import 'package:crcivan/BloC/contenedores_event.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:crcivan/bars/app_bar';
|
|
import 'package:crcivan/bars/bottom_bar';
|
|
import 'package:crcivan/pages/noticias';
|
|
import 'package:crcivan/pages/pregon';
|
|
import 'package:crcivan/pages/embalses';
|
|
import 'package:crcivan/pages/secciones';
|
|
import 'package:crcivan/widgets/background_widget.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
import 'package:crcivan/pages/utils.dart';
|
|
import 'dart:math' show min; // Añadir esta importación
|
|
|
|
class MyHomePage extends StatefulWidget {
|
|
const MyHomePage({super.key, required this.title});
|
|
final String title;
|
|
|
|
@override
|
|
_MyHomePageState createState() => _MyHomePageState();
|
|
}
|
|
|
|
class _MyHomePageState extends State<MyHomePage> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
verificarPrimerInicio();
|
|
}
|
|
|
|
Future<void> verificarPrimerInicio() async {
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
bool yaMostrado = prefs.getBool('aviso_mostrado') ?? false;
|
|
|
|
if (!yaMostrado) {
|
|
Future.delayed(Duration.zero, () => mostrarAvisoLegal());
|
|
await prefs.setBool('aviso_mostrado', true);
|
|
}
|
|
}
|
|
|
|
void mostrarAvisoLegal() {
|
|
showDialog(
|
|
context: context,
|
|
barrierDismissible: false,
|
|
builder: (context) {
|
|
return AlertDialog(
|
|
title: Text("Aviso Legal"),
|
|
content: SingleChildScrollView(
|
|
child: Text(
|
|
"1. Relación con Entidades Oficiales:\n"
|
|
"Esta aplicación no está afiliada, respaldada ni oficialmente conectada con ninguna entidad gubernamental, institución o autoridad pública. "
|
|
"CR-Civán no representa a ninguna organización oficial ni gubernamental.\n\n"
|
|
"2. Datos de los Embalses:\n"
|
|
"Los datos sobre el estado de los embalses son proporcionados exclusivamente por la Confederación Hidrográfica del Ebro (CHE), "
|
|
"los cuales están a disposición de todo el mundo en (https://www.saihebro.com/homepage/estado-cuenca-ebro). "
|
|
"Los datos mostrados en esta aplicación no han sido alterados ni modificados; simplemente se presentan para mayor comodidad del usuario. "
|
|
"CR-Civán no representa ni tiene relación directa con la Confederación Hidrográfica del Ebro y, por lo tanto, no se hace responsable de la exactitud o veracidad de los datos proporcionados por la CHE.\n\n"
|
|
"3. Información Meteorológica:\n"
|
|
"La información meteorológica se proporciona a través de un enlace a la página oficial de la Agencia Estatal de Meteorología (AEMET), "
|
|
"disponible en (https://www.aemet.es). CR-Civán no se hace responsable de la exactitud de los datos proporcionados por AEMET, "
|
|
"ya que la aplicación solo redirige al usuario a su página oficial sin modificar ni representar la información de manera directa. "
|
|
"La información meteorológica se muestra en un navegador externo y no dentro de la propia aplicación, por lo que CR-Civán no se responsabiliza del contenido mostrado en dicho enlace.\n\n"
|
|
"4. Responsabilidad sobre los Datos:\n"
|
|
"Todos los datos presentados en esta aplicación provienen de fuentes externas y no han sido alterados ni modificados. "
|
|
"CR-Civán no asume ninguna responsabilidad sobre la veracidad o exactitud de los mismos.",
|
|
style: TextStyle(
|
|
fontSize: min(getResponsiveFontSize(context, 16), 18)), // Limitar a 18px
|
|
),
|
|
),
|
|
actions: [
|
|
ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor:
|
|
Color.fromARGB(255, 255, 255, 255), // Color del botón
|
|
),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
child: Text(
|
|
"LO ENTIENDO",
|
|
style: TextStyle(
|
|
fontSize: min(getResponsiveFontSize(context, 16), 18), // Limitar a 18px
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
double getResponsiveFontSize(BuildContext context, double baseFontSize) {
|
|
double screenWidth = MediaQuery.of(context).size.width;
|
|
// Ajustar el tamaño del texto en función del ancho de la pantalla
|
|
if (screenWidth > 600) {
|
|
return baseFontSize * 1.5; // Aumentar el tamaño del texto en tablets
|
|
} else {
|
|
return baseFontSize; // Mantener el tamaño del texto en teléfonos
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: const CustomAppBar(),
|
|
body: BackgroundWidget(
|
|
child: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
InkWell(
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => const NoticiasPage()),
|
|
);
|
|
},
|
|
child: SizedBox(
|
|
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, 240, 35, 35),
|
|
borderRadius: BorderRadius.circular(7.0),
|
|
),
|
|
child: Text(
|
|
'Avisos',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: min(getResponsiveFontSize(context, 26.0), 26.0),
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => const Pregon()),
|
|
);
|
|
},
|
|
child: SizedBox(
|
|
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, 230, 226, 0),
|
|
borderRadius: BorderRadius.circular(7.0),
|
|
),
|
|
child: Text(
|
|
'Pregón',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: min(getResponsiveFontSize(context, 26.0), 26.0),
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => const EmbalsesPage()),
|
|
);
|
|
},
|
|
child: SizedBox(
|
|
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, 6, 71, 169),
|
|
borderRadius: BorderRadius.circular(7.0),
|
|
),
|
|
child: Text(
|
|
'Embalses',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: min(getResponsiveFontSize(context, 26.0), 26.0),
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => const SeccionesPage()),
|
|
);
|
|
},
|
|
child: SizedBox(
|
|
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, 97, 97, 97),
|
|
borderRadius: BorderRadius.circular(7.0),
|
|
),
|
|
child: Text(
|
|
'Secciones',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: min(getResponsiveFontSize(context, 26.0), 26.0),
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
launchAemetURL();
|
|
},
|
|
child: SizedBox(
|
|
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, 255, 255, 255),
|
|
borderRadius: BorderRadius.circular(7.0),
|
|
),
|
|
child: Text(
|
|
'Tiempo',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
color: Color.fromARGB(255, 78, 169, 6),
|
|
fontSize: min(getResponsiveFontSize(context, 26.0), 26.0),
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 20),
|
|
Center(
|
|
child: InkWell(
|
|
onTap: () {
|
|
launchPrivacyPolicyURL();
|
|
},
|
|
child: Text(
|
|
'Lee nuestras políticas de privacidad',
|
|
style: TextStyle(
|
|
color: Colors.blue,
|
|
decoration: TextDecoration.underline,
|
|
fontSize: min(getResponsiveFontSize(context, 14.0), 14.0),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 10),
|
|
Center( // Añadir este widget
|
|
child: ElevatedButton(
|
|
onPressed: mostrarAvisoLegal,
|
|
child: Text(
|
|
'Aviso Legal',
|
|
style: TextStyle(
|
|
fontSize: min(getResponsiveFontSize(context, 14.0), 14.0),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
bottomNavigationBar: const CustomBottomBar(),
|
|
);
|
|
}
|
|
}
|