update calendar
This commit is contained in:
+2
-6
@@ -47,7 +47,7 @@ void main() async {
|
|||||||
if (!kIsWeb) {
|
if (!kIsWeb) {
|
||||||
FirebaseMessaging messaging = FirebaseMessaging.instance;
|
FirebaseMessaging messaging = FirebaseMessaging.instance;
|
||||||
|
|
||||||
NotificationSettings settings = await messaging.requestPermission(
|
await messaging.requestPermission(
|
||||||
alert: true,
|
alert: true,
|
||||||
announcement: false,
|
announcement: false,
|
||||||
badge: true,
|
badge: true,
|
||||||
@@ -57,14 +57,10 @@ void main() async {
|
|||||||
sound: true,
|
sound: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
print('User granted permission: ${settings.authorizationStatus}');
|
|
||||||
|
|
||||||
FirebaseMessaging.onBackgroundMessage(
|
FirebaseMessaging.onBackgroundMessage(
|
||||||
(_firebaseMessagingBackgroundHandler));
|
(_firebaseMessagingBackgroundHandler));
|
||||||
|
|
||||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
FirebaseMessaging.onMessage.listen((RemoteMessage message) {});
|
||||||
// Tu código para manejar las notificaciones aquí
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await initNotifications();
|
await initNotifications();
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ Future<List<Event>> getByProId(String day) async {
|
|||||||
try {
|
try {
|
||||||
var snapshot = await FirebaseFirestore.instance
|
var snapshot = await FirebaseFirestore.instance
|
||||||
.collection('services')
|
.collection('services')
|
||||||
.where('professional_id', isEqualTo: uid)
|
// .where('professional_id', isEqualTo: uid)
|
||||||
.where('day', isEqualTo: day.toString())
|
.where('day', isEqualTo: day.toString())
|
||||||
.where('status', isEqualTo: 'aprobado')
|
.where('status', isEqualTo: 'aprobado')
|
||||||
.orderBy('Timestamp', descending: true)
|
// .orderBy('Timestamp', descending: true)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
List<Event> eventos = [];
|
List<Event> eventos = [];
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:prosappco/src/components/pop_appbar.dart';
|
|||||||
import 'package:prosappco/src/components/primary_btn.dart';
|
import 'package:prosappco/src/components/primary_btn.dart';
|
||||||
import 'package:prosappco/src/models/event_model.dart';
|
import 'package:prosappco/src/models/event_model.dart';
|
||||||
import 'package:prosappco/src/presentation/screens/cita.dart';
|
import 'package:prosappco/src/presentation/screens/cita.dart';
|
||||||
|
import 'package:prosappco/src/presentation/widgets/shared/loading_item_list.dart';
|
||||||
import 'package:table_calendar/table_calendar.dart';
|
import 'package:table_calendar/table_calendar.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
@@ -64,6 +65,8 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
|
today = DateTime.utc(today.year, today.month, today.day);
|
||||||
|
|
||||||
if (_events == null) {
|
if (_events == null) {
|
||||||
Event.getEventsAllByIdStatus(uid ?? "", 'aprobado')
|
Event.getEventsAllByIdStatus(uid ?? "", 'aprobado')
|
||||||
.then((value) => setState(() {
|
.then((value) => setState(() {
|
||||||
@@ -87,8 +90,10 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (_events == null) {
|
if (_events == null) {
|
||||||
return const Center(
|
return const Scaffold(
|
||||||
child: CircularProgressIndicator(),
|
body: Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,16 +356,32 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
|||||||
return FutureBuilder(
|
return FutureBuilder(
|
||||||
future: getByProId(DateFormat("yyyy-MM-dd 00:00:00.000").format(today)),
|
future: getByProId(DateFormat("yyyy-MM-dd 00:00:00.000").format(today)),
|
||||||
builder: (BuildContext context, AsyncSnapshot<List<Event>> snapshot) {
|
builder: (BuildContext context, AsyncSnapshot<List<Event>> snapshot) {
|
||||||
if (!snapshot.hasData) {
|
|
||||||
return const Text('No tienes citas');
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Event> eventos = [];
|
List<Event> eventos = [];
|
||||||
|
|
||||||
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
|
return const Column(
|
||||||
|
children: [
|
||||||
|
LoadingItemList(useCircleAvatar: false),
|
||||||
|
LoadingItemList(useCircleAvatar: false),
|
||||||
|
LoadingItemList(useCircleAvatar: false),
|
||||||
|
LoadingItemList(useCircleAvatar: false),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
|
snapshot.data!.sort((a, b) {
|
||||||
|
String? range1Hour1A = a.range1Hour1;
|
||||||
|
String? range1Hour1B = b.range1Hour1;
|
||||||
|
|
||||||
|
DateTime dateTimeA = DateTime.parse(range1Hour1A);
|
||||||
|
DateTime dateTimeB = DateTime.parse(range1Hour1B);
|
||||||
|
|
||||||
|
return dateTimeB.compareTo(dateTimeA);
|
||||||
|
});
|
||||||
|
|
||||||
eventos.addAll(snapshot.data!);
|
eventos.addAll(snapshot.data!);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Error" + e.toString());
|
print("Error al cargar eventos: inflar $e");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventos.isEmpty) {
|
if (eventos.isEmpty) {
|
||||||
|
|||||||
@@ -262,7 +262,6 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
final ultimoMensaje = mensajes.last;
|
final ultimoMensaje = mensajes.last;
|
||||||
final ultimoMensajeUser = ultimoMensaje['user'];
|
final ultimoMensajeUser = ultimoMensaje['user'];
|
||||||
if (ultimoMensajeUser == uid) {
|
if (ultimoMensajeUser == uid) {
|
||||||
// El último mensaje fue enviado por ti, no se envía la notificación
|
|
||||||
} else {
|
} else {
|
||||||
sendPushNotification(user!.token!);
|
sendPushNotification(user!.token!);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ class _ProfessionalScreenState extends State<ProfessionalScreen> {
|
|||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemCount: 8,
|
itemCount: 8,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
return const LoadingItemList();
|
return const LoadingItemList(useCircleAvatar: true);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:shimmer/shimmer.dart';
|
import 'package:shimmer/shimmer.dart';
|
||||||
|
|
||||||
class LoadingItemList extends StatelessWidget {
|
class LoadingItemList extends StatelessWidget {
|
||||||
const LoadingItemList({super.key});
|
final bool useCircleAvatar;
|
||||||
|
|
||||||
|
const LoadingItemList({super.key, required this.useCircleAvatar});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -10,10 +12,19 @@ class LoadingItemList extends StatelessWidget {
|
|||||||
baseColor: Colors.grey[300]!,
|
baseColor: Colors.grey[300]!,
|
||||||
highlightColor: Colors.grey[100]!,
|
highlightColor: Colors.grey[100]!,
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: const CircleAvatar(
|
leading: useCircleAvatar
|
||||||
radius: 25,
|
? const CircleAvatar(
|
||||||
backgroundColor: Colors.white,
|
radius: 25,
|
||||||
),
|
backgroundColor: Colors.white,
|
||||||
|
)
|
||||||
|
: Container(
|
||||||
|
width: 45,
|
||||||
|
height: 20,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
),
|
||||||
title: Container(
|
title: Container(
|
||||||
height: 20,
|
height: 20,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
class NotificationSnackbar {
|
||||||
|
static void show({
|
||||||
|
required String title,
|
||||||
|
required String message,
|
||||||
|
SnackPosition position = SnackPosition.TOP,
|
||||||
|
Duration duration = const Duration(seconds: 4),
|
||||||
|
Color backgroundColor = Colors.red,
|
||||||
|
Color textColor = Colors.white,
|
||||||
|
double borderRadius = 10.0,
|
||||||
|
EdgeInsets margin = const EdgeInsets.all(10.0),
|
||||||
|
SnackStyle snackStyle = SnackStyle.FLOATING,
|
||||||
|
Duration animationDuration = const Duration(milliseconds: 800),
|
||||||
|
bool isDismissible = true,
|
||||||
|
DismissDirection dismissDirection = DismissDirection.horizontal,
|
||||||
|
Curve forwardAnimationCurve = Curves.easeOutBack,
|
||||||
|
Curve reverseAnimationCurve = Curves.easeInBack,
|
||||||
|
Icon icon = const Icon(Icons.warning, color: Colors.white),
|
||||||
|
bool shouldIconPulse = true,
|
||||||
|
}) {
|
||||||
|
Get.snackbar(
|
||||||
|
title,
|
||||||
|
message,
|
||||||
|
snackPosition: position,
|
||||||
|
duration: duration,
|
||||||
|
backgroundColor: backgroundColor,
|
||||||
|
colorText: textColor,
|
||||||
|
borderRadius: borderRadius,
|
||||||
|
margin: margin,
|
||||||
|
snackStyle: snackStyle,
|
||||||
|
animationDuration: animationDuration,
|
||||||
|
isDismissible: isDismissible,
|
||||||
|
dismissDirection: dismissDirection,
|
||||||
|
forwardAnimationCurve: forwardAnimationCurve,
|
||||||
|
reverseAnimationCurve: reverseAnimationCurve,
|
||||||
|
icon: icon,
|
||||||
|
shouldIconPulse: shouldIconPulse,
|
||||||
|
titleText: Text(
|
||||||
|
title,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18.0, fontWeight: FontWeight.bold, color: Colors.white),
|
||||||
|
),
|
||||||
|
messageText: Text(
|
||||||
|
message,
|
||||||
|
style: const TextStyle(fontSize: 16.0, color: Colors.white),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user