Skip to content

Commit 145addb

Browse files
author
Wojciech Lembryk
committed
Day cell configuration extended to set custom selection view corner radius and ranged background view inset.
1 parent 6669cb9 commit 145addb

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

Fastis.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Fastis'
3-
s.version = '1.0.11'
3+
s.version = '1.0.12'
44
s.summary = "Simple date picker created using JTAppleCalendar library"
55
s.description = <<-DESC
66
Fastis is a fully customizable UI component for picking dates and ranges created using JTAppleCalendar library.

Source/Views/DayCell.swift

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class DayCell: JTACDayCell {
5858
// MARK: - Variables
5959

6060
private var config: FastisConfig.DayCell = FastisConfig.default.dayCell
61+
private var rangedBackgroundViewTopBootomConstraints: [Constraint] = []
6162

6263
// MARK: - Lifecycle
6364

@@ -85,6 +86,10 @@ class DayCell: JTACDayCell {
8586
self.selectionBackgroundView.backgroundColor = config.selectedBackgroundColor
8687
self.dateLabel.font = config.dateLabelFont
8788
self.dateLabel.textColor = config.dateLabelColor
89+
if let cornerRadius = config.customSelectionViewCornerRadius {
90+
self.selectionBackgroundView.layer.cornerRadius = cornerRadius
91+
}
92+
rangedBackgroundViewTopBootomConstraints.map{ $0.update(inset: config.rangedBackgroundViewInset)}
8893
}
8994

9095
public func configureSubviews() {
@@ -98,24 +103,25 @@ class DayCell: JTACDayCell {
98103
}
99104

100105
public func configureConstraints() {
106+
let inset = config.rangedBackgroundViewInset
101107
self.rangedBackgroundViewRoundedLeft.snp.makeConstraints { (maker) in
102108
maker.left.equalToSuperview()
103-
maker.bottom.top.equalToSuperview().inset(3)
109+
rangedBackgroundViewTopBootomConstraints.append(maker.bottom.top.equalToSuperview().inset(inset).constraint)
104110
maker.width.equalToSuperview().dividedBy(2)
105111
}
106112
self.rangedBackgroundViewSquaredLeft.snp.makeConstraints { (maker) in
107113
maker.left.equalToSuperview()
108-
maker.bottom.top.equalToSuperview().inset(3)
114+
rangedBackgroundViewTopBootomConstraints.append(maker.bottom.top.equalToSuperview().inset(inset).constraint)
109115
maker.width.equalToSuperview().dividedBy(2)
110116
}
111117
self.rangedBackgroundViewRoundedRight.snp.makeConstraints { (maker) in
112118
maker.right.equalToSuperview()
113-
maker.bottom.top.equalToSuperview().inset(3)
119+
rangedBackgroundViewTopBootomConstraints.append(maker.bottom.top.equalToSuperview().inset(inset).constraint)
114120
maker.width.equalToSuperview().dividedBy(2)
115121
}
116122
self.rangedBackgroundViewSquaredRight.snp.makeConstraints { (maker) in
117123
maker.right.equalToSuperview()
118-
maker.bottom.top.equalToSuperview().inset(3)
124+
rangedBackgroundViewTopBootomConstraints.append(maker.bottom.top.equalToSuperview().inset(inset).constraint)
119125
maker.width.equalToSuperview().dividedBy(2)
120126
}
121127
self.selectionBackgroundView.snp.makeConstraints { (maker) in
@@ -307,9 +313,12 @@ extension FastisConfig {
307313
public var rangeViewCornerRadius: CGFloat = 6
308314
public var onRangeBackgroundColor: UIColor = UIColor.systemBlue.withAlphaComponent(0.2)
309315
public var onRangeLabelColor: UIColor = .black
316+
public var rangedBackgroundViewInset: CGFloat = 3
310317

318+
/**
319+
This property allows to set custom radius for selection view. Circle is default.
320+
*/
321+
public var customSelectionViewCornerRadius: CGFloat?
311322
}
312-
313-
}
314-
315323

324+
}

0 commit comments

Comments
 (0)