horario pro
This commit is contained in:
+1
-1
@@ -17,7 +17,7 @@ class MyAppView extends StatelessWidget {
|
||||
theme: ThemeData(
|
||||
colorScheme: const ColorScheme.light(
|
||||
background: Colors.white,
|
||||
onBackground: Colors.grey,
|
||||
onBackground: Colors.black12,
|
||||
primary: Color.fromRGBO(66, 164, 239, 1),
|
||||
onPrimary: Colors.white,
|
||||
secondary: Colors.white,
|
||||
|
||||
@@ -42,7 +42,9 @@ class ProfessionalProfileBloc
|
||||
event.locationPreferences,
|
||||
event.latitude,
|
||||
event.longitude,
|
||||
event.schedules,
|
||||
event.paymentMethods,
|
||||
|
||||
);
|
||||
|
||||
emit(const UpdateProfessionalInfoSuccess());
|
||||
|
||||
@@ -25,7 +25,7 @@ class UpdateProfessionalProfileInfo extends ProfessionalProfileEvent {
|
||||
final LocationPreferences locationPreferences;
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
// final Schedules schedules;
|
||||
final Schedules schedules;
|
||||
final PaymentMethodEntity paymentMethods;
|
||||
|
||||
const UpdateProfessionalProfileInfo({
|
||||
@@ -35,7 +35,7 @@ class UpdateProfessionalProfileInfo extends ProfessionalProfileEvent {
|
||||
required this.locationPreferences,
|
||||
required this.latitude,
|
||||
required this.longitude,
|
||||
// required this.schedules,
|
||||
required this.schedules,
|
||||
required this.paymentMethods,
|
||||
});
|
||||
|
||||
@@ -47,7 +47,7 @@ class UpdateProfessionalProfileInfo extends ProfessionalProfileEvent {
|
||||
locationPreferences,
|
||||
latitude,
|
||||
longitude,
|
||||
// schedules,
|
||||
schedules,
|
||||
paymentMethods
|
||||
];
|
||||
}
|
||||
|
||||
@@ -8,10 +8,13 @@ import 'package:prosappco/components/general_drawer_header.dart';
|
||||
import 'package:prosappco/components/general_drawer_item.dart';
|
||||
import 'package:prosappco/screens/configuration/configuration_screen.dart';
|
||||
import 'package:prosappco/screens/configuration/configuration_support_screen.dart';
|
||||
import 'package:prosappco/screens/professional/professional_calendar_screen.dart';
|
||||
import 'package:prosappco/screens/professional/professional_denied_screen.dart';
|
||||
import 'package:prosappco/screens/professional/professional_form_screen.dart';
|
||||
import 'package:prosappco/screens/professional/professional_pending_screen.dart';
|
||||
import 'package:prosappco/screens/professional/professional_profile_screen.dart';
|
||||
import 'package:prosappco/screens/user/user_history_services_screen.dart';
|
||||
import 'package:prosappco/screens/user/user_services_screen.dart';
|
||||
import 'package:prosappco/screens/web/web_view_screen.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:user_repository/user_repository.dart';
|
||||
@@ -71,12 +74,46 @@ class GeneralDrawer extends StatelessWidget {
|
||||
)
|
||||
: const SizedBox(),
|
||||
GeneralDrawerItem(
|
||||
leading: Icons.history,
|
||||
leading: Icons.checklist_outlined,
|
||||
label: 'Mis servicios',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
const UserServicesScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
GeneralDrawerItem(
|
||||
leading: Icons.access_time_outlined,
|
||||
label: 'Historial',
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
const UserHistoryServicesScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
shouldProModeActive(context, professionalState)
|
||||
? GeneralDrawerItem(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
const ProfessionalCalendarScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
label: 'Calendario',
|
||||
leading: Icons.calendar_month_outlined,
|
||||
)
|
||||
: const SizedBox(),
|
||||
GeneralDrawerItem(
|
||||
leading: Icons.settings_outlined,
|
||||
label: 'Configuración',
|
||||
@@ -124,12 +161,40 @@ class GeneralDrawer extends StatelessWidget {
|
||||
}
|
||||
},
|
||||
),
|
||||
shouldProModeActive(context, professionalState)
|
||||
? const GeneralDrawerItem(
|
||||
label: 'Calendario',
|
||||
leading: Icons.calendar_month_outlined,
|
||||
)
|
||||
: const SizedBox(),
|
||||
Container(
|
||||
color: const Color(0xFF2BA4EC),
|
||||
child: ListTile(
|
||||
onTap: () {
|
||||
shouldProModeActive(context, professionalState)
|
||||
? Navigator.pop(context)
|
||||
: Navigator.pop(context);
|
||||
},
|
||||
trailing: const Icon(
|
||||
Icons.keyboard_arrow_right,
|
||||
color: Colors.white,
|
||||
),
|
||||
title: Text(
|
||||
shouldProModeActive(context, professionalState)
|
||||
? 'Solicitudes'
|
||||
: 'Solicitar servicio',
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
'Prosapp ® todos los derechos reservados',
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:professional_repository/professional_repository.dart';
|
||||
|
||||
class ScheduleItem extends StatelessWidget {
|
||||
ScheduleEntity schedule;
|
||||
String label;
|
||||
final ValueChanged<ScheduleEntity> onChanged;
|
||||
|
||||
ScheduleItem(
|
||||
{super.key,
|
||||
required this.label,
|
||||
required this.schedule,
|
||||
required this.onChanged});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
value: schedule.enabled,
|
||||
onChanged: (value) {
|
||||
onChanged.call(schedule.copyWith(enabled: value));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
Visibility(
|
||||
visible: schedule.enabled,
|
||||
child: Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'Jornada continua',
|
||||
style: TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
value: schedule.continuousDay,
|
||||
onChanged: (value) {
|
||||
onChanged.call(schedule.copyWith(continuousDay: value));
|
||||
},
|
||||
),
|
||||
],
|
||||
)),
|
||||
Visibility(
|
||||
visible: schedule.enabled,
|
||||
child: hoursRangesBody(context),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
hoursRangesBody(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
timePickerField(
|
||||
context: context,
|
||||
text: schedule.getFormatTime(schedule.range1Hour1),
|
||||
onPick: (pickedTime) {
|
||||
onChanged.call(schedule.copyWith(range1Hour1: pickedTime));
|
||||
},
|
||||
),
|
||||
Center(
|
||||
child: Container(
|
||||
width: 10,
|
||||
height: 1,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: !schedule.continuousDay,
|
||||
child: timePickerField(
|
||||
context: context,
|
||||
text: schedule.getFormatTime(schedule.range1Hour2),
|
||||
onPick: (pickedTime) {
|
||||
onChanged.call(schedule.copyWith(range1Hour2: pickedTime));
|
||||
},
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: !schedule.continuousDay,
|
||||
child: const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: !schedule.continuousDay,
|
||||
child: timePickerField(
|
||||
context: context,
|
||||
text: schedule.getFormatTime(schedule.range2Hour1),
|
||||
onPick: (pickedTime) {
|
||||
onChanged.call(schedule.copyWith(range2Hour1: pickedTime));
|
||||
},
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: !schedule.continuousDay,
|
||||
child: Center(
|
||||
child: Container(
|
||||
width: 10,
|
||||
height: 1,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
timePickerField(
|
||||
context: context,
|
||||
text: schedule.getFormatTime(schedule.range2Hour2),
|
||||
onPick: (pickedTime) {
|
||||
onChanged.call(schedule.copyWith(range2Hour2: pickedTime));
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
timePickerField(
|
||||
{required BuildContext context,
|
||||
required String? text,
|
||||
required Function(TimeOfDay) onPick}) {
|
||||
return Expanded(
|
||||
child: TextField(
|
||||
readOnly: true,
|
||||
controller: TextEditingController(
|
||||
text: text,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
onTap: () async {
|
||||
final TimeOfDay? pickedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.now(),
|
||||
);
|
||||
if (pickedTime != null) {
|
||||
onPick.call(pickedTime);
|
||||
}
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Hora',
|
||||
border: UnderlineInputBorder(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:table_calendar/table_calendar.dart';
|
||||
|
||||
class ProfessionalCalendarScreen extends StatefulWidget {
|
||||
const ProfessionalCalendarScreen({super.key});
|
||||
|
||||
@override
|
||||
State<ProfessionalCalendarScreen> createState() =>
|
||||
_ProfessionalCalendarScreenState();
|
||||
}
|
||||
|
||||
class _ProfessionalCalendarScreenState
|
||||
extends State<ProfessionalCalendarScreen> {
|
||||
TextEditingController _titleController = TextEditingController();
|
||||
TextEditingController _descriptionController = TextEditingController();
|
||||
|
||||
DateTime today = DateTime.now();
|
||||
DateTime now = DateTime.now();
|
||||
|
||||
CalendarFormat _calendarFormat = CalendarFormat.month;
|
||||
|
||||
TimeOfDay? _selectedTime1;
|
||||
TimeOfDay? _selectedTime2;
|
||||
|
||||
Future<TimeOfDay?> _selectTime1(BuildContext context) async {
|
||||
final TimeOfDay? pickedTime1 = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.now(),
|
||||
);
|
||||
if (pickedTime1 != null) {
|
||||
setState(() {
|
||||
_selectedTime1 = pickedTime1;
|
||||
});
|
||||
}
|
||||
return pickedTime1;
|
||||
}
|
||||
|
||||
Future<TimeOfDay?> _selectTime2(BuildContext context) async {
|
||||
final TimeOfDay? pickedTime2 = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.now(),
|
||||
);
|
||||
if (pickedTime2 != null) {
|
||||
setState(() {
|
||||
_selectedTime2 = pickedTime2;
|
||||
});
|
||||
}
|
||||
|
||||
return pickedTime2;
|
||||
}
|
||||
|
||||
void _onDaySelected(DateTime day, DateTime focusedDay) {
|
||||
setState(() {
|
||||
today = day;
|
||||
});
|
||||
}
|
||||
|
||||
void _onFormatChange(CalendarFormat format) {
|
||||
setState(() {
|
||||
_calendarFormat = format;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
DateTime lastDay = today.add(const Duration(days: 365));
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Calendario'),
|
||||
),
|
||||
floatingActionButtonLocation: kIsWeb
|
||||
? FloatingActionButtonLocation.startFloat
|
||||
: FloatingActionButtonLocation.endFloat,
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Column(
|
||||
children: [
|
||||
Container(
|
||||
color: const Color.fromARGB(255, 224, 247, 255),
|
||||
child: TableCalendar(
|
||||
// locale: 'es_MX',
|
||||
firstDay: DateTime.utc(2010, 10, 16),
|
||||
lastDay: lastDay,
|
||||
focusedDay: today,
|
||||
availableGestures: AvailableGestures.all,
|
||||
onDaySelected: _onDaySelected,
|
||||
selectedDayPredicate: (day) => isSameDay(day, today),
|
||||
calendarFormat: _calendarFormat,
|
||||
onFormatChanged: _onFormatChange,
|
||||
eventLoader: (date) {
|
||||
return [];
|
||||
// return events
|
||||
// .where((element) {
|
||||
// DateTime day = DateTime.parse(element.day);
|
||||
// return (date.year == day.year &&
|
||||
// date.month == day.month &&
|
||||
// date.day == day.day);
|
||||
// })
|
||||
// .map((e) => e.description)
|
||||
// .toList();
|
||||
},
|
||||
availableCalendarFormats: const {
|
||||
CalendarFormat.month: 'Mes',
|
||||
CalendarFormat.week: 'Semana',
|
||||
CalendarFormat.twoWeeks: '2 Semanas',
|
||||
},
|
||||
),
|
||||
),
|
||||
// SizedBox(
|
||||
// width: double.infinity,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
|
||||
// child: Text(DateFormat('dd MMMM yyyy', 'es').format(today),
|
||||
// style: const TextStyle(
|
||||
// color: Colors.black,
|
||||
// fontSize: 16,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// )),
|
||||
// ),
|
||||
// ),
|
||||
const Divider(
|
||||
height: 0,
|
||||
),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.only(bottom: 15),
|
||||
child: Column(
|
||||
children: const [],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {},
|
||||
// onPressed: _showDialog,
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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()}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:professional_repository/professional_repository.dart';
|
||||
import 'package:prosappco/components/general_primary_button.dart';
|
||||
import 'package:prosappco/screens/professional/components/schedule_item.dart';
|
||||
|
||||
class ProfessionalScheduleScreen extends StatefulWidget {
|
||||
const ProfessionalScheduleScreen({super.key});
|
||||
Schedules schedules;
|
||||
ProfessionalScheduleScreen({
|
||||
super.key,
|
||||
required this.schedules,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ProfessionalScheduleScreen> createState() =>
|
||||
@@ -10,6 +17,13 @@ class ProfessionalScheduleScreen extends StatefulWidget {
|
||||
|
||||
class _ProfessionalScheduleScreenState
|
||||
extends State<ProfessionalScheduleScreen> {
|
||||
Schedules schedules = Schedules.empty;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
schedules = widget.schedules;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -19,26 +33,63 @@ class _ProfessionalScheduleScreenState
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Lunes',
|
||||
style: TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
value: false,
|
||||
onChanged: (value) {
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
],
|
||||
ScheduleItem(
|
||||
label: "Lunes",
|
||||
schedule: schedules.monday,
|
||||
onChanged: (s) {
|
||||
setState(() => schedules = schedules.copyWith(monday: s));
|
||||
},
|
||||
),
|
||||
ScheduleItem(
|
||||
label: "Martes",
|
||||
schedule: schedules.thursday,
|
||||
onChanged: (s) {
|
||||
setState(() => schedules = schedules.copyWith(thursday: s));
|
||||
},
|
||||
),
|
||||
ScheduleItem(
|
||||
label: "Miercoles",
|
||||
schedule: schedules.wednesday,
|
||||
onChanged: (s) {
|
||||
setState(() => schedules = schedules.copyWith(wednesday: s));
|
||||
},
|
||||
),
|
||||
ScheduleItem(
|
||||
label: "Jueves",
|
||||
schedule: schedules.tuesday,
|
||||
onChanged: (s) {
|
||||
setState(() => schedules = schedules.copyWith(tuesday: s));
|
||||
},
|
||||
),
|
||||
ScheduleItem(
|
||||
label: "Viernes",
|
||||
schedule: schedules.friday,
|
||||
onChanged: (s) {
|
||||
setState(() => schedules = schedules.copyWith(friday: s));
|
||||
},
|
||||
),
|
||||
ScheduleItem(
|
||||
label: "Sabado",
|
||||
schedule: schedules.saturday,
|
||||
onChanged: (s) {
|
||||
setState(() => schedules = schedules.copyWith(saturday: s));
|
||||
},
|
||||
),
|
||||
ScheduleItem(
|
||||
label: "Domingo",
|
||||
schedule: schedules.sunday,
|
||||
onChanged: (s) {
|
||||
setState(() => schedules = schedules.copyWith(sunday: s));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
GeneralPrimaryButton(
|
||||
label: "Guardar",
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(schedules);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class UserHistoryServicesScreen extends StatelessWidget {
|
||||
const UserHistoryServicesScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Historial de servicios'),
|
||||
),
|
||||
body: const Center(
|
||||
child: Text('Historial de servicios'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class UserServicesScreen extends StatelessWidget {
|
||||
const UserServicesScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Mis servicios'),
|
||||
),
|
||||
body: const Center(
|
||||
child: Text('Servicios'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -53,13 +53,54 @@ class ProfessionalEntity extends Equatable {
|
||||
latitude: double.parse(doc['latitude'].toString()),
|
||||
longitude: double.parse(doc['longitude'].toString()),
|
||||
specializations: List<String>.from(doc['specializations']),
|
||||
specializationsPictures:
|
||||
List<String>.from(doc['specializations_pictures']),
|
||||
specializationsPictures: List<String>.from(doc['specializations_pictures']),
|
||||
schedules: Schedules.fromDocument(doc['schedules']),
|
||||
paymentMethods: PaymentMethodEntity.fromDocument(doc['payment_methods']),
|
||||
);
|
||||
}
|
||||
|
||||
// copy func
|
||||
|
||||
ProfessionalEntity copyWith({
|
||||
String? id,
|
||||
String? identification,
|
||||
String? address,
|
||||
String? aditionalAddress,
|
||||
String? profession,
|
||||
String? rate,
|
||||
LocationPreferences? locationPreferences,
|
||||
String? bannerPicture,
|
||||
String? identificationPicture,
|
||||
String? certificatePicture,
|
||||
double? latitude,
|
||||
double? longitude,
|
||||
List<String>? specializations,
|
||||
List<String>? specializationsPictures,
|
||||
Schedules? schedules,
|
||||
PaymentMethodEntity? paymentMethods,
|
||||
}) {
|
||||
return ProfessionalEntity(
|
||||
id: id ?? this.id,
|
||||
identification: identification ?? this.identification,
|
||||
address: address ?? this.address,
|
||||
aditionalAddress: aditionalAddress ?? this.aditionalAddress,
|
||||
profession: profession ?? this.profession,
|
||||
rate: rate ?? this.rate,
|
||||
locationPreferences: locationPreferences ?? this.locationPreferences,
|
||||
bannerPicture: bannerPicture ?? this.bannerPicture,
|
||||
identificationPicture:
|
||||
identificationPicture ?? this.identificationPicture,
|
||||
certificatePicture: certificatePicture ?? this.certificatePicture,
|
||||
latitude: latitude ?? this.latitude,
|
||||
longitude: longitude ?? this.longitude,
|
||||
specializations: specializations ?? this.specializations,
|
||||
specializationsPictures:
|
||||
specializationsPictures ?? this.specializationsPictures,
|
||||
schedules: schedules ?? this.schedules,
|
||||
paymentMethods: paymentMethods ?? this.paymentMethods,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toDocument() {
|
||||
return {
|
||||
'id': id,
|
||||
|
||||
@@ -28,6 +28,25 @@ class ScheduleEntity extends Equatable {
|
||||
range2Hour2: null,
|
||||
);
|
||||
|
||||
// copy func
|
||||
ScheduleEntity copyWith({
|
||||
bool? enabled,
|
||||
bool? continuousDay,
|
||||
TimeOfDay? range1Hour1,
|
||||
TimeOfDay? range1Hour2,
|
||||
TimeOfDay? range2Hour1,
|
||||
TimeOfDay? range2Hour2,
|
||||
}) {
|
||||
return ScheduleEntity(
|
||||
enabled: enabled ?? this.enabled,
|
||||
continuousDay: continuousDay ?? this.continuousDay,
|
||||
range1Hour1: range1Hour1 ?? this.range1Hour1,
|
||||
range1Hour2: range1Hour2 ?? this.range1Hour2,
|
||||
range2Hour1: range2Hour1 ?? this.range2Hour1,
|
||||
range2Hour2: range2Hour2 ?? this.range2Hour2,
|
||||
);
|
||||
}
|
||||
|
||||
static ScheduleEntity fromDocument(Map<String, dynamic> doc) {
|
||||
return ScheduleEntity(
|
||||
enabled: doc['habilitado'] as bool,
|
||||
@@ -40,17 +59,18 @@ class ScheduleEntity extends Equatable {
|
||||
}
|
||||
|
||||
static TimeOfDay? _parseTime(String? time) {
|
||||
if (time == null) return null;
|
||||
final components = time.split(' ');
|
||||
final hourMinutes = components[0].split(':');
|
||||
final hour = int.parse(hourMinutes[0]);
|
||||
final minutes = int.parse(hourMinutes[1]);
|
||||
if (components[1] == 'PM' && hour < 12) {
|
||||
return TimeOfDay(hour: hour + 12, minute: minutes);
|
||||
} else if (components[1] == 'AM' && hour == 12) {
|
||||
return TimeOfDay(hour: 0, minute: minutes);
|
||||
try {
|
||||
if (time == null) return null;
|
||||
final components = time.split(':');
|
||||
if (components.length != 2) {
|
||||
return null;
|
||||
}
|
||||
final hour = int.parse(components[0]);
|
||||
final minutes = int.parse(components[1]);
|
||||
return TimeOfDay(hour: hour, minute: minutes);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
return TimeOfDay(hour: hour, minute: minutes);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@@ -66,15 +86,22 @@ class ScheduleEntity extends Equatable {
|
||||
|
||||
String? formatTimeOfDay(TimeOfDay? time) {
|
||||
if (time != null) {
|
||||
final now = DateTime.now();
|
||||
final dateTime =
|
||||
DateTime(now.year, now.month, now.day, time.hour, time.minute);
|
||||
final format = DateFormat.jm();
|
||||
return format.format(dateTime);
|
||||
return "${time.hour.toString()}:${time.minute.toString()}";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String? getFormatTime(TimeOfDay? time) {
|
||||
if (time == null) {
|
||||
return null;
|
||||
}
|
||||
final now = DateTime.now();
|
||||
final dateTime =
|
||||
DateTime(now.year, now.month, now.day, time.hour, time.minute);
|
||||
final format = DateFormat.jm();
|
||||
return format.format(dateTime);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
enabled,
|
||||
|
||||
@@ -29,6 +29,27 @@ class Schedules extends Equatable {
|
||||
sunday: ScheduleEntity.empty,
|
||||
);
|
||||
|
||||
// Copy function
|
||||
Schedules copyWith({
|
||||
ScheduleEntity? monday,
|
||||
ScheduleEntity? tuesday,
|
||||
ScheduleEntity? wednesday,
|
||||
ScheduleEntity? thursday,
|
||||
ScheduleEntity? friday,
|
||||
ScheduleEntity? saturday,
|
||||
ScheduleEntity? sunday,
|
||||
}) {
|
||||
return Schedules(
|
||||
monday: monday ?? this.monday,
|
||||
tuesday: tuesday ?? this.tuesday,
|
||||
wednesday: wednesday ?? this.wednesday,
|
||||
thursday: thursday ?? this.thursday,
|
||||
friday: friday ?? this.friday,
|
||||
saturday: saturday ?? this.saturday,
|
||||
sunday: sunday ?? this.sunday,
|
||||
);
|
||||
}
|
||||
|
||||
factory Schedules.fromDocument(Map<String, dynamic> doc) {
|
||||
return Schedules(
|
||||
monday: ScheduleEntity.fromDocument(doc['monday']),
|
||||
|
||||
+2
@@ -89,6 +89,7 @@ class FirebaseProfessionalRepository {
|
||||
LocationPreferences locationPreferences,
|
||||
double latitude,
|
||||
double longitude,
|
||||
Schedules schedules,
|
||||
PaymentMethodEntity paymentMethods,
|
||||
) async {
|
||||
if (_proInfo == null) {
|
||||
@@ -102,6 +103,7 @@ class FirebaseProfessionalRepository {
|
||||
'location_preferences': enumToInt(locationPreferences),
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'schedules': schedules.toJson(),
|
||||
'payment_methods': paymentMethods.toDocument(),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user