This commit is contained in:
Felipe
2024-01-06 13:59:44 -05:00
parent a7db9d986d
commit 7977a9be24
5 changed files with 72 additions and 133 deletions
+1 -1
View File
@@ -92,7 +92,7 @@ class DefaultPhotoWeb extends StatelessWidget {
color: const Color.fromARGB(255, 255, 255, 255),
size: iconDefault,
),
).animate().shake();
);
}
}
+1 -13
View File
@@ -40,19 +40,7 @@ class Professional {
@override
String toString() {
return 'Professional {\n'
' professionalRef: $professionalRef,\n'
' name: $name,\n'
' professionName: $professionName,\n'
' cityName: $cityName,\n'
' ubicacion: $ubicacion,\n'
' realAddress: $realAddress,\n'
' latitude: $latitude,\n'
' longitude: $longitude,\n'
' professionalEspecializado: ${getEspecializaciones()}\n'
' tarifa: $tarifa,\n'
' token: $token,\n'
'}';
return 'Professional { professionalRef: $professionalRef, name: $name, professionName: $professionName, cityName: $cityName, ubicacion: $ubicacion, realAddress: $realAddress, latitude: $latitude, longitude: $longitude, professionalEspecializado: ${getEspecializaciones()} tarifa: $tarifa token: $token, }';
}
static Future<Professional?> getProfessional(String uid) async {
+14 -9
View File
@@ -101,7 +101,7 @@ class _CalendarProScreenState extends State<CalendarProScreen> {
color: const Color.fromARGB(255, 224, 247, 255),
child: TableCalendar(
locale: 'es_MX',
firstDay: DateTime.utc(2010, 10, 16),
firstDay: DateTime.now(),
lastDay: lastDay,
focusedDay: today,
availableGestures: AvailableGestures.all,
@@ -213,14 +213,19 @@ class _CalendarProScreenState extends State<CalendarProScreen> {
),
child: ListTile(
onTap: () {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => ServiceScreen(
fechaSeleccionada: today, horaSeleccionada: time),
),
(route) => false, // Elimina todas las rutas en la pila
);
Navigator.pop(context, [today, time, widget.professional]);
// Navigator.pushAndRemoveUntil(
// context,
// MaterialPageRoute(
// builder: (context) => ServiceScreen(
// fechaSeleccionada: today,
// horaSeleccionada: time,
// professionalSeleccionado: widget.professional,
// ),
// ),
// (route) => false,
// );
},
contentPadding: const EdgeInsets.all(16),
leading: Container(
+44 -105
View File
@@ -29,15 +29,14 @@ import 'package:prosappco/src/presentation/widgets/shared/drawer_menu.dart';
import 'package:prosappco/src/presentation/widgets/shared/primary_button.dart';
import 'package:prosappco/src/presentation/widgets/shared/warning_snackbar.dart';
import 'package:prosappco/src/providers/user_provider.dart';
import 'package:prosappco/src/utils/time_of_day_extension.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
class ServiceScreen extends StatefulWidget {
final DateTime? fechaSeleccionada;
final TimeOfDay? horaSeleccionada;
const ServiceScreen(
{super.key, this.fechaSeleccionada, this.horaSeleccionada});
const ServiceScreen({
super.key,
});
@override
State<ServiceScreen> createState() => _ServiceScreenState();
@@ -95,6 +94,10 @@ class _ServiceScreenState extends State<ServiceScreen> {
late final FirebaseAuth _auth;
final _nameController = TextEditingController();
DateTime? fechaSeleccionada;
TimeOfDay? horaSeleccionada;
Professional? profesionalSeleccionado;
@override
void initState() {
super.initState();
@@ -105,9 +108,6 @@ class _ServiceScreenState extends State<ServiceScreen> {
_auth = FirebaseAuth.instance;
print('jurgo 1 ${widget.fechaSeleccionada}');
print('jurgo 2 ${widget.horaSeleccionada}');
final currentUser = _auth.currentUser;
if (currentUser != null && currentUser.displayName != null) {
@@ -507,11 +507,15 @@ class _ServiceScreenState extends State<ServiceScreen> {
},
),
);
if (datos != null) {
Professional? profesional = datos[0];
ubicacion = datos[1];
fechaSeleccionada = datos[0];
horaSeleccionada = datos[1];
Professional? profesional = datos[2];
profesionalSeleccionado = profesional;
if (profesional != null) {
ubicacion = profesional.ubicacion;
if (mounted) {
setState(() {
_profesionalController.text =
@@ -619,12 +623,10 @@ class _ServiceScreenState extends State<ServiceScreen> {
},
),
),
widget.fechaSeleccionada == null &&
widget.horaSeleccionada == null
fechaSeleccionada == null && horaSeleccionada == null
? const SizedBox()
: const SizedBox(height: 15),
widget.fechaSeleccionada == null &&
widget.horaSeleccionada == null
fechaSeleccionada == null && horaSeleccionada == null
? const SizedBox()
: Row(
children: [
@@ -635,71 +637,40 @@ class _ServiceScreenState extends State<ServiceScreen> {
prefixIcon: Icon(Icons.calendar_month),
hintText: 'Fecha',
),
// controller: TextEditingController(
// text: _selectedDate == null
// ? ''
// : formatter.format(_selectedDate!),
// ),
controller: TextEditingController(
text: widget.fechaSeleccionada == null
text: fechaSeleccionada == null
? ''
: formatter
.format(widget.fechaSeleccionada!),
: formatter.format(fechaSeleccionada!),
),
// onTap: () {
// if (_profesionalController
// .text.isNotEmpty) {
// _selectDateAndTime(context);
// } else {
// WarningSnackbar.show(
// title: 'Selecciona un profesional',
// message:
// 'Selecciona un profesional antes de elegir la fecha y la hora de la cita.',
// backgroundColor: Colors.orange,
// );
// }
// },
),
),
Expanded(
child: TextFormField(
// onTap: () {
// if (_profesionalController.text.isNotEmpty) {
// _selectDateAndTime(context);
// } else {
// WarningSnackbar.show(
// title: 'Selecciona un profesional',
// message:
// 'Selecciona un profesional antes de elegir la fecha y la hora de la cita.',
// backgroundColor: Colors.orange);
// }
// },
readOnly: true,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.watch_later_outlined),
hintText: 'Hora',
),
// controller: TextEditingController(
// text: _selectedTime == null
// ? ''
// : ' ${_selectedTime!.format(context)}',
// ),
controller: TextEditingController(
text: widget.horaSeleccionada == null
text: horaSeleccionada == null
? ''
: ' ${widget.horaSeleccionada!.format(context)}',
: ' ${horaSeleccionada!.format(context)}',
),
))
],
),
const SizedBox(height: 15),
TextFormField(
controller: _observacionController,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.message_outlined),
hintText: 'Observaciones',
),
),
fechaSeleccionada == null && horaSeleccionada == null
? const SizedBox()
: const SizedBox(height: 15),
fechaSeleccionada == null && horaSeleccionada == null
? const SizedBox()
: TextFormField(
controller: _observacionController,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.message_outlined),
hintText: 'Observaciones',
),
),
const SizedBox(height: 20),
Center(
child: PrimaryButton(
@@ -724,25 +695,25 @@ class _ServiceScreenState extends State<ServiceScreen> {
);
} else {
try {
final DateTime combinedDate = DateTime(
_selectedDate!.year,
_selectedDate!.month,
_selectedDate!.day,
_selectedTime!.hour,
_selectedTime!.minute,
DateTime time1 = DateTime(
fechaSeleccionada!.year,
fechaSeleccionada!.month,
fechaSeleccionada!.day,
horaSeleccionada!.hour,
horaSeleccionada!.minute,
);
DateTime time2 = combinedDate.add(
const Duration(hours: 2),
);
DateTime time2 =
time1.add(const Duration(hours: 2));
UserModel.getUser(uid.toString()).then((value) {
eventoService
.createEvent(
value.name,
_observacionController.text,
'$_selectedDate',
'$combinedDate',
fechaSeleccionada.toString().substring(0,
fechaSeleccionada.toString().length - 1),
'$time1',
'$time2',
professionalId,
ubicacion,
@@ -780,7 +751,7 @@ class _ServiceScreenState extends State<ServiceScreen> {
WarningSnackbar.show(
title: 'Llena todos los campos',
message:
'Asegurate de llenar todos los campos antes de solicitar un servicio.',
'Asegurate de llenar todos los campos antes de solicitar un servicio. $e',
);
}
}
@@ -995,38 +966,6 @@ class _ServiceScreenState extends State<ServiceScreen> {
}
}
Future<void> _selectDate(BuildContext context) async {
final DateTime? picked = await showDatePicker(
context: context,
initialDate: now,
firstDate: now,
lastDate: DateTime(now.year + 1),
);
if (picked != null && picked != _selectedDate) {
if (mounted) {
setState(() {
_selectedDate = picked;
});
}
}
}
Future<void> _selectTime(BuildContext context) async {
final TimeOfDay? pickedTime = await showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
);
if (pickedTime != null) {
if (mounted) {
setState(() {
_selectedTime = pickedTime;
});
}
}
}
Future<List<DocumentSnapshot<Map<String, dynamic>>>> getUsersWithActiveStatus(
String serviceType) async {
dynamic querySnapshot;
+12 -5
View File
@@ -17,7 +17,10 @@ import '../../models/scores_model.dart';
class ProfessionalScreen extends StatefulWidget {
final String profession;
const ProfessionalScreen({super.key, required this.profession});
const ProfessionalScreen({
super.key,
required this.profession,
});
@override
State<ProfessionalScreen> createState() => _ProfessionalScreenState();
@@ -377,7 +380,7 @@ class _ProfessionalScreenState extends State<ProfessionalScreen> {
),
],
),
onTap: () {
onTap: () async {
if (professionals[index].ubicacion == 'ambos') {
_showChoiceDialog(context).then((String? value) {
if (value != null) {
@@ -388,15 +391,19 @@ class _ProfessionalScreenState extends State<ProfessionalScreen> {
} else if (professionals[index].ubicacion ==
'sitio') {
// Navigator.pop(context, [professionals[index], 'sitio']);
Navigator.of(context).push(
var datos = await Navigator.of(context).push(
CupertinoPageRoute(
builder: (BuildContext context) {
return CalendarProScreen(
professional: professionals[index]);
professional: professionals[index],
);
},
),
);
if (datos != null) {
Navigator.pop(context, datos);
}
} else {
Navigator.pop(
context, [professionals[index], 'domicilio']);