solicitar servicio

This commit is contained in:
Juan Felipe Duarte
2023-06-16 11:44:21 -05:00
parent f923a8f5bc
commit b7b246b03a
+77 -41
View File
@@ -30,13 +30,13 @@ class ServiceScreen extends StatefulWidget {
class _ServiceScreenState extends State<ServiceScreen> {
EventoService eventoService = EventoService();
final TextEditingController _locationController = TextEditingController();
String _locationPosition = '';
String ubicacion = '';
final _ubicationController = TextEditingController();
final _profesionalController = TextEditingController();
final _serviceTypeController = TextEditingController();
final _observacionController = TextEditingController();
final TextEditingController _locationController = TextEditingController();
final TextEditingController _ubicationController = TextEditingController();
final TextEditingController _profesionalController = TextEditingController();
final TextEditingController _serviceTypeController = TextEditingController();
final TextEditingController _observacionController = TextEditingController();
String professionalId = '';
int? professionalTarifa;
String professionalAddress = '';
@@ -283,37 +283,15 @@ class _ServiceScreenState extends State<ServiceScreen> {
setState(() {
_profesionalController.text =
profesional.name.toString();
professionalId = profesional.id;
professionalTarifa = profesional.tarifa ?? 0;
professionalUbicacion = profesional.ubicacion;
professionalAddress = _ubicationController.text;
// 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),
// ),
// );
// }
// }
if (ubicacion == 'sitio') {
professionalAddress = profesional.realAddress;
_ubicationController.text = profesional.realAddress;
}
});
}
}
@@ -405,12 +383,70 @@ class _ServiceScreenState extends State<ServiceScreen> {
const SizedBox(height: 20.0),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => LocalNotificationScreen(),
),
);
if (user?.name == null ||
user?.name == '' ||
user?.phoneNumber == null ||
user?.phoneNumber == '') {
Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return const ProfileScreen();
},
),
);
} else {
try {
final DateTime combinedDate = DateTime(
_selectedDate!.year,
_selectedDate!.month,
_selectedDate!.day,
_selectedTime!.hour,
_selectedTime!.minute,
);
DateTime time2 =
combinedDate.add(const Duration(hours: 2));
UserModel.getUser(uid.toString()).then((value) {
eventoService
.createEvent(
value.name,
_observacionController.text,
'$_selectedDate',
'$combinedDate',
'$time2',
professionalId,
ubicacion,
professionalAddress,
0.0,
0.0,
'pendiente',
professionalTarifa == 0 ? 0 : professionalTarifa,
false,
false,
)
.then((value) {
Navigator.pushReplacement(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return ServiceAfterScreen(
eventoId: value,
);
},
),
);
});
});
} catch (e) {
Get.snackbar(
'Llena todos los campos',
'Asegurate de llenar todos los campos.',
snackPosition: SnackPosition.BOTTOM,
);
}
}
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF2BA4EC),