update
This commit is contained in:
@@ -92,7 +92,7 @@ class DefaultPhotoWeb extends StatelessWidget {
|
|||||||
color: const Color.fromARGB(255, 255, 255, 255),
|
color: const Color.fromARGB(255, 255, 255, 255),
|
||||||
size: iconDefault,
|
size: iconDefault,
|
||||||
),
|
),
|
||||||
).animate().shake();
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,19 +40,7 @@ class Professional {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Professional {\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, }';
|
||||||
' 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'
|
|
||||||
'}';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<Professional?> getProfessional(String uid) async {
|
static Future<Professional?> getProfessional(String uid) async {
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class _CalendarProScreenState extends State<CalendarProScreen> {
|
|||||||
color: const Color.fromARGB(255, 224, 247, 255),
|
color: const Color.fromARGB(255, 224, 247, 255),
|
||||||
child: TableCalendar(
|
child: TableCalendar(
|
||||||
locale: 'es_MX',
|
locale: 'es_MX',
|
||||||
firstDay: DateTime.utc(2010, 10, 16),
|
firstDay: DateTime.now(),
|
||||||
lastDay: lastDay,
|
lastDay: lastDay,
|
||||||
focusedDay: today,
|
focusedDay: today,
|
||||||
availableGestures: AvailableGestures.all,
|
availableGestures: AvailableGestures.all,
|
||||||
@@ -213,14 +213,19 @@ class _CalendarProScreenState extends State<CalendarProScreen> {
|
|||||||
),
|
),
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pushAndRemoveUntil(
|
Navigator.pop(context, [today, time, widget.professional]);
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
// Navigator.pushAndRemoveUntil(
|
||||||
builder: (context) => ServiceScreen(
|
// context,
|
||||||
fechaSeleccionada: today, horaSeleccionada: time),
|
// MaterialPageRoute(
|
||||||
),
|
// builder: (context) => ServiceScreen(
|
||||||
(route) => false, // Elimina todas las rutas en la pila
|
// fechaSeleccionada: today,
|
||||||
);
|
// horaSeleccionada: time,
|
||||||
|
// professionalSeleccionado: widget.professional,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// (route) => false,
|
||||||
|
// );
|
||||||
},
|
},
|
||||||
contentPadding: const EdgeInsets.all(16),
|
contentPadding: const EdgeInsets.all(16),
|
||||||
leading: Container(
|
leading: Container(
|
||||||
|
|||||||
@@ -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/primary_button.dart';
|
||||||
import 'package:prosappco/src/presentation/widgets/shared/warning_snackbar.dart';
|
import 'package:prosappco/src/presentation/widgets/shared/warning_snackbar.dart';
|
||||||
import 'package:prosappco/src/providers/user_provider.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:provider/provider.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class ServiceScreen extends StatefulWidget {
|
class ServiceScreen extends StatefulWidget {
|
||||||
final DateTime? fechaSeleccionada;
|
const ServiceScreen({
|
||||||
final TimeOfDay? horaSeleccionada;
|
super.key,
|
||||||
|
});
|
||||||
const ServiceScreen(
|
|
||||||
{super.key, this.fechaSeleccionada, this.horaSeleccionada});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ServiceScreen> createState() => _ServiceScreenState();
|
State<ServiceScreen> createState() => _ServiceScreenState();
|
||||||
@@ -95,6 +94,10 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
|||||||
late final FirebaseAuth _auth;
|
late final FirebaseAuth _auth;
|
||||||
final _nameController = TextEditingController();
|
final _nameController = TextEditingController();
|
||||||
|
|
||||||
|
DateTime? fechaSeleccionada;
|
||||||
|
TimeOfDay? horaSeleccionada;
|
||||||
|
Professional? profesionalSeleccionado;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -105,9 +108,6 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
|||||||
|
|
||||||
_auth = FirebaseAuth.instance;
|
_auth = FirebaseAuth.instance;
|
||||||
|
|
||||||
print('jurgo 1 ${widget.fechaSeleccionada}');
|
|
||||||
print('jurgo 2 ${widget.horaSeleccionada}');
|
|
||||||
|
|
||||||
final currentUser = _auth.currentUser;
|
final currentUser = _auth.currentUser;
|
||||||
|
|
||||||
if (currentUser != null && currentUser.displayName != null) {
|
if (currentUser != null && currentUser.displayName != null) {
|
||||||
@@ -507,11 +507,15 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (datos != null) {
|
if (datos != null) {
|
||||||
Professional? profesional = datos[0];
|
fechaSeleccionada = datos[0];
|
||||||
ubicacion = datos[1];
|
horaSeleccionada = datos[1];
|
||||||
|
Professional? profesional = datos[2];
|
||||||
|
profesionalSeleccionado = profesional;
|
||||||
|
|
||||||
if (profesional != null) {
|
if (profesional != null) {
|
||||||
|
ubicacion = profesional.ubicacion;
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_profesionalController.text =
|
_profesionalController.text =
|
||||||
@@ -619,12 +623,10 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
widget.fechaSeleccionada == null &&
|
fechaSeleccionada == null && horaSeleccionada == null
|
||||||
widget.horaSeleccionada == null
|
|
||||||
? const SizedBox()
|
? const SizedBox()
|
||||||
: const SizedBox(height: 15),
|
: const SizedBox(height: 15),
|
||||||
widget.fechaSeleccionada == null &&
|
fechaSeleccionada == null && horaSeleccionada == null
|
||||||
widget.horaSeleccionada == null
|
|
||||||
? const SizedBox()
|
? const SizedBox()
|
||||||
: Row(
|
: Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -635,71 +637,40 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
|||||||
prefixIcon: Icon(Icons.calendar_month),
|
prefixIcon: Icon(Icons.calendar_month),
|
||||||
hintText: 'Fecha',
|
hintText: 'Fecha',
|
||||||
),
|
),
|
||||||
// controller: TextEditingController(
|
|
||||||
// text: _selectedDate == null
|
|
||||||
// ? ''
|
|
||||||
// : formatter.format(_selectedDate!),
|
|
||||||
// ),
|
|
||||||
controller: TextEditingController(
|
controller: TextEditingController(
|
||||||
text: widget.fechaSeleccionada == null
|
text: fechaSeleccionada == null
|
||||||
? ''
|
? ''
|
||||||
: formatter
|
: formatter.format(fechaSeleccionada!),
|
||||||
.format(widget.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(
|
Expanded(
|
||||||
child: TextFormField(
|
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,
|
readOnly: true,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
prefixIcon: Icon(Icons.watch_later_outlined),
|
prefixIcon: Icon(Icons.watch_later_outlined),
|
||||||
hintText: 'Hora',
|
hintText: 'Hora',
|
||||||
),
|
),
|
||||||
// controller: TextEditingController(
|
|
||||||
// text: _selectedTime == null
|
|
||||||
// ? ''
|
|
||||||
// : ' ${_selectedTime!.format(context)}',
|
|
||||||
// ),
|
|
||||||
controller: TextEditingController(
|
controller: TextEditingController(
|
||||||
text: widget.horaSeleccionada == null
|
text: horaSeleccionada == null
|
||||||
? ''
|
? ''
|
||||||
: ' ${widget.horaSeleccionada!.format(context)}',
|
: ' ${horaSeleccionada!.format(context)}',
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 15),
|
fechaSeleccionada == null && horaSeleccionada == null
|
||||||
TextFormField(
|
? const SizedBox()
|
||||||
controller: _observacionController,
|
: const SizedBox(height: 15),
|
||||||
decoration: const InputDecoration(
|
fechaSeleccionada == null && horaSeleccionada == null
|
||||||
prefixIcon: Icon(Icons.message_outlined),
|
? const SizedBox()
|
||||||
hintText: 'Observaciones',
|
: TextFormField(
|
||||||
),
|
controller: _observacionController,
|
||||||
),
|
decoration: const InputDecoration(
|
||||||
|
prefixIcon: Icon(Icons.message_outlined),
|
||||||
|
hintText: 'Observaciones',
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Center(
|
Center(
|
||||||
child: PrimaryButton(
|
child: PrimaryButton(
|
||||||
@@ -724,25 +695,25 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
final DateTime combinedDate = DateTime(
|
DateTime time1 = DateTime(
|
||||||
_selectedDate!.year,
|
fechaSeleccionada!.year,
|
||||||
_selectedDate!.month,
|
fechaSeleccionada!.month,
|
||||||
_selectedDate!.day,
|
fechaSeleccionada!.day,
|
||||||
_selectedTime!.hour,
|
horaSeleccionada!.hour,
|
||||||
_selectedTime!.minute,
|
horaSeleccionada!.minute,
|
||||||
);
|
);
|
||||||
|
|
||||||
DateTime time2 = combinedDate.add(
|
DateTime time2 =
|
||||||
const Duration(hours: 2),
|
time1.add(const Duration(hours: 2));
|
||||||
);
|
|
||||||
|
|
||||||
UserModel.getUser(uid.toString()).then((value) {
|
UserModel.getUser(uid.toString()).then((value) {
|
||||||
eventoService
|
eventoService
|
||||||
.createEvent(
|
.createEvent(
|
||||||
value.name,
|
value.name,
|
||||||
_observacionController.text,
|
_observacionController.text,
|
||||||
'$_selectedDate',
|
fechaSeleccionada.toString().substring(0,
|
||||||
'$combinedDate',
|
fechaSeleccionada.toString().length - 1),
|
||||||
|
'$time1',
|
||||||
'$time2',
|
'$time2',
|
||||||
professionalId,
|
professionalId,
|
||||||
ubicacion,
|
ubicacion,
|
||||||
@@ -780,7 +751,7 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
|||||||
WarningSnackbar.show(
|
WarningSnackbar.show(
|
||||||
title: 'Llena todos los campos',
|
title: 'Llena todos los campos',
|
||||||
message:
|
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(
|
Future<List<DocumentSnapshot<Map<String, dynamic>>>> getUsersWithActiveStatus(
|
||||||
String serviceType) async {
|
String serviceType) async {
|
||||||
dynamic querySnapshot;
|
dynamic querySnapshot;
|
||||||
|
|||||||
@@ -17,7 +17,10 @@ import '../../models/scores_model.dart';
|
|||||||
|
|
||||||
class ProfessionalScreen extends StatefulWidget {
|
class ProfessionalScreen extends StatefulWidget {
|
||||||
final String profession;
|
final String profession;
|
||||||
const ProfessionalScreen({super.key, required this.profession});
|
const ProfessionalScreen({
|
||||||
|
super.key,
|
||||||
|
required this.profession,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ProfessionalScreen> createState() => _ProfessionalScreenState();
|
State<ProfessionalScreen> createState() => _ProfessionalScreenState();
|
||||||
@@ -377,7 +380,7 @@ class _ProfessionalScreenState extends State<ProfessionalScreen> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
if (professionals[index].ubicacion == 'ambos') {
|
if (professionals[index].ubicacion == 'ambos') {
|
||||||
_showChoiceDialog(context).then((String? value) {
|
_showChoiceDialog(context).then((String? value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
@@ -388,15 +391,19 @@ class _ProfessionalScreenState extends State<ProfessionalScreen> {
|
|||||||
} else if (professionals[index].ubicacion ==
|
} else if (professionals[index].ubicacion ==
|
||||||
'sitio') {
|
'sitio') {
|
||||||
// Navigator.pop(context, [professionals[index], 'sitio']);
|
// Navigator.pop(context, [professionals[index], 'sitio']);
|
||||||
|
var datos = await Navigator.of(context).push(
|
||||||
Navigator.of(context).push(
|
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return CalendarProScreen(
|
return CalendarProScreen(
|
||||||
professional: professionals[index]);
|
professional: professionals[index],
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (datos != null) {
|
||||||
|
Navigator.pop(context, datos);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Navigator.pop(
|
Navigator.pop(
|
||||||
context, [professionals[index], 'domicilio']);
|
context, [professionals[index], 'domicilio']);
|
||||||
|
|||||||
Reference in New Issue
Block a user