43 lines
1.3 KiB
Dart
43 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:tm_app/view_models/notification_view_model.dart';
|
|
import 'package:tm_app/views/notification/strings/notification_strings.dart';
|
|
import 'notification_card.dart';
|
|
|
|
class NotificationImportantTab extends StatelessWidget {
|
|
const NotificationImportantTab({this.scrollController, super.key});
|
|
|
|
final ScrollController? scrollController;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final viewModel = context.watch<NotificationViewModel>();
|
|
|
|
if (viewModel.isLoadingImportant &&
|
|
(viewModel.importantNotificationResponse?.data?.isEmpty ?? true)) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
|
|
final importantNotifications =
|
|
viewModel.importantNotificationResponse?.data ?? [];
|
|
|
|
if (importantNotifications.isEmpty) {
|
|
return const Center(
|
|
child: Text(NotificationStrings.noImportantNotifications),
|
|
);
|
|
}
|
|
|
|
return ListView.builder(
|
|
controller: scrollController,
|
|
itemCount: importantNotifications.length,
|
|
itemBuilder: (context, index) {
|
|
final notification = importantNotifications[index];
|
|
return Padding(
|
|
padding: const EdgeInsets.only(bottom: 16.0),
|
|
child: NotificationCard(notification: notification),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|