notificaciones al cancelar servicio
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:injector/injector.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:professional_repository/professional_repository.dart';
|
import 'package:professional_repository/professional_repository.dart';
|
||||||
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
||||||
|
import 'package:prosappco/local_notifications/local_notifications.dart';
|
||||||
import 'package:service_repository/service_repository.dart';
|
import 'package:service_repository/service_repository.dart';
|
||||||
import 'package:setting_repository/setting_repository.dart';
|
import 'package:setting_repository/setting_repository.dart';
|
||||||
import 'package:user_repository/user_repository.dart';
|
import 'package:user_repository/user_repository.dart';
|
||||||
@@ -276,7 +277,7 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
|||||||
vertical: 10,
|
vertical: 10,
|
||||||
horizontal: 15,
|
horizontal: 15,
|
||||||
),
|
),
|
||||||
child: customButton(service, context),
|
child: customButton(service, context, userInfo),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -372,7 +373,8 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ElevatedButton customButton(ServiceEntity service, BuildContext context) {
|
ElevatedButton customButton(
|
||||||
|
ServiceEntity service, BuildContext context, MyUser userInfo) {
|
||||||
if (service.status == ServiceStatus.pending) {
|
if (service.status == ServiceStatus.pending) {
|
||||||
return ElevatedButton(
|
return ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -384,6 +386,14 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
|||||||
ServiceStatus.cancelled,
|
ServiceStatus.cancelled,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (userInfo.token != null) {
|
||||||
|
LocalNotifications.sendPushNotification(
|
||||||
|
userInfo.token!,
|
||||||
|
'Servicio cancelado',
|
||||||
|
'Servicio cancelado por ${userInfo.name}',
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
style: FilledButton.styleFrom(
|
style: FilledButton.styleFrom(
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import 'package:professional_repository/professional_repository.dart';
|
|||||||
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
||||||
import 'package:prosappco/components/drawer_reputation.dart';
|
import 'package:prosappco/components/drawer_reputation.dart';
|
||||||
import 'package:prosappco/components/general_reputation.dart';
|
import 'package:prosappco/components/general_reputation.dart';
|
||||||
|
import 'package:prosappco/local_notifications/local_notifications.dart';
|
||||||
import 'package:prosappco/screens/chat/chat_screen.dart';
|
import 'package:prosappco/screens/chat/chat_screen.dart';
|
||||||
import 'package:prosappco/components/general_secondary_button.dart';
|
import 'package:prosappco/components/general_secondary_button.dart';
|
||||||
import 'package:prosappco/screens/score/score_screen.dart';
|
import 'package:prosappco/screens/score/score_screen.dart';
|
||||||
@@ -420,7 +421,7 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
|
|||||||
vertical: 10,
|
vertical: 10,
|
||||||
horizontal: 15,
|
horizontal: 15,
|
||||||
),
|
),
|
||||||
child: customButton(service, context),
|
child: customButton(service, context, userInfo),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -892,7 +893,8 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
|
|||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget customButton(ServiceEntity service, BuildContext context) {
|
Widget customButton(
|
||||||
|
ServiceEntity service, BuildContext context, MyUser userInfo) {
|
||||||
if (service.status == ServiceStatus.pending) {
|
if (service.status == ServiceStatus.pending) {
|
||||||
return GeneralSecondaryButton(
|
return GeneralSecondaryButton(
|
||||||
label: 'Cancelar servicio',
|
label: 'Cancelar servicio',
|
||||||
@@ -903,6 +905,14 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
|
|||||||
context.read<ServiceBloc>().add(
|
context.read<ServiceBloc>().add(
|
||||||
UpdateServiceStatus(widget.serviceId, ServiceStatus.cancelled));
|
UpdateServiceStatus(widget.serviceId, ServiceStatus.cancelled));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (userInfo.token != null) {
|
||||||
|
LocalNotifications.sendPushNotification(
|
||||||
|
userInfo.token!,
|
||||||
|
'Servicio cancelado',
|
||||||
|
'Servicio cancelado por ${userInfo.name}',
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import 'package:professional_repository/professional_repository.dart';
|
|||||||
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
||||||
import 'package:prosappco/components/general_primary_button.dart';
|
import 'package:prosappco/components/general_primary_button.dart';
|
||||||
import 'package:prosappco/components/general_secondary_button.dart';
|
import 'package:prosappco/components/general_secondary_button.dart';
|
||||||
|
import 'package:prosappco/local_notifications/local_notifications.dart';
|
||||||
import 'package:service_repository/service_repository.dart';
|
import 'package:service_repository/service_repository.dart';
|
||||||
import 'package:setting_repository/setting_repository.dart';
|
import 'package:setting_repository/setting_repository.dart';
|
||||||
import 'package:user_repository/user_repository.dart';
|
import 'package:user_repository/user_repository.dart';
|
||||||
@@ -255,7 +256,7 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
|
|||||||
vertical: 10,
|
vertical: 10,
|
||||||
horizontal: 15,
|
horizontal: 15,
|
||||||
),
|
),
|
||||||
child: customButton(service, context),
|
child: customButton(service, context, userInfo),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -352,7 +353,7 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GeneralSecondaryButton customButton(
|
GeneralSecondaryButton customButton(
|
||||||
ServiceEntity service, BuildContext context) {
|
ServiceEntity service, BuildContext context, MyUser userInfo) {
|
||||||
if (service.status == ServiceStatus.pending) {
|
if (service.status == ServiceStatus.pending) {
|
||||||
return GeneralSecondaryButton(
|
return GeneralSecondaryButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -364,6 +365,14 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
|
|||||||
ServiceStatus.cancelled,
|
ServiceStatus.cancelled,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (userInfo.token != null) {
|
||||||
|
LocalNotifications.sendPushNotification(
|
||||||
|
userInfo.token!,
|
||||||
|
'Servicio cancelado',
|
||||||
|
'Servicio cancelado por ${userInfo.name}',
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
|
|||||||
Reference in New Issue
Block a user