Digital ACT-191 CXTDT-568463 defect: Calendar - On long press, hover randomizes

This commit is contained in:
vasavk 2024-06-14 21:17:48 +05:30
parent 17d119fa6c
commit b8326faa16
3 changed files with 40 additions and 43 deletions

View File

@ -201,7 +201,7 @@ open class CalendarBase: Control, Changeable {
} }
} }
updateViewConstraints() updateViewConstraints()
} }
func updateViewConstraints() { func updateViewConstraints() {
collectionView.reloadData() 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) { public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
// reload selected index, if it is in enabled state. // reload selected index, if it is in enabled state.
if let cell = collectionView.cellForItem(at: indexPath) as? CalendarDateViewCell { if let cell = collectionView.cellForItem(at: indexPath) as? CalendarDateViewCell {
let isEnabled: Bool = cell.isDateEnabled() let hasDate: Bool = cell.hasText()
if isEnabled { if hasDate {
cell.activeModeEnd() let isEnabled: Bool = cell.isDateEnabled()
if isEnabled {
// Callback to pass selected date if it is enabled only. // Callback to pass selected date if it is enabled only.
selectedDate = dates[indexPath.row] selectedDate = dates[indexPath.row]
sendActions(for: .valueChanged) sendActions(for: .valueChanged)
displayDate = selectedDate displayDate = selectedDate
var reloadIndexPaths = [indexPath] var reloadIndexPaths = [indexPath]
// If an cell is already selected, then it needs to be deselected. // 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. // Add its index path to the array of index paths to be reloaded.
if let deselectIndexPath = selectedIndexPath { if let deselectIndexPath = selectedIndexPath {
reloadIndexPaths.append(deselectIndexPath) reloadIndexPaths.append(deselectIndexPath)
}
collectionView.reloadItems(at: reloadIndexPaths)
} }
collectionView.reloadItems(at: reloadIndexPaths)
} }
} }
} }

View File

@ -41,6 +41,21 @@ final class CalendarDateViewCell: UICollectionViewCell {
$0.textStyle = .bodySmall $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 lazy var shapeLayer = CAShapeLayer()
private var surface: Surface = .light private var surface: Surface = .light
private let selectedTextColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryInverseOnlight, VDSColor.elementsPrimaryInverseOndark) private let selectedTextColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryInverseOnlight, VDSColor.elementsPrimaryInverseOndark)
@ -155,24 +170,16 @@ final class CalendarDateViewCell: UICollectionViewCell {
numberLabel.textStyle = .bodySmall numberLabel.textStyle = .bodySmall
} }
} }
func hasText() -> Bool {
return !numberLabel.text.isEmpty
}
// returns cell enabled state. // returns cell enabled state.
func isDateEnabled() -> Bool { func isDateEnabled() -> Bool {
return numberLabel.isEnabled 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) { func disableLabel(with surface: Surface) {
numberLabel.isEnabled = false numberLabel.isEnabled = false
numberLabel.textColor = disabledTextColorConfiguration.getColor(surface) numberLabel.textColor = disabledTextColorConfiguration.getColor(surface)

View File

@ -1,6 +1,6 @@
1.0.67 1.0.67
---------------- ----------------
- CXTDT-553663 - DropdownSelect - Accessibility - has popup - CXTDT-568463 - Calendar - On long press, hover randomizes
1.0.66 1.0.66
---------------- ----------------