From 24e4f4dd26aba8f93dcee808639f7fd45ef08819 Mon Sep 17 00:00:00 2001 From: cp-sneha-s Date: Wed, 13 Mar 2024 15:18:10 +0530 Subject: [PATCH] Implement- Show upcoming Events --- lib/data/core/utils/date_formatter.dart | 6 ++++-- lib/data/l10n/app_en.arb | 2 +- lib/data/model/employee/employee.g.dart | 3 +-- lib/ui/shared/events/model/event.dart | 12 ++++++++---- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/data/core/utils/date_formatter.dart b/lib/data/core/utils/date_formatter.dart index f4946e3cf..7d653d505 100644 --- a/lib/data/core/utils/date_formatter.dart +++ b/lib/data/core/utils/date_formatter.dart @@ -97,10 +97,12 @@ class DateFormatter { String showAnniversaries({required DateTime dateTime,required String name, int? number}){ final today = DateTime.now().dateOnly; + final difference= dateTime.difference(today); + int yearDifference= (difference.inDays/365).floor(); if(dateTime.dateOnly.isAtSameMomentAs(today)){ - return _localization.present_birthday_text(name); + return _localization.present_anniversary_text(name, yearDifference); }else{ - return "${_localization.upcoming_birthday_text(name)} ${getDateRepresentation(dateTime)}🎉"; + return "${_localization.upcoming_anniversary_text(name, yearDifference)} ${getDateRepresentation(dateTime)}🎉"; } } diff --git a/lib/data/l10n/app_en.arb b/lib/data/l10n/app_en.arb index d679c4385..0975b8a2a 100644 --- a/lib/data/l10n/app_en.arb +++ b/lib/data/l10n/app_en.arb @@ -287,7 +287,7 @@ } } }, - "present_anniversary_text":"Congratulations on {years} with us {name}! Keep up the good work! ", + "present_anniversary_text":"Congratulations on {years} with us {name} 💐💐! Keep up the good work! ", "@present_anniversary_text":{ "placeholders":{ "name":{ diff --git a/lib/data/model/employee/employee.g.dart b/lib/data/model/employee/employee.g.dart index d5d9f78c8..1212711b8 100644 --- a/lib/data/model/employee/employee.g.dart +++ b/lib/data/model/employee/employee.g.dart @@ -10,8 +10,7 @@ Employee _$EmployeeFromJson(Map json) => Employee( uid: json['uid'] as String, name: json['name'] as String, email: json['email'] as String, - role: Role.admin, - //role: $enumDecode(_$RoleEnumMap, json['role']), + role: $enumDecode(_$RoleEnumMap, json['role']), employeeId: json['employee_id'] as String?, designation: json['designation'] as String?, phone: json['phone'] as String?, diff --git a/lib/ui/shared/events/model/event.dart b/lib/ui/shared/events/model/event.dart index 095683ab6..dd6620515 100644 --- a/lib/ui/shared/events/model/event.dart +++ b/lib/ui/shared/events/model/event.dart @@ -1,7 +1,11 @@ -class Event{ +import 'package:flutter/material.dart'; + +class Event { final String name; final String? imageUrl; - final DateTime dateTime; + DateTime dateTime; - Event({required this.name,required this.dateTime,this.imageUrl}); -} \ No newline at end of file + Event({required this.name, required this.dateTime, this.imageUrl}) { + dateTime = DateUtils.dateOnly(dateTime); + } +}