pick profesional

This commit is contained in:
Juan Felipe Duarte
2023-04-28 21:44:47 -05:00
parent f57d3792c8
commit 0f90bc7ee9
4 changed files with 177 additions and 24 deletions
-1
View File
@@ -32,7 +32,6 @@ class _CitaScreenState extends State<CitaScreen> {
ScoresModel.scoreTo(widget.evento.userId.toString(), false, false).then(
(ScoresModel s) => setState(() {
scoresModel = s;
print('escore $scoresModel');
}),
);
}
+86 -1
View File
@@ -3,6 +3,7 @@ import 'package:diacritic/diacritic.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:prosappco/src/authentication/authentication_repository.dart';
import 'package:prosappco/src/components/photo_view.dart';
import 'package:prosappco/src/components/pop_appbar.dart';
@@ -31,6 +32,9 @@ class Professional {
final String professionName;
final String cityName;
final String ubicacion;
final String realAddress;
final double latitude;
final double longitude;
final List<String> professionalEspecializado;
final ScoresModel scores;
@@ -43,6 +47,9 @@ class Professional {
required this.ubicacion,
required this.professionalEspecializado,
required this.scores,
required this.realAddress,
required this.latitude,
required this.longitude,
});
String getEspecializaciones() {
@@ -57,6 +64,9 @@ class Professional {
' professionName: $professionName,\n'
' cityName: $cityName,\n'
' ubicacion: $ubicacion,\n'
' realAddress: $realAddress,\n'
' latitude: $latitude,\n'
' longitude: $longitude,\n'
' professionalEspecializado: ${getEspecializaciones()}\n'
'}';
}
@@ -88,6 +98,9 @@ class Professional {
professionalRef: storage.ref().child(photo),
professionalEspecializado: especializaciones,
ubicacion: data['ubicacion'] ?? '',
realAddress: data['address'] ?? '',
latitude: data['latitude'] ?? 0,
longitude: data['longitude'] ?? 0,
scores: await ScoresModel.scoreFrom(uid, true, true),
);
return professional;
@@ -100,6 +113,44 @@ class Professional {
}
class _ProfessionalScreenState extends State<ProfessionalScreen> {
Future<String?> _showChoiceDialog(BuildContext context) async {
String? selectedOption = await showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
content: SingleChildScrollView(
child: ListBody(
children: [
GestureDetector(
child: const Text(
textAlign: TextAlign.center,
"A domicilio",
style: TextStyle(color: Color(0xFF2BA4EC)),
),
onTap: () {
Navigator.of(context).pop("domicilio");
},
),
const Divider(color: Colors.black54),
GestureDetector(
child: const Text(
textAlign: TextAlign.center,
"En sitio",
style: TextStyle(color: Color(0xFF2BA4EC)),
),
onTap: () {
Navigator.of(context).pop("sitio");
},
),
],
),
),
);
},
);
return selectedOption;
}
List<Professional>? filteredProfessionals;
TextEditingController searchController = TextEditingController();
@@ -136,6 +187,9 @@ class _ProfessionalScreenState extends State<ProfessionalScreen> {
professionalRef: storage.ref().child(_photo),
professionalEspecializado: especializaciones,
ubicacion: data['ubicacion'] ?? '',
realAddress: data['address'] ?? '',
latitude: data['latitude'] ?? 0,
longitude: data['longitude'] ?? 0,
scores: await ScoresModel.scoreTo(user.id, true, true),
);
professionals.add(professional);
@@ -265,8 +319,39 @@ class _ProfessionalScreenState extends State<ProfessionalScreen> {
],
),
),
subtitle: professionals[index].ubicacion == 'ambos'
? const Text(
'Disponibilidad a domicilio y en sitio',
style: 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: () {
Navigator.pop(context, professionals[index]);
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']);
}
},
);
},
+72 -22
View File
@@ -1,4 +1,3 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
@@ -14,6 +13,7 @@ import 'package:prosappco/src/models/event_model.dart';
import 'package:prosappco/src/models/user_model.dart';
import 'package:prosappco/src/screens/professional.dart';
import 'package:intl/intl.dart';
import 'package:prosappco/src/screens/service_after.dart';
import 'package:prosappco/src/screens/service_type.dart';
class ServiceScreen extends StatefulWidget {
@@ -31,7 +31,11 @@ class _ServiceScreenState extends State<ServiceScreen> {
final _profesionalController = TextEditingController();
final _serviceTypeController = TextEditingController();
final _observacionController = TextEditingController();
var professionalId = '';
String professionalId = '';
String professionalAddress = '';
String professionalUbicacion = '';
double? professionalLatitude;
double? professionalLongitude;
String _serviceType = 'Servicio';
String _professional = '';
final DateFormat formatter = DateFormat('dd/MM/yyyy');
@@ -161,14 +165,16 @@ class _ServiceScreenState extends State<ServiceScreen> {
googleMapController = controller;
},
onCameraIdle: () {
if (coordinates != null) {
getLocationName(
coordinates.latitude, coordinates.longitude)
.then((locationName) {
setState(() {
_locationController.text = locationName;
if (professionalAddress == '') {
if (coordinates != null) {
getLocationName(
coordinates.latitude, coordinates.longitude)
.then((locationName) {
setState(() {
_locationController.text = locationName;
});
});
});
}
}
},
onCameraMove: (position) {
@@ -223,11 +229,6 @@ class _ServiceScreenState extends State<ServiceScreen> {
}
// markers.clear();
// markers.add(Marker(
// markerId: MarkerId('currentLocation'),
// position:
// LatLng(position.latitude, position.longitude)));
},
elevation: 0,
child: const Icon(
@@ -340,8 +341,7 @@ class _ServiceScreenState extends State<ServiceScreen> {
controller: _profesionalController,
readOnly: true,
onTap: () async {
final Professional? profesional =
await Navigator.push(
final dynamic datos = await Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
@@ -351,13 +351,54 @@ class _ServiceScreenState extends State<ServiceScreen> {
},
),
);
if (datos != null) {
Professional? profesional = datos[0];
if (profesional != null) {
setState(() {
_profesionalController.text =
profesional.name.toString();
professionalId = profesional.id;
});
if (profesional != null) {
setState(() {
_profesionalController.text =
profesional.name.toString();
professionalAddress =
profesional.realAddress;
professionalUbicacion =
profesional.ubicacion;
_locationController.text =
profesional.realAddress;
professionalLatitude =
profesional.latitude;
professionalLongitude =
profesional.longitude;
if (professionalLatitude != null &&
professionalLatitude != 0 &&
professionalLongitude != null &&
professionalLongitude != 0) {
markers.clear();
markers.add(Marker(
markerId:
const MarkerId('professional'),
position: LatLng(
professionalLatitude!,
professionalLongitude!)));
googleMapController.animateCamera(
CameraUpdate.newCameraPosition(
CameraPosition(
target: LatLng(
professionalLatitude!,
professionalLongitude!,
),
zoom: 17),
),
);
}
professionalId = profesional.id;
});
}
}
},
decoration: const InputDecoration(
@@ -440,6 +481,15 @@ class _ServiceScreenState extends State<ServiceScreen> {
professionalId,
);
});
// Navigator.push(
// context,
// CupertinoPageRoute(
// builder: (BuildContext context) {
// return const ServiceAfterScreen();
// },
// ),
// );
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF2BA4EC),
+19
View File
@@ -0,0 +1,19 @@
import 'package:flutter/material.dart';
import 'package:prosappco/src/components/pop_appbar.dart';
class ServiceAfterScreen extends StatefulWidget {
const ServiceAfterScreen({super.key});
@override
State<ServiceAfterScreen> createState() => _ServiceAfterScreenState();
}
class _ServiceAfterScreenState extends State<ServiceAfterScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar:
PopAppbar(onPressed: () => Navigator.pop(context), label: 'Servicio'),
);
}
}