Digital ACT-191 ONEAPP-7016 story: updating surface for all childviews
This commit is contained in:
parent
890ad97f0a
commit
f043ac74d3
@ -146,7 +146,7 @@ open class CalendarBase: View {
|
||||
containerView.centerXAnchor.constraint(equalTo: centerXAnchor).activate()
|
||||
containerView.layer.borderWidth = VDSFormControls.borderWidth
|
||||
|
||||
let spacing = CGFloat(VDSLayout.space2X) //CGFloat(VDSFormControls.spaceInset) //
|
||||
let spacing = CGFloat(VDSLayout.space2X) //CGFloat(VDSFormControls.spaceInset) //
|
||||
|
||||
// Calendar View
|
||||
containerView.addSubview(collectionView)
|
||||
@ -220,7 +220,7 @@ extension CalendarBase: UICollectionViewDelegate, UICollectionViewDataSource, UI
|
||||
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CalendarDateCollectionViewCell.identifier, for: indexPath) as? CalendarDateCollectionViewCell else { return UICollectionViewCell() }
|
||||
var indicatorCount = 0
|
||||
for x in (0...(self.indicators.count-1)) {
|
||||
for x in (0...(self.indicators.count-1)) {
|
||||
if (self.days[indexPath.row] == self.getDay(with: self.indicators[x].date)) {
|
||||
indicatorCount += 1
|
||||
}
|
||||
@ -235,7 +235,7 @@ extension CalendarBase: UICollectionViewDelegate, UICollectionViewDataSource, UI
|
||||
guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: CalendarHeaderReusableView.identifier, for: indexPath) as? CalendarHeaderReusableView else {
|
||||
return UICollectionReusableView()
|
||||
}
|
||||
header.configure(with: true)
|
||||
header.configure(with: surface)
|
||||
return header
|
||||
} else {
|
||||
// Footer
|
||||
@ -243,7 +243,7 @@ extension CalendarBase: UICollectionViewDelegate, UICollectionViewDataSource, UI
|
||||
guard let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: CalendarFooterReusableView.identifier, for: indexPath) as? CalendarFooterReusableView else {
|
||||
return UICollectionReusableView()
|
||||
}
|
||||
footer.configure(with: indicators)
|
||||
footer.configure(with: surface, indicators: indicators)
|
||||
return footer
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ final class CalendarDateCollectionViewCell: UICollectionViewCell {
|
||||
|
||||
func configure(with surface: Surface, indicators: [CalendarBase.CalendarIndicatorModel], text: String, indicatorCount: Int) {
|
||||
addSubview(dateView)
|
||||
dateView.surface = surface
|
||||
dateView.numberLabel.text = text
|
||||
dateView.indicatorCount = indicatorCount
|
||||
dateView.dateIndicators = indicators
|
||||
@ -120,7 +121,7 @@ private class DateView : View {
|
||||
|
||||
// Indicators
|
||||
containerView.addSubview(stackView)
|
||||
let topPos = containerSize.height * 0.6
|
||||
let topPos = containerSize.height * 0.7
|
||||
stackView.pinTop(topPos).pinBottom().pinTopGreaterThanOrEqualTo().pinTrailingLessThanOrEqualTo().pinCenterY()
|
||||
stackView.centerXAnchor.constraint(equalTo: centerXAnchor).activate()
|
||||
}
|
||||
|
||||
@ -127,14 +127,14 @@ private class LegendCollectionViewCell: UICollectionViewCell {
|
||||
|
||||
private let indicatorColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsSecondaryOnlight, VDSColor.elementsSecondaryOndark)
|
||||
|
||||
private var title = Label().with {
|
||||
private var title: Label = Label().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.textAlignment = .left
|
||||
$0.numberOfLines = 1
|
||||
$0.textStyle = .bodySmall
|
||||
$0.backgroundColor = .clear
|
||||
$0.isAccessibilityElement = false
|
||||
}
|
||||
|
||||
private var legendIndicatorWrapper: View = View().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.backgroundColor = .clear
|
||||
@ -180,6 +180,7 @@ private class LegendCollectionViewCell: UICollectionViewCell {
|
||||
}
|
||||
|
||||
func updateTitle(text: String, color: UIColor, surface: Surface, clearFullcircle: Bool, drawSemiCircle: Bool) {
|
||||
title.surface = surface
|
||||
title.text = text
|
||||
title.textColor = textColorConfiguration.getColor(surface)
|
||||
|
||||
|
||||
@ -130,6 +130,7 @@ open class CalendarHeaderView: View {
|
||||
.pinLeading()
|
||||
.pinTrailing()
|
||||
.pinBottom(VDSLayout.space1X)
|
||||
stackView.centerXAnchor.constraint(equalTo: containerView.centerXAnchor).activate()
|
||||
|
||||
// month label view, previous and next buttons
|
||||
stackView.addArrangedSubview(monthView)
|
||||
@ -157,11 +158,14 @@ open class CalendarHeaderView: View {
|
||||
stackView.addArrangedSubview(daysCollectionView)
|
||||
daysCollectionView.widthAnchor.constraint(equalTo: widthAnchor).activate()
|
||||
daysCollectionView.heightAnchor.constraint(equalTo: monthView.heightAnchor).activate()
|
||||
print("daysOfWeek: \(daysOfWeek)")
|
||||
daysCollectionView.centerXAnchor.constraint(equalTo: containerView.centerXAnchor).activate()
|
||||
}
|
||||
|
||||
open override func updateView() {
|
||||
super.updateView()
|
||||
monthYearLabel.surface = surface
|
||||
previousButton.surface = surface
|
||||
nextButton.surface = surface
|
||||
daysCollectionView.reloadData()
|
||||
monthYearLabel.text = "May 2024"
|
||||
monthYearLabel.textColor = monthYearLabelTextColorConfiguration.getColor(surface)
|
||||
|
||||
@ -24,7 +24,8 @@ class CalendarHeaderReusableView: UICollectionReusableView {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func configure(with color: Bool) {
|
||||
func configure(with surface: Surface) {
|
||||
headerView.surface = surface
|
||||
addSubview(headerView)
|
||||
}
|
||||
|
||||
@ -49,8 +50,9 @@ class CalendarFooterReusableView: UICollectionReusableView {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func configure(with indicators: [CalendarBase.CalendarIndicatorModel]) {
|
||||
func configure(with surface: Surface, indicators: [CalendarBase.CalendarIndicatorModel]) {
|
||||
footerView.items = indicators
|
||||
footerView.surface = surface
|
||||
addSubview(footerView)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user