update calendar
This commit is contained in:
+2
-6
@@ -47,7 +47,7 @@ void main() async {
|
||||
if (!kIsWeb) {
|
||||
FirebaseMessaging messaging = FirebaseMessaging.instance;
|
||||
|
||||
NotificationSettings settings = await messaging.requestPermission(
|
||||
await messaging.requestPermission(
|
||||
alert: true,
|
||||
announcement: false,
|
||||
badge: true,
|
||||
@@ -57,14 +57,10 @@ void main() async {
|
||||
sound: true,
|
||||
);
|
||||
|
||||
print('User granted permission: ${settings.authorizationStatus}');
|
||||
|
||||
FirebaseMessaging.onBackgroundMessage(
|
||||
(_firebaseMessagingBackgroundHandler));
|
||||
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
// Tu código para manejar las notificaciones aquí
|
||||
});
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {});
|
||||
}
|
||||
|
||||
await initNotifications();
|
||||
|
||||
@@ -62,10 +62,10 @@ Future<List<Event>> getByProId(String day) async {
|
||||
try {
|
||||
var snapshot = await FirebaseFirestore.instance
|
||||
.collection('services')
|
||||
.where('professional_id', isEqualTo: uid)
|
||||
// .where('professional_id', isEqualTo: uid)
|
||||
.where('day', isEqualTo: day.toString())
|
||||
.where('status', isEqualTo: 'aprobado')
|
||||
.orderBy('Timestamp', descending: true)
|
||||
// .orderBy('Timestamp', descending: true)
|
||||
.get();
|
||||
|
||||
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/models/event_model.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:intl/intl.dart';
|
||||
|
||||
@@ -64,6 +65,8 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
today = DateTime.utc(today.year, today.month, today.day);
|
||||
|
||||
if (_events == null) {
|
||||
Event.getEventsAllByIdStatus(uid ?? "", 'aprobado')
|
||||
.then((value) => setState(() {
|
||||
@@ -87,8 +90,10 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_events == null) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
return const Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -351,16 +356,32 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
return FutureBuilder(
|
||||
future: getByProId(DateFormat("yyyy-MM-dd 00:00:00.000").format(today)),
|
||||
builder: (BuildContext context, AsyncSnapshot<List<Event>> snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return const Text('No tienes citas');
|
||||
}
|
||||
|
||||
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 {
|
||||
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!);
|
||||
} catch (e) {
|
||||
print("Error" + e.toString());
|
||||
print("Error al cargar eventos: inflar $e");
|
||||
}
|
||||
|
||||
if (eventos.isEmpty) {
|
||||
|
||||
@@ -262,7 +262,6 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
final ultimoMensaje = mensajes.last;
|
||||
final ultimoMensajeUser = ultimoMensaje['user'];
|
||||
if (ultimoMensajeUser == uid) {
|
||||
// El último mensaje fue enviado por ti, no se envía la notificación
|
||||
} else {
|
||||
sendPushNotification(user!.token!);
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ class _ProfessionalScreenState extends State<ProfessionalScreen> {
|
||||
child: ListView.builder(
|
||||
itemCount: 8,
|
||||
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';
|
||||
|
||||
class LoadingItemList extends StatelessWidget {
|
||||
const LoadingItemList({super.key});
|
||||
final bool useCircleAvatar;
|
||||
|
||||
const LoadingItemList({super.key, required this.useCircleAvatar});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -10,10 +12,19 @@ class LoadingItemList extends StatelessWidget {
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: ListTile(
|
||||
leading: const CircleAvatar(
|
||||
radius: 25,
|
||||
backgroundColor: Colors.white,
|
||||
),
|
||||
leading: useCircleAvatar
|
||||
? const CircleAvatar(
|
||||
radius: 25,
|
||||
backgroundColor: Colors.white,
|
||||
)
|
||||
: Container(
|
||||
width: 45,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
title: Container(
|
||||
height: 20,
|
||||
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