From c97cd20fb2648a2575de94cecb1c4a85c573df8b Mon Sep 17 00:00:00 2001 From: Sneha Canopas <92501869+cp-sneha-s@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:23:15 +0530 Subject: [PATCH] Fix next month leaves are not showing in calendar (#57) --- ios/Flutter/AppFrameworkInfo.plist | 2 +- ios/Podfile | 2 +- ios/Runner.xcodeproj/project.pbxproj | 6 +++--- lib/data/repo/leave_repo.dart | 2 +- lib/data/services/leave_service.dart | 31 ++++++++++++++++------------ 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/ios/Flutter/AppFrameworkInfo.plist b/ios/Flutter/AppFrameworkInfo.plist index 9625e105d..7c5696400 100644 --- a/ios/Flutter/AppFrameworkInfo.plist +++ b/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 11.0 + 12.0 diff --git a/ios/Podfile b/ios/Podfile index 313ea4a15..2c068c404 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -platform :ios, '11.0' +platform :ios, '12.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 1c9624175..ad4c351f8 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -393,7 +393,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -476,7 +476,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -525,7 +525,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/lib/data/repo/leave_repo.dart b/lib/data/repo/leave_repo.dart index 83dfa2999..db25dc9ff 100644 --- a/lib/data/repo/leave_repo.dart +++ b/lib/data/repo/leave_repo.dart @@ -50,7 +50,7 @@ class LeaveRepo { (leavesByStartDate, leavesByEndDate) { List mergedList = leavesByStartDate; mergedList.addAll(leavesByEndDate.where((endDateLeave) => - !leavesByEndDate.any((startDateLeave) => + !leavesByStartDate.any((startDateLeave) => startDateLeave.leaveId == endDateLeave.leaveId))); return mergedList; }, diff --git a/lib/data/services/leave_service.dart b/lib/data/services/leave_service.dart index f3478b4fc..a14150cba 100644 --- a/lib/data/services/leave_service.dart +++ b/lib/data/services/leave_service.dart @@ -67,19 +67,24 @@ class LeaveService { .map((event) => event.docs.map((leave) => leave.data()).toList()); Stream> monthlyLeaveByEndDate( - {required int year, required int month, required String spaceId}) => - _leaveDb(spaceId: spaceId) - .where(FireStoreConst.leaveStatus, - isEqualTo: LeaveStatus.approved.value) - .where(FireStoreConst.endLeaveDate, - isGreaterThanOrEqualTo: DateTime(year, month).timeStampToInt) - .where(FireStoreConst.endLeaveDate, - isLessThan: DateTime(year, month + 1).timeStampToInt) - .snapshots() - .asyncMap((event) => event.docs - .map((leave) => leave.data()) - .where((leave) => leave.startDate.isBefore(DateTime(year, month))) - .toList()); + {required int year, required int month, required String spaceId}) { + final leaves = _leaveDb(spaceId: spaceId) + .where(FireStoreConst.leaveStatus, + isEqualTo: LeaveStatus.approved.value) + .where(FireStoreConst.endLeaveDate, + isLessThan: DateTime(year, month + 1).timeStampToInt) + .where(FireStoreConst.endLeaveDate, + isGreaterThanOrEqualTo: DateTime(year, month).timeStampToInt) + .snapshots() + .asyncMap((event) => event.docs + .map((leave) { + return leave.data(); + }) + .where((leave) => leave.startDate.isBefore(DateTime(year, month))) + .toList()); + + return leaves; + } Stream> userLeaveByStatus( {required String uid,