notificaciones al pedir servicio y al enviar mensaje de chat
This commit is contained in:
@@ -180,7 +180,7 @@ class UserCalendarScreenState extends State<UserCalendarScreen> {
|
||||
schedule.range2Hour2!,
|
||||
);
|
||||
|
||||
return rangesItemList(ranges, _services);
|
||||
return rangesItemList(ranges, _services, today);
|
||||
}
|
||||
|
||||
List<TimeOfDay> ranges1 = TimeOfDayUtils.genRanges(
|
||||
@@ -193,26 +193,29 @@ class UserCalendarScreenState extends State<UserCalendarScreen> {
|
||||
);
|
||||
|
||||
return [
|
||||
...rangesItemList(ranges1, _services),
|
||||
...rangesItemList(ranges2, _services),
|
||||
...rangesItemList(ranges1, _services, today),
|
||||
...rangesItemList(ranges2, _services, today),
|
||||
];
|
||||
}
|
||||
|
||||
bool _isHora1Ocupada(TimeOfDay hora1, List<ServiceEntity>? events) {
|
||||
bool _isHora1Ocupada(
|
||||
TimeOfDay hora1, List<ServiceEntity>? events, DateTime selectedDay) {
|
||||
if (events != null) {
|
||||
for (ServiceEntity event in events) {
|
||||
if (hora1 == event.range1Hour1) {
|
||||
return true;
|
||||
if (selectedDay.toString() == event.day) {
|
||||
if (hora1 == event.range1Hour1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Widget> rangesItemList(
|
||||
List<TimeOfDay> ranges, List<ServiceEntity>? events) {
|
||||
List<Widget> rangesItemList(List<TimeOfDay> ranges,
|
||||
List<ServiceEntity>? events, DateTime selectedDay) {
|
||||
return ranges.map((time) {
|
||||
if (_isHora1Ocupada(time, events)) {
|
||||
if (_isHora1Ocupada(time, events, selectedDay)) {
|
||||
return Card(
|
||||
elevation: 4,
|
||||
margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
|
||||
|
||||
@@ -13,9 +13,11 @@ import 'package:injector/injector.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:professional_repository/professional_repository.dart';
|
||||
import 'package:prosappco/blocs/my_user_bloc/my_user_bloc.dart';
|
||||
import 'package:prosappco/blocs/notification_bloc/notification_bloc.dart';
|
||||
import 'package:prosappco/blocs/professional_list_bloc/professional_list_bloc.dart';
|
||||
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
||||
import 'package:prosappco/constansts.dart';
|
||||
import 'package:prosappco/local_notifications/local_notifications.dart';
|
||||
import 'package:prosappco/screens/lists/professional_list_screen.dart';
|
||||
import 'package:prosappco/screens/user/user_service_screen.dart';
|
||||
import 'package:prosappco/utils/time_of_day_extension.dart';
|
||||
@@ -86,6 +88,10 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
// void requestNotificationPermission() async {
|
||||
// context.read<NotificationBloc>().requestPermission();
|
||||
// }
|
||||
|
||||
void _loadSettings() {
|
||||
settingRepository.getSettings().then(
|
||||
(value) => setState(() {
|
||||
@@ -172,10 +178,13 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
elevation: 3,
|
||||
minimumSize: const Size(50, 50),
|
||||
),
|
||||
child: const Icon(
|
||||
child: Icon(
|
||||
Icons.menu,
|
||||
color: Colors.black,
|
||||
size: 35,
|
||||
size: context.select(
|
||||
(NotificationBloc bloc) =>
|
||||
bloc.state.status.index > 0 ? 35 : 35,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
Scaffold.of(context).openDrawer();
|
||||
@@ -318,6 +327,9 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
decoration: const InputDecoration(
|
||||
prefixIcon: Icon(Icons.assignment_ind_rounded),
|
||||
suffixIcon: Icon(Icons.arrow_drop_down),
|
||||
// hintText: context.select(
|
||||
// (NotificationBloc bloc) => '${bloc.state.status}',
|
||||
// ),
|
||||
hintText: 'Selecciona un profesional',
|
||||
),
|
||||
),
|
||||
@@ -386,7 +398,7 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
onPressed: isLoading
|
||||
? null
|
||||
: () {
|
||||
// tODO: Crear servicio
|
||||
if (profesionalSeleccionado == null) return;
|
||||
if (serviceLocationPreference ==
|
||||
ServiceLocationPreferences.office) {
|
||||
if (settings?.tarifas == true) {
|
||||
@@ -487,7 +499,14 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
// TODO: error inesperado
|
||||
}
|
||||
|
||||
// clear inputs
|
||||
if (profesionalSeleccionado!.myUser.token != null) {
|
||||
LocalNotifications.sendPushNotification(
|
||||
profesionalSeleccionado!.myUser.token!,
|
||||
'Nuevo servicio',
|
||||
'Tienes una nueva solicitud de servicio pendiente',
|
||||
);
|
||||
}
|
||||
|
||||
fechaSeleccionada = null;
|
||||
horaSeleccionada = null;
|
||||
profesionalSeleccionado = null;
|
||||
@@ -538,7 +557,6 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
//x
|
||||
child: const Icon(
|
||||
CupertinoIcons.xmark,
|
||||
color: Colors.white,
|
||||
|
||||
Reference in New Issue
Block a user