Digital ACT-191 CXTDT-568463 defect: Calendar - On long press, hover randomizes
This commit is contained in:
parent
17d119fa6c
commit
b8326faa16
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
1.0.67
|
||||
----------------
|
||||
- CXTDT-553663 - DropdownSelect - Accessibility - has popup
|
||||
- CXTDT-568463 - Calendar - On long press, hover randomizes
|
||||
|
||||
1.0.66
|
||||
----------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user