aplicacion terminada, clase widget creada y separacion bloc

This commit is contained in:
2024-05-21 16:52:01 +02:00
parent df5651feac
commit 20a4cb7ab2
7 changed files with 248 additions and 275 deletions

View File

@ -4,6 +4,9 @@ import 'package:html/parser.dart' as htmlParser;
import 'package:html/dom.dart' as htmlDom;
import 'package:flutter_project/bars/app_bar';
import 'package:flutter_project/bars/bottom_bar';
import 'package:flutter_project/widgets/background_widget.dart';
class Pregon extends StatefulWidget {
const Pregon({Key? key}) : super(key: key);
@ -35,41 +38,32 @@ class _PregonState extends State<Pregon> {
});
// Agregar textos de los elementos <p> a la lista, evitando los que contienen solo espacios
for (var elemento in elementosParrafos) {
final texto = elemento.text.trim(); // Eliminar espacios al inicio y al final del texto
if (texto.isNotEmpty) {
setState(() {
datos.add(texto);
});
for (var elemento in elementosParrafos) {
final texto = elemento.text.trim(); // Eliminar espacios al inicio y al final del texto
if (texto.isNotEmpty) {
setState(() {
datos.add(texto);
});
}
}
}
} else {
throw Exception('Error al cargar los datos');
}
}
@override
Widget build(BuildContext context) {
// Lista de nombres de los meses del año
final meses = [
'enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio',
'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'
];
@override
Widget build(BuildContext context) {
// Lista de nombres de los meses del año
final meses = [
'enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio',
'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'
];
return Scaffold(
appBar: const CustomAppBar(),
body: Stack(
children: [
// Fondo con la imagen
Positioned.fill(
child: Image(
image: AssetImage('assets/logo-fondo-verde.png'),
fit: BoxFit.cover,
),
),
// Contenedor para los párrafos
Center(
return Scaffold(
appBar: const CustomAppBar(),
body: BackgroundWidget(
child: Center(
child: ListView.builder(
itemCount: datos.length,
itemBuilder: (context, index) {
@ -78,38 +72,36 @@ Widget build(BuildContext context) {
return Column(
children: [
if (hasMes)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Divider(color: Colors.green, thickness: 3.0), // Divider antes del párrafo
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Divider(color: Colors.green, 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), fontWeight : FontWeight.bold, fontSize : 22.0
),
? 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), fontWeight : FontWeight.bold, fontSize : 22.0
),
),
)
: SizedBox.shrink(),
if (hasMes)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 100.0),
child: Divider(color: Colors.green, thickness: 1.0), // Divider después del párrafo
),
],
);
},
),
)
: SizedBox.shrink(),
if (hasMes)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 100.0),
child: Divider(color: Colors.green, thickness: 1.0), // Divider después del párrafo
),
],
);
},
shrinkWrap: true, // Ajusta el tamaño de ListView al contenido
),
),
],
),
bottomNavigationBar: const CustomBottomBar(),
);
}
),
bottomNavigationBar: const CustomBottomBar(),
);
}
}