Added notification logic and view api
This commit is contained in:
@@ -1,93 +1,90 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tm_app/core/constants/assets.dart';
|
||||
import 'package:tm_app/core/theme/colors.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
|
||||
import '../pages/notification_screen.dart';
|
||||
import 'package:tm_app/data/services/model/notification_data/notification_data.dart';
|
||||
import 'package:tm_app/view_models/notification_view_model.dart';
|
||||
|
||||
class NotificationCard extends StatelessWidget {
|
||||
final NotificationItem notification;
|
||||
const NotificationCard({required this.notification, super.key});
|
||||
final NotificationModel notification;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final viewModel = context.read<NotificationViewModel>();
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
// height: 108.0.h(),
|
||||
margin: EdgeInsets.symmetric(horizontal: 24.0.w()),
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0.w(), vertical: 16.0.h()),
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
notification.title == 'Tender Submitted'
|
||||
notification.type == 'reject'
|
||||
? AppColors.orange10
|
||||
: notification.title == 'New Tender Invitation'
|
||||
? AppColors.mainBlue.withValues(alpha: 0.03)
|
||||
: notification.type == 'info'
|
||||
? AppColors.primary10Light
|
||||
: AppColors.green0,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color:
|
||||
notification.title == 'Tender Submitted'
|
||||
notification.type! == 'reject'
|
||||
? AppColors.warningColor
|
||||
: notification.title == 'New Tender Invitation'
|
||||
? AppColors.mainBlue.withValues(alpha: 0.15)
|
||||
: AppColors.green20,
|
||||
: notification.type == 'info' ? AppColors.primary20 : AppColors.green20,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 3.0.h()),
|
||||
child: SvgPicture.asset(
|
||||
notification.type! == 'info'
|
||||
? AssetsManager.notification
|
||||
: notification.type! == 'reject'
|
||||
? AssetsManager.danger
|
||||
: AssetsManager.tickCircle,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
notification.title == 'Tender Submitted'
|
||||
? AssetsManager.danger
|
||||
: notification.title == 'New Tender Invitation'
|
||||
? AssetsManager.notification
|
||||
: AssetsManager.tickCircle,
|
||||
),
|
||||
SizedBox(width: 8.0.w()),
|
||||
Text(
|
||||
notification.title,
|
||||
notification.title!,
|
||||
style: TextStyle(
|
||||
fontSize: 16.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.grey80,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8.0.h()),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.only(start: 28.0.w()),
|
||||
child: Text(
|
||||
notification.description,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.start,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.grey60,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8.0.h()),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.only(start: 28.0.w()),
|
||||
child: Row(
|
||||
children: [
|
||||
SvgPicture.asset(AssetsManager.calendar),
|
||||
SizedBox(width: 4.0.w()),
|
||||
Text(
|
||||
notification.time,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
color: AppColors.grey60,
|
||||
),
|
||||
SizedBox(height: 8.0.h()),
|
||||
Text(
|
||||
notification.message!,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.grey70,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8.0.h()),
|
||||
Row(
|
||||
children: [
|
||||
SvgPicture.asset(AssetsManager.calendar),
|
||||
SizedBox(width: 4.0.w()),
|
||||
Text(
|
||||
viewModel.timeAgo(notification.createdAt!),
|
||||
style: TextStyle(
|
||||
fontSize: 12.0.sp(),
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.grey60,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user