horario pro

This commit is contained in:
Felipe
2024-03-19 22:00:48 -05:00
parent 10536be873
commit f37f8c89c2
14 changed files with 751 additions and 62 deletions
@@ -41,6 +41,9 @@ class _ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
TextEditingController();
final TextEditingController _rateController = TextEditingController();
Schedules schedules = Schedules.empty;
bool isInit = false;
double _longitudeController = 0;
double _latitudeController = 0;
@@ -96,6 +99,11 @@ class _ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
if (state.proInfo == null) {
return const Text('Loading...');
} else {
if (!isInit) {
schedules = state.proInfo!.schedules;
isInit = true;
}
return body(state.proInfo!);
}
}
@@ -340,15 +348,138 @@ class _ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
),
const Divider(height: 0),
GestureDetector(
onTap: () {
Navigator.push(
onTap: () async {
Schedules? schedules = await Navigator.push(
context,
CupertinoPageRoute(
builder: (context) => const ProfessionalScheduleScreen(),
builder: (context) =>
ProfessionalScheduleScreen(schedules: this.schedules),
),
);
if (schedules != null) {
setState(() {
this.schedules = schedules;
});
}
},
child: Text(proInfo.schedules.toString()),
child: Table(
defaultColumnWidth: const IntrinsicColumnWidth(),
children: [
TableRow(
children: [
TableCell(
child: Container(
padding: const EdgeInsets.all(8.0),
child: const Text('Lunes'),
),
),
TableCell(
child: Container(
padding: const EdgeInsets.all(8.0),
child: Text(timeList(schedules.monday, context)),
),
),
],
),
TableRow(
children: [
TableCell(
child: Container(
padding: const EdgeInsets.all(8.0),
child: const Text('Martes'),
),
),
TableCell(
child: Container(
padding: const EdgeInsets.all(8.0),
child: Text(timeList(schedules.tuesday, context)),
),
),
],
),
TableRow(
children: [
TableCell(
child: Container(
padding: const EdgeInsets.all(8.0),
child: const Text('Miercoles'),
),
),
TableCell(
child: Container(
padding: const EdgeInsets.all(8.0),
child: Text(timeList(schedules.wednesday, context)),
),
),
],
),
TableRow(
children: [
TableCell(
child: Container(
padding: const EdgeInsets.all(8.0),
child: const Text('Jueves'),
),
),
TableCell(
child: Container(
padding: const EdgeInsets.all(8.0),
child: Text(timeList(schedules.thursday, context)),
),
),
],
),
TableRow(
children: [
TableCell(
child: Container(
padding: const EdgeInsets.all(8.0),
child: const Text('Viernes'),
),
),
TableCell(
child: Container(
padding: const EdgeInsets.all(8.0),
child: Text(timeList(schedules.friday, context)),
),
),
],
),
TableRow(
children: [
TableCell(
child: Container(
padding: const EdgeInsets.all(8.0),
child: const Text('Sabado'),
),
),
TableCell(
child: Container(
padding: const EdgeInsets.all(8.0),
child: Text(timeList(schedules.saturday, context)),
),
),
],
),
TableRow(
children: [
TableCell(
child: Container(
padding: const EdgeInsets.all(8.0),
child: const Text('Domingo'),
),
),
TableCell(
child: Container(
padding: const EdgeInsets.all(8.0),
child: Text(timeList(schedules.sunday, context)),
),
),
],
),
],
),
),
const Divider(height: 0),
const SizedBox(height: 20),
@@ -372,16 +503,8 @@ class _ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
nequi: isNequiActive,
transferencia: isTransferActive,
),
schedules: schedules,
rate: _rateController.text,
// schedules: Schedules(
// monday: monday,
// tuesday: tuesday,
// wednesday: wednesday,
// thursday: thursday,
// friday: friday,
// saturday: saturday,
// sunday: sunday,
// ),
),
);
context.read<ProfessionalProfileBloc>().add(
@@ -453,4 +576,25 @@ class _ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
child: widget,
);
}
String timeList(ScheduleEntity? schedule, BuildContext context) {
if (schedule == null) {
return 'N/A';
}
if (!schedule.enabled) {
return 'N/A';
}
if (schedule.range1Hour1 == null || schedule.range2Hour2 == null) {
return 'N/A';
}
if (schedule.continuousDay) {
return '${schedule.range1Hour1?.format(context).toString()} - ${schedule.range2Hour2?.format(context).toString()}';
} else {
if (schedule.range1Hour2 == null || schedule.range2Hour1 == null) {
return 'N/A';
}
return '${schedule.range1Hour1?.format(context).toString()} - ${schedule.range1Hour2?.format(context).toString()}; ${schedule.range2Hour1?.format(context).toString()} - ${schedule.range2Hour2?.format(context).toString()}';
}
}
}