diff --git a/images/pro_marke_android.png b/images/pro_marke_android.png new file mode 100644 index 0000000..d196ffc Binary files /dev/null and b/images/pro_marke_android.png differ diff --git a/lib/src/presentation/screens/map/service.dart b/lib/src/presentation/screens/map/service.dart index 877b79b..36a927f 100644 --- a/lib/src/presentation/screens/map/service.dart +++ b/lib/src/presentation/screens/map/service.dart @@ -147,15 +147,29 @@ class _ServiceScreenState extends State { _saveToken(); - BitmapDescriptor.fromAssetImage( - const ImageConfiguration(size: Size(1, 1)), 'images/pro_marke.png') - .then((icon) { - if (mounted) { - setState(() { - _markerIcon = icon; - }); - } - }); + if (Platform.isAndroid) { + BitmapDescriptor.fromAssetImage( + const ImageConfiguration(size: Size(2, 2)), + 'images/pro_marke_android.png', + ).then((icon) { + if (mounted) { + setState(() { + _markerIcon = icon; + }); + } + }); + } else { + BitmapDescriptor.fromAssetImage( + const ImageConfiguration(size: Size(1, 1)), + 'images/pro_marke.png', + ).then((icon) { + if (mounted) { + setState(() { + _markerIcon = icon; + }); + } + }); + } updateMarkersForServiceType(_serviceType); } @@ -177,6 +191,7 @@ class _ServiceScreenState extends State { Widget build(BuildContext context) { final userProvider = Provider.of(context); UserModel? user = userProvider.user; + dynamic datos; return SafeArea( child: Scaffold( @@ -328,6 +343,80 @@ class _ServiceScreenState extends State { updateMarkersForServiceType(_serviceType); }); + + 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) { + if (mounted) { + setState(() { + _profesionalController.text = + profesional.name.toString(); + + professionalId = profesional.id; + + if (profesional.token != '') { + professionalToken = profesional.token!; + } + + professionalTarifa = + profesional.tarifa ?? 0; + + professionalUbicacion = + profesional.ubicacion; + + professionalLatitude = profesional.latitude; + professionalLongitude = + profesional.longitude; + + if (ubicacion == 'sitio') { + professionalAddress = + profesional.realAddress; + + _locacionController.text = + profesional.realAddress; + + LatLng professionalCoordinates = LatLng( + professionalLatitude!, + professionalLongitude!); + + if (professionalLatitude != null && + professionalLatitude != 0 && + professionalLongitude != null && + professionalLongitude != 0) { + _animateCameraToPosition( + LatLng(professionalLatitude!, + professionalLongitude!), + ); + + getPolylinePoints(_currentP!, + professionalCoordinates) + .then( + (coordinates) => { + generatePolyLineFromPoints( + coordinates), + }, + ); + } + } else { + polylines.clear(); + } + }); + } + } + } } } }, @@ -367,7 +456,7 @@ class _ServiceScreenState extends State { return; } - final dynamic datos = await Navigator.push( + datos = await Navigator.push( context, CupertinoPageRoute( builder: (BuildContext context) { diff --git a/lib/src/presentation/screens/professional.dart b/lib/src/presentation/screens/professional.dart index c4a3d48..7f5aaa4 100644 --- a/lib/src/presentation/screens/professional.dart +++ b/lib/src/presentation/screens/professional.dart @@ -300,127 +300,140 @@ class _ProfessionalScreenState extends State { ), ), ), - Expanded( - child: ListView.builder( - itemCount: professionals.length, - itemBuilder: (BuildContext context, int index) { - return ListTile( - leading: GestureDetector( - onTap: () { - Navigator.of(context).push( - CupertinoPageRoute( - builder: (BuildContext context) { - return ProfessionalInfoScreen( - professional: professionals[index], - ); - }, - ), - ); - }, - child: ReferencePhoto( - ref: professionals[index].professionalRef, - sizeCircle: 50, - size: 50, - sizeIcon: 35, - ), - ), - trailing: GestureDetector( - child: const Icon(Icons.keyboard_arrow_right), - onTap: () { - Navigator.of(context).push( - CupertinoPageRoute( - builder: (BuildContext context) { - return ProfessionalInfoScreen( - professional: professionals[index], - ); - }, - ), - ); - }, - ), - title: RichText( - text: TextSpan( - style: const TextStyle( - fontSize: 15.0, - color: Colors.black, - ), - children: [ - TextSpan( - text: '${professionals[index].name}, ', - style: const TextStyle(fontWeight: FontWeight.bold), - ), - TextSpan( - text: - "${professionals[index].professionName}, ${professionals[index].cityName}", - style: TextStyle(color: Colors.grey[600]), - ), - ], - ), - ), - subtitle: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - settings?.tarifas == true - ? professionals[index].tarifa == 0 - ? const SizedBox() - : Container( - padding: const EdgeInsets.symmetric( - horizontal: 10, vertical: 5), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20.0), - color: const Color(0xFFD6F4FF), - ), - child: Text( - formatCurrency( - professionals[index].tarifa ?? 0), - style: TextStyle( - color: Colors.grey[850], - fontWeight: FontWeight.w600, - ), - ), - ) - : const SizedBox(), - professionals[index].ubicacion == 'ambos' - ? Text( - 'Disponibilidad a domicilio y en sitio ${professionals[index].tarifa}', - style: const TextStyle( - color: Colors.blue, + professionals.isEmpty + ? Expanded( + child: Padding( + padding: + const EdgeInsets.only(left: 20, right: 20, top: 50), + child: + Text('Aún no tenemos ningun(a) ${widget.profession}'), + )) + : Expanded( + child: ListView.builder( + itemCount: professionals.length, + itemBuilder: (BuildContext context, int index) { + return ListTile( + leading: GestureDetector( + onTap: () { + Navigator.of(context).push( + CupertinoPageRoute( + builder: (BuildContext context) { + return ProfessionalInfoScreen( + professional: professionals[index], + ); + }, ), - ) - : professionals[index].ubicacion == 'sitio' - ? Text( - 'Disponibilidad en ${professionals[index].ubicacion} ', - style: const TextStyle( - color: Colors.blue, - ), - ) - : Text( - 'Disponibilidad a ${professionals[index].ubicacion}', - style: const TextStyle( - color: Colors.blue, - ), - ), - ], + ); + }, + child: ReferencePhoto( + ref: professionals[index].professionalRef, + sizeCircle: 50, + size: 50, + sizeIcon: 35, + ), + ), + trailing: GestureDetector( + child: const Icon(Icons.keyboard_arrow_right), + onTap: () { + Navigator.of(context).push( + CupertinoPageRoute( + builder: (BuildContext context) { + return ProfessionalInfoScreen( + professional: professionals[index], + ); + }, + ), + ); + }, + ), + title: RichText( + text: TextSpan( + style: const TextStyle( + fontSize: 15.0, + color: Colors.black, + ), + children: [ + TextSpan( + text: '${professionals[index].name}, ', + style: const TextStyle( + fontWeight: FontWeight.bold), + ), + TextSpan( + text: + "${professionals[index].professionName}, ${professionals[index].cityName}", + style: TextStyle(color: Colors.grey[600]), + ), + ], + ), + ), + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + settings?.tarifas == true + ? professionals[index].tarifa == 0 + ? const SizedBox() + : Container( + padding: const EdgeInsets.symmetric( + horizontal: 10, vertical: 5), + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(20.0), + color: const Color(0xFFD6F4FF), + ), + child: Text( + formatCurrency( + professionals[index].tarifa ?? + 0), + style: TextStyle( + color: Colors.grey[850], + fontWeight: FontWeight.w600, + ), + ), + ) + : const SizedBox(), + professionals[index].ubicacion == 'ambos' + ? Text( + 'Disponibilidad a domicilio y en sitio ${professionals[index].tarifa}', + style: const TextStyle( + color: Colors.blue, + ), + ) + : professionals[index].ubicacion == 'sitio' + ? Text( + 'Disponibilidad en ${professionals[index].ubicacion} ', + style: const TextStyle( + color: Colors.blue, + ), + ) + : Text( + 'Disponibilidad a ${professionals[index].ubicacion}', + style: const TextStyle( + color: Colors.blue, + ), + ), + ], + ), + onTap: () { + if (professionals[index].ubicacion == 'ambos') { + _showChoiceDialog(context).then((String? value) { + if (value != null) { + Navigator.pop( + context, [professionals[index], value]); + } + }); + } else if (professionals[index].ubicacion == + 'sitio') { + Navigator.pop( + context, [professionals[index], 'sitio']); + } else { + Navigator.pop( + context, [professionals[index], 'domicilio']); + } + }, + ); + }, ), - onTap: () { - if (professionals[index].ubicacion == 'ambos') { - _showChoiceDialog(context).then((String? value) { - if (value != null) { - Navigator.pop( - context, [professionals[index], value]); - } - }); - } else if (professionals[index].ubicacion == 'sitio') { - Navigator.pop(context, [professionals[index], 'sitio']); - } else { - Navigator.pop( - context, [professionals[index], 'domicilio']); - } - }, - ); - }, - ), - ), + ), ], ), ), diff --git a/lib/src/presentation/screens/service_type.dart b/lib/src/presentation/screens/service_type.dart index daba9bc..47fc79b 100644 --- a/lib/src/presentation/screens/service_type.dart +++ b/lib/src/presentation/screens/service_type.dart @@ -1,7 +1,9 @@ import 'package:diacritic/diacritic.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:prosappco/src/components/pop_appbar.dart'; import 'package:prosappco/src/presentation/screens/profession.dart'; +import 'package:prosappco/src/presentation/screens/professional.dart'; class ServiceTypeScreen extends StatefulWidget { const ServiceTypeScreen({super.key}); @@ -52,7 +54,7 @@ class _ServiceTypeScreenState extends State { ), ); } - var professions = filteredProfessions!; + List professions = filteredProfessions!; return Scaffold( appBar: PopAppbar( @@ -86,6 +88,17 @@ class _ServiceTypeScreenState extends State { ), onTap: () { Navigator.pop(context, professions[index]); + + // Navigator.push( + // context, + // CupertinoPageRoute( + // builder: (BuildContext context) { + // return ProfessionalScreen( + // profession: professions[index], + // ); + // }, + // ), + // ); }, ); },