Digital ACT-191 ONEAPP-7016 story: hide/show container border
This commit is contained in:
parent
f043ac74d3
commit
3eaf29f3f1
@ -33,7 +33,7 @@ open class CalendarBase: View {
|
|||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
/// If set to true, the calendar will not have a border.
|
/// If set to true, the calendar will not have a border.
|
||||||
open var hideContainerBorder: Bool = false
|
open var hideContainerBorder: Bool = false { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
/// If set to true, the calendar will not have current date indication.
|
/// If set to true, the calendar will not have current date indication.
|
||||||
open var hideCurrentDateIndicator: Bool = false
|
open var hideCurrentDateIndicator: Bool = false
|
||||||
@ -144,9 +144,8 @@ open class CalendarBase: View {
|
|||||||
.width(containerSize.width)
|
.width(containerSize.width)
|
||||||
|
|
||||||
containerView.centerXAnchor.constraint(equalTo: centerXAnchor).activate()
|
containerView.centerXAnchor.constraint(equalTo: centerXAnchor).activate()
|
||||||
containerView.layer.borderWidth = VDSFormControls.borderWidth
|
|
||||||
|
|
||||||
let spacing = CGFloat(VDSLayout.space2X) //CGFloat(VDSFormControls.spaceInset) //
|
let spacing = CGFloat(VDSFormControls.spaceInset) //CGFloat(VDSLayout.space2X)
|
||||||
|
|
||||||
// Calendar View
|
// Calendar View
|
||||||
containerView.addSubview(collectionView)
|
containerView.addSubview(collectionView)
|
||||||
@ -166,7 +165,15 @@ open class CalendarBase: View {
|
|||||||
super.updateView()
|
super.updateView()
|
||||||
self.fetchDates(with: selectedDate ?? Date())
|
self.fetchDates(with: selectedDate ?? Date())
|
||||||
collectionView.reloadData()
|
collectionView.reloadData()
|
||||||
containerView.layer.borderColor = containerBorderColorConfiguration.getColor(self).cgColor
|
if hideContainerBorder {
|
||||||
|
layer.borderColor = nil
|
||||||
|
layer.borderWidth = 0
|
||||||
|
layer.cornerRadius = 0
|
||||||
|
} else {
|
||||||
|
layer.borderColor = containerBorderColorConfiguration.getColor(self).cgColor
|
||||||
|
layer.borderWidth = VDSFormControls.borderWidth
|
||||||
|
layer.cornerRadius = VDSFormControls.borderRadius
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override open func layoutSubviews() {
|
override open func layoutSubviews() {
|
||||||
@ -220,9 +227,11 @@ extension CalendarBase: UICollectionViewDelegate, UICollectionViewDataSource, UI
|
|||||||
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||||
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CalendarDateCollectionViewCell.identifier, for: indexPath) as? CalendarDateCollectionViewCell else { return UICollectionViewCell() }
|
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CalendarDateCollectionViewCell.identifier, for: indexPath) as? CalendarDateCollectionViewCell else { return UICollectionViewCell() }
|
||||||
var indicatorCount = 0
|
var indicatorCount = 0
|
||||||
for x in (0...(self.indicators.count-1)) {
|
if self.indicators.count > 0 {
|
||||||
if (self.days[indexPath.row] == self.getDay(with: self.indicators[x].date)) {
|
for x in (0...(self.indicators.count-1)) {
|
||||||
indicatorCount += 1
|
if (self.days[indexPath.row] == self.getDay(with: self.indicators[x].date)) {
|
||||||
|
indicatorCount += 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cell.configure(with: surface, indicators: indicators, text: days[indexPath.row], indicatorCount: indicatorCount)
|
cell.configure(with: surface, indicators: indicators, text: days[indexPath.row], indicatorCount: indicatorCount)
|
||||||
@ -251,8 +260,8 @@ extension CalendarBase: UICollectionViewDelegate, UICollectionViewDataSource, UI
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||||
let date = Calendar.current.date(byAdding: .day, value: 1, to: self.dates[indexPath.row])!
|
// let selectedDate = Calendar.current.date(byAdding: .day, value: 1, to: self.dates[indexPath.row])!
|
||||||
// print("selected day: \(days[indexPath.row]), date: \(date)")
|
// print("selected day: \(days[indexPath.row]), date: \(selectedDate)")
|
||||||
}
|
}
|
||||||
|
|
||||||
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
|
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
|
||||||
|
|||||||
@ -28,10 +28,6 @@ class CalendarHeaderReusableView: UICollectionReusableView {
|
|||||||
headerView.surface = surface
|
headerView.surface = surface
|
||||||
addSubview(headerView)
|
addSubview(headerView)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func layoutSubviews() {
|
|
||||||
super.layoutSubviews()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Custom footer view
|
/// Custom footer view
|
||||||
@ -55,8 +51,4 @@ class CalendarFooterReusableView: UICollectionReusableView {
|
|||||||
footerView.surface = surface
|
footerView.surface = surface
|
||||||
addSubview(footerView)
|
addSubview(footerView)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func layoutSubviews() {
|
|
||||||
super.layoutSubviews()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user