Skip to content

Commit

Permalink
WeekView mode optimization #28
Browse files Browse the repository at this point in the history
* Huge WeekView mode optimization
* Proper mode value loading
* Performance improvement
* Minor bug fixes
  • Loading branch information
mozharovsky committed Apr 14, 2015
1 parent a23c3e9 commit b4f93d6
Show file tree
Hide file tree
Showing 11 changed files with 616 additions and 958 deletions.
16 changes: 0 additions & 16 deletions CVCalendar Demo/CVCalendar Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
553319271A7294AF004DF673 /* CVCalendarWeekContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 553319261A7294AF004DF673 /* CVCalendarWeekContentView.swift */; };
5534574E1A75114B00370955 /* CVCalendarWeekContentRecovery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5534574D1A75114B00370955 /* CVCalendarWeekContentRecovery.swift */; };
5535246A1A794AC400EE9FDE /* CVCalendarContentDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 553524691A794AC400EE9FDE /* CVCalendarContentDelegate.swift */; };
55E1221E1A588CB60013B002 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E1221D1A588CB60013B002 /* AppDelegate.swift */; };
55E122201A588CB60013B002 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E1221F1A588CB60013B002 /* ViewController.swift */; };
Expand Down Expand Up @@ -53,8 +51,6 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
553319261A7294AF004DF673 /* CVCalendarWeekContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CVCalendarWeekContentView.swift; sourceTree = "<group>"; };
5534574D1A75114B00370955 /* CVCalendarWeekContentRecovery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CVCalendarWeekContentRecovery.swift; sourceTree = "<group>"; };
553524691A794AC400EE9FDE /* CVCalendarContentDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CVCalendarContentDelegate.swift; sourceTree = "<group>"; };
55E122181A588CB60013B002 /* CVCalendar Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "CVCalendar Demo.app"; sourceTree = BUILT_PRODUCTS_DIR; };
55E1221C1A588CB60013B002 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -171,7 +167,6 @@
isa = PBXGroup;
children = (
8F694F661AD9B8AD00868CA5 /* Content Controllers */,
8F61EDD61AD1A65A00F7F8B6 /* Content Views */,
8F61EDD51AD1A60F00F7F8B6 /* Main Views */,
8F61EDD71AD1A67900F7F8B6 /* Unit Views */,
8F61EDD31AD1A5CD00F7F8B6 /* Controllers */,
Expand Down Expand Up @@ -200,7 +195,6 @@
55E122401A588CC50013B002 /* CVCalendarDayViewControlCoordinator.swift */,
55E122411A588CC50013B002 /* CVCalendarManager.swift */,
55E122461A588CC50013B002 /* CVCalendarViewAnimator.swift */,
5534574D1A75114B00370955 /* CVCalendarWeekContentRecovery.swift */,
);
name = Controllers;
sourceTree = "<group>";
Expand All @@ -214,14 +208,6 @@
name = "Main Views";
sourceTree = "<group>";
};
8F61EDD61AD1A65A00F7F8B6 /* Content Views */ = {
isa = PBXGroup;
children = (
553319261A7294AF004DF673 /* CVCalendarWeekContentView.swift */,
);
name = "Content Views";
sourceTree = "<group>";
};
8F61EDD71AD1A67900F7F8B6 /* Unit Views */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -383,8 +369,6 @@
55E1221E1A588CB60013B002 /* AppDelegate.swift in Sources */,
55E1224F1A588CC50013B002 /* CVCalendarDayView.swift in Sources */,
8F6D3F1E1ADAF1330028BE6D /* CVCalendarWeekContentViewController.swift in Sources */,
553319271A7294AF004DF673 /* CVCalendarWeekContentView.swift in Sources */,
5534574E1A75114B00370955 /* CVCalendarWeekContentRecovery.swift in Sources */,
55E122561A588CC50013B002 /* CVCalendarViewAnimator.swift in Sources */,
8F1080D31AB8C84600D9FAC6 /* CVSet.swift in Sources */,
55E122501A588CC50013B002 /* CVCalendarDayViewControlCoordinator.swift in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions CVCalendar Demo/CVCalendar Demo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CVCalendarViewMode</key>
<string>MonthView</string>
<key>CVCalendarStarterWeekday</key>
<integer>1</integer>
<key>CVCalendarViewMode</key>
<string>WeekView</string>
</dict>
</plist>
69 changes: 25 additions & 44 deletions CVCalendar Demo/CVCalendar/CVCalendarContentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ class CVCalendarContentViewController: UIViewController {
return scrollView.bounds
}

var page = 0
var pageChanged = false
var currentPage = 1
var pageChanged: Bool {
get {
return currentPage == 1 ? false : true
}
}

var pageLoadingEnabled = true
var lastContentOffset: CGFloat = 0
var direction: CVScrollDirection = .None
Expand All @@ -52,12 +57,6 @@ class CVCalendarContentViewController: UIViewController {
}
}

// MARK: - UIScrollViewDelegate

extension CVCalendarContentViewController: UIScrollViewDelegate {

}

// MARK: - UI Refresh

extension CVCalendarContentViewController {
Expand All @@ -69,28 +68,22 @@ extension CVCalendarContentViewController {
}
}

// MARK: - Convenience API
// MARK: - Abstract methods

/// UIScrollViewDelegate
extension CVCalendarContentViewController: UIScrollViewDelegate { }

/// Convenience API.
extension CVCalendarContentViewController {
func performedDayViewSelection(dayView: DayView) {
//delegate.performedDayViewSelection(dayView)
}
func performedDayViewSelection(dayView: DayView) { }

func togglePresentedDate(date: NSDate) {
//delegate.togglePresentedDate(date)
}
func togglePresentedDate(date: NSDate) { }

func presentNextView(view: UIView?) {
//delegate.presentNextView(dayView)
}
func presentNextView(view: UIView?) { }

func presentPreviousView(view: UIView?) {
//delegate.presentPreviousView(dayView)
}
func presentPreviousView(view: UIView?) { }

func updateDayViews(hidden: Bool) {
//delegate.updateDayViews(hidden)
}
func updateDayViews(hidden: Bool) { }
}

// MARK: - Contsant conversion
Expand Down Expand Up @@ -134,28 +127,16 @@ extension CVCalendarContentViewController {
return dateAfter
}

func match(lhs: NSDate, _ rhs: NSDate) -> Bool {
let lhsRange = Manager.sharedManager.dateRange(lhs)
let rhsRange = Manager.sharedManager.dateRange(rhs)

if lhsRange.year == rhsRange.year && lhsRange.month == rhsRange.month {
return true
}

return false
func matchedMonths(lhs: Date, _ rhs: Date) -> Bool {
return lhs.year == rhs.year && lhs.month == rhs.month
}

func selectDayViewWithDay(day: Int, inMonthView monthView: CVCalendarMonthView) {
let coordinator = CVCalendarDayViewControlCoordinator.sharedControlCoordinator
monthView.mapDayViews { dayView in
if dayView.date.day == day && !dayView.isOut {
if let selected = coordinator.selectedDayView where selected != dayView {
self.calendarView.didSelectDayView(dayView)
}

coordinator.performDayViewSingleSelection(dayView)
}
}
func matchedWeeks(lhs: Date, _ rhs: Date) -> Bool {
return (lhs.year == rhs.year && lhs.month == rhs.month && lhs.week == rhs.week)
}

func matchedDays(lhs: Date, _ rhs: Date) -> Bool {
return (lhs.year == rhs.year && lhs.month == rhs.month && lhs.day == rhs.day)
}
}

Expand Down
2 changes: 1 addition & 1 deletion CVCalendar Demo/CVCalendar/CVCalendarDayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class CVCalendarDayView: UIView {

let dateRange = CVCalendarManager.sharedManager.dateRange(monthView.date)
let year = dateRange.year
let week = dateRange.weekOfMonth
let week = weekView.index + 1
var month = dateRange.month

if isOut {
Expand Down
Loading

0 comments on commit b4f93d6

Please sign in to comment.