diff --git a/lib/src/authentication/authentication_repository.dart b/lib/src/authentication/authentication_repository.dart index 9fecdbe..2821463 100644 --- a/lib/src/authentication/authentication_repository.dart +++ b/lib/src/authentication/authentication_repository.dart @@ -83,7 +83,7 @@ class AuthenticationRepository extends GetxController { } on FirebaseAuthException catch (e) { final ex = SignUpWithEmailAndPasswordFailure.code(e.code); Get.snackbar( - 'Correo Invalido', + 'Correo ya registrado', 'Por favor pruebe con otro.', snackPosition: SnackPosition.BOTTOM, ); diff --git a/lib/src/components/schedule_picker.dart b/lib/src/components/schedule_picker.dart index 082e031..b5a99f3 100644 --- a/lib/src/components/schedule_picker.dart +++ b/lib/src/components/schedule_picker.dart @@ -196,6 +196,7 @@ class Schedule { await FirebaseFirestore.instance.collection('users').doc(uid).get(); final Map? data = snapshot.data(); final Map? horarioData = data?['horario']; + print('hola ${fromJson(data)}'); return fromJson(horarioData); } catch (e) { print('Error getting user: $e'); diff --git a/lib/src/screens/calendar.dart b/lib/src/screens/calendar.dart index 0efb28e..6f16201 100644 --- a/lib/src/screens/calendar.dart +++ b/lib/src/screens/calendar.dart @@ -406,26 +406,30 @@ class _CalendarScreenState extends State { children: [ Row( children: [ - RatingBar.builder( - initialRating: e.scoresModel?.average ?? 0, - minRating: 1, - direction: Axis.horizontal, - allowHalfRating: true, - itemCount: 5, - itemSize: 25, - maxRating: 5, - itemPadding: - const EdgeInsets.symmetric(horizontal: 0), - itemBuilder: (context, _) => const Icon( - Icons.star, - color: Color(0xFF2BA4EC), - ), - onRatingUpdate: (rating) {}, - ignoreGestures: true, - ), + e.professionalId == e.userId + ? const SizedBox() + : RatingBar.builder( + initialRating: e.scoresModel?.average ?? 0, + minRating: 1, + direction: Axis.horizontal, + allowHalfRating: true, + itemCount: 5, + itemSize: 25, + maxRating: 5, + itemPadding: + const EdgeInsets.symmetric(horizontal: 0), + itemBuilder: (context, _) => const Icon( + Icons.star, + color: Color(0xFF2BA4EC), + ), + onRatingUpdate: (rating) {}, + ignoreGestures: true, + ), const SizedBox(width: 5), - Text( - '(${e.scoresModel?.total.toString()}) ${e.scoresModel?.average.toStringAsFixed(1)}'), + e.professionalId == e.userId + ? const SizedBox() + : Text( + '(${e.scoresModel?.total.toString()}) ${e.scoresModel?.average.toStringAsFixed(1)}'), ], ), Text( diff --git a/lib/src/screens/login_email.dart b/lib/src/screens/login_email.dart index 7630ec4..8f478a2 100644 --- a/lib/src/screens/login_email.dart +++ b/lib/src/screens/login_email.dart @@ -28,6 +28,8 @@ class _LoginEmailScreenState extends State { } Widget _mobileView(BuildContext context) { + bool isIOS = Theme.of(context).platform == TargetPlatform.iOS; + return SafeArea( child: Scaffold( backgroundColor: const Color(0xFFD6F4FF), @@ -91,60 +93,65 @@ class _LoginEmailScreenState extends State { margin: const EdgeInsets.only(top: 210, left: 50, right: 50), child: Column( children: [ - Padding( - padding: const EdgeInsets.only(bottom: 20), - child: ElevatedButton( - onPressed: () async { - await AuthenticationRepository.instance - .signInWithGoogle(); - }, - style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xFF2BA4EC), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(50), - ), - elevation: 0, - minimumSize: const Size(230, 60), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: const [ - Text( - 'Entrar con Google ', - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 18, + !isIOS + ? Padding( + padding: const EdgeInsets.only(bottom: 20), + child: ElevatedButton( + onPressed: () async { + await AuthenticationRepository.instance + .signInWithGoogle(); + }, + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF2BA4EC), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(50), + ), + elevation: 0, + minimumSize: const Size(230, 60), ), - ), - SizedBox(width: 5), - FaIcon(FontAwesomeIcons.google), - ], - )), - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 5), - child: Row( - children: const [ - Expanded( - child: Divider( - color: Colors.black38, - thickness: 1, + child: const Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Entrar con Google ', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), + SizedBox(width: 5), + FaIcon(FontAwesomeIcons.google), + ], + )), + ) + : const SizedBox(), + !isIOS + ? const Padding( + padding: EdgeInsets.symmetric(vertical: 5), + child: Row( + children: [ + Expanded( + child: Divider( + color: Colors.black38, + thickness: 1, + ), + ), + Padding( + padding: + EdgeInsets.symmetric(horizontal: 10), + child: Text("ó"), + ), + Expanded( + child: Divider( + color: Colors.black38, + thickness: 1, + ), + ), + ], ), - ), - Padding( - padding: EdgeInsets.symmetric(horizontal: 10), - child: Text("ó"), - ), - Expanded( - child: Divider( - color: Colors.black38, - thickness: 1, - ), - ), - ], - ), - ), + ) + : const SizedBox(), const Padding( padding: EdgeInsets.only(bottom: 5), child: Align( @@ -294,60 +301,60 @@ class _LoginEmailScreenState extends State { padding: const EdgeInsets.symmetric( horizontal: 0, vertical: 20), child: Column(children: [ - Padding( - padding: const EdgeInsets.only(bottom: 20), - child: ElevatedButton( - onPressed: () async { - await AuthenticationRepository.instance - .signInWithGoogle(); - }, - style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xFF2BA4EC), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(50), - ), - elevation: 0, - minimumSize: const Size(230, 60), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: const [ - Text( - 'Entrar con Google ', - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 18, - ), - ), - SizedBox(width: 5), - FaIcon(FontAwesomeIcons.google), - ], - )), - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 5), - child: Row( - children: const [ - Expanded( - child: Divider( - color: Colors.black38, - thickness: 1, - ), - ), - Padding( - padding: EdgeInsets.symmetric(horizontal: 10), - child: Text("ó"), - ), - Expanded( - child: Divider( - color: Colors.black38, - thickness: 1, - ), - ), - ], - ), - ), + // Padding( + // padding: const EdgeInsets.only(bottom: 20), + // child: ElevatedButton( + // onPressed: () async { + // await AuthenticationRepository.instance + // .signInWithGoogle(); + // }, + // style: ElevatedButton.styleFrom( + // backgroundColor: const Color(0xFF2BA4EC), + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadius.circular(50), + // ), + // elevation: 0, + // minimumSize: const Size(230, 60), + // ), + // child: const Row( + // mainAxisAlignment: MainAxisAlignment.center, + // children: [ + // Text( + // 'Entrar con Google ', + // style: TextStyle( + // color: Colors.white, + // fontWeight: FontWeight.bold, + // fontSize: 18, + // ), + // ), + // SizedBox(width: 5), + // FaIcon(FontAwesomeIcons.google), + // ], + // )), + // ), + // const Padding( + // padding: EdgeInsets.symmetric(vertical: 5), + // child: Row( + // children: [ + // Expanded( + // child: Divider( + // color: Colors.black38, + // thickness: 1, + // ), + // ), + // Padding( + // padding: EdgeInsets.symmetric(horizontal: 10), + // child: Text("ó"), + // ), + // Expanded( + // child: Divider( + // color: Colors.black38, + // thickness: 1, + // ), + // ), + // ], + // ), + // ), const Padding( padding: EdgeInsets.only(bottom: 5), child: Align( diff --git a/lib/src/screens/my_services_pro.dart b/lib/src/screens/my_services_pro.dart index 1b5071e..21ad0a8 100644 --- a/lib/src/screens/my_services_pro.dart +++ b/lib/src/screens/my_services_pro.dart @@ -97,100 +97,102 @@ class _MyServicesProScreenState extends State { return Column( children: [ ...eventos.map( - (event) => ListTile( - tileColor: event.status == 'denegado' - ? Colors.red[100] - : Colors.blue[100], - onTap: () { - Navigator.push( - context, - CupertinoPageRoute( - builder: (BuildContext context) { - return CitaScreen(evento: event); - }, - ), - ); - }, - leading: event.status == 'aprobado' - ? const Icon( - Icons.check, - color: Colors.blue, - size: 40, - ) - : event.status == 'iniciado' - ? const Icon( - Icons.access_time, - color: Colors.blue, - size: 40, - ) - : event.status == 'terminado' - ? const Icon( - Icons.rocket_launch, - color: Colors.blue, - size: 40, - ) - : const Icon( - Icons.close, - color: Colors.red, - size: 40, - ), - title: RichText( - text: TextSpan( - children: [ - TextSpan( - text: '${event.title}, ', - style: const TextStyle( - color: Colors.black, - fontWeight: FontWeight.bold, - fontSize: 16, - ), - ), - TextSpan( - text: - '${DateFormat('dd MMM', 'es').format(DateTime.parse(event.day))} - ${TimeOfDay.fromDateTime(DateTime.parse(event.range1Hour1)).format(context)}', - style: TextStyle( - color: Colors.grey[600], - fontSize: 16, - ), - ), - ], - ), - ), - subtitle: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - RatingBar.builder( - initialRating: event.scoresModel?.average ?? 0, - minRating: 1, - direction: Axis.horizontal, - allowHalfRating: true, - itemCount: 5, - itemSize: 25, - maxRating: 5, - itemPadding: - const EdgeInsets.symmetric(horizontal: 0), - itemBuilder: (context, _) => const Icon( - Icons.star, - color: Color(0xFF2BA4EC), + (event) => event.userId == event.professionalId + ? const SizedBox() + : ListTile( + tileColor: event.status == 'denegado' + ? Colors.red[100] + : Colors.blue[100], + onTap: () { + Navigator.push( + context, + CupertinoPageRoute( + builder: (BuildContext context) { + return CitaScreen(evento: event); + }, ), - onRatingUpdate: (rating) {}, - ignoreGestures: true, + ); + }, + leading: event.status == 'aprobado' + ? const Icon( + Icons.check, + color: Colors.blue, + size: 40, + ) + : event.status == 'iniciado' + ? const Icon( + Icons.access_time, + color: Colors.blue, + size: 40, + ) + : event.status == 'terminado' + ? const Icon( + Icons.rocket_launch, + color: Colors.blue, + size: 40, + ) + : const Icon( + Icons.close, + color: Colors.red, + size: 40, + ), + title: RichText( + text: TextSpan( + children: [ + TextSpan( + text: '${event.title}, ', + style: const TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ), + TextSpan( + text: + '${DateFormat('dd MMM', 'es').format(DateTime.parse(event.day))} - ${TimeOfDay.fromDateTime(DateTime.parse(event.range1Hour1)).format(context)}', + style: TextStyle( + color: Colors.grey[600], + fontSize: 16, + ), + ), + ], ), - const SizedBox(width: 5), - Text( - '(${event.scoresModel?.total.toString()}) ${event.scoresModel?.average.toStringAsFixed(1)}'), - ], + ), + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + RatingBar.builder( + initialRating: event.scoresModel?.average ?? 0, + minRating: 1, + direction: Axis.horizontal, + allowHalfRating: true, + itemCount: 5, + itemSize: 25, + maxRating: 5, + itemPadding: + const EdgeInsets.symmetric(horizontal: 0), + itemBuilder: (context, _) => const Icon( + Icons.star, + color: Color(0xFF2BA4EC), + ), + onRatingUpdate: (rating) {}, + ignoreGestures: true, + ), + const SizedBox(width: 5), + Text( + '(${event.scoresModel?.total.toString()}) ${event.scoresModel?.average.toStringAsFixed(1)}'), + ], + ), + Text( + '" ${event.description}"', + style: const TextStyle(fontStyle: FontStyle.italic), + ), + ], + ), + trailing: const Icon(Icons.keyboard_arrow_right), ), - Text( - '" ${event.description}"', - style: const TextStyle(fontStyle: FontStyle.italic), - ), - ], - ), - trailing: const Icon(Icons.keyboard_arrow_right), - ), ), ], ); diff --git a/lib/src/screens/professional.dart b/lib/src/screens/professional.dart index 1ff1016..f280fd1 100644 --- a/lib/src/screens/professional.dart +++ b/lib/src/screens/professional.dart @@ -8,6 +8,7 @@ import 'package:prosappco/src/authentication/authentication_repository.dart'; import 'package:prosappco/src/components/photo_view.dart'; import 'package:prosappco/src/components/pop_appbar.dart'; import 'package:prosappco/src/models/setting_model.dart'; +import 'package:prosappco/src/models/user_model.dart'; import 'package:prosappco/src/screens/professional_info.dart'; import '../models/scores_model.dart'; @@ -117,6 +118,54 @@ class Professional { } class _ProfessionalScreenState extends State { + UserModel? userme; + SettingModel? settings; + + @override + void initState() { + super.initState(); + + if (userme == null) { + UserModel.getUser(uid.toString()).then( + (UserModel s) => setState(() => userme = s), + ); + } + + if (settings == null) { + SettingModel.getSettings().then( + (SettingModel value) => setState(() { + settings = value; + }), + ); + } + searchController.addListener(() { + setState(() { + if (_professionals != null) { + if (searchController.text.isEmpty) { + filteredProfessionals = _professionals! + .where((professional) => professional.id != uid) + .toList(); + } else { + filteredProfessionals = _professionals! + .where((professional) => + removeDiacritics(professional.name).toLowerCase().contains( + removeDiacritics( + searchController.text.toLowerCase())) && + professional.id != uid) + .toList(); + } + } + }); + }); + + if (_professionals == null) { + getProfessionals().then((List element) => setState(() { + _professionals = element; + filteredProfessionals = element; + })); + } + } + String formatCurrency(int number) { final formatter = NumberFormat.currency(locale: 'es_CO', decimalDigits: 0, symbol: ''); @@ -189,7 +238,7 @@ class _ProfessionalScreenState extends State { .toList(); if (widget.profession == data['profesion'] || - widget.profession == '') { + widget.profession == '' && userme?.city == data['city']) { Professional professional = Professional( id: user.id, name: data['name'], @@ -216,47 +265,6 @@ class _ProfessionalScreenState extends State { return professionals; } - SettingModel? settings; - - @override - void initState() { - super.initState(); - - if (settings == null) { - SettingModel.getSettings().then( - (SettingModel value) => setState(() { - settings = value; - }), - ); - } - searchController.addListener(() { - setState(() { - if (_professionals != null) { - if (searchController.text.isEmpty) { - filteredProfessionals = _professionals! - .where((professional) => professional.id != uid) - .toList(); - } else { - filteredProfessionals = _professionals! - .where((professional) => - removeDiacritics(professional.name).toLowerCase().contains( - removeDiacritics( - searchController.text.toLowerCase())) && - professional.id != uid) - .toList(); - } - } - }); - }); - - if (_professionals == null) { - getProfessionals().then((List element) => setState(() { - _professionals = element; - filteredProfessionals = element; - })); - } - } - @override Widget build(BuildContext context) { if (filteredProfessionals == null) { diff --git a/lib/src/screens/profile_web.dart b/lib/src/screens/profile_web.dart index 1ab7ab9..fb36ccf 100644 --- a/lib/src/screens/profile_web.dart +++ b/lib/src/screens/profile_web.dart @@ -14,6 +14,7 @@ import 'package:prosappco/src/components/pop_appbar.dart'; import 'package:prosappco/src/screens/city.dart'; import 'package:prosappco/src/screens/new_number.dart'; import 'package:prosappco/src/screens/new_password.dart'; +import 'package:universal_html/html.dart' as html; class ProfileWebScreen extends StatefulWidget { const ProfileWebScreen({super.key}); @@ -197,8 +198,6 @@ class _ProfileWebScreenState extends State { } else { await _uploadFile(); updateImage(photoTemp); - - //image } } catch (e) { print('Error al actualizar la imagen de perfil $e'); @@ -418,6 +417,8 @@ class _ProfileWebScreenState extends State { onPressed: () async { if (_formKey.currentState!.validate()) { await updateInfo().whenComplete(() { + html.window.location.reload(); + Get.snackbar( 'Perfil', 'Información actualizada correctamente.', diff --git a/lib/src/screens/register.dart b/lib/src/screens/register.dart index ba1a56b..c2c86ae 100644 --- a/lib/src/screens/register.dart +++ b/lib/src/screens/register.dart @@ -7,7 +7,6 @@ import 'package:prosappco/src/authentication/authentication_repository.dart'; import 'package:prosappco/src/components/primary_btn.dart'; import 'package:prosappco/src/controllers/register_controller.dart'; import 'package:prosappco/src/screens/login.dart'; -import 'package:provider/provider.dart'; import 'package:responsive_builder/responsive_builder.dart'; class RegisterScreen extends StatefulWidget { @@ -32,6 +31,8 @@ class _RegisterScreenState extends State { } Widget _mobileView(BuildContext context) { + bool isIOS = Theme.of(context).platform == TargetPlatform.iOS; + return SafeArea( child: Scaffold( backgroundColor: const Color(0xFFD6F4FF), @@ -95,60 +96,65 @@ class _RegisterScreenState extends State { margin: const EdgeInsets.only(top: 200, left: 50, right: 50), child: Column( children: [ - Padding( - padding: const EdgeInsets.only(bottom: 20), - child: ElevatedButton( - onPressed: () async { - await AuthenticationRepository.instance - .signInWithGoogle(); - }, - style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xFF2BA4EC), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(50), - ), - elevation: 0, - minimumSize: const Size(230, 60), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: const [ - Text( - 'Entrar con Google ', - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 18, + !isIOS + ? Padding( + padding: const EdgeInsets.only(bottom: 20), + child: ElevatedButton( + onPressed: () async { + await AuthenticationRepository.instance + .signInWithGoogle(); + }, + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF2BA4EC), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(50), + ), + elevation: 0, + minimumSize: const Size(230, 60), ), - ), - SizedBox(width: 5), - FaIcon(FontAwesomeIcons.google), - ], - )), - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 0), - child: Row( - children: const [ - Expanded( - child: Divider( - color: Colors.black38, - thickness: 1, + child: const Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Entrar con Google ', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), + SizedBox(width: 5), + FaIcon(FontAwesomeIcons.google), + ], + )), + ) + : const SizedBox(), + !isIOS + ? const Padding( + padding: EdgeInsets.symmetric(vertical: 0), + child: Row( + children: [ + Expanded( + child: Divider( + color: Colors.black38, + thickness: 1, + ), + ), + Padding( + padding: + EdgeInsets.symmetric(horizontal: 10), + child: Text("ó"), + ), + Expanded( + child: Divider( + color: Colors.black38, + thickness: 1, + ), + ), + ], ), - ), - Padding( - padding: EdgeInsets.symmetric(horizontal: 10), - child: Text("ó"), - ), - Expanded( - child: Divider( - color: Colors.black38, - thickness: 1, - ), - ), - ], - ), - ), + ) + : const SizedBox(), Form( key: _formKey, child: Column( @@ -400,60 +406,60 @@ class _RegisterScreenState extends State { horizontal: 0, vertical: 20), child: Column( children: [ - Padding( - padding: const EdgeInsets.only(bottom: 20), - child: ElevatedButton( - onPressed: () async { - await AuthenticationRepository.instance - .signInWithGoogle(); - }, - style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xFF2BA4EC), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(50), - ), - elevation: 0, - minimumSize: const Size(230, 60), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: const [ - Text( - 'Entrar con Google ', - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 18, - ), - ), - SizedBox(width: 5), - FaIcon(FontAwesomeIcons.google), - ], - )), - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 0), - child: Row( - children: const [ - Expanded( - child: Divider( - color: Colors.black38, - thickness: 1, - ), - ), - Padding( - padding: EdgeInsets.symmetric(horizontal: 10), - child: Text("ó"), - ), - Expanded( - child: Divider( - color: Colors.black38, - thickness: 1, - ), - ), - ], - ), - ), + // Padding( + // padding: const EdgeInsets.only(bottom: 20), + // child: ElevatedButton( + // onPressed: () async { + // await AuthenticationRepository.instance + // .signInWithGoogle(); + // }, + // style: ElevatedButton.styleFrom( + // backgroundColor: const Color(0xFF2BA4EC), + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadius.circular(50), + // ), + // elevation: 0, + // minimumSize: const Size(230, 60), + // ), + // child: const Row( + // mainAxisAlignment: MainAxisAlignment.center, + // children: [ + // Text( + // 'Entrar con Google ', + // style: TextStyle( + // color: Colors.white, + // fontWeight: FontWeight.bold, + // fontSize: 18, + // ), + // ), + // SizedBox(width: 5), + // FaIcon(FontAwesomeIcons.google), + // ], + // )), + // ), + // const Padding( + // padding: EdgeInsets.symmetric(vertical: 0), + // child: Row( + // children: [ + // Expanded( + // child: Divider( + // color: Colors.black38, + // thickness: 1, + // ), + // ), + // Padding( + // padding: EdgeInsets.symmetric(horizontal: 10), + // child: Text("ó"), + // ), + // Expanded( + // child: Divider( + // color: Colors.black38, + // thickness: 1, + // ), + // ), + // ], + // ), + // ), Form( key: _formKey, child: Column( diff --git a/lib/src/screens/service.dart b/lib/src/screens/service.dart index b0b0027..eb2bb6f 100644 --- a/lib/src/screens/service.dart +++ b/lib/src/screens/service.dart @@ -236,37 +236,6 @@ class _ServiceScreenState extends State { crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ - TextFormField( - controller: _ubicationController, - readOnly: true, - onTap: () async { - final List datos = await Navigator.push( - context, - CupertinoPageRoute( - builder: (BuildContext context) { - return const UbicacionScreen(); - }, - ), - ); - - if (datos.length == 3) { - final formattedAddress = datos[0]; - final lat = datos[1]; - final lng = datos[2]; - - setState(() { - _ubicationController.text = formattedAddress; - latUser = lat; - lngUser = lng; - }); - } - }, - decoration: const InputDecoration( - hintText: 'Escribe tu ubicación', - prefixIcon: Icon(Icons.location_on), - ), - ), - const SizedBox(height: 20.0), TextFormField( controller: _profesionalController, readOnly: true, @@ -311,6 +280,37 @@ class _ServiceScreenState extends State { hintText: 'Seleccionar profesional'), ), const SizedBox(height: 20.0), + TextFormField( + controller: _ubicationController, + readOnly: true, + onTap: () async { + final List datos = await Navigator.push( + context, + CupertinoPageRoute( + builder: (BuildContext context) { + return const UbicacionScreen(); + }, + ), + ); + + if (datos.length == 3) { + final formattedAddress = datos[0]; + final lat = datos[1]; + final lng = datos[2]; + + setState(() { + _ubicationController.text = formattedAddress; + latUser = lat; + lngUser = lng; + }); + } + }, + decoration: const InputDecoration( + hintText: 'Escribe tu ubicación', + prefixIcon: Icon(Icons.location_on), + ), + ), + const SizedBox(height: 20.0), TextFormField( onTap: () { if (_profesionalController.text.isNotEmpty) { @@ -672,84 +672,85 @@ class _ServiceScreenState extends State { Column( children: [ TextFormField( + controller: _profesionalController, readOnly: true, - controller: _locationController, + onTap: () async { + final dynamic datos = await Navigator.push( + context, + CupertinoPageRoute( + builder: (BuildContext context) { + return ProfessionalScreen( + profession: + _serviceTypeController.text, + ); + }, + ), + ); + if (datos != null) { + Professional? profesional = datos[0]; + ubicacion = datos[1]; + + if (profesional != null) { + setState(() { + _profesionalController.text = + profesional.name.toString(); + + professionalId = profesional.id; + + professionalTarifa = + profesional.tarifa ?? 0; + + professionalUbicacion = + profesional.ubicacion; + + professionalLatitude = + profesional.latitude; + professionalLongitude = + profesional.longitude; + + if (ubicacion == 'sitio') { + professionalAddress = + profesional.realAddress; + + _locationController.text = + profesional.realAddress; + + if (professionalLatitude != null && + professionalLatitude != 0 && + professionalLongitude != null && + professionalLongitude != 0) { + googleMapController.animateCamera( + CameraUpdate.newCameraPosition( + CameraPosition( + target: LatLng( + professionalLatitude!, + professionalLongitude!, + ), + zoom: 17), + ), + ); + } + } + }); + } + } + }, decoration: const InputDecoration( - prefixIcon: Icon(Icons.near_me), - hintText: 'Dirección', - ), + prefixIcon: + Icon(Icons.assignment_ind_rounded), + suffixIcon: Icon(Icons.arrow_drop_down), + hintText: 'Seleccionar profesional'), ), ], ), const SizedBox(height: 15), TextFormField( - controller: _profesionalController, readOnly: true, - onTap: () async { - final dynamic datos = await Navigator.push( - context, - CupertinoPageRoute( - builder: (BuildContext context) { - return ProfessionalScreen( - profession: _serviceTypeController.text, - ); - }, - ), - ); - if (datos != null) { - Professional? profesional = datos[0]; - ubicacion = datos[1]; - - if (profesional != null) { - setState(() { - _profesionalController.text = - profesional.name.toString(); - - professionalId = profesional.id; - - professionalTarifa = - profesional.tarifa ?? 0; - - professionalUbicacion = - profesional.ubicacion; - - professionalLatitude = - profesional.latitude; - professionalLongitude = - profesional.longitude; - - if (ubicacion == 'sitio') { - professionalAddress = - profesional.realAddress; - - _locationController.text = - profesional.realAddress; - - if (professionalLatitude != null && - professionalLatitude != 0 && - professionalLongitude != null && - professionalLongitude != 0) { - googleMapController.animateCamera( - CameraUpdate.newCameraPosition( - CameraPosition( - target: LatLng( - professionalLatitude!, - professionalLongitude!, - ), - zoom: 17), - ), - ); - } - } - }); - } - } - }, + controller: _locationController, decoration: const InputDecoration( - prefixIcon: - Icon(Icons.assignment_ind_rounded), - suffixIcon: Icon(Icons.arrow_drop_down), - hintText: 'Seleccionar profesional'), + prefixIcon: Icon(Icons.near_me), + hintText: 'Dirección', + ), ), const SizedBox(height: 15), Row( diff --git a/pubspec.lock b/pubspec.lock index 05f36cb..941eb1c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -41,6 +41,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" + charcode: + dependency: transitive + description: + name: charcode + sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 + url: "https://pub.dev" + source: hosted + version: "1.3.1" clock: dependency: transitive description: @@ -917,6 +925,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + universal_html: + dependency: "direct main" + description: + name: universal_html + sha256: a5cc5a84188e5d3e58f3ed77fe3dd4575dc1f68aa7c89e51b5b4105b9aab3b9d + url: "https://pub.dev" + source: hosted + version: "2.2.3" + universal_io: + dependency: transitive + description: + name: universal_io + sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad" + url: "https://pub.dev" + source: hosted + version: "2.2.2" url_launcher: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 851e8d6..32da15d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -66,6 +66,7 @@ dependencies: flutter_local_notifications: ^14.1.1 http: ^0.13.5 flutter_dialogs: ^3.0.0 + universal_html: ^2.2.3 dev_dependencies: flutter_test: