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

@ -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()
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
// Callback to pass selected date if it is enabled only.
selectedDate = dates[indexPath.row]
sendActions(for: .valueChanged)
displayDate = selectedDate
var reloadIndexPaths = [indexPath]
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)
}
// 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)
}
}
}

View File

@ -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)
@ -156,23 +171,15 @@ final class CalendarDateViewCell: UICollectionViewCell {
}
}
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)

View File

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