From f043ac74d38787e390148ab6a0ac1bc068f4117b Mon Sep 17 00:00:00 2001 From: vasavk Date: Fri, 3 May 2024 19:59:49 +0530 Subject: [PATCH] Digital ACT-191 ONEAPP-7016 story: updating surface for all childviews --- VDS/Components/Calendar/Calendar.swift | 8 ++++---- .../Calendar/CalendarDateCollectionViewCell.swift | 3 ++- VDS/Components/Calendar/CalendarFooterView.swift | 5 +++-- VDS/Components/Calendar/CalendarHeaderView.swift | 6 +++++- VDS/Components/Calendar/CalendarReusableView.swift | 6 ++++-- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/VDS/Components/Calendar/Calendar.swift b/VDS/Components/Calendar/Calendar.swift index f9cb16cf..3e1442e1 100644 --- a/VDS/Components/Calendar/Calendar.swift +++ b/VDS/Components/Calendar/Calendar.swift @@ -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 } } diff --git a/VDS/Components/Calendar/CalendarDateCollectionViewCell.swift b/VDS/Components/Calendar/CalendarDateCollectionViewCell.swift index fd33611b..68917069 100644 --- a/VDS/Components/Calendar/CalendarDateCollectionViewCell.swift +++ b/VDS/Components/Calendar/CalendarDateCollectionViewCell.swift @@ -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() } diff --git a/VDS/Components/Calendar/CalendarFooterView.swift b/VDS/Components/Calendar/CalendarFooterView.swift index 84d76cab..6574dc84 100644 --- a/VDS/Components/Calendar/CalendarFooterView.swift +++ b/VDS/Components/Calendar/CalendarFooterView.swift @@ -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) diff --git a/VDS/Components/Calendar/CalendarHeaderView.swift b/VDS/Components/Calendar/CalendarHeaderView.swift index 44f5462f..f217ae40 100644 --- a/VDS/Components/Calendar/CalendarHeaderView.swift +++ b/VDS/Components/Calendar/CalendarHeaderView.swift @@ -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) diff --git a/VDS/Components/Calendar/CalendarReusableView.swift b/VDS/Components/Calendar/CalendarReusableView.swift index 33bedfe2..3a61e635 100644 --- a/VDS/Components/Calendar/CalendarReusableView.swift +++ b/VDS/Components/Calendar/CalendarReusableView.swift @@ -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) }