diff --git a/assets/logo-fondo.png b/assets/logo-fondo.png new file mode 100644 index 0000000..24815c2 Binary files /dev/null and b/assets/logo-fondo.png differ diff --git a/lib/assets/logo-fondo.png b/lib/assets/logo-fondo.png new file mode 100644 index 0000000..24815c2 Binary files /dev/null and b/lib/assets/logo-fondo.png differ diff --git a/lib/contenedores_bloc.dart b/lib/contenedores_bloc.dart new file mode 100644 index 0000000..217d7e0 --- /dev/null +++ b/lib/contenedores_bloc.dart @@ -0,0 +1,16 @@ +import 'dart:async'; +import 'package:flutter\_bloc/flutter\_bloc.dart'; + + +import 'package:flutter_project/contenedores_event.dart'; +import 'package:flutter_project/contenedores_state.dart'; + + +/* +class ContenedoresBloc extends Bloc { + ContenedoresBloc() : super(const ContenedoresState()) { + on((event, emit) { + emit(ContenedoresState(currentContenedor: event.contenedor)); + }); + } +}*/ \ No newline at end of file diff --git a/lib/contenedores_event.dart b/lib/contenedores_event.dart new file mode 100644 index 0000000..fc39f52 --- /dev/null +++ b/lib/contenedores_event.dart @@ -0,0 +1,12 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; + +// Define el estado +class MyState { + +} + +// Define el bloc +class MyBloc extends Cubit { + MyBloc() : super(MyState()); + +} diff --git a/lib/contenedores_state.dart b/lib/contenedores_state.dart new file mode 100644 index 0000000..a9c34e0 --- /dev/null +++ b/lib/contenedores_state.dart @@ -0,0 +1,8 @@ +// This class represents the state of the ContenedoresBloc +/*import 'package:flutter_project/contenedores_event.dart'; + +class ContenedoresState { + final Contenedor? currentContenedor; + + const ContenedoresState({this.currentContenedor}); +}*/ \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index b6005f2..3cc0d33 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,31 +1,15 @@ import 'package:flutter/material.dart'; -import 'dart:async'; -import 'package:url_launcher/url_launcher.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_project/contenedores_event.dart'; +import 'my_home_page.dart'; -// Definir eventos -enum Contenedor { noticias, pregon, embalses, tiempo } - -// Definir estado -class ContenedoresState { - final Contenedor? currentContenedor; - - ContenedoresState({this.currentContenedor}); -} - -// Definir Bloc -class ContenedoresBloc { - final _stateController = StreamController.broadcast(); - - Stream get state => _stateController.stream; - - void dispose() { - _stateController.close(); - } - - void selectContenedor(Contenedor contenedor) { - final newState = ContenedoresState(currentContenedor: contenedor); - _stateController.sink.add(newState); - } +void main() { + runApp( + BlocProvider( + create: (context) => MyBloc(), + child: const MyApp(), + ), + ); } class MyApp extends StatelessWidget { @@ -36,155 +20,10 @@ class MyApp extends StatelessWidget { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( - colorScheme: - ColorScheme.fromSeed(seedColor: Color.fromARGB(255, 255, 255, 255)), + colorScheme: ColorScheme.fromSeed(seedColor: Color.fromARGB(255, 0, 67, 168)), useMaterial3: true, ), - home: MyHomePage( - title: 'COMUNIDAD DE REGANTES DE CIVÁN', - contenedoresBloc: ContenedoresBloc() - ), + home: const MyHomePage(title: 'COMUNIDAD DE REGANTES DE CIVÁN'), ); } } - -class MyHomePage extends StatelessWidget { - final String title; - final ContenedoresBloc contenedoresBloc; - - MyHomePage({Key? key, required this.title, required this.contenedoresBloc}) - : super(key: key); - - Future _launchURL(String url) async { - try { - await launch(url); - } catch (e) { - // Captura de la excepción - print('An error occurred: $e'); - } -} - - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text(''), - centerTitle: true, - backgroundColor: const Color.fromARGB(255, 33, 150, 243), - leading: IconButton( - onPressed: () {}, - icon: const Icon(Icons.menu), - color: Colors.white, - ), - flexibleSpace: Container( - padding: const EdgeInsets.all(8.0), - child: Center( - child: Image.asset( - 'assets/logo-civan.png', - height: 150, - width: 150, - ), - ), - ), - ), - body: Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage('assets/agua.jpg'), - fit: BoxFit.cover, - ), - ), - child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - _buildContenedor(context, 'Noticias'), - _buildContenedor(context, 'Pregón del día'), - _buildContenedor(context, 'Embalses'), - _buildContenedor(context, 'Tiempo'), - ], - ), - ), - ), - bottomNavigationBar: BottomNavigationBar( - items: const [ - BottomNavigationBarItem( - icon: Icon(Icons.call), - label: 'Llamar', - ), - BottomNavigationBarItem( - icon: Icon(Icons.email), - label: 'Correo', - ), - ], - selectedItemColor: Colors.blue, - unselectedItemColor: Colors.blue, - backgroundColor: const Color.fromARGB(255, 255, 255, 255), - currentIndex: 0, - onTap: (int index) { - if (index == 0) { - // Abre la aplicación de teléfono con el número marcado - _launchURL('tel:+348766361379'); // Reemplazar con el número de teléfono real - } else if (index == 1) { - // Abre la aplicación de correo electrónico - _launchURL('mailto:info@example.com'); // Reemplazar con la dirección de correo electrónico real - } - }, - ), - ); -} - - Widget _buildContenedor(BuildContext context, String nombre) { - return InkWell( - onTap: () { - switch (nombre) { - case 'Noticias': - contenedoresBloc.selectContenedor(Contenedor.noticias); - print("Contenedor noticias pulsado"); - break; - case 'Pregón del día': - contenedoresBloc.selectContenedor(Contenedor.pregon); - print("Contenedor pregon pulsado"); - break; - case 'Embalses': - contenedoresBloc.selectContenedor(Contenedor.embalses); - print("Contenedor embalses pulsado"); - break; - case 'Tiempo': - contenedoresBloc.selectContenedor(Contenedor.tiempo); - print("Contenedor tiempo pulsado"); - break; - } - }, - 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: nombre == 'Noticias' - ? Colors.blue - : const Color.fromRGBO(33, 150, 243, 1), - borderRadius: BorderRadius.circular(7.0), - ), - child: Text( - nombre, - textAlign: TextAlign.center, - style: const TextStyle( - color: Colors.white, - fontSize: 32.0, - fontWeight: FontWeight.bold, - ), - ), - ), - ), - ), - ); - } -} - -void main() { - runApp(const MyApp()); -} diff --git a/lib/my_home_page.dart b/lib/my_home_page.dart new file mode 100644 index 0000000..1a1af4a --- /dev/null +++ b/lib/my_home_page.dart @@ -0,0 +1,152 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.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: AppBar( + title: const Text(''), + centerTitle: true, + backgroundColor: Color.fromARGB(255, 194, 218, 230), + flexibleSpace: Container( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Padding( + padding: const EdgeInsets.only(top: 30.0), // Margen superior + child: Image.asset( + 'assets/logo-civan.png', + height: 150, + width: 150, + ), + ), + ), + ), +), + + + body: Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/logo-fondo.png'), + fit: BoxFit.cover, + ), + ), + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + InkWell( + onTap: () { + }, + 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: Color.fromARGB(255, 43, 102, 150), + 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: () { + }, + 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: Color.fromARGB(255, 43, 102, 150), + 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: () { + }, + 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: Color.fromARGB(255, 43, 102, 150), + 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: () { + }, + 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: Color.fromARGB(255, 43, 102, 150), + borderRadius: BorderRadius.circular(7.0), + ), + child: const Text( + 'Tiempo', + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontSize: 32.0, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index e35a375..4325320 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -9,6 +9,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" + bloc: + dependency: transitive + description: + name: bloc + sha256: "6f1b87b6eca9041d5672b6e29273cd1594db48ebb66fd2471066e9f3c3a516bd" + url: "https://pub.dev" + source: hosted + version: "7.2.1" boolean_selector: dependency: transitive description: @@ -62,6 +70,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_bloc: + dependency: "direct main" + description: + name: flutter_bloc + sha256: cdd1351ced09eeb46cfa7946e095b7679344af927415ca9cd972928fa6d5b23f + url: "https://pub.dev" + source: hosted + version: "7.3.3" flutter_lints: dependency: "direct dev" description: @@ -136,6 +152,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.11.0" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" + source: hosted + version: "1.0.0" path: dependency: transitive description: @@ -152,6 +176,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" + provider: + dependency: transitive + description: + name: provider + sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c + url: "https://pub.dev" + source: hosted + version: "6.1.2" sky_engine: dependency: transitive description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index d36c6a4..8cca170 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -31,6 +31,7 @@ dependencies: flutter: sdk: flutter url_launcher: ^6.0.12 + flutter_bloc: ^7.0.0 # The following adds the Cupertino Icons font to your application. @@ -63,6 +64,7 @@ flutter: assets: - assets/logo-civan.png - assets/agua.jpg + - assets/logo-fondo.png # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see