Added notification logic and view api
This commit is contained in:
@@ -1,21 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tm_app/view_models/notification_view_model.dart';
|
||||
|
||||
import '../pages/notification_screen.dart';
|
||||
import 'notification_card.dart';
|
||||
|
||||
class NotificationImportantTab extends StatelessWidget {
|
||||
const NotificationImportantTab({super.key});
|
||||
const NotificationImportantTab({this.scrollController, super.key});
|
||||
|
||||
final ScrollController? scrollController;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final viewModel = context.watch<NotificationViewModel>();
|
||||
final allNotifications =
|
||||
viewModel.notificationResponse?.data?.notifications ?? [];
|
||||
|
||||
final importantNotifications = allNotifications
|
||||
.where((n) => n.priority?.toLowerCase() == 'important')
|
||||
.toList();
|
||||
|
||||
return ListView.builder(
|
||||
itemCount: notifications.length,
|
||||
controller: scrollController,
|
||||
itemCount: importantNotifications.length,
|
||||
itemBuilder: (context, index) {
|
||||
final notification = notifications[index];
|
||||
final notification = importantNotifications[index];
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: 16.0.h()),
|
||||
child: NotificationCard(notification: notification),
|
||||
padding: const EdgeInsets.only(bottom: 16.0),
|
||||
child: NotificationCard(
|
||||
notification: notification,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user