This commit is contained in:
Felipe
2023-11-17 17:53:54 -05:00
parent ef58892c13
commit a760c3c863
4 changed files with 245 additions and 130 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

+92 -3
View File
@@ -147,15 +147,29 @@ class _ServiceScreenState extends State<ServiceScreen> {
_saveToken(); _saveToken();
if (Platform.isAndroid) {
BitmapDescriptor.fromAssetImage( BitmapDescriptor.fromAssetImage(
const ImageConfiguration(size: Size(1, 1)), 'images/pro_marke.png') const ImageConfiguration(size: Size(2, 2)),
.then((icon) { 'images/pro_marke_android.png',
).then((icon) {
if (mounted) { if (mounted) {
setState(() { setState(() {
_markerIcon = icon; _markerIcon = icon;
}); });
} }
}); });
} else {
BitmapDescriptor.fromAssetImage(
const ImageConfiguration(size: Size(1, 1)),
'images/pro_marke.png',
).then((icon) {
if (mounted) {
setState(() {
_markerIcon = icon;
});
}
});
}
updateMarkersForServiceType(_serviceType); updateMarkersForServiceType(_serviceType);
} }
@@ -177,6 +191,7 @@ class _ServiceScreenState extends State<ServiceScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final userProvider = Provider.of<UserProvider>(context); final userProvider = Provider.of<UserProvider>(context);
UserModel? user = userProvider.user; UserModel? user = userProvider.user;
dynamic datos;
return SafeArea( return SafeArea(
child: Scaffold( child: Scaffold(
@@ -328,6 +343,80 @@ class _ServiceScreenState extends State<ServiceScreen> {
updateMarkersForServiceType(_serviceType); 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<ServiceScreen> {
return; return;
} }
final dynamic datos = await Navigator.push( datos = await Navigator.push(
context, context,
CupertinoPageRoute( CupertinoPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
+19 -6
View File
@@ -300,7 +300,15 @@ class _ProfessionalScreenState extends State<ProfessionalScreen> {
), ),
), ),
), ),
Expanded( 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( child: ListView.builder(
itemCount: professionals.length, itemCount: professionals.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
@@ -347,7 +355,8 @@ class _ProfessionalScreenState extends State<ProfessionalScreen> {
children: <TextSpan>[ children: <TextSpan>[
TextSpan( TextSpan(
text: '${professionals[index].name}, ', text: '${professionals[index].name}, ',
style: const TextStyle(fontWeight: FontWeight.bold), style: const TextStyle(
fontWeight: FontWeight.bold),
), ),
TextSpan( TextSpan(
text: text:
@@ -367,12 +376,14 @@ class _ProfessionalScreenState extends State<ProfessionalScreen> {
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 5), horizontal: 10, vertical: 5),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0), borderRadius:
BorderRadius.circular(20.0),
color: const Color(0xFFD6F4FF), color: const Color(0xFFD6F4FF),
), ),
child: Text( child: Text(
formatCurrency( formatCurrency(
professionals[index].tarifa ?? 0), professionals[index].tarifa ??
0),
style: TextStyle( style: TextStyle(
color: Colors.grey[850], color: Colors.grey[850],
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
@@ -410,8 +421,10 @@ class _ProfessionalScreenState extends State<ProfessionalScreen> {
context, [professionals[index], value]); context, [professionals[index], value]);
} }
}); });
} else if (professionals[index].ubicacion == 'sitio') { } else if (professionals[index].ubicacion ==
Navigator.pop(context, [professionals[index], 'sitio']); 'sitio') {
Navigator.pop(
context, [professionals[index], 'sitio']);
} else { } else {
Navigator.pop( Navigator.pop(
context, [professionals[index], 'domicilio']); context, [professionals[index], 'domicilio']);
+14 -1
View File
@@ -1,7 +1,9 @@
import 'package:diacritic/diacritic.dart'; import 'package:diacritic/diacritic.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:prosappco/src/components/pop_appbar.dart'; import 'package:prosappco/src/components/pop_appbar.dart';
import 'package:prosappco/src/presentation/screens/profession.dart'; import 'package:prosappco/src/presentation/screens/profession.dart';
import 'package:prosappco/src/presentation/screens/professional.dart';
class ServiceTypeScreen extends StatefulWidget { class ServiceTypeScreen extends StatefulWidget {
const ServiceTypeScreen({super.key}); const ServiceTypeScreen({super.key});
@@ -52,7 +54,7 @@ class _ServiceTypeScreenState extends State<ServiceTypeScreen> {
), ),
); );
} }
var professions = filteredProfessions!; List<String> professions = filteredProfessions!;
return Scaffold( return Scaffold(
appBar: PopAppbar( appBar: PopAppbar(
@@ -86,6 +88,17 @@ class _ServiceTypeScreenState extends State<ServiceTypeScreen> {
), ),
onTap: () { onTap: () {
Navigator.pop(context, professions[index]); Navigator.pop(context, professions[index]);
// Navigator.push(
// context,
// CupertinoPageRoute(
// builder: (BuildContext context) {
// return ProfessionalScreen(
// profession: professions[index],
// );
// },
// ),
// );
}, },
); );
}, },