Merge branch 'bugfix/calendar_fixes' of https://gitlab.verizon.com/BPHV_MIPS/vds_ios.git into mbruce/bugfix
This commit is contained in:
commit
e76674cfc8
@ -160,7 +160,7 @@ open class CalendarBase: Control, Changeable {
|
||||
if (minDate <= maxDate) {
|
||||
// Check if current date falls between min & max dates.
|
||||
let fallsBetween = displayDate.isBetweeen(date: minDate, andDate: maxDate)
|
||||
displayDate = fallsBetween ? displayDate : minDate
|
||||
displayDate = fallsBetween ? displayDate : (displayDate.monthInt == minDate.monthInt) ? minDate : maxDate
|
||||
fetchDates(with: displayDate)
|
||||
}
|
||||
containerView.backgroundColor = transparentBackground ? .clear : backgroundColorConfiguration.getColor(self)
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 var isEnabled = false
|
||||
private lazy var shapeLayer = CAShapeLayer()
|
||||
private var surface: Surface = .light
|
||||
private let selectedTextColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryInverseOnlight, VDSColor.elementsPrimaryInverseOndark)
|
||||
@ -120,20 +135,21 @@ final class CalendarDateViewCell: UICollectionViewCell {
|
||||
}
|
||||
}
|
||||
|
||||
// update text color, bg color, corner radius.
|
||||
if numberLabel.text == selectedDate.getDay()
|
||||
&& selectedDate.monthInt == displayDate.monthInt
|
||||
&& selectedDate.yearInt == displayDate.yearInt
|
||||
&& numberLabel.isEnabled {
|
||||
// Set selected/unselected state text color, bg color, corner radius if cell is in enabled state.
|
||||
if isEnabled {
|
||||
if numberLabel.text == selectedDate.getDay()
|
||||
&& selectedDate.monthInt == displayDate.monthInt
|
||||
&& selectedDate.yearInt == displayDate.yearInt {
|
||||
|
||||
numberLabel.textColor = selectedTextColorConfiguration.getColor(surface)
|
||||
layer.backgroundColor = selectedBackgroundColor.getColor(surface).cgColor
|
||||
layer.cornerRadius = VDSFormControls.borderRadius
|
||||
numberLabel.textColor = selectedTextColorConfiguration.getColor(surface)
|
||||
layer.backgroundColor = selectedBackgroundColor.getColor(surface).cgColor
|
||||
layer.cornerRadius = VDSFormControls.borderRadius
|
||||
|
||||
} else {
|
||||
numberLabel.textColor = unselectedTextColorConfiguration.getColor(surface)
|
||||
layer.backgroundColor = nil
|
||||
layer.cornerRadius = 0
|
||||
} else {
|
||||
numberLabel.textColor = unselectedTextColorConfiguration.getColor(surface)
|
||||
layer.backgroundColor = nil
|
||||
layer.cornerRadius = 0
|
||||
}
|
||||
}
|
||||
|
||||
// add indicators.
|
||||
@ -156,25 +172,17 @@ 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
|
||||
return isEnabled
|
||||
}
|
||||
|
||||
func disableLabel(with surface: Surface) {
|
||||
numberLabel.isEnabled = false
|
||||
isEnabled = false
|
||||
numberLabel.textColor = disabledTextColorConfiguration.getColor(surface)
|
||||
layer.backgroundColor = disabledBackgroundColor.getColor(surface).cgColor
|
||||
}
|
||||
@ -183,7 +191,7 @@ final class CalendarDateViewCell: UICollectionViewCell {
|
||||
for x in 0...activeDates.count-1 {
|
||||
if activeDates[x].monthInt == displayDate.monthInt && activeDates[x].yearInt == displayDate.yearInt {
|
||||
if let day:Int = Int(numberLabel.text), day == activeDates[x].dayInt {
|
||||
numberLabel.isEnabled = true
|
||||
isEnabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -194,7 +202,7 @@ final class CalendarDateViewCell: UICollectionViewCell {
|
||||
if activeDates.count > 0 && inactiveDates.count == 0 {
|
||||
showActiveDates(with: displayDate, activeDates: activeDates, inactiveDates: inactiveDates)
|
||||
} else {
|
||||
numberLabel.isEnabled = true
|
||||
isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,7 +212,7 @@ final class CalendarDateViewCell: UICollectionViewCell {
|
||||
disableLabel(with: surface)
|
||||
showActiveDates(with: displayDate, activeDates: activeDates, inactiveDates: inactiveDates)
|
||||
} else {
|
||||
numberLabel.isEnabled = true
|
||||
isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,7 +221,7 @@ final class CalendarDateViewCell: UICollectionViewCell {
|
||||
if let day = Int(numberLabel.text), day < minDate.dayInt {
|
||||
disableLabel(with: surface)
|
||||
} else {
|
||||
numberLabel.isEnabled = false
|
||||
isEnabled = false
|
||||
handleActiveDates(with: displayDate, activeDates: activeDates, inactiveDates: inactiveDates)
|
||||
}
|
||||
}
|
||||
@ -223,7 +231,7 @@ final class CalendarDateViewCell: UICollectionViewCell {
|
||||
if let day = Int(numberLabel.text), day > maxDate.dayInt {
|
||||
disableLabel(with: surface)
|
||||
} else {
|
||||
numberLabel.isEnabled = false
|
||||
isEnabled = false
|
||||
handleActiveDates(with: displayDate, activeDates: activeDates, inactiveDates: inactiveDates)
|
||||
}
|
||||
}
|
||||
@ -233,7 +241,7 @@ final class CalendarDateViewCell: UICollectionViewCell {
|
||||
if let day = Int(numberLabel.text), day < minDate.dayInt || day > maxDate.dayInt {
|
||||
disableLabel(with: surface)
|
||||
} else {
|
||||
numberLabel.isEnabled = false
|
||||
isEnabled = false
|
||||
handleActiveDates(with: displayDate, activeDates: activeDates, inactiveDates: inactiveDates)
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ private class LegendCollectionViewCell: UICollectionViewCell {
|
||||
title.text = text
|
||||
title.textColor = textColorConfiguration.getColor(surface)
|
||||
|
||||
legendIndicator.backgroundColor = drawSemiCircle ? .clear : (clearFullcircle ? .clear : color)
|
||||
legendIndicator.backgroundColor = drawSemiCircle ? .clear : (clearFullcircle ? .clear : indicatorColorConfiguration.getColor(surface))
|
||||
legendIndicator.layer.borderColor = indicatorColorConfiguration.getColor(surface).cgColor
|
||||
|
||||
self.layoutIfNeeded()
|
||||
@ -239,7 +239,7 @@ private class LegendCollectionViewCell: UICollectionViewCell {
|
||||
path.addArc(withCenter: center, radius: center.x, startAngle: 2 * .pi, endAngle: .pi, clockwise: true)
|
||||
path.close()
|
||||
shapeLayer.path = path.cgPath
|
||||
shapeLayer.fillColor = color.cgColor
|
||||
shapeLayer.fillColor = indicatorColorConfiguration.getColor(surface).cgColor
|
||||
|
||||
guard legendIndicator.layer.sublayers?.contains(shapeLayer) ?? true else { return }
|
||||
legendIndicator.layer.addSublayer(shapeLayer)
|
||||
|
||||
@ -68,16 +68,16 @@ class CalendarHeaderReusableView: UICollectionReusableView {
|
||||
$0.kind = .ghost
|
||||
$0.iconName = .leftCaret
|
||||
$0.iconOffset = .init(x: -2, y: 0)
|
||||
$0.icon.size = .small
|
||||
$0.size = .small
|
||||
$0.customContainerSize = 40
|
||||
$0.icon.customSize = 16
|
||||
}
|
||||
|
||||
internal var nextButton = ButtonIcon().with {
|
||||
$0.kind = .ghost
|
||||
$0.iconName = .rightCaret
|
||||
$0.iconOffset = .init(x: 2, y: 0)
|
||||
$0.icon.size = .small
|
||||
$0.size = .small
|
||||
$0.customContainerSize = 40
|
||||
$0.icon.customSize = 16
|
||||
}
|
||||
|
||||
internal var headerTitle = Label().with {
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
1.0.67
|
||||
----------------
|
||||
- CXTDT-553663 - DropdownSelect - Accessibility - has popup
|
||||
- CXTDT-568463 - Calendar - On long press, hover randomizes
|
||||
- CXTDT-568412 - Calendar - Incorrect side nav icon size
|
||||
- CXTDT-568422 - Calendar - DarkMode Legend icon fill using Light mode color
|
||||
|
||||
1.0.66
|
||||
----------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user