From f1571e6374787d1e6b26ab9d81fc87f70a5e5755 Mon Sep 17 00:00:00 2001 From: Juan Felipe Duarte <70235683+DuarteJFelipe@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:41:24 -0500 Subject: [PATCH] update --- lib/src/screens/cita.dart | 186 ++++++++++++------ linux/flutter/generated_plugin_registrant.cc | 4 + linux/flutter/generated_plugins.cmake | 1 + macos/Flutter/GeneratedPluginRegistrant.swift | 2 + pubspec.lock | 72 +++++++ pubspec.yaml | 4 +- .../flutter/generated_plugin_registrant.cc | 3 + windows/flutter/generated_plugins.cmake | 1 + 8 files changed, 207 insertions(+), 66 deletions(-) diff --git a/lib/src/screens/cita.dart b/lib/src/screens/cita.dart index 2921590..2ebb463 100644 --- a/lib/src/screens/cita.dart +++ b/lib/src/screens/cita.dart @@ -8,6 +8,8 @@ import 'package:prosappco/src/components/pop_appbar.dart'; import 'package:prosappco/src/models/event_model.dart'; import 'package:prosappco/src/models/scores_model.dart'; import 'package:prosappco/src/models/user_model.dart'; +import 'package:url_launcher/url_launcher.dart'; +import 'package:community_material_icon/community_material_icon.dart'; class CitaScreen extends StatefulWidget { final Event evento; @@ -24,6 +26,26 @@ class _CitaScreenState extends State { Reference? ref_photo; ScoresModel? scoresModel; + final phoneNumber = '+573022548060'; + + Future _openMap(double lat, double lng) async { + final Uri _url = + Uri.parse('https://www.google.com/maps/search/?api=1&query=$lat,$lng'); + + if (!await launchUrl(_url)) { + print('hola'); + throw Exception('Could not launch $_url'); + } + } + + Future _sendWhatsapp() async { + final whatsappUrl = + 'https://wa.me/$phoneNumber?text=${Uri.parse('Hola! me contactaste por Prossapp')}'; + if (!await launch(whatsappUrl)) { + throw Exception('Could not launch $whatsappUrl'); + } + } + @override void initState() { super.initState(); @@ -37,6 +59,7 @@ class _CitaScreenState extends State { } } + @override Widget build(BuildContext context) { if (nombre == '') { UserModel.getUser(widget.evento.userId).then((value) { @@ -166,86 +189,119 @@ class _CitaScreenState extends State { Row( children: [ const Expanded(child: SizedBox()), - Container( - decoration: BoxDecoration( - color: Colors.white, - border: Border.all( - color: const Color(0xFF2BA4EC), width: 2), - borderRadius: BorderRadius.circular(50), - ), - child: FloatingActionButton( - onPressed: () {}, + ElevatedButton( + onPressed: () => launch("tel:+573163225944"), + style: ElevatedButton.styleFrom( + foregroundColor: const Color(0xFF2BA4EC), backgroundColor: Colors.white, - elevation: 0, - child: const Icon(Icons.phone_android, - size: 30, color: Color(0xFF2BA4EC)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(50), + side: const BorderSide( + color: Color(0xFF2BA4EC), + width: 2, + ), + ), + ), + child: const Padding( + padding: + EdgeInsets.symmetric(vertical: 18, horizontal: 0), + child: Icon( + Icons.phone_android, + size: 30, + color: Color(0xFF2BA4EC), + ), ), ), const SizedBox(width: 20), - Container( - decoration: BoxDecoration( - color: Colors.white, - border: Border.all( - color: const Color(0xFF2BA4EC), width: 2), - borderRadius: BorderRadius.circular(50), - ), - child: FloatingActionButton( - onPressed: () {}, + ElevatedButton( + onPressed: () { + _sendWhatsapp(); + }, + style: ElevatedButton.styleFrom( + foregroundColor: const Color(0xFF2BA4EC), backgroundColor: Colors.white, - elevation: 0, - child: const Icon(Icons.message, - size: 30, color: Color(0xFF2BA4EC)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(50), + side: const BorderSide( + color: Color(0xFF2BA4EC), + width: 2, + ), + ), + ), + child: const Padding( + padding: + EdgeInsets.symmetric(vertical: 18, horizontal: 0), + child: Icon( + CommunityMaterialIcons.whatsapp, + size: 30, + color: Color(0xFF2BA4EC), + ), ), ), const Expanded(child: SizedBox()), ], ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 20), - child: Row( - children: [ - Container( - decoration: BoxDecoration( - color: const Color(0xFF2BA4EC), - border: Border.all( - color: const Color(0xFF2BA4EC), width: 2), - borderRadius: BorderRadius.circular(50), + widget.evento.ubicacion == 'sitio' + ? const SizedBox() + : Padding( + padding: const EdgeInsets.only(top: 40), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ElevatedButton( + onPressed: () { + _openMap(widget.evento.latitud!, + widget.evento.longitud!); + }, + style: ElevatedButton.styleFrom( + foregroundColor: const Color(0xFF2BA4EC), + backgroundColor: const Color(0xFF2BA4EC), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(50), + side: const BorderSide( + color: Color(0xFF2BA4EC), + width: 2, + ), + ), + ), + child: const Padding( + padding: EdgeInsets.symmetric( + vertical: 18, horizontal: 0), + child: Icon( + Icons.near_me, + size: 30, + color: Color(0xFFFFFFFF), + ), + ), + ), + const SizedBox(width: 20), + SizedBox( + width: 200, + child: Text('${widget.evento.address}')) + ], ), - child: FloatingActionButton( - onPressed: () {}, - backgroundColor: const Color(0xFF2BA4EC), - elevation: 0, - child: const Icon(Icons.near_me, - size: 30, color: Colors.white), - ), - ), - Text('${widget.evento.address}') - ], - ), - ) + ) ], ), ), - Center( - child: Padding( - padding: const EdgeInsets.only(bottom: 30), - child: ElevatedButton( - onPressed: () {}, - style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xFFEC2B2B), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(50), - ), - elevation: 0, - minimumSize: const Size(230, 60), + Padding( + padding: const EdgeInsets.only(bottom: 30), + child: ElevatedButton( + onPressed: () {}, + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFFEC2B2B), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(50), ), - child: const Text( - 'Cancelar servicio', - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 18, - ), + elevation: 0, + minimumSize: const Size(230, 60), + ), + child: const Text( + 'Cancelar servicio', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 18, ), ), ), diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index e71a16d..f6f23bf 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,6 +6,10 @@ #include "generated_plugin_registrant.h" +#include 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); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 2e1de87..f16b4c3 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + url_launcher_linux ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 2da9559..9c4e7a1 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -10,6 +10,7 @@ import firebase_auth import firebase_core import firebase_storage import geolocator_apple +import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin")) @@ -17,4 +18,5 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) FLTFirebaseStoragePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseStoragePlugin")) GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index 264af2f..25ddfc5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -73,6 +73,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.17.0" + community_material_icon: + dependency: "direct main" + description: + name: community_material_icon + sha256: bb389689f6278158d7b9d9b0c9433e603933283104fea226594590f61503fd08 + url: "https://pub.dev" + source: hosted + version: "5.9.55" cross_file: dependency: transitive description: @@ -645,6 +653,70 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + sha256: "75f2846facd11168d007529d6cd8fcb2b750186bea046af9711f10b907e1587e" + url: "https://pub.dev" + source: hosted + version: "6.1.10" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "22f8db4a72be26e9e3a4aa3f194b1f7afbc76d20ec141f84be1d787db2155cbd" + url: "https://pub.dev" + source: hosted + version: "6.0.31" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: "9af7ea73259886b92199f9e42c116072f05ff9bea2dcb339ab935dfc957392c2" + url: "https://pub.dev" + source: hosted + version: "6.1.4" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: "207f4ddda99b95b4d4868320a352d374b0b7e05eefad95a4a26f57da413443f5" + url: "https://pub.dev" + source: hosted + version: "3.0.5" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: "91ee3e75ea9dadf38036200c5d3743518f4a5eb77a8d13fda1ee5764373f185e" + url: "https://pub.dev" + source: hosted + version: "3.0.5" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "6c9ca697a5ae218ce56cece69d46128169a58aa8653c1b01d26fcd4aad8c4370" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "81fe91b6c4f84f222d186a9d23c73157dc4c8e1c71489c4d08be1ad3b228f1aa" + url: "https://pub.dev" + source: hosted + version: "2.0.16" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "254708f17f7c20a9c8c471f67d86d76d4a3f9c1591aad1e15292008aceb82771" + url: "https://pub.dev" + source: hosted + version: "3.0.6" vector_math: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index ad17d61..a5ec4e1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,7 +42,7 @@ dependencies: google_sign_in: provider: get: - font_awesome_flutter: + font_awesome_flutter: ^10.4.0 flutter_otp_text_field: intl_phone_field: cloud_firestore: @@ -56,6 +56,8 @@ dependencies: google_maps_flutter: ^2.2.5 geolocator: ^9.0.2 geocoding: ^2.1.0 + url_launcher: ^6.0.3 + community_material_icon: ^5.9.55 dev_dependencies: flutter_test: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 1ece8f2..94586cc 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,8 +7,11 @@ #include "generated_plugin_registrant.h" #include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { GeolocatorWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("GeolocatorWindows")); + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 7f101a7..f0bcafd 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -4,6 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST geolocator_windows + url_launcher_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST