Merge branch 'vasavk/calendar' of https://gitlab.verizon.com/BPHV_MIPS/vds_ios.git into feature/datePicker

# Conflicts:
#	VDS/Components/Calendar/Calendar.swift

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-05-14 17:44:32 -05:00
commit c3e84a0440
2 changed files with 34 additions and 9 deletions

View File

@ -164,15 +164,15 @@ open class CalendarBase: Control, Changeable {
fetchDates(with: displayDate)
}
layer.backgroundColor = backgroundColorConfiguration.getColor(self).cgColor
containerView.layer.backgroundColor = backgroundColorConfiguration.getColor(self).cgColor
if hideContainerBorder {
layer.borderColor = nil
layer.borderWidth = 0
layer.cornerRadius = 0
containerView.layer.borderColor = nil
containerView.layer.borderWidth = 0
containerView.layer.cornerRadius = 0
} else {
layer.borderColor = containerBorderColorConfiguration.getColor(self).cgColor
layer.borderWidth = VDSFormControls.borderWidth
layer.cornerRadius = VDSFormControls.borderRadius
containerView.layer.borderColor = containerBorderColorConfiguration.getColor(self).cgColor
containerView.layer.borderWidth = VDSFormControls.borderWidth
containerView.layer.cornerRadius = VDSFormControls.borderRadius
}
}
@ -317,11 +317,23 @@ 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]

View File

@ -42,7 +42,7 @@ final class CalendarDateViewCell: UICollectionViewCell {
}
private lazy var shapeLayer = CAShapeLayer()
private var surface: Surface = .light
private let selectedTextColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryInverseOnlight, VDSColor.elementsPrimaryInverseOndark)
private let selectedBackgroundColor = SurfaceColorConfiguration(VDSColor.backgroundPrimaryInverseLight, VDSColor.backgroundPrimaryInverseDark)
private let selectedCellIndicatorColorConfiguration = SurfaceColorConfiguration(VDSColor.paletteGray65, VDSColor.paletteGray44)
@ -50,7 +50,7 @@ final class CalendarDateViewCell: UICollectionViewCell {
private let unselectedCellIndicatorColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsSecondaryOnlight, VDSColor.elementsSecondaryOndark)
private let disabledTextColorConfiguration = SurfaceColorConfiguration(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark)
private let disabledBackgroundColor = SurfaceColorConfiguration(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark)
private var activeBorderColorConfiguration = SurfaceColorConfiguration(VDSFormControlsColor.borderHoverOnlight , VDSFormControlsColor.borderHoverOndark)
private let currentDate = Date()
//--------------------------------------------------
@ -104,6 +104,7 @@ final class CalendarDateViewCell: UICollectionViewCell {
stackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
numberLabel.surface = surface
numberLabel.text = text
self.surface = surface
// enable/disable cells based on min date, max date and active/inactive dates.
updateLabel(with:surface, displayDate: displayDate, minDate: minDate, maxDate: maxDate, activeDates: activeDates, inactiveDates: inactiveDates)
@ -160,6 +161,18 @@ final class CalendarDateViewCell: UICollectionViewCell {
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)