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
+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),