horario del profesional
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:prosappco/screens/authentication/welcome_screen.dart';
|
||||
import 'package:prosappco/screens/home/home_screen.dart';
|
||||
import 'package:prosappco/screens/splash/splash_screen.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
|
||||
import 'blocs/authentication_bloc/authentication_bloc.dart';
|
||||
|
||||
@@ -14,6 +15,13 @@ class MyAppView extends StatelessWidget {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'Prosappco',
|
||||
localizationsDelegates: const [
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: const [
|
||||
Locale('es'),
|
||||
],
|
||||
theme: ThemeData(
|
||||
colorScheme: const ColorScheme.light(
|
||||
background: Colors.white,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'dart:developer';
|
||||
|
||||
// ignore: depend_on_referenced_packages
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:professional_repository/professional_repository.dart';
|
||||
import 'package:user_repository/user_repository.dart';
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:service_repository/service_repository.dart';
|
||||
|
||||
part 'service_event.dart';
|
||||
part 'service_state.dart';
|
||||
|
||||
class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
||||
final FirebaseServiceRepository _serviceRepository;
|
||||
|
||||
ServiceBloc({required FirebaseServiceRepository serviceRepository})
|
||||
: _serviceRepository = serviceRepository,
|
||||
super(ServiceInitial()) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
part of 'service_bloc.dart';
|
||||
|
||||
abstract class ServiceEvent extends Equatable {
|
||||
const ServiceEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
part of 'service_bloc.dart';
|
||||
|
||||
abstract class ServiceState extends Equatable {
|
||||
const ServiceState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ServiceInitial extends ServiceState {}
|
||||
@@ -99,15 +99,19 @@ class _ProfessionalListScreenState extends State<ProfessionalListScreen> {
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
onTap: () async {
|
||||
var datos = await Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => UserCalendarScreen(
|
||||
// userProfessional: filteredUsers[index],
|
||||
),
|
||||
userProfessional: filteredUsers[index],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (datos != null) {
|
||||
Navigator.pop(context, datos);
|
||||
}
|
||||
},
|
||||
trailing: GestureDetector(
|
||||
onTap: () {
|
||||
|
||||
@@ -78,7 +78,7 @@ class _ProfessionalCalendarScreenState
|
||||
Container(
|
||||
color: const Color.fromARGB(255, 224, 247, 255),
|
||||
child: TableCalendar(
|
||||
// locale: 'es_MX',
|
||||
locale: 'es_MX',
|
||||
firstDay: DateTime.utc(2010, 10, 16),
|
||||
lastDay: lastDay,
|
||||
focusedDay: today,
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:professional_repository/professional_repository.dart';
|
||||
import 'package:prosappco/blocs/professional_list_bloc/professional_list_bloc.dart';
|
||||
import 'package:prosappco/utils/time_of_day_utils.dart';
|
||||
import 'package:service_repository/service_repository.dart';
|
||||
import 'package:table_calendar/table_calendar.dart';
|
||||
|
||||
class UserCalendarScreen extends StatefulWidget {
|
||||
const UserCalendarScreen({super.key});
|
||||
final UserProfessional userProfessional;
|
||||
|
||||
const UserCalendarScreen({super.key, required this.userProfessional});
|
||||
|
||||
@override
|
||||
State<UserCalendarScreen> createState() => UserCalendarScreenState();
|
||||
@@ -54,7 +61,7 @@ class UserCalendarScreenState extends State<UserCalendarScreen> {
|
||||
Container(
|
||||
color: const Color.fromARGB(255, 224, 247, 255),
|
||||
child: TableCalendar(
|
||||
// locale: 'es_MX',
|
||||
locale: 'es_MX',
|
||||
firstDay: DateTime.now(),
|
||||
lastDay: lastDay,
|
||||
focusedDay: today,
|
||||
@@ -75,8 +82,7 @@ class UserCalendarScreenState extends State<UserCalendarScreen> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
|
||||
child: Text(
|
||||
'adwa',
|
||||
// DateFormat('dd MMMM yyyy', 'es').format(today),
|
||||
DateFormat('dd MMMM yyyy', 'es').format(today),
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 16,
|
||||
@@ -93,7 +99,7 @@ class UserCalendarScreenState extends State<UserCalendarScreen> {
|
||||
padding: const EdgeInsets.only(bottom: 15),
|
||||
child: Column(
|
||||
children: [
|
||||
Text('Hola'),
|
||||
..._rangesItems(_getScheduleFromNumDay(numDay)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -102,4 +108,179 @@ class UserCalendarScreenState extends State<UserCalendarScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
ScheduleEntity? _getScheduleFromNumDay(int numDay) {
|
||||
switch (numDay) {
|
||||
case 1:
|
||||
return widget.userProfessional.professionalInfo.schedules.monday;
|
||||
case 2:
|
||||
return widget.userProfessional.professionalInfo.schedules.tuesday;
|
||||
case 3:
|
||||
return widget.userProfessional.professionalInfo.schedules.wednesday;
|
||||
case 4:
|
||||
return widget.userProfessional.professionalInfo.schedules.thursday;
|
||||
case 5:
|
||||
return widget.userProfessional.professionalInfo.schedules.friday;
|
||||
case 6:
|
||||
return widget.userProfessional.professionalInfo.schedules.saturday;
|
||||
case 7:
|
||||
return widget.userProfessional.professionalInfo.schedules.sunday;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
List<Widget> _rangesItems(ScheduleEntity? schedule) {
|
||||
if (schedule == null ||
|
||||
schedule.enabled == false ||
|
||||
schedule.range1Hour1 == null ||
|
||||
schedule.range2Hour2 == null) {
|
||||
return [const Text("No hay horarios disponibles")];
|
||||
}
|
||||
|
||||
if (schedule.continuousDay) {
|
||||
List<TimeOfDay> ranges = TimeOfDayUtils.genRanges(
|
||||
schedule.range1Hour1!,
|
||||
schedule.range2Hour2!,
|
||||
);
|
||||
|
||||
return rangesItemList(ranges, null);
|
||||
}
|
||||
|
||||
List<TimeOfDay> ranges1 = TimeOfDayUtils.genRanges(
|
||||
schedule.range1Hour1!,
|
||||
schedule.range1Hour2!,
|
||||
);
|
||||
List<TimeOfDay> ranges2 = TimeOfDayUtils.genRanges(
|
||||
schedule.range2Hour1!,
|
||||
schedule.range2Hour2!,
|
||||
);
|
||||
|
||||
return [
|
||||
...rangesItemList(ranges1, null),
|
||||
...rangesItemList(ranges2, null),
|
||||
];
|
||||
}
|
||||
|
||||
bool _isHora1Ocupada(TimeOfDay hora1, List<ServiceEntity>? events) {
|
||||
if (events != null) {
|
||||
for (ServiceEntity event in events) {
|
||||
DateTime time1 = DateTime(
|
||||
today.year,
|
||||
today.month,
|
||||
today.day,
|
||||
hora1.hour,
|
||||
hora1.minute,
|
||||
);
|
||||
|
||||
if (event.range1Hour1 == time1.toString()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Widget> rangesItemList(
|
||||
List<TimeOfDay> ranges, List<ServiceEntity>? events) {
|
||||
return ranges.map((time) {
|
||||
if (_isHora1Ocupada(time, events)) {
|
||||
return Card(
|
||||
elevation: 4,
|
||||
margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: ListTile(
|
||||
onTap: () {
|
||||
ScaffoldMessenger.of(context).clearSnackBars();
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||
content: Text('Este horario ya fue ocupado'),
|
||||
));
|
||||
},
|
||||
contentPadding: const EdgeInsets.all(16),
|
||||
leading: Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Colors.yellow, Colors.red, Colors.red],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Center(
|
||||
child: Icon(
|
||||
Icons.access_time,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
time.format(context),
|
||||
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
|
||||
),
|
||||
subtitle: const Text(
|
||||
'Ocupado',
|
||||
style: TextStyle(
|
||||
color: Colors.red, fontSize: 13, fontWeight: FontWeight.bold),
|
||||
),
|
||||
trailing: const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Card(
|
||||
elevation: 4,
|
||||
margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: ListTile(
|
||||
onTap: () {
|
||||
Navigator.pop(context, [today, time, widget.userProfessional]);
|
||||
},
|
||||
contentPadding: const EdgeInsets.all(16),
|
||||
leading: Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Colors.blue, Colors.green],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Center(
|
||||
child: Icon(
|
||||
Icons.access_time,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
time.format(context),
|
||||
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
|
||||
),
|
||||
subtitle: const Text(
|
||||
'Disponible',
|
||||
style: TextStyle(
|
||||
color: Colors.green,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
trailing: const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,12 @@ import 'dart:developer';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:injector/injector.dart';
|
||||
import 'package:prosappco/constansts.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:prosappco/blocs/my_user_bloc/my_user_bloc.dart';
|
||||
import 'package:prosappco/screens/lists/professional_list_screen.dart';
|
||||
import 'package:setting_repository/setting_repository.dart';
|
||||
|
||||
@@ -25,6 +27,11 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
final settingRepository = Injector.appInstance.get<SettingRepository>();
|
||||
SettingEntity? settings;
|
||||
|
||||
final DateFormat formatter = DateFormat('dd/MM/yyyy');
|
||||
|
||||
DateTime? fechaSeleccionada;
|
||||
TimeOfDay? horaSeleccionada;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -42,102 +49,109 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
GoogleMap(
|
||||
myLocationEnabled: true,
|
||||
onMapCreated: (GoogleMapController controller) {
|
||||
_mapController.complete(controller);
|
||||
},
|
||||
initialCameraPosition: const CameraPosition(
|
||||
target: LatLng(7.078511421411328, -73.08832615613937
|
||||
// currentPosition.latitude, currentPosition.longitude
|
||||
),
|
||||
zoom: 16,
|
||||
),
|
||||
myLocationButtonEnabled: false,
|
||||
),
|
||||
Positioned(
|
||||
top: 10,
|
||||
left: 0,
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
shape: const CircleBorder(),
|
||||
elevation: 3,
|
||||
minimumSize: const Size(50, 50),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.menu,
|
||||
color: Colors.black,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () {
|
||||
Scaffold.of(context).openDrawer();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const Positioned(
|
||||
bottom: 30,
|
||||
right: 0,
|
||||
left: 0,
|
||||
top: 0,
|
||||
child: Icon(
|
||||
Icons.location_on,
|
||||
size: 40,
|
||||
color: Color(0xFFFF0000),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 10,
|
||||
right: 10,
|
||||
child: FloatingActionButton(
|
||||
onPressed: () async {
|
||||
try {
|
||||
Position position = await _determinePosition();
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_currentP = LatLng(
|
||||
position.latitude,
|
||||
position.longitude,
|
||||
);
|
||||
});
|
||||
|
||||
_animateCameraToPosition(_currentP!);
|
||||
}
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).clearSnackBars();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Por favor activa la ubicacion'),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
elevation: 0,
|
||||
child: const Icon(
|
||||
Icons.gps_fixed,
|
||||
size: 30,
|
||||
return BlocBuilder<MyUserBloc, MyUserState>(
|
||||
builder: (context, state) {
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
GoogleMap(
|
||||
myLocationEnabled: true,
|
||||
onMapCreated: (GoogleMapController controller) {
|
||||
_mapController.complete(controller);
|
||||
},
|
||||
initialCameraPosition: const CameraPosition(
|
||||
target: LatLng(
|
||||
// 7.078511421411328, -73.08832615613937
|
||||
7.1253900,
|
||||
-73.1198000
|
||||
// currentPosition.latitude, currentPosition.longitude
|
||||
),
|
||||
zoom: 16,
|
||||
),
|
||||
myLocationButtonEnabled: false,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 10,
|
||||
left: 0,
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
shape: const CircleBorder(),
|
||||
elevation: 3,
|
||||
minimumSize: const Size(50, 50),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.menu,
|
||||
color: Colors.black,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () {
|
||||
Scaffold.of(context).openDrawer();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const Positioned(
|
||||
bottom: 30,
|
||||
right: 0,
|
||||
left: 0,
|
||||
top: 0,
|
||||
child: Icon(
|
||||
Icons.location_on,
|
||||
size: 40,
|
||||
color: Color(0xFFFF0000),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 10,
|
||||
right: 10,
|
||||
child: FloatingActionButton(
|
||||
onPressed: () async {
|
||||
try {
|
||||
Position position = await _determinePosition();
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_currentP = LatLng(
|
||||
position.latitude,
|
||||
position.longitude,
|
||||
);
|
||||
});
|
||||
|
||||
_animateCameraToPosition(_currentP!);
|
||||
}
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).clearSnackBars();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Por favor activa la ubicacion'),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
elevation: 0,
|
||||
child: const Icon(
|
||||
Icons.gps_fixed,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
buildBottom(context)
|
||||
],
|
||||
),
|
||||
buildBottom(context, state),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Container buildBottom(BuildContext context) {
|
||||
Container buildBottom(BuildContext context, MyUserState state) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 10),
|
||||
color: Colors.white,
|
||||
@@ -147,11 +161,22 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
TextField(
|
||||
readOnly: true,
|
||||
onTap: () async {
|
||||
var datos = await Navigator.push(context, CupertinoPageRoute(builder: (context) {
|
||||
var datos = await Navigator.push(context,
|
||||
CupertinoPageRoute(builder: (context) {
|
||||
return const ProfessionalListScreen();
|
||||
}));
|
||||
|
||||
log('xd -- $datos');
|
||||
log('xd -- datos $datos');
|
||||
|
||||
if (datos != null) {
|
||||
fechaSeleccionada = datos[0];
|
||||
horaSeleccionada = datos[1];
|
||||
|
||||
log('xd -- $fechaSeleccionada');
|
||||
log('xd -- $horaSeleccionada');
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
prefixIcon: Icon(Icons.assignment_ind_rounded),
|
||||
@@ -167,35 +192,52 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
hintText: 'Dirección',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
const Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
readOnly: true,
|
||||
Visibility(
|
||||
visible: fechaSeleccionada != null && horaSeleccionada != null,
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 15),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
readOnly: true,
|
||||
controller: TextEditingController(
|
||||
text: fechaSeleccionada == null
|
||||
? ''
|
||||
: formatter.format(fechaSeleccionada!),
|
||||
),
|
||||
decoration: const InputDecoration(
|
||||
prefixIcon: Icon(Icons.calendar_month),
|
||||
hintText: 'Fecha',
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
readOnly: true,
|
||||
controller: TextEditingController(
|
||||
text: horaSeleccionada == null
|
||||
? ''
|
||||
: horaSeleccionada!.format(context),
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: Icon(Icons.watch_later_outlined),
|
||||
hintText: 'Hora',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
const TextField(
|
||||
// controller: _observacionController,
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: Icon(Icons.calendar_month),
|
||||
hintText: 'Fecha',
|
||||
prefixIcon: Icon(Icons.message_outlined),
|
||||
hintText: 'Observaciones',
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
readOnly: true,
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: Icon(Icons.watch_later_outlined),
|
||||
hintText: 'Hora',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
const TextField(
|
||||
// controller: _observacionController,
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: Icon(Icons.message_outlined),
|
||||
hintText: 'Observaciones',
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension TimeOfDayExtension on TimeOfDay {
|
||||
TimeOfDay add({int hour = 0, int minute = 0}) {
|
||||
return replacing(hour: this.hour + hour, minute: this.minute + minute);
|
||||
}
|
||||
|
||||
int compareTo(TimeOfDay other) {
|
||||
if (hour < other.hour) return -1;
|
||||
if (hour > other.hour) return 1;
|
||||
if (minute < other.minute) return -1;
|
||||
if (minute > other.minute) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool isBefore(TimeOfDay other) {
|
||||
return compareTo(other) == -1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:prosappco/utils/time_of_day_extension.dart';
|
||||
|
||||
class TimeOfDayUtils {
|
||||
static List<TimeOfDay> genRanges(TimeOfDay timeStart, TimeOfDay timeEnd) {
|
||||
List<TimeOfDay> ranges = [];
|
||||
TimeOfDay current = timeStart;
|
||||
while (current.isBefore(timeEnd)) {
|
||||
ranges.add(current);
|
||||
// Sumar 2 horas al objeto DateTime
|
||||
current = current.add(hour: 2);
|
||||
}
|
||||
return ranges;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user