Skip to content

Commit 9dc96ea

Browse files
committed
Update access modifiers of the API #242
1 parent fc4939c commit 9dc96ea

File tree

11 files changed

+126
-106
lines changed

11 files changed

+126
-106
lines changed

CalendarKitDemo/CalendarApp.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
75776AF58133F6BBDDCF1CE7 /* Pods_CalendarApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A223D8E39EB8C7A25F4E823A /* Pods_CalendarApp.framework */; };
11+
791ACF5023FC887D00B2D602 /* TimeChunk+DateComponents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 791ACF4F23FC887D00B2D602 /* TimeChunk+DateComponents.swift */; };
1112
7924834B23CB7B57003E3D27 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7924834923CB7B57003E3D27 /* Main.storyboard */; };
1213
7924834D23CB7B58003E3D27 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7924834C23CB7B58003E3D27 /* Assets.xcassets */; };
1314
7924835023CB7B58003E3D27 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7924834E23CB7B58003E3D27 /* LaunchScreen.storyboard */; };
@@ -21,6 +22,7 @@
2122

2223
/* Begin PBXFileReference section */
2324
786F0C3439DCA027A1D04664 /* Pods-CalendarApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CalendarApp.release.xcconfig"; path = "Target Support Files/Pods-CalendarApp/Pods-CalendarApp.release.xcconfig"; sourceTree = "<group>"; };
25+
791ACF4F23FC887D00B2D602 /* TimeChunk+DateComponents.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TimeChunk+DateComponents.swift"; sourceTree = "<group>"; };
2426
7924834023CB7B57003E3D27 /* CalendarApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CalendarApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
2527
7924834A23CB7B57003E3D27 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
2628
7924834C23CB7B58003E3D27 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -79,6 +81,7 @@
7981
isa = PBXGroup;
8082
children = (
8183
7924836523CB7BFE003E3D27 /* AppDelegate.swift */,
84+
791ACF4F23FC887D00B2D602 /* TimeChunk+DateComponents.swift */,
8285
7924836623CB7BFE003E3D27 /* CustomCalendarExampleController.swift */,
8386
7924836423CB7BFE003E3D27 /* DatePickerController.swift */,
8487
7924836723CB7BFE003E3D27 /* ExampleController.swift */,
@@ -220,6 +223,7 @@
220223
7924836E23CB7BFE003E3D27 /* ExampleNotificationController.swift in Sources */,
221224
7924836C23CB7BFE003E3D27 /* CustomCalendarExampleController.swift in Sources */,
222225
7924836923CB7BFE003E3D27 /* StyleGenerator.swift in Sources */,
226+
791ACF5023FC887D00B2D602 /* TimeChunk+DateComponents.swift in Sources */,
223227
7924836D23CB7BFE003E3D27 /* ExampleController.swift in Sources */,
224228
7924836A23CB7BFE003E3D27 /* DatePickerController.swift in Sources */,
225229
);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Foundation
2+
import DateToolsSwift
3+
4+
extension TimeChunk {
5+
static func dateComponents(seconds: Int = 0,
6+
minutes: Int = 0,
7+
hours: Int = 0,
8+
days: Int = 0,
9+
weeks: Int = 0,
10+
months: Int = 0,
11+
years: Int = 0) -> TimeChunk {
12+
return TimeChunk(seconds: seconds,
13+
minutes: minutes,
14+
hours: hours,
15+
days: days,
16+
weeks: weeks,
17+
months: months,
18+
years: years)
19+
}
20+
}

Source/Extensions/Date+AddChunk.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extension Date {
1313
* - returns: A date with components increased by the values of the
1414
* corresponding `TimeChunk` variables
1515
*/
16-
public func add(_ chunk: TimeChunk, calendar: Calendar) -> Date {
16+
func add(_ chunk: TimeChunk, calendar: Calendar) -> Date {
1717
var components = DateComponents()
1818
components.year = chunk.years
1919
components.month = chunk.months
@@ -33,7 +33,7 @@ extension Date {
3333
* - returns: A date with components decreased by the values of the
3434
* corresponding `TimeChunk` variables
3535
*/
36-
public func subtract(_ chunk: TimeChunk, calendar: Calendar) -> Date {
36+
func subtract(_ chunk: TimeChunk, calendar: Calendar) -> Date {
3737
var components = DateComponents()
3838
components.year = -chunk.years
3939
components.month = -chunk.months

Source/Extensions/TimeChunk+DateComponents.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import Foundation
22
import DateToolsSwift
33

44
extension TimeChunk {
5-
public static func dateComponents(seconds: Int = 0,
6-
minutes: Int = 0,
7-
hours: Int = 0,
8-
days: Int = 0,
9-
weeks: Int = 0,
10-
months: Int = 0,
11-
years: Int = 0) -> TimeChunk {
5+
static func dateComponents(seconds: Int = 0,
6+
minutes: Int = 0,
7+
hours: Int = 0,
8+
days: Int = 0,
9+
weeks: Int = 0,
10+
months: Int = 0,
11+
years: Int = 0) -> TimeChunk {
1212
return TimeChunk(seconds: seconds,
1313
minutes: minutes,
1414
hours: hours,

Source/Header/DayHeaderView.swift

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import UIKit
22
import DateToolsSwift
33

4-
public class DayHeaderView: UIView, DaySelectorDelegate, DayViewStateUpdating, UIPageViewControllerDataSource, UIPageViewControllerDelegate {
5-
6-
public var daysInWeek = 7
4+
public final class DayHeaderView: UIView, DaySelectorDelegate, DayViewStateUpdating, UIPageViewControllerDataSource, UIPageViewControllerDelegate {
5+
public private(set) var daysInWeek = 7
76
public let calendar: Calendar
87

9-
var style = DayHeaderStyle()
10-
var currentSizeClass = UIUserInterfaceSizeClass.compact
8+
private var style = DayHeaderStyle()
9+
private var currentSizeClass = UIUserInterfaceSizeClass.compact
1110

1211
public weak var state: DayViewState? {
1312
willSet(newValue) {
@@ -19,17 +18,17 @@ public class DayHeaderView: UIView, DaySelectorDelegate, DayViewStateUpdating, U
1918
}
2019
}
2120

22-
var currentWeekdayIndex = -1
21+
private var currentWeekdayIndex = -1
2322

24-
var daySymbolsViewHeight: CGFloat = 20
25-
var pagingScrollViewHeight: CGFloat = 40
26-
var swipeLabelViewHeight: CGFloat = 20
23+
private var daySymbolsViewHeight: CGFloat = 20
24+
private var pagingScrollViewHeight: CGFloat = 40
25+
private var swipeLabelViewHeight: CGFloat = 20
2726

28-
let daySymbolsView: DaySymbolsView
29-
var pagingViewController = UIPageViewController(transitionStyle: .scroll,
27+
private let daySymbolsView: DaySymbolsView
28+
private var pagingViewController = UIPageViewController(transitionStyle: .scroll,
3029
navigationOrientation: .horizontal,
3130
options: nil)
32-
let swipeLabelView: SwipeLabelView
31+
private let swipeLabelView: SwipeLabelView
3332

3433
public init(calendar: Calendar) {
3534
self.calendar = calendar
@@ -45,13 +44,13 @@ public class DayHeaderView: UIView, DaySelectorDelegate, DayViewStateUpdating, U
4544
fatalError("init(coder:) has not been implemented")
4645
}
4746

48-
func configure() {
47+
private func configure() {
4948
[daySymbolsView, swipeLabelView].forEach(addSubview)
5049
backgroundColor = style.backgroundColor
5150
configurePagingViewController()
5251
}
5352

54-
func configurePagingViewController() {
53+
private func configurePagingViewController() {
5554
let selectedDate = Date()
5655
let vc = makeSelectorController(startDate: beginningOfWeek(selectedDate))
5756
vc.selectedDate = selectedDate
@@ -62,7 +61,7 @@ public class DayHeaderView: UIView, DaySelectorDelegate, DayViewStateUpdating, U
6261
addSubview(pagingViewController.view!)
6362
}
6463

65-
func makeSelectorController(startDate: Date) -> DaySelectorController {
64+
private func makeSelectorController(startDate: Date) -> DaySelectorController {
6665
let new = DaySelectorController()
6766
new.calendar = calendar
6867
new.transitionToHorizontalSizeClass(currentSizeClass)
@@ -72,7 +71,7 @@ public class DayHeaderView: UIView, DaySelectorDelegate, DayViewStateUpdating, U
7271
return new
7372
}
7473

75-
func beginningOfWeek(_ date: Date) -> Date {
74+
private func beginningOfWeek(_ date: Date) -> Date {
7675
let weekOfYear = component(component: .weekOfYear, from: date)
7776
let yearForWeekOfYear = component(component: .yearForWeekOfYear, from: date)
7877
return calendar.date(from: DateComponents(calendar: calendar,
@@ -108,7 +107,7 @@ public class DayHeaderView: UIView, DaySelectorDelegate, DayViewStateUpdating, U
108107

109108
// MARK: DaySelectorDelegate
110109

111-
func dateSelectorDidSelectDate(_ date: Date) {
110+
public func dateSelectorDidSelectDate(_ date: Date) {
112111
state?.move(to: date)
113112
}
114113

Source/Header/DaySelector/DateLabel.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import UIKit
22
import DateToolsSwift
33

4-
class DateLabel: UILabel, DaySelectorItemProtocol {
5-
var calendar = Calendar.autoupdatingCurrent {
4+
public final class DateLabel: UILabel, DaySelectorItemProtocol {
5+
public var calendar = Calendar.autoupdatingCurrent {
66
didSet {
77
updateState()
88
}
99
}
1010

11-
var date = Date() {
11+
public var date = Date() {
1212
didSet {
1313
text = String(date.day)
1414
updateState()
@@ -19,15 +19,15 @@ class DateLabel: UILabel, DaySelectorItemProtocol {
1919
return calendar.isDateInToday(date)
2020
}
2121

22-
var selected: Bool = false {
22+
public var selected: Bool = false {
2323
didSet {
2424
animate()
2525
}
2626
}
2727

28-
var style = DaySelectorStyle()
28+
private var style = DaySelectorStyle()
2929

30-
override var intrinsicContentSize: CGSize {
30+
override public var intrinsicContentSize: CGSize {
3131
return CGSize(width: 35, height: 35)
3232
}
3333

@@ -41,13 +41,13 @@ class DateLabel: UILabel, DaySelectorItemProtocol {
4141
configure()
4242
}
4343

44-
func configure() {
44+
private func configure() {
4545
isUserInteractionEnabled = true
4646
textAlignment = .center
4747
clipsToBounds = true
4848
}
4949

50-
func updateStyle(_ newStyle: DaySelectorStyle) {
50+
public func updateStyle(_ newStyle: DaySelectorStyle) {
5151
style = newStyle
5252
updateState()
5353
}
@@ -79,7 +79,7 @@ class DateLabel: UILabel, DaySelectorItemProtocol {
7979
return false
8080
}
8181

82-
func animate(){
82+
private func animate(){
8383
UIView.transition(with: self,
8484
duration: 0.4,
8585
options: .transitionCrossDissolve,
@@ -88,10 +88,10 @@ class DateLabel: UILabel, DaySelectorItemProtocol {
8888
}, completion: nil)
8989
}
9090

91-
override func layoutSubviews() {
91+
override public func layoutSubviews() {
9292
layer.cornerRadius = bounds.height / 2
9393
}
94-
override func tintColorDidChange() {
94+
override public func tintColorDidChange() {
9595
updateState()
9696
}
9797
}

Source/Header/DaySelector/DayDateCell.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,29 @@ import UIKit
22
import DateToolsSwift
33
import Neon
44

5-
class DayDateCell: UIView, DaySelectorItemProtocol {
5+
public final class DayDateCell: UIView, DaySelectorItemProtocol {
66

7-
let dateLabel = DateLabel()
8-
let dayLabel = UILabel()
7+
private let dateLabel = DateLabel()
8+
private let dayLabel = UILabel()
99

10-
var regularSizeClassFontSize: CGFloat = 16
10+
private var regularSizeClassFontSize: CGFloat = 16
1111

12-
var date = Date() {
12+
public var date = Date() {
1313
didSet {
1414
dateLabel.date = date
1515
updateState()
1616
}
1717
}
1818

19-
var calendar = Calendar.autoupdatingCurrent {
19+
public var calendar = Calendar.autoupdatingCurrent {
2020
didSet {
2121
dateLabel.calendar = calendar
2222
updateState()
2323
}
2424
}
2525

2626

27-
var selected: Bool {
27+
public var selected: Bool {
2828
get {
2929
return dateLabel.selected
3030
}
@@ -35,7 +35,7 @@ class DayDateCell: UIView, DaySelectorItemProtocol {
3535

3636
var style = DaySelectorStyle()
3737

38-
override var intrinsicContentSize: CGSize {
38+
override public var intrinsicContentSize: CGSize {
3939
return CGSize(width: 75, height: 35)
4040
}
4141

@@ -49,18 +49,18 @@ class DayDateCell: UIView, DaySelectorItemProtocol {
4949
configure()
5050
}
5151

52-
func configure() {
52+
private func configure() {
5353
clipsToBounds = true
5454
[dayLabel, dateLabel].forEach(addSubview(_:))
5555
}
5656

57-
func updateStyle(_ newStyle: DaySelectorStyle) {
57+
public func updateStyle(_ newStyle: DaySelectorStyle) {
5858
style = newStyle
5959
dateLabel.updateStyle(newStyle)
6060
updateState()
6161
}
6262

63-
func updateState() {
63+
private func updateState() {
6464
let isWeekend = isAWeekend(date: date)
6565
dayLabel.font = UIFont.systemFont(ofSize: regularSizeClassFontSize)
6666
dayLabel.textColor = isWeekend ? style.weekendTextColor : style.inactiveTextColor
@@ -69,7 +69,7 @@ class DayDateCell: UIView, DaySelectorItemProtocol {
6969
setNeedsLayout()
7070
}
7171

72-
func updateDayLabel() {
72+
private func updateDayLabel() {
7373
let daySymbols = calendar.shortWeekdaySymbols
7474
let weekendMask = [true] + [Bool](repeating: false, count: 5) + [true]
7575
var weekDays = Array(zip(daySymbols, weekendMask))
@@ -90,7 +90,7 @@ class DayDateCell: UIView, DaySelectorItemProtocol {
9090
return false
9191
}
9292

93-
override func layoutSubviews() {
93+
override public func layoutSubviews() {
9494
super.layoutSubviews()
9595
dayLabel.sizeToFit()
9696
dayLabel.center.y = center.y
@@ -106,7 +106,7 @@ class DayDateCell: UIView, DaySelectorItemProtocol {
106106
label.frame.origin.x += padding
107107
}
108108
}
109-
override func tintColorDidChange() {
109+
override public func tintColorDidChange() {
110110
updateState()
111111
}
112112
}

0 commit comments

Comments
 (0)