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:
commit
c3e84a0440
@ -164,15 +164,15 @@ open class CalendarBase: Control, Changeable {
|
|||||||
fetchDates(with: displayDate)
|
fetchDates(with: displayDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
layer.backgroundColor = backgroundColorConfiguration.getColor(self).cgColor
|
containerView.layer.backgroundColor = backgroundColorConfiguration.getColor(self).cgColor
|
||||||
if hideContainerBorder {
|
if hideContainerBorder {
|
||||||
layer.borderColor = nil
|
containerView.layer.borderColor = nil
|
||||||
layer.borderWidth = 0
|
containerView.layer.borderWidth = 0
|
||||||
layer.cornerRadius = 0
|
containerView.layer.cornerRadius = 0
|
||||||
} else {
|
} else {
|
||||||
layer.borderColor = containerBorderColorConfiguration.getColor(self).cgColor
|
containerView.layer.borderColor = containerBorderColorConfiguration.getColor(self).cgColor
|
||||||
layer.borderWidth = VDSFormControls.borderWidth
|
containerView.layer.borderWidth = VDSFormControls.borderWidth
|
||||||
layer.cornerRadius = VDSFormControls.borderRadius
|
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) {
|
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 isEnabled: Bool = cell.isDateEnabled()
|
||||||
if isEnabled {
|
if isEnabled {
|
||||||
|
cell.activeModeEnd()
|
||||||
|
|
||||||
// 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]
|
||||||
|
|||||||
@ -42,7 +42,7 @@ final class CalendarDateViewCell: UICollectionViewCell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private lazy var shapeLayer = CAShapeLayer()
|
private lazy var shapeLayer = CAShapeLayer()
|
||||||
|
private var surface: Surface = .light
|
||||||
private let selectedTextColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryInverseOnlight, VDSColor.elementsPrimaryInverseOndark)
|
private let selectedTextColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryInverseOnlight, VDSColor.elementsPrimaryInverseOndark)
|
||||||
private let selectedBackgroundColor = SurfaceColorConfiguration(VDSColor.backgroundPrimaryInverseLight, VDSColor.backgroundPrimaryInverseDark)
|
private let selectedBackgroundColor = SurfaceColorConfiguration(VDSColor.backgroundPrimaryInverseLight, VDSColor.backgroundPrimaryInverseDark)
|
||||||
private let selectedCellIndicatorColorConfiguration = SurfaceColorConfiguration(VDSColor.paletteGray65, VDSColor.paletteGray44)
|
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 unselectedCellIndicatorColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsSecondaryOnlight, VDSColor.elementsSecondaryOndark)
|
||||||
private let disabledTextColorConfiguration = SurfaceColorConfiguration(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark)
|
private let disabledTextColorConfiguration = SurfaceColorConfiguration(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark)
|
||||||
private let disabledBackgroundColor = SurfaceColorConfiguration(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark)
|
private let disabledBackgroundColor = SurfaceColorConfiguration(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark)
|
||||||
|
private var activeBorderColorConfiguration = SurfaceColorConfiguration(VDSFormControlsColor.borderHoverOnlight , VDSFormControlsColor.borderHoverOndark)
|
||||||
private let currentDate = Date()
|
private let currentDate = Date()
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -104,6 +104,7 @@ final class CalendarDateViewCell: UICollectionViewCell {
|
|||||||
stackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
|
stackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
|
||||||
numberLabel.surface = surface
|
numberLabel.surface = surface
|
||||||
numberLabel.text = text
|
numberLabel.text = text
|
||||||
|
self.surface = surface
|
||||||
|
|
||||||
// enable/disable cells based on min date, max date and active/inactive dates.
|
// 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)
|
updateLabel(with:surface, displayDate: displayDate, minDate: minDate, maxDate: maxDate, activeDates: activeDates, inactiveDates: inactiveDates)
|
||||||
@ -160,6 +161,18 @@ final class CalendarDateViewCell: UICollectionViewCell {
|
|||||||
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)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user