You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
131 lines
4.7 KiB
Dart
131 lines
4.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
import 'package:test_sa/extensions/text_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/item_views/info_date_widget.dart';
|
|
import 'package:test_sa/views/widgets/item_views/info_header_widget.dart';
|
|
import 'package:test_sa/views/widgets/item_views/info_text_widget.dart';
|
|
|
|
class NotificationCardRedesigned extends StatelessWidget {
|
|
final SystemNotificationModel notification;
|
|
final VoidCallback onTap;
|
|
|
|
const NotificationCardRedesigned({
|
|
Key? key,
|
|
required this.notification,
|
|
required this.onTap,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isUnread = !(notification.readed ?? false);
|
|
return Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: AppColor.background(context),
|
|
borderRadius: BorderRadius.circular(8),
|
|
border: Border.all(color: AppColor.borderColor(context)),
|
|
),
|
|
child: InkWell(
|
|
onTap: onTap,
|
|
borderRadius: BorderRadius.circular(8),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Priority Badge & Date Row
|
|
Row(
|
|
children: [
|
|
// Priority Badge
|
|
if (notification.priorityName != null && notification.priorityName!.isNotEmpty)
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
|
decoration: BoxDecoration(
|
|
color: AppColor.getRequestStatusColorByName(
|
|
context,
|
|
notification.priorityName!,
|
|
),
|
|
borderRadius: BorderRadius.circular(4),
|
|
),
|
|
child: Text(
|
|
notification.priorityName!,
|
|
style: AppTextStyles.tinyFont2.copyWith(
|
|
color: AppColor.getRequestStatusTextColorByName(
|
|
context,
|
|
notification.priorityName!,
|
|
),
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
const Spacer(),
|
|
|
|
// Date & Time - Top Right
|
|
if (notification.createdOn?.isNotEmpty ?? false)
|
|
InfoDateWidget(notification.createdOn ?? ""),
|
|
],
|
|
),
|
|
8.height,
|
|
|
|
// Title with Unread Dot
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Unread indicator (blue dot) - aligned with title
|
|
if (isUnread)
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 6, right: 8),
|
|
child: Container(
|
|
width: 8,
|
|
height: 8,
|
|
decoration: const BoxDecoration(
|
|
color: AppColor.primary10,
|
|
shape: BoxShape.circle,
|
|
),
|
|
),
|
|
),
|
|
|
|
// Title
|
|
Expanded(
|
|
child: InfoHeader16Widget(
|
|
notification.title ?? '',
|
|
),
|
|
),
|
|
],
|
|
),
|
|
8.height,
|
|
if (notification.sourceName?.isNotEmpty ?? false)
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
|
decoration: BoxDecoration(
|
|
color: AppColor.primary10.withValues(alpha: 0.1),
|
|
borderRadius: BorderRadius.circular(4),
|
|
),
|
|
child: Text(
|
|
notification.sourceName!,
|
|
style: AppTextStyles.tinyFont2.copyWith(
|
|
color: AppColor.primary10,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
if (notification.sourceName?.isNotEmpty ?? false) 8.height,
|
|
|
|
// Message Preview
|
|
if (notification.text?.isNotEmpty ?? false)
|
|
InfoTextLabelWidget(
|
|
label: notification.text!,
|
|
// style: AppTextStyles.bodyText2.copyWith(
|
|
// color: AppColor.textColor(context),
|
|
// height: 1.4,
|
|
// ),
|
|
// maxLines: 3,
|
|
// overflow: TextOverflow.ellipsis,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
} |