|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/models/system_notification_model.dart';
|
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
|
|
|
|
|
|
|
|
|
class NotificationItem extends StatelessWidget {
|
|
|
|
|
final SystemNotificationModel notification;
|
|
|
|
|
final Function(SystemNotificationModel) onPressed;
|
|
|
|
|
|
|
|
|
|
final bool isLoading;
|
|
|
|
|
|
|
|
|
|
const NotificationItem({Key? key, required this.notification, required this.onPressed, this.isLoading = false}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
if (notification.priorityName != null)
|
|
|
|
|
StatusLabel(
|
|
|
|
|
label: notification.priorityName,
|
|
|
|
|
textColor: AppColor.getRequestStatusTextColorByName(context, notification.priorityName!),
|
|
|
|
|
backgroundColor: AppColor.getRequestStatusColorByName(context, notification.priorityName!),
|
|
|
|
|
).toShimmer(isShow: isLoading,context: context),
|
|
|
|
|
8.width,
|
|
|
|
|
if ((notification.statusName ?? "").isNotEmpty && notification.sourceName != "Asset Transfer")
|
|
|
|
|
StatusLabel(
|
|
|
|
|
label: notification.statusName ?? "",
|
|
|
|
|
textColor: AppColor.getRequestStatusTextColorByName(context, notification.statusName ?? ""),
|
|
|
|
|
backgroundColor: AppColor.getRequestStatusColorByName(context, notification.statusName ?? ""),
|
|
|
|
|
).toShimmer(isShow: isLoading,context: context),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
notification.title ?? "",
|
|
|
|
|
style: AppTextStyles.heading6.copyWith(
|
|
|
|
|
color: context.isDark ? AppColor.neutral30 : AppColor.neutral50,
|
|
|
|
|
),
|
|
|
|
|
).toShimmer(isShow: isLoading,context: context).expanded,
|
|
|
|
|
8.width,
|
|
|
|
|
Text(
|
|
|
|
|
notification.createdOn?.toServiceRequestCardFormat ?? "",
|
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
|
style: AppTextStyles.tinyFont.copyWith(
|
|
|
|
|
color: context.isDark ? AppColor.neutral20 : AppColor.neutral50,
|
|
|
|
|
),
|
|
|
|
|
).toShimmer(isShow: isLoading,context: context),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
notification.text ?? "",
|
|
|
|
|
style: AppTextStyles.bodyText2.copyWith(
|
|
|
|
|
color: context.isDark ? AppColor.neutral10 : const Color(0xFF757575),
|
|
|
|
|
),
|
|
|
|
|
).toShimmer(isShow: isLoading,context: context),
|
|
|
|
|
],
|
|
|
|
|
).onPress(() {
|
|
|
|
|
onPressed(notification);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|