agregado patron bloc y barra de contacto
This commit is contained in:
308
lib/main.dart
308
lib/main.dart
@ -1,7 +1,31 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'dart:async';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
void main() {
|
// Definir eventos
|
||||||
runApp(const MyApp());
|
enum Contenedor { noticias, pregon, embalses, tiempo }
|
||||||
|
|
||||||
|
// Definir estado
|
||||||
|
class ContenedoresState {
|
||||||
|
final Contenedor? currentContenedor;
|
||||||
|
|
||||||
|
ContenedoresState({this.currentContenedor});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Definir Bloc
|
||||||
|
class ContenedoresBloc {
|
||||||
|
final _stateController = StreamController<ContenedoresState>.broadcast();
|
||||||
|
|
||||||
|
Stream<ContenedoresState> get state => _stateController.stream;
|
||||||
|
|
||||||
|
void dispose() {
|
||||||
|
_stateController.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void selectContenedor(Contenedor contenedor) {
|
||||||
|
final newState = ContenedoresState(currentContenedor: contenedor);
|
||||||
|
_stateController.sink.add(newState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
@ -13,174 +37,154 @@ class MyApp extends StatelessWidget {
|
|||||||
title: 'Flutter Demo',
|
title: 'Flutter Demo',
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
colorScheme:
|
colorScheme:
|
||||||
ColorScheme.fromSeed(seedColor: Color.fromARGB(255, 0, 67, 168)),
|
ColorScheme.fromSeed(seedColor: Color.fromARGB(255, 255, 255, 255)),
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
),
|
),
|
||||||
home: const MyHomePage(title: 'COMUNIDAD DE REGANTES DE CIVÁN'),
|
home: MyHomePage(
|
||||||
|
title: 'COMUNIDAD DE REGANTES DE CIVÁN',
|
||||||
|
contenedoresBloc: ContenedoresBloc()
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
class MyHomePage extends StatelessWidget {
|
||||||
const MyHomePage({Key? key, required this.title}) : super(key: key);
|
|
||||||
final String title;
|
final String title;
|
||||||
|
final ContenedoresBloc contenedoresBloc;
|
||||||
|
|
||||||
@override
|
MyHomePage({Key? key, required this.title, required this.contenedoresBloc})
|
||||||
State<MyHomePage> createState() => _MyHomePageState();
|
: super(key: key);
|
||||||
|
|
||||||
|
Future<void> _launchURL(String url) async {
|
||||||
|
try {
|
||||||
|
await launch(url);
|
||||||
|
} catch (e) {
|
||||||
|
// Captura de la excepción
|
||||||
|
print('An error occurred: $e');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text(''),
|
title: const Text(''),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
backgroundColor: const Color.fromARGB(255, 33, 150, 243),
|
backgroundColor: const Color.fromARGB(255, 33, 150, 243),
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
icon: const Icon(Icons.menu),
|
icon: const Icon(Icons.menu),
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
flexibleSpace: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Center(
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/logo-civan.png',
|
||||||
|
height: 150,
|
||||||
|
width: 150,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
flexibleSpace: Container(
|
),
|
||||||
|
),
|
||||||
|
body: Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: AssetImage('assets/agua.jpg'),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
_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),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Center(
|
decoration: BoxDecoration(
|
||||||
child: Image.asset(
|
color: nombre == 'Noticias'
|
||||||
'assets/logo-civan.png',
|
? Colors.blue
|
||||||
height: 200, // Cambia la altura según sea necesario
|
: const Color.fromRGBO(33, 150, 243, 1),
|
||||||
width: 200, // Cambia el ancho según sea necesario
|
borderRadius: BorderRadius.circular(7.0),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
nombre,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 32.0,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: Container(
|
),
|
||||||
decoration: BoxDecoration(
|
);
|
||||||
image: DecorationImage(
|
|
||||||
image:
|
|
||||||
AssetImage('assets/agua.jpg'), // Ruta de la imagen de fondo
|
|
||||||
fit: BoxFit
|
|
||||||
.cover, // Ajusta la imagen para que cubra todo el contenedor
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
child: Center(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
InkWell(
|
|
||||||
onTap: () {
|
|
||||||
print('Contenedor noticias clickeado');
|
|
||||||
},
|
|
||||||
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: Colors.blue,
|
|
||||||
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: () {
|
|
||||||
print('Contenedor pregón clickeado');
|
|
||||||
},
|
|
||||||
customBorder: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(100)),
|
|
||||||
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: Colors.blue,
|
|
||||||
borderRadius: BorderRadius.circular(7.0),
|
|
||||||
),
|
|
||||||
child: const Text(
|
|
||||||
'Pregón del día',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 32.0,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
InkWell(
|
|
||||||
onTap: () {
|
|
||||||
print('Contenedor embalses clickeado');
|
|
||||||
},
|
|
||||||
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.fromRGBO(33, 150, 243, 1),
|
|
||||||
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: () {
|
|
||||||
print('Contenedor tiempo clickeado');
|
|
||||||
},
|
|
||||||
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.fromRGBO(33, 150, 243, 1),
|
|
||||||
borderRadius: BorderRadius.circular(7.0),
|
|
||||||
),
|
|
||||||
child: const Text(
|
|
||||||
'Tiempo',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 32.0,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
runApp(const MyApp());
|
||||||
|
}
|
||||||
|
|||||||
@ -6,6 +6,10 @@
|
|||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
|
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||||
|
|
||||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||||
|
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
||||||
|
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
||||||
|
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
|
url_launcher_linux
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
|
|||||||
@ -5,6 +5,8 @@
|
|||||||
import FlutterMacOS
|
import FlutterMacOS
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
import url_launcher_macos
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
|
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||||
}
|
}
|
||||||
|
|||||||
86
pubspec.lock
86
pubspec.lock
@ -75,6 +75,11 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_web_plugins:
|
||||||
|
dependency: transitive
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
leak_tracker:
|
leak_tracker:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -139,6 +144,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.0"
|
version: "1.9.0"
|
||||||
|
plugin_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: plugin_platform_interface
|
||||||
|
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.8"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -192,6 +205,70 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.1"
|
version: "0.6.1"
|
||||||
|
url_launcher:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: url_launcher
|
||||||
|
sha256: "6ce1e04375be4eed30548f10a315826fd933c1e493206eab82eed01f438c8d2e"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.2.6"
|
||||||
|
url_launcher_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: url_launcher_android
|
||||||
|
sha256: "360a6ed2027f18b73c8d98e159dda67a61b7f2e0f6ec26e86c3ada33b0621775"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.3.1"
|
||||||
|
url_launcher_ios:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: url_launcher_ios
|
||||||
|
sha256: "9149d493b075ed740901f3ee844a38a00b33116c7c5c10d7fb27df8987fb51d5"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.2.5"
|
||||||
|
url_launcher_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: url_launcher_linux
|
||||||
|
sha256: ab360eb661f8879369acac07b6bb3ff09d9471155357da8443fd5d3cf7363811
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.1.1"
|
||||||
|
url_launcher_macos:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: url_launcher_macos
|
||||||
|
sha256: b7244901ea3cf489c5335bdacda07264a6e960b1c1b1a9f91e4bc371d9e68234
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.1.0"
|
||||||
|
url_launcher_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: url_launcher_platform_interface
|
||||||
|
sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.2"
|
||||||
|
url_launcher_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: url_launcher_web
|
||||||
|
sha256: "8d9e750d8c9338601e709cd0885f95825086bd8b642547f26bda435aade95d8a"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.1"
|
||||||
|
url_launcher_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: url_launcher_windows
|
||||||
|
sha256: ecf9725510600aa2bb6d7ddabe16357691b6d2805f66216a97d1b881e21beff7
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.1.1"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -208,5 +285,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "13.0.0"
|
version: "13.0.0"
|
||||||
|
web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: web
|
||||||
|
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.5.1"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.3.4 <4.0.0"
|
dart: ">=3.3.4 <4.0.0"
|
||||||
|
flutter: ">=3.19.0"
|
||||||
|
|||||||
@ -30,6 +30,7 @@ environment:
|
|||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
url_launcher: ^6.0.12
|
||||||
|
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
|
|||||||
@ -6,6 +6,9 @@
|
|||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
|
#include <url_launcher_windows/url_launcher_windows.h>
|
||||||
|
|
||||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||||
|
UrlLauncherWindowsRegisterWithRegistrar(
|
||||||
|
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
|
url_launcher_windows
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
|
|||||||
Reference in New Issue
Block a user