Ultima version para Google Play, cambios en politicas y colores. Nuevo aviso legal

This commit is contained in:
2025-03-12 09:54:39 +01:00
parent 0d61ca6d01
commit 6c062682f6
13 changed files with 624 additions and 125 deletions

View File

@ -28,4 +28,76 @@ class DataService {
throw Exception('Error al obtener datos');
}
}
Future<String> obtenerFechaComunicacionEmbalses() async {
final response = await http
.get(Uri.parse('https://crcivan.asociacionador.es/contenedores.html'));
if (response.statusCode == 200) {
final document = htmlParser.parse(response.body);
final dateElement =
document.querySelector('span[style="font-size: 12pt;"]');
final communicationDate = dateElement != null
? dateElement.text.replaceAll(':', '').trim()
: 'Fecha no encontrada';
return communicationDate;
} else {
throw Exception('Error al obtener la fecha de comunicación');
}
}
Future<Map<String, dynamic>> obtenerDatosSecciones() async {
final response = await http.get(Uri.parse('https://crcivan.asociacionador.es/secciones.html'));
if (response.statusCode == 200) {
final document = htmlParser.parse(response.body);
final rows = document.querySelectorAll('table[style="height: 1202px; font-size: 13px;"] tbody tr');
List<Map<String, dynamic>> seccionesData = [];
String? currentSection;
String? currentGuardInfo;
List<Map<String, String>> currentSectionData = [];
// Extraer la fecha de la comunicación
final dateRegex = RegExp(r'\d{2}/\d{2}/\d{4}');
final dateMatch = dateRegex.firstMatch(document.body!.text);
final communicationDate = dateMatch != null ? dateMatch.group(0) : 'Fecha no encontrada';
for (var row in rows) {
var cells = row.querySelectorAll('td');
if (cells.length == 2) {
var sectionElement = cells[1].querySelector('strong');
if (sectionElement != null && sectionElement.text.contains('SECCIÓN')) {
if (currentSection != null) {
seccionesData.add({
'section': currentSection,
'guardInfo': currentGuardInfo,
'data': currentSectionData,
});
}
currentSection = sectionElement.text.trim();
currentGuardInfo = cells[1].querySelector('span[style="text-decoration: underline;"]')?.text.trim();
currentSectionData = [];
} else {
currentSectionData.add({
'date': cells[0].text.trim(),
'location': cells[1].text.trim(),
});
}
}
}
if (currentSection != null) {
seccionesData.add({
'section': currentSection,
'guardInfo': currentGuardInfo,
'data': currentSectionData,
});
}
return {
'communicationDate': communicationDate,
'seccionesData': seccionesData,
};
} else {
throw Exception('Error al cargar los datos de secciones');
}
}
}