diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 363e9b6b..fd2b2d43 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -37,7 +37,7 @@ 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 200386442A0227A4004229C6 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; 2098A8512A022A2400D543AF /* RunnerDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RunnerDebug.entitlements; sourceTree = ""; }; - 20D227A02BB6922D002B4D6B /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = file; name = PrivacyInfo.xcprivacy; path = ../PrivacyInfo.xcprivacy; sourceTree = ""; }; + 20D227A02BB6922D002B4D6B /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; 26A55DE803EBC37682D1817B /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 72C690916D5A4943B686E116 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; @@ -90,6 +90,7 @@ 97C146E51CF9000F007C117D = { isa = PBXGroup; children = ( + 20D227A02BB6922D002B4D6B /* PrivacyInfo.xcprivacy */, 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, @@ -110,7 +111,6 @@ 97C146F01CF9000F007C117D /* Runner */ = { isa = PBXGroup; children = ( - 20D227A02BB6922D002B4D6B /* PrivacyInfo.xcprivacy */, 2098A8512A022A2400D543AF /* RunnerDebug.entitlements */, 200386442A0227A4004229C6 /* Runner.entitlements */, 9A2DD91F2949D6B7002464EF /* GoogleService-Info.plist */, @@ -414,17 +414,18 @@ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1.0.2; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = S985H2T7J8; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = Unity; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1; + MARKETING_VERSION = 1.0.2; PRODUCT_BUNDLE_IDENTIFIER = com.canopas.projectunity; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -551,17 +552,18 @@ CODE_SIGN_ENTITLEMENTS = Runner/RunnerDebug.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1.0.2; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = S985H2T7J8; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = Unity; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1; + MARKETING_VERSION = 1.0.2; PRODUCT_BUNDLE_IDENTIFIER = com.canopas.projectunity; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -583,18 +585,19 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 1.0.2; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = S985H2T7J8; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = Unity; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1; + MARKETING_VERSION = 1.0.2; PRODUCT_BUNDLE_IDENTIFIER = com.canopas.projectunity; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/lib/data/core/extensions/date_time.dart b/lib/data/core/extensions/date_time.dart index 6b8a3a12..34971b55 100644 --- a/lib/data/core/extensions/date_time.dart +++ b/lib/data/core/extensions/date_time.dart @@ -25,6 +25,14 @@ extension TimestampExtension on DateTime { .add(Duration(days: DateTime.daysPerWeek - currentDate.weekday)) .day; + int calculateDifferenceInYears(DateTime currentDate) { + int yearDifference = year - currentDate.year; + if (month < currentDate.month || !isDateInCurrentWeek(currentDate)) { + yearDifference--; + } + return yearDifference.abs(); + } + bool isBeforeOrSame(DateTime date) => isBefore(date) || isAtSameMomentAs(date); diff --git a/lib/data/l10n/app_en.arb b/lib/data/l10n/app_en.arb index 012cf247..e9d27cab 100644 --- a/lib/data/l10n/app_en.arb +++ b/lib/data/l10n/app_en.arb @@ -276,7 +276,9 @@ } }, - "upcoming_anniversary_text":"{name} will have successfully completed {years} years with us on", + + + "upcoming_anniversary_text":"{years, plural, =1{{name} will have successfully completed {years} year with us on} other {{name} will have successfully completed {years} years with us on}}", "@upcoming_anniversary_text":{ "placeholders":{ "name":{ @@ -287,7 +289,8 @@ } } }, - "present_anniversary_text":"Congratulations on {years} with us {name} 💐💐! Keep up the good work!", + + "present_anniversary_text":"{years,plural, =1{Congratulations on {years} year with us {name} 💐💐! Keep up the good work!} other {Congratulations on {years} years with us {name} 💐💐! Keep up the good work!}}", "@present_anniversary_text":{ "placeholders":{ "name":{ diff --git a/lib/ui/shared/events/bloc/celebrations_bloc.dart b/lib/ui/shared/events/bloc/celebrations_bloc.dart index 264de89a..95352a95 100644 --- a/lib/ui/shared/events/bloc/celebrations_bloc.dart +++ b/lib/ui/shared/events/bloc/celebrations_bloc.dart @@ -33,8 +33,8 @@ class CelebrationsBloc extends Bloc { final List allEmployees = await _employeeService.getEmployees(); employees = allEmployees .where((employee) => employee.status == EmployeeStatus.active) - .where((employee) => employee.status == EmployeeStatus.active). - map((e) { + .where((employee) => employee.status == EmployeeStatus.active) + .map((e) { if (e.dateOfBirth != null) { final birthdate = e.dateOfBirth!.convertToUpcomingDay(); final Event event = Event( @@ -44,8 +44,10 @@ class CelebrationsBloc extends Bloc { imageUrl: e.imageUrl); allBirthdayEvents.add(event); } - if (e.role != Role.admin) { + if (e.role != Role.admin && + e.dateOfJoining.calculateDifferenceInYears(DateTime.now()) >= 1) { final upcomingDate = e.dateOfJoining.convertToUpcomingDay(); + final Event event = Event( name: e.name, dateTime: DateUtils.dateOnly(e.dateOfJoining), diff --git a/test/unit_test/shared/events/celebration_event_bloc_test.dart b/test/unit_test/shared/events/celebration_event_bloc_test.dart index 1815c313..2ac19df7 100644 --- a/test/unit_test/shared/events/celebration_event_bloc_test.dart +++ b/test/unit_test/shared/events/celebration_event_bloc_test.dart @@ -23,7 +23,7 @@ void main() { employeeId: "CA-1000", email: "dummy.t@canopas.com", designation: "Application Tester", - dateOfJoining: DateTime.now().dateOnly, + dateOfJoining: DateTime.now().dateOnly.add(const Duration(days: 360)), level: "SW-L2", gender: Gender.male, dateOfBirth: DateTime.now().dateOnly, @@ -36,17 +36,22 @@ void main() { employeeId: "CA-1000", email: "dummy.t@canopas.com", designation: "Application Tester", - dateOfJoining: DateTime.now().add(const Duration(days: 7)).dateOnly, + dateOfJoining: DateTime.now().dateOnly.add(const Duration(days: 367)), level: "SW-L2", gender: Gender.male, dateOfBirth: DateTime.now().add(const Duration(days: 7)).dateOnly, ); - Event event = Event( + Event birthEvent = Event( name: employee1.name, dateTime: employee1.dateOfBirth!, upcomingDate: employee1.dateOfBirth!.convertToUpcomingDay(), imageUrl: employee1.imageUrl); + Event anniversaryEvent2 = Event( + name: employee2.name, + dateTime: employee2.dateOfJoining, + upcomingDate: employee2.dateOfJoining.convertToUpcomingDay(), + imageUrl: employee1.imageUrl); Event event2 = Event( name: employee2.name, dateTime: employee2.dateOfBirth!, @@ -74,8 +79,8 @@ void main() { const CelebrationsState(status: Status.loading), CelebrationsState( status: Status.success, - birthdays: [event], - anniversaries: [event]), + birthdays: [birthEvent], + anniversaries: [anniversaryEvent2]), ]), ); }); @@ -88,11 +93,13 @@ void main() { celebrationsBloc.add(ShowBirthdaysEvent()); final successState = CelebrationsState( - status: Status.success, birthdays: [event], anniversaries: [event]); + status: Status.success, + birthdays: [birthEvent], + anniversaries: [anniversaryEvent2]); final allBdayState = successState.copyWith( showAllBdays: !celebrationsState.showAllBdays, - birthdays: [event, event2], - anniversaries: [event]); + birthdays: [birthEvent, event2], + anniversaries: [anniversaryEvent2]); expectLater( celebrationsBloc.stream, emitsInOrder([ @@ -112,11 +119,13 @@ void main() { celebrationsBloc.add(ShowAnniversariesEvent()); final successState = CelebrationsState( - status: Status.success, birthdays: [event], anniversaries: [event]); + status: Status.success, + birthdays: [birthEvent], + anniversaries: [anniversaryEvent2]); final allAnniversariesState = successState.copyWith( showAllAnniversaries: !celebrationsState.showAllAnniversaries, - birthdays: [event], - anniversaries: [event, event2]); + birthdays: [birthEvent], + anniversaries: [anniversaryEvent2]); expectLater( celebrationsBloc.stream, emitsInOrder([