From f6f2e403d8619f73910861a85745fa1e98870e6f Mon Sep 17 00:00:00 2001 From: Felipe Date: Sat, 17 Aug 2024 11:41:25 -0500 Subject: [PATCH] update lat, lng 0 y horarios --- .../professional_calendar_screen.dart | 6 +- .../professional_profile_screen.dart | 15 +-- .../profile_register_phone_screen.dart | 6 +- lib/screens/user/user_calendar_screen.dart | 96 +++++++++++++++++-- lib/screens/user/user_map_screen.dart | 6 +- 5 files changed, 106 insertions(+), 23 deletions(-) diff --git a/lib/screens/professional/professional_calendar_screen.dart b/lib/screens/professional/professional_calendar_screen.dart index 5f03400..04fb9ad 100644 --- a/lib/screens/professional/professional_calendar_screen.dart +++ b/lib/screens/professional/professional_calendar_screen.dart @@ -25,8 +25,7 @@ class ProfessionalCalendarScreen extends StatefulWidget { _ProfessionalCalendarScreenState(); } -class _ProfessionalCalendarScreenState - extends State { +class _ProfessionalCalendarScreenState extends State { final settingRepository = Injector.appInstance.get(); final serviceRepository = Injector.appInstance.get(); @@ -238,8 +237,7 @@ class _ProfessionalCalendarScreenState return false; } - List rangesItemList(List ranges, - List? events, DateTime selectedDay, BuildContext context) { + List rangesItemList(List ranges, List? events, DateTime selectedDay, BuildContext context) { return ranges.map((time) { if (_isHora1Ocupada(time, events, selectedDay)) { return Card( diff --git a/lib/screens/professional/professional_profile_screen.dart b/lib/screens/professional/professional_profile_screen.dart index 032548c..e698744 100644 --- a/lib/screens/professional/professional_profile_screen.dart +++ b/lib/screens/professional/professional_profile_screen.dart @@ -112,6 +112,9 @@ class _ProfessionalProfileScreenState extends State { _addressController.text = proInfo.address; _aditionalAddressController.text = proInfo.aditionalAddress; + _longitudeController = proInfo.longitude; + _latitudeController = proInfo.latitude; + isNequiActive = proInfo.paymentMethods.nequi; isDatafonoActive = proInfo.paymentMethods.datafono; isTransferActive = proInfo.paymentMethods.transferencia; @@ -606,22 +609,22 @@ class _ProfessionalProfileScreenState extends State { String timeList(ScheduleEntity? schedule, BuildContext context) { if (schedule == null) { - return 'N/A'; + return 'No hay horarios'; } if (!schedule.enabled) { - return 'N/A'; + return 'No hay horarios'; } if (schedule.range1Hour1 == null || schedule.range2Hour2 == null) { - return 'N/A'; + return 'No hay horarios'; } if (schedule.continuousDay) { - return '${ScheduleEntity.getFormatTime(schedule.range1Hour1)} - ${ScheduleEntity.getFormatTime(schedule.range2Hour2)}'; + return '${ScheduleEntity.getFormatTime(schedule.range1Hour1)} a ${ScheduleEntity.getFormatTime(schedule.range2Hour2)}'; } else { if (schedule.range1Hour2 == null || schedule.range2Hour1 == null) { - return 'N/A'; + return 'No hay horarios'; } - return '${ScheduleEntity.getFormatTime(schedule.range1Hour1)} - ${ScheduleEntity.getFormatTime(schedule.range1Hour2)}; ${ScheduleEntity.getFormatTime(schedule.range2Hour1)} - ${ScheduleEntity.getFormatTime(schedule.range2Hour2)}'; + return '${ScheduleEntity.getFormatTime(schedule.range1Hour1)} a ${ScheduleEntity.getFormatTime(schedule.range1Hour2)} - ${ScheduleEntity.getFormatTime(schedule.range2Hour1)} a ${ScheduleEntity.getFormatTime(schedule.range2Hour2)}'; } } } diff --git a/lib/screens/profile/profile_register_phone_screen.dart b/lib/screens/profile/profile_register_phone_screen.dart index 78bb6b0..1384239 100644 --- a/lib/screens/profile/profile_register_phone_screen.dart +++ b/lib/screens/profile/profile_register_phone_screen.dart @@ -15,12 +15,10 @@ class ProfileRegisterPhoneScreen extends StatefulWidget { const ProfileRegisterPhoneScreen({super.key}); @override - State createState() => - _ProfileRegisterPhoneScreenState(); + State createState() => _ProfileRegisterPhoneScreenState(); } -class _ProfileRegisterPhoneScreenState - extends State { +class _ProfileRegisterPhoneScreenState extends State { late final AuthBloc authBloc; late String verificationCode; diff --git a/lib/screens/user/user_calendar_screen.dart b/lib/screens/user/user_calendar_screen.dart index 018aa4f..1243d9c 100644 --- a/lib/screens/user/user_calendar_screen.dart +++ b/lib/screens/user/user_calendar_screen.dart @@ -162,26 +162,55 @@ class UserCalendarScreenState extends State { } List _rangesItems(ScheduleEntity? schedule) { - if (schedule == null || - schedule.enabled == false || - schedule.range1Hour1 == null || - schedule.range2Hour2 == null) { + if (schedule == null) { return [ const Padding( - padding: EdgeInsets.symmetric(vertical: 25), + padding: EdgeInsets.symmetric(vertical: 20), + child: Text("No hay horarios disponibles"), + ) + ]; + } + if (!schedule.enabled) { + return [ + const Padding( + padding: EdgeInsets.symmetric(vertical: 20), child: Text("No hay horarios disponibles"), ) ]; } if (schedule.continuousDay) { + if (schedule.range1Hour1 == null || + schedule.range2Hour2 == null || + schedule.range1Hour1!.compareTo(schedule.range2Hour2!) >= 0) { + return [ + const Padding( + padding: EdgeInsets.symmetric(vertical: 20), + child: Text("No hay horarios disponibles"), + ) + ]; + } + List ranges = TimeOfDayUtils.genRanges( schedule.range1Hour1!, schedule.range2Hour2!, ); return rangesItemList(ranges, _services, today); - } + } else { + if (schedule.range1Hour1 == null || + schedule.range1Hour2 == null || + schedule.range2Hour1 == null || + schedule.range2Hour2 == null || + schedule.range1Hour1!.compareTo(schedule.range1Hour2!) >= 0 || + schedule.range2Hour1!.compareTo(schedule.range2Hour2!) >= 0) { + return [ + const Padding( + padding: EdgeInsets.symmetric(vertical: 20), + child: Text("No hay horarios disponibles"), + ) + ]; + } List ranges1 = TimeOfDayUtils.genRanges( schedule.range1Hour1!, @@ -214,7 +243,62 @@ class UserCalendarScreenState extends State { List rangesItemList(List ranges, List? events, DateTime selectedDay) { + final currentDateTime = DateTime.now(); + return ranges.map((time) { + final selectedDateTime = DateTime( + selectedDay.year, + selectedDay.month, + selectedDay.day, + time.hour, + time.minute, + ); + + if (selectedDateTime + .isBefore(currentDateTime.add(const Duration(hours: 3)))) { + return Card( + elevation: 4, + margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 10), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + child: ListTile( + contentPadding: const EdgeInsets.all(16), + leading: Container( + width: 40, + height: 40, + decoration: const BoxDecoration( + gradient: LinearGradient( + color: Colors.grey, + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + shape: BoxShape.circle, + ), + child: const Center( + child: Icon( + Icons.access_time, + color: Colors.white, + ), + ), + ), + title: Text( + ScheduleEntity.getFormatTime(time) ?? '', + style: const TextStyle(fontSize: 15, fontWeight: FontWeight.bold), + ), + subtitle: const Text( + 'No disponible', + style: TextStyle( + color: Colors.red, fontSize: 13, fontWeight: FontWeight.bold), + ), + trailing: const Icon( + Icons.arrow_forward_ios, + color: Colors.grey, + ), + ), + ); + } + if (_isHora1Ocupada(time, events, selectedDay)) { return Card( elevation: 4, diff --git a/lib/screens/user/user_map_screen.dart b/lib/screens/user/user_map_screen.dart index 93dc93d..e35e9ed 100644 --- a/lib/screens/user/user_map_screen.dart +++ b/lib/screens/user/user_map_screen.dart @@ -262,7 +262,8 @@ class _UserMapScreenState extends State { })); }, onCameraMove: (position) { - if (serviceLocationPreference != ServiceLocationPreferences.office) { + if (serviceLocationPreference != + ServiceLocationPreferences.office) { coordenadas = position.target; } }, @@ -609,8 +610,7 @@ class _UserMapScreenState extends State { } else { context.read().add( CreateService( - professionalId: profesionalSeleccionado! - .professionalInfo.id, + professionalId: profesionalSeleccionado!.professionalInfo.id, userId: state.user!.id, address: _addressController.text, aditionalAddress: '',