From b8326faa161848132331665c15bad99dc966930a Mon Sep 17 00:00:00 2001 From: vasavk Date: Fri, 14 Jun 2024 21:17:48 +0530 Subject: [PATCH 1/6] Digital ACT-191 CXTDT-568463 defect: Calendar - On long press, hover randomizes --- VDS/Components/Calendar/Calendar.swift | 48 ++++++++----------- .../Calendar/CalendarDateViewCell.swift | 33 ++++++++----- VDS/SupportingFiles/ReleaseNotes.txt | 2 +- 3 files changed, 40 insertions(+), 43 deletions(-) diff --git a/VDS/Components/Calendar/Calendar.swift b/VDS/Components/Calendar/Calendar.swift index 2b0ba57b..3dbf0ba1 100644 --- a/VDS/Components/Calendar/Calendar.swift +++ b/VDS/Components/Calendar/Calendar.swift @@ -201,7 +201,7 @@ open class CalendarBase: Control, Changeable { } } updateViewConstraints() - } + } func updateViewConstraints() { collectionView.reloadData() @@ -331,38 +331,28 @@ extension CalendarBase: UICollectionViewDelegate, UICollectionViewDataSource, UI } } - - public func collectionView(_ collectionView: UICollectionView, shouldHighlightItemAt indexPath: IndexPath) -> Bool { - if let cell = collectionView.cellForItem(at: indexPath) as? CalendarDateViewCell { - let isEnabled: Bool = cell.isDateEnabled() - if isEnabled { - cell.activeModeStart() - } - } - return true - } - public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { // reload selected index, if it is in enabled state. if let cell = collectionView.cellForItem(at: indexPath) as? CalendarDateViewCell { - let isEnabled: Bool = cell.isDateEnabled() - if isEnabled { - cell.activeModeEnd() - - // Callback to pass selected date if it is enabled only. - selectedDate = dates[indexPath.row] - sendActions(for: .valueChanged) - displayDate = selectedDate - - var reloadIndexPaths = [indexPath] - - // If an cell is already selected, then it needs to be deselected. - // Add its index path to the array of index paths to be reloaded. - if let deselectIndexPath = selectedIndexPath { - reloadIndexPaths.append(deselectIndexPath) + let hasDate: Bool = cell.hasText() + if hasDate { + let isEnabled: Bool = cell.isDateEnabled() + if isEnabled { + // Callback to pass selected date if it is enabled only. + selectedDate = dates[indexPath.row] + sendActions(for: .valueChanged) + displayDate = selectedDate + + var reloadIndexPaths = [indexPath] + + // If an cell is already selected, then it needs to be deselected. + // Add its index path to the array of index paths to be reloaded. + if let deselectIndexPath = selectedIndexPath { + reloadIndexPaths.append(deselectIndexPath) + } + + collectionView.reloadItems(at: reloadIndexPaths) } - - collectionView.reloadItems(at: reloadIndexPaths) } } } diff --git a/VDS/Components/Calendar/CalendarDateViewCell.swift b/VDS/Components/Calendar/CalendarDateViewCell.swift index 4b6f400d..ee2f01c9 100644 --- a/VDS/Components/Calendar/CalendarDateViewCell.swift +++ b/VDS/Components/Calendar/CalendarDateViewCell.swift @@ -41,6 +41,21 @@ final class CalendarDateViewCell: UICollectionViewCell { $0.textStyle = .bodySmall } + override var isHighlighted: Bool { + didSet{ + if self.isHighlighted && hasText() && isDateEnabled() { + self.contentView.layer.borderColor = activeBorderColorConfiguration.getColor(surface).cgColor + self.contentView.layer.borderWidth = VDSFormControls.borderWidth + self.contentView.layer.cornerRadius = VDSFormControls.borderRadius + + } else { + self.contentView.layer.borderColor = nil + self.contentView.layer.borderWidth = 0 + self.contentView.layer.cornerRadius = 0 + } + } + } + private lazy var shapeLayer = CAShapeLayer() private var surface: Surface = .light private let selectedTextColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryInverseOnlight, VDSColor.elementsPrimaryInverseOndark) @@ -155,24 +170,16 @@ final class CalendarDateViewCell: UICollectionViewCell { numberLabel.textStyle = .bodySmall } } - + + func hasText() -> Bool { + return !numberLabel.text.isEmpty + } + // returns cell enabled state. func isDateEnabled() -> Bool { return numberLabel.isEnabled } - func activeModeStart() { - numberLabel.layer.borderColor = activeBorderColorConfiguration.getColor(surface).cgColor - numberLabel.layer.borderWidth = VDSFormControls.borderWidth - numberLabel.layer.cornerRadius = VDSFormControls.borderRadius - } - - func activeModeEnd() { - numberLabel.layer.borderColor = nil - numberLabel.layer.borderWidth = 0 - numberLabel.layer.cornerRadius = 0 - } - func disableLabel(with surface: Surface) { numberLabel.isEnabled = false numberLabel.textColor = disabledTextColorConfiguration.getColor(surface) diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index 326146fb..a3772a7b 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,6 +1,6 @@ 1.0.67 ---------------- -- CXTDT-553663 - DropdownSelect - Accessibility - has popup +- CXTDT-568463 - Calendar - On long press, hover randomizes 1.0.66 ---------------- From 4119a6c1806e350439139e20e4e7ef3f0ce1ee9f Mon Sep 17 00:00:00 2001 From: vasavk Date: Fri, 14 Jun 2024 21:20:11 +0530 Subject: [PATCH 2/6] Using internal enabled var for cell instead of label enabled state --- .../Calendar/CalendarDateViewCell.swift | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/VDS/Components/Calendar/CalendarDateViewCell.swift b/VDS/Components/Calendar/CalendarDateViewCell.swift index ee2f01c9..607eac76 100644 --- a/VDS/Components/Calendar/CalendarDateViewCell.swift +++ b/VDS/Components/Calendar/CalendarDateViewCell.swift @@ -47,7 +47,6 @@ final class CalendarDateViewCell: UICollectionViewCell { self.contentView.layer.borderColor = activeBorderColorConfiguration.getColor(surface).cgColor self.contentView.layer.borderWidth = VDSFormControls.borderWidth self.contentView.layer.cornerRadius = VDSFormControls.borderRadius - } else { self.contentView.layer.borderColor = nil self.contentView.layer.borderWidth = 0 @@ -56,6 +55,7 @@ final class CalendarDateViewCell: UICollectionViewCell { } } + private var isEnabled = false private lazy var shapeLayer = CAShapeLayer() private var surface: Surface = .light private let selectedTextColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryInverseOnlight, VDSColor.elementsPrimaryInverseOndark) @@ -135,20 +135,21 @@ final class CalendarDateViewCell: UICollectionViewCell { } } - // update text color, bg color, corner radius. - if numberLabel.text == selectedDate.getDay() - && selectedDate.monthInt == displayDate.monthInt - && selectedDate.yearInt == displayDate.yearInt - && numberLabel.isEnabled { - - numberLabel.textColor = selectedTextColorConfiguration.getColor(surface) - layer.backgroundColor = selectedBackgroundColor.getColor(surface).cgColor - layer.cornerRadius = VDSFormControls.borderRadius - - } else { - numberLabel.textColor = unselectedTextColorConfiguration.getColor(surface) - layer.backgroundColor = nil - layer.cornerRadius = 0 + // Set selected/unselected state text color, bg color, corner radius if cell is in enabled state. + if isEnabled { + if numberLabel.text == selectedDate.getDay() + && selectedDate.monthInt == displayDate.monthInt + && selectedDate.yearInt == displayDate.yearInt { + + numberLabel.textColor = selectedTextColorConfiguration.getColor(surface) + layer.backgroundColor = selectedBackgroundColor.getColor(surface).cgColor + layer.cornerRadius = VDSFormControls.borderRadius + + } else { + numberLabel.textColor = unselectedTextColorConfiguration.getColor(surface) + layer.backgroundColor = nil + layer.cornerRadius = 0 + } } // add indicators. @@ -177,11 +178,11 @@ final class CalendarDateViewCell: UICollectionViewCell { // returns cell enabled state. func isDateEnabled() -> Bool { - return numberLabel.isEnabled + return isEnabled } func disableLabel(with surface: Surface) { - numberLabel.isEnabled = false + isEnabled = false numberLabel.textColor = disabledTextColorConfiguration.getColor(surface) layer.backgroundColor = disabledBackgroundColor.getColor(surface).cgColor } @@ -190,7 +191,7 @@ final class CalendarDateViewCell: UICollectionViewCell { for x in 0...activeDates.count-1 { if activeDates[x].monthInt == displayDate.monthInt && activeDates[x].yearInt == displayDate.yearInt { if let day:Int = Int(numberLabel.text), day == activeDates[x].dayInt { - numberLabel.isEnabled = true + isEnabled = true } } } @@ -201,7 +202,7 @@ final class CalendarDateViewCell: UICollectionViewCell { if activeDates.count > 0 && inactiveDates.count == 0 { showActiveDates(with: displayDate, activeDates: activeDates, inactiveDates: inactiveDates) } else { - numberLabel.isEnabled = true + isEnabled = true } } @@ -211,7 +212,7 @@ final class CalendarDateViewCell: UICollectionViewCell { disableLabel(with: surface) showActiveDates(with: displayDate, activeDates: activeDates, inactiveDates: inactiveDates) } else { - numberLabel.isEnabled = true + isEnabled = true } } @@ -220,7 +221,7 @@ final class CalendarDateViewCell: UICollectionViewCell { if let day = Int(numberLabel.text), day < minDate.dayInt { disableLabel(with: surface) } else { - numberLabel.isEnabled = false + isEnabled = false handleActiveDates(with: displayDate, activeDates: activeDates, inactiveDates: inactiveDates) } } @@ -230,7 +231,7 @@ final class CalendarDateViewCell: UICollectionViewCell { if let day = Int(numberLabel.text), day > maxDate.dayInt { disableLabel(with: surface) } else { - numberLabel.isEnabled = false + isEnabled = false handleActiveDates(with: displayDate, activeDates: activeDates, inactiveDates: inactiveDates) } } @@ -240,7 +241,7 @@ final class CalendarDateViewCell: UICollectionViewCell { if let day = Int(numberLabel.text), day < minDate.dayInt || day > maxDate.dayInt { disableLabel(with: surface) } else { - numberLabel.isEnabled = false + isEnabled = false handleActiveDates(with: displayDate, activeDates: activeDates, inactiveDates: inactiveDates) } } From ed356299b5048248e3c6be38b1cad675eb63bf0b Mon Sep 17 00:00:00 2001 From: vasavk Date: Fri, 14 Jun 2024 21:21:26 +0530 Subject: [PATCH 3/6] Fixed issue observed: fetching days with wrong date if display date exceeds min/max date --- VDS/Components/Calendar/Calendar.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VDS/Components/Calendar/Calendar.swift b/VDS/Components/Calendar/Calendar.swift index 3dbf0ba1..cd1c783b 100644 --- a/VDS/Components/Calendar/Calendar.swift +++ b/VDS/Components/Calendar/Calendar.swift @@ -160,7 +160,7 @@ open class CalendarBase: Control, Changeable { if (minDate <= maxDate) { // Check if current date falls between min & max dates. let fallsBetween = displayDate.isBetweeen(date: minDate, andDate: maxDate) - displayDate = fallsBetween ? displayDate : minDate + displayDate = fallsBetween ? displayDate : (displayDate.monthInt == minDate.monthInt) ? minDate : maxDate fetchDates(with: displayDate) } containerView.backgroundColor = transparentBackground ? .clear : backgroundColorConfiguration.getColor(self) From c9c3b54484f526f34b63abfff6c64ac6fee8f7c8 Mon Sep 17 00:00:00 2001 From: vasavk Date: Fri, 14 Jun 2024 21:24:53 +0530 Subject: [PATCH 4/6] updated missed note. --- VDS/SupportingFiles/ReleaseNotes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index a3772a7b..5014b345 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,5 +1,6 @@ 1.0.67 ---------------- +- CXTDT-553663 - DropdownSelect - Accessibility - has popup - CXTDT-568463 - Calendar - On long press, hover randomizes 1.0.66 From bec994e2d486d05f9aedabfbc1e39bceebe30e40 Mon Sep 17 00:00:00 2001 From: vasavk Date: Fri, 14 Jun 2024 21:33:02 +0530 Subject: [PATCH 5/6] Digital ACT-191 CXTDT-568412 defect: Calendar - Incorrect side nav icon size --- VDS/Components/Calendar/CalendarHeaderReusableView.swift | 8 ++++---- VDS/SupportingFiles/ReleaseNotes.txt | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/VDS/Components/Calendar/CalendarHeaderReusableView.swift b/VDS/Components/Calendar/CalendarHeaderReusableView.swift index d3da2dca..218f5471 100644 --- a/VDS/Components/Calendar/CalendarHeaderReusableView.swift +++ b/VDS/Components/Calendar/CalendarHeaderReusableView.swift @@ -68,16 +68,16 @@ class CalendarHeaderReusableView: UICollectionReusableView { $0.kind = .ghost $0.iconName = .leftCaret $0.iconOffset = .init(x: -2, y: 0) - $0.icon.size = .small - $0.size = .small + $0.customContainerSize = 40 + $0.icon.customSize = 16 } internal var nextButton = ButtonIcon().with { $0.kind = .ghost $0.iconName = .rightCaret $0.iconOffset = .init(x: 2, y: 0) - $0.icon.size = .small - $0.size = .small + $0.customContainerSize = 40 + $0.icon.customSize = 16 } internal var headerTitle = Label().with { diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index 5014b345..e89bb500 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -2,6 +2,7 @@ ---------------- - CXTDT-553663 - DropdownSelect - Accessibility - has popup - CXTDT-568463 - Calendar - On long press, hover randomizes +- CXTDT-568412 - Calendar - Incorrect side nav icon size 1.0.66 ---------------- From 69cdae83749b60f0debced661db3cc0134c13365 Mon Sep 17 00:00:00 2001 From: vasavk Date: Fri, 14 Jun 2024 22:04:25 +0530 Subject: [PATCH 6/6] Digital ACT-191 CXTDT-568422 defect: Calendar - DarkMode Legend icon fill using Light mode color --- VDS/Components/Calendar/CalendarFooterReusableView.swift | 4 ++-- VDS/SupportingFiles/ReleaseNotes.txt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/VDS/Components/Calendar/CalendarFooterReusableView.swift b/VDS/Components/Calendar/CalendarFooterReusableView.swift index 263cd83e..020655ea 100644 --- a/VDS/Components/Calendar/CalendarFooterReusableView.swift +++ b/VDS/Components/Calendar/CalendarFooterReusableView.swift @@ -224,7 +224,7 @@ private class LegendCollectionViewCell: UICollectionViewCell { title.text = text title.textColor = textColorConfiguration.getColor(surface) - legendIndicator.backgroundColor = drawSemiCircle ? .clear : (clearFullcircle ? .clear : color) + legendIndicator.backgroundColor = drawSemiCircle ? .clear : (clearFullcircle ? .clear : indicatorColorConfiguration.getColor(surface)) legendIndicator.layer.borderColor = indicatorColorConfiguration.getColor(surface).cgColor self.layoutIfNeeded() @@ -239,7 +239,7 @@ private class LegendCollectionViewCell: UICollectionViewCell { path.addArc(withCenter: center, radius: center.x, startAngle: 2 * .pi, endAngle: .pi, clockwise: true) path.close() shapeLayer.path = path.cgPath - shapeLayer.fillColor = color.cgColor + shapeLayer.fillColor = indicatorColorConfiguration.getColor(surface).cgColor guard legendIndicator.layer.sublayers?.contains(shapeLayer) ?? true else { return } legendIndicator.layer.addSublayer(shapeLayer) diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index e89bb500..8a038e51 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -3,6 +3,7 @@ - CXTDT-553663 - DropdownSelect - Accessibility - has popup - CXTDT-568463 - Calendar - On long press, hover randomizes - CXTDT-568412 - Calendar - Incorrect side nav icon size +- CXTDT-568422 - Calendar - DarkMode Legend icon fill using Light mode color 1.0.66 ----------------