Digital ACT-191 ONEAPP-7958 story: callback when the date changes and is in enabled state only.
This commit is contained in:
parent
6bb6d31b39
commit
20f5926bbf
@ -287,6 +287,11 @@ extension CalendarBase: UICollectionViewDelegate, UICollectionViewDataSource, UI
|
||||
}
|
||||
|
||||
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 {
|
||||
// Callback to pass selected date if it is enabled only.
|
||||
let selectedItem = Calendar.current.date(byAdding: .day, value: 1, to: self.dates[indexPath.row])!
|
||||
onChangeSelectedDate?(selectedItem)
|
||||
|
||||
@ -299,6 +304,8 @@ extension CalendarBase: UICollectionViewDelegate, UICollectionViewDataSource, UI
|
||||
if let deselectIndexPath = selectedIndexPath { reloadIndexPaths.append(deselectIndexPath) }
|
||||
self.collectionView.reloadItems(at: reloadIndexPaths)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
|
||||
return CGSize(width: collectionView.frame.size.width, height: headerHeight)
|
||||
|
||||
@ -147,6 +147,11 @@ final class CalendarDateViewCell: UICollectionViewCell {
|
||||
}
|
||||
}
|
||||
|
||||
// returns cell enabled state.
|
||||
func isDateEnabled() -> Bool {
|
||||
return numberLabel.isEnabled
|
||||
}
|
||||
|
||||
func disableLabel(with surface: Surface) {
|
||||
numberLabel.isEnabled = false
|
||||
numberLabel.textColor = disabledTextColorConfiguration.getColor(surface)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user