├── CalendarDemo ├── en.lproj │ └── InfoPlist.strings ├── fr.lproj │ └── InfoPlist.strings ├── Images.xcassets │ ├── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── Settings.bundle │ ├── en.lproj │ │ └── Root.strings │ └── Root.plist ├── CustomTimedEventsViewLayout.m ├── CustomTimedEventsViewLayout.h ├── AppDelegate.h ├── main.m ├── Calendar-Prefix.pch ├── MonthViewController.h ├── MonthSettingsViewController.h ├── WeekSettingsViewController.h ├── DayViewController.h ├── WeekViewController.h ├── YearViewController.h ├── MainViewController.h ├── Calendar-Info.plist ├── AppDelegate.m ├── MonthViewController.m ├── Launch Screen.storyboard └── DayViewController.m ├── CalendarTests ├── en.lproj │ └── InfoPlist.strings ├── fr.lproj │ └── InfoPlist.strings ├── CalendarTests.m └── CalendarTests-Info.plist ├── CalendarDocs ├── YearView.png ├── DayPlannerView.png ├── DayPlannerView2.png ├── MonthPlannerView.png └── MonthPlannerView2.png ├── Pods ├── Target Support Files │ ├── OSCache │ │ ├── OSCache-prefix.pch │ │ ├── OSCache.modulemap │ │ ├── OSCache-dummy.m │ │ ├── OSCache-umbrella.h │ │ └── OSCache.xcconfig │ └── OrderedDictionary │ │ ├── OrderedDictionary-prefix.pch │ │ ├── OrderedDictionary.modulemap │ │ ├── OrderedDictionary-dummy.m │ │ ├── OrderedDictionary-umbrella.h │ │ └── OrderedDictionary.xcconfig ├── Manifest.lock ├── OSCache │ ├── LICENSE.md │ └── OSCache │ │ └── OSCache.h └── OrderedDictionary │ ├── LICENCE.md │ ├── README.md │ └── OrderedDictionary │ └── OrderedDictionary.h ├── Podfile ├── Calendar.xcodeproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── Calendar.xccheckout ├── Calendar.xcworkspace ├── contents.xcworkspacedata └── xcshareddata │ └── Calendar.xccheckout ├── CalendarLib ├── MGCCalendarHeaderCell.h ├── MGCCalendarHeaderView.h ├── MGCMonthPlannerHeaderView.h ├── MGCYearCalendarMonthHeaderView.h ├── MGCMonthPlannerWeekView.h ├── MGCYearCalendarMonthCell.h ├── MGCMonthPlannerViewController.h ├── MGCMonthPlannerViewDayCell.h ├── MGCEventCellLayoutAttributes.h ├── MGCAlignedGeometry.h ├── en.lproj │ └── Localizable.strings ├── MGCMonthPlannerEKViewController.h ├── fr.lproj │ └── Localizable.strings ├── MGCEventCell.h ├── MGCInteractiveEventView.h ├── MGCEventCellLayoutAttributes.m ├── MGCYearCalendarMonthHeaderView.m ├── MGCYearCalendarMonthCell.m ├── MGCEventKitSupport.h ├── MGCMonthPlannerBackgroundView.h ├── MGCDayPlannerViewController.h ├── MGCMonthPlannerHeaderView.m ├── MGCEventView.m ├── NSCalendar+MGCAdditions.h ├── NSAttributedString+MGCAdditions.h ├── MGCDateRange.h ├── MGCMonthPlannerViewLayout.h ├── MGCMonthPlannerWeekView.m ├── MGCDayPlannerEKViewController.h ├── MGCEventCell.m ├── MGCAlignedGeometry.m ├── MGCAllDayEventsViewLayout.h ├── MGCMonthMiniCalendarView.h ├── MGCStandardEventView.h ├── MGCInteractiveEventView.m ├── MGCTimeRowsView.h ├── MGCDayColumnCell.h ├── Constant.h ├── MGCReusableObjectQueue.h ├── MGCEventsRowView.h ├── MGCCalendarHeaderCell.m ├── MGCEventView.h ├── MGCTimedEventsViewLayout.h ├── MGCMonthPlannerBackgroundView.m ├── MGCMonthPlannerViewController.m ├── MGCMonthPlannerViewDayCell.m ├── NSAttributedString+MGCAdditions.m ├── MGCReusableObjectQueue.m ├── MGCYearCalendarView.h ├── MGCCalendarHeaderCell.xib ├── MGCDayPlannerViewController.m └── MGCDateRange.m ├── Podfile.lock ├── LICENSE ├── .gitignore ├── CalendarLib.podspec ├── CHANGELOG.md └── README.md /CalendarDemo/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CalendarDemo/fr.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CalendarTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CalendarTests/fr.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CalendarDocs/YearView.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jumartin/Calendar/HEAD/CalendarDocs/YearView.png -------------------------------------------------------------------------------- /CalendarDocs/DayPlannerView.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jumartin/Calendar/HEAD/CalendarDocs/DayPlannerView.png -------------------------------------------------------------------------------- /CalendarDocs/DayPlannerView2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jumartin/Calendar/HEAD/CalendarDocs/DayPlannerView2.png -------------------------------------------------------------------------------- /Pods/Target Support Files/OSCache/OSCache-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /CalendarDocs/MonthPlannerView.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jumartin/Calendar/HEAD/CalendarDocs/MonthPlannerView.png -------------------------------------------------------------------------------- /CalendarDocs/MonthPlannerView2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jumartin/Calendar/HEAD/CalendarDocs/MonthPlannerView2.png -------------------------------------------------------------------------------- /CalendarDemo/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Pods/Target Support Files/OrderedDictionary/OrderedDictionary-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /CalendarDemo/Settings.bundle/en.lproj/Root.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jumartin/Calendar/HEAD/CalendarDemo/Settings.bundle/en.lproj/Root.strings -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | use_frameworks! 3 | 4 | target "CalendarDemo" do 5 | pod 'CalendarLib' , :path => '.' 6 | end 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/OSCache/OSCache.modulemap: -------------------------------------------------------------------------------- 1 | framework module OSCache { 2 | umbrella header "OSCache-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/OSCache/OSCache-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_OSCache : NSObject 3 | @end 4 | @implementation PodsDummy_OSCache 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/OrderedDictionary/OrderedDictionary.modulemap: -------------------------------------------------------------------------------- 1 | framework module OrderedDictionary { 2 | umbrella header "OrderedDictionary-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/OrderedDictionary/OrderedDictionary-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_OrderedDictionary : NSObject 3 | @end 4 | @implementation PodsDummy_OrderedDictionary 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/OSCache/OSCache-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "OSCache.h" 4 | 5 | FOUNDATION_EXPORT double OSCacheVersionNumber; 6 | FOUNDATION_EXPORT const unsigned char OSCacheVersionString[]; 7 | 8 | -------------------------------------------------------------------------------- /Calendar.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Pods/Target Support Files/OrderedDictionary/OrderedDictionary-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "OrderedDictionary.h" 4 | 5 | FOUNDATION_EXPORT double OrderedDictionaryVersionNumber; 6 | FOUNDATION_EXPORT const unsigned char OrderedDictionaryVersionString[]; 7 | 8 | -------------------------------------------------------------------------------- /Calendar.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /CalendarDemo/CustomTimedEventsViewLayout.m: -------------------------------------------------------------------------------- 1 | // 2 | // CustomTimedEventsViewLayout.m 3 | // Calendar 4 | // 5 | // Created by GK on 2016.11.29.. 6 | // Copyright © 2016. Julien Martin. All rights reserved. 7 | // 8 | 9 | #import "CustomTimedEventsViewLayout.h" 10 | 11 | @implementation CustomTimedEventsViewLayout 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /CalendarDemo/CustomTimedEventsViewLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // CustomTimedEventsViewLayout.h 3 | // Calendar 4 | // 5 | // Created by GK on 2016.11.29.. 6 | // Copyright © 2016. Julien Martin. All rights reserved. 7 | // 8 | 9 | #import "MGCTimedEventsViewLayout.h" 10 | 11 | @interface CustomTimedEventsViewLayout : MGCTimedEventsViewLayout 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /CalendarDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CalendarDemo - Graphical Calendars Library for iOS 4 | // 5 | // Copyright (c) 2014-2015 Julien Martin. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface AppDelegate : UIResponder 11 | 12 | @property (nonatomic) UIWindow *window; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /CalendarDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CalendarDemo - Graphical Calendars Library for iOS 4 | // 5 | // Copyright (c) 2014-2015 Julien Martin. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) 13 | { 14 | @autoreleasepool { 15 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CalendarDemo/Calendar-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_3_0 10 | #warning "This project uses features only available in iOS SDK 3.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #import "Constant.h" 17 | #endif 18 | -------------------------------------------------------------------------------- /CalendarLib/MGCCalendarHeaderCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCCalendarHeaderCell.h 3 | // Calendar 4 | // 5 | // Copyright © 2016 Julien Martin. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface MGCCalendarHeaderCell : UICollectionViewCell 11 | 12 | @property (nonatomic, strong) IBOutlet UILabel *dayNumberLabel; 13 | @property (nonatomic, strong) IBOutlet UILabel *dayNameLabel; 14 | @property (nonatomic, strong) NSDate *date; 15 | 16 | @end -------------------------------------------------------------------------------- /Pods/Target Support Files/OSCache/OSCache.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/OSCache 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 4 | PODS_BUILD_DIR = $BUILD_DIR 5 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 8 | SKIP_INSTALL = YES 9 | -------------------------------------------------------------------------------- /CalendarDemo/MonthViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MonthViewController.h 3 | // CalendarDemo - Graphical Calendars Library for iOS 4 | // 5 | // Copyright (c) 2014-2015 Julien Martin. All rights reserved. 6 | // 7 | 8 | #import "MGCMonthPlannerEKViewController.h" 9 | #import "MainViewController.h" 10 | 11 | 12 | @interface MonthViewController : MGCMonthPlannerEKViewController 13 | 14 | @property (nonatomic, weak) id delegate; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /CalendarDemo/MonthSettingsViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MonthSettingsViewController.h 3 | // CalendarDemo - Graphical Calendars Library for iOS 4 | // 5 | // Copyright (c) 2014-2015 Julien Martin. All rights reserved. 6 | // 7 | 8 | #import 9 | #import "MGCMonthPlannerView.h" 10 | 11 | @protocol MonthSettingsViewControllerDelegate; 12 | 13 | 14 | @interface MonthSettingsViewController : UITableViewController 15 | 16 | @property (nonatomic) MGCMonthPlannerView *monthPlannerView; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /CalendarDemo/WeekSettingsViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // WeekSettingsViewController.h 3 | // CalendarDemo - Graphical Calendars Library for iOS 4 | // 5 | // Copyright (c) 2014-2015 Julien Martin. All rights reserved. 6 | // 7 | 8 | #import 9 | #import "WeekViewController.h" 10 | 11 | 12 | @protocol WeekSettingsViewControllerDelegate; 13 | 14 | 15 | @interface WeekSettingsViewController : UITableViewController 16 | 17 | @property (nonatomic) WeekViewController *weekViewController; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Pods/Target Support Files/OrderedDictionary/OrderedDictionary.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/OrderedDictionary 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 4 | PODS_BUILD_DIR = $BUILD_DIR 5 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 8 | SKIP_INSTALL = YES 9 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CalendarLib (2.0): 3 | - OrderedDictionary (~> 1.2) 4 | - OSCache (~> 1.2) 5 | - OrderedDictionary (1.2) 6 | - OSCache (1.2.1) 7 | 8 | DEPENDENCIES: 9 | - CalendarLib (from `.`) 10 | 11 | EXTERNAL SOURCES: 12 | CalendarLib: 13 | :path: "." 14 | 15 | SPEC CHECKSUMS: 16 | CalendarLib: 6b0f0bcd4cdf21e2090c999ffee7609fcaf52483 17 | OrderedDictionary: 9cc5d69c5c5314ad696ed1839190724e83d534c7 18 | OSCache: 826996b68e8542a8a3d8af1ab0a0fc3070d8f357 19 | 20 | PODFILE CHECKSUM: f0c33ba38eb3de386c34bcd88371a475e11b702a 21 | 22 | COCOAPODS: 1.0.1 23 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CalendarLib (2.0): 3 | - OrderedDictionary (~> 1.2) 4 | - OSCache (~> 1.2) 5 | - OrderedDictionary (1.2) 6 | - OSCache (1.2.1) 7 | 8 | DEPENDENCIES: 9 | - CalendarLib (from `.`) 10 | 11 | EXTERNAL SOURCES: 12 | CalendarLib: 13 | :path: "." 14 | 15 | SPEC CHECKSUMS: 16 | CalendarLib: 6b0f0bcd4cdf21e2090c999ffee7609fcaf52483 17 | OrderedDictionary: 9cc5d69c5c5314ad696ed1839190724e83d534c7 18 | OSCache: 826996b68e8542a8a3d8af1ab0a0fc3070d8f357 19 | 20 | PODFILE CHECKSUM: f0c33ba38eb3de386c34bcd88371a475e11b702a 21 | 22 | COCOAPODS: 1.0.1 23 | -------------------------------------------------------------------------------- /CalendarDemo/DayViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DayViewController.h 3 | // Calendar 4 | // 5 | // Copyright © 2016 Julien Martin. All rights reserved. 6 | // 7 | 8 | #import "MGCDayPlannerEKViewController.h" 9 | #import "MainViewController.h" 10 | 11 | 12 | @protocol DayViewControllerDelegate 13 | 14 | @end 15 | 16 | 17 | @interface DayViewController : MGCDayPlannerEKViewController 18 | 19 | @property (nonatomic, weak) id delegate; 20 | 21 | @end 22 | 23 | -------------------------------------------------------------------------------- /CalendarDemo/WeekViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // WeekViewController.h 3 | // CalendarDemo - Graphical Calendars Library for iOS 4 | // 5 | // Copyright (c) 2014-2015 Julien Martin. All rights reserved. 6 | // 7 | 8 | #import "MGCDayPlannerEKViewController.h" 9 | #import "MainViewController.h" 10 | 11 | 12 | @protocol WeekViewControllerDelegate 13 | 14 | @end 15 | 16 | 17 | @interface WeekViewController : MGCDayPlannerEKViewController 18 | 19 | @property (nonatomic, weak) id delegate; 20 | @property (nonatomic) BOOL showDimmedTimeRanges; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /CalendarTests/CalendarTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CalendarTests.m 3 | // CalendarTests 4 | // 5 | // Copyright (c) 2014-2015 Julien Martin. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface CalendarTests : XCTestCase 11 | 12 | @end 13 | 14 | @implementation CalendarTests 15 | 16 | - (void)setUp 17 | { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown 23 | { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample 29 | { 30 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /CalendarTests/CalendarTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /CalendarDemo/YearViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // YearViewController.h 3 | // CalendarDemo - Graphical Calendars Library for iOS 4 | // 5 | // Copyright (c) 2014-2015 Julien Martin. All rights reserved. 6 | // 7 | 8 | #import "MGCYearCalendarView.h" 9 | #import "MainViewController.h" 10 | 11 | 12 | @class YearViewController; 13 | 14 | @protocol YearViewControllerDelegate 15 | 16 | @optional 17 | 18 | - (void)yearViewController:(YearViewController*)controller didSelectMonthAtDate:(NSDate*)date; 19 | 20 | @end 21 | 22 | ///////////// 23 | @interface YearViewController : UIViewController 24 | 25 | @property (nonatomic, readonly) MGCYearCalendarView* yearCalendarView; 26 | 27 | @property (nonatomic) NSCalendar *calendar; 28 | @property (nonatomic, weak) id delegate; 29 | 30 | @end 31 | 32 | 33 | -------------------------------------------------------------------------------- /Pods/OSCache/LICENSE.md: -------------------------------------------------------------------------------- 1 | OSCache 2 | version 1.2.1, Decembet 18th, 2015 3 | 4 | Copyright (C) 2014 Charcoal Design 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | 10 | Permission is granted to anyone to use this software for any purpose, 11 | including commercial applications, and to alter it and redistribute it 12 | freely, subject to the following restrictions: 13 | 14 | 1. The origin of this software must not be misrepresented; you must not 15 | claim that you wrote the original software. If you use this software 16 | in a product, an acknowledgment in the product documentation would be 17 | appreciated but is not required. 18 | 2. Altered source versions must be plainly marked as such, and must not be 19 | misrepresented as being the original software. 20 | 3. This notice may not be removed or altered from any source distribution. -------------------------------------------------------------------------------- /Pods/OrderedDictionary/LICENCE.md: -------------------------------------------------------------------------------- 1 | OrderedDictionary 2 | 3 | Version 1.2, September 28th, 2014 4 | 5 | Copyright (C) 2010 Charcoal Design 6 | 7 | This software is provided 'as-is', without any express or implied 8 | warranty. In no event will the authors be held liable for any damages 9 | arising from the use of this software. 10 | 11 | Permission is granted to anyone to use this software for any purpose, 12 | including commercial applications, and to alter it and redistribute it 13 | freely, subject to the following restrictions: 14 | 15 | 1. The origin of this software must not be misrepresented; you must not 16 | claim that you wrote the original software. If you use this software 17 | in a product, an acknowledgment in the product documentation would be 18 | appreciated but is not required. 19 | 2. Altered source versions must be plainly marked as such, and must not be 20 | misrepresented as being the original software. 21 | 3. This notice may not be removed or altered from any source distribution. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Julien Martin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /CalendarLib/MGCCalendarHeaderView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CalendarHeaderView.h 3 | // Calendar 4 | // 5 | // Copyright © 2016 Julien Martin. All rights reserved. 6 | // 7 | 8 | #import 9 | @class MGCDayPlannerView; 10 | 11 | @interface MGCCalendarHeaderView : UICollectionView 12 | 13 | 14 | /*! 15 | @abstract The current selected date on the calendar 16 | @discussion Read only, you can set the visible date via selectDate 17 | */ 18 | @property (nonatomic, readonly) NSDate *selectedDate; 19 | 20 | /*! 21 | @abstract The header background color 22 | @discussion Light gray by default 23 | */ 24 | @property (nonatomic, strong) UIColor *headerBackgroundColor; 25 | 26 | /*! 27 | @abstract Initialization 28 | @discussion The day planner view instance needs to be passed along 29 | */ 30 | - (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout andDayPlannerView:(MGCDayPlannerView *)dayPlannerView; 31 | 32 | /*! 33 | @abstract Sets and moves the header view to the given date 34 | @parameter date the date to be set 35 | */ 36 | - (void)selectDate:(NSDate *)date; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | *.xcscheme 26 | 27 | ## Obj-C/Swift specific 28 | *.hmap 29 | *.ipa 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 52 | 53 | fastlane/report.xml 54 | fastlane/screenshots -------------------------------------------------------------------------------- /CalendarLib.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "CalendarLib" 3 | s.version = "2.0" 4 | s.summary = "A set of views and controllers for displaying and scheduling events on iOS" 5 | s.homepage = "https://github.com/jumartin/Calendar" 6 | s.license = "MIT" 7 | s.author = { "Julien Martin" => "julienmartin@hotmail.com" } 8 | s.platform = :ios, "8.0" 9 | s.source = { :git => "https://github.com/jumartin/Calendar.git", :tag => s.version.to_s } 10 | s.screenshots = [ "https://raw.githubusercontent.com/jumartin/Calendar/master/CalendarDocs/DayPlannerView.jpg", "https://raw.githubusercontent.com/jumartin/Calendar/master/CalendarDocs/MonthPlannerView.jpg", "https://raw.githubusercontent.com/jumartin/Calendar/master/CalendarDocs/YearView.jpg"] 11 | s.source_files = "CalendarLib/**/*.{h,m}" 12 | s.public_header_files = "CalendarLib/{MGCDateRange.h,NSCalendar+MGCAdditions.h,NSAttributedString+MGCAdditions.h,MGCDayPlannerEKViewController.h,MGCMonthPlannerEKViewController.h,MGCEventView.h,MGCStandardEventView.h,MGCDayPlannerView.h,MGCDayPlannerViewController.h,MGCMonthPlannerView.h,MGCMonthPlannerViewController.h,MGCMonthMiniCalendarView.h,MGCYearCalendarView.h,MGCReusableObjectQueue.h}" 13 | s.resource_bundle = { 'CalendarLib' => ['CalendarLib/*.lproj'] } 14 | s.frameworks = "EventKit", "EventKitUI", "UIKit", "Foundation", "CoreGraphics" 15 | s.dependency "OSCache", "~> 1.2" 16 | s.dependency "OrderedDictionary", "~> 1.2" 17 | end 18 | -------------------------------------------------------------------------------- /CalendarDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "83.5x83.5", 66 | "scale" : "2x" 67 | } 68 | ], 69 | "info" : { 70 | "version" : 1, 71 | "author" : "xcode" 72 | } 73 | } -------------------------------------------------------------------------------- /CalendarLib/MGCMonthPlannerHeaderView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCMonthPlannerHeaderView.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | 32 | #import 33 | 34 | 35 | @interface MGCMonthPlannerHeaderView : UICollectionReusableView 36 | 37 | @property (nonatomic) UILabel *label; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /CalendarLib/MGCYearCalendarMonthHeaderView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCYearCalendarMonthHeaderView.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | 33 | 34 | @interface MGCYearCalendarMonthHeaderView : UICollectionReusableView 35 | 36 | @property (nonatomic) UILabel *label; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Calendar.xcworkspace/xcshareddata/Calendar.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | FB1B9293-44FA-4831-90B6-74F8DA2E076E 9 | IDESourceControlProjectName 10 | Calendar 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | C52FA12F0F638351E8AE774D6995B04A15747832 14 | https://github.com/jumartin/Calendar.git 15 | 16 | IDESourceControlProjectPath 17 | Calendar.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | C52FA12F0F638351E8AE774D6995B04A15747832 21 | .. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/jumartin/Calendar.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | C52FA12F0F638351E8AE774D6995B04A15747832 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | C52FA12F0F638351E8AE774D6995B04A15747832 36 | IDESourceControlWCCName 37 | Calendar 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /CalendarDemo/MainViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.h 3 | // CalendarDemo - Graphical Calendars Library for iOS 4 | // 5 | // Copyright (c) 2014-2015 Julien Martin. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | 12 | @protocol CalendarViewControllerNavigation 13 | 14 | @property (nonatomic, readonly) NSDate* centerDate; 15 | 16 | - (void)moveToDate:(NSDate*)date animated:(BOOL)animated; 17 | - (void)moveToNextPageAnimated:(BOOL)animated; 18 | - (void)moveToPreviousPageAnimated:(BOOL)animated; 19 | 20 | @optional 21 | 22 | @property (nonatomic) NSSet* visibleCalendars; 23 | 24 | @end 25 | 26 | 27 | typedef UIViewController CalendarViewController; 28 | 29 | 30 | @protocol CalendarViewControllerDelegate 31 | 32 | @optional 33 | 34 | - (void)calendarViewController:(CalendarViewController*)controller didShowDate:(NSDate*)date; 35 | - (void)calendarViewController:(CalendarViewController*)controller didSelectEvent:(EKEvent*)event; 36 | 37 | @end 38 | 39 | 40 | 41 | @interface MainViewController : UIViewController 42 | 43 | @property (nonatomic) CalendarViewController* calendarViewController; 44 | 45 | @property (nonatomic, weak) IBOutlet UIView *containerView; 46 | @property (nonatomic, weak) IBOutlet UILabel *currentDateLabel; 47 | @property (nonatomic, weak) IBOutlet UIBarButtonItem *settingsButtonItem; 48 | @property (nonatomic, weak) IBOutlet UISegmentedControl *viewChooser; 49 | 50 | @property (nonatomic) NSCalendar *calendar; 51 | @property (nonatomic) EKEventStore *eventStore; 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /CalendarLib/MGCMonthPlannerWeekView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCMonthPlannerWeekView.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | #import "MGCEventsRowView.h" 33 | 34 | 35 | @interface MGCMonthPlannerWeekView : UICollectionReusableView 36 | 37 | @property (nonatomic) MGCEventsRowView *eventsView; 38 | 39 | @end 40 | 41 | -------------------------------------------------------------------------------- /CalendarLib/MGCYearCalendarMonthCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCYearCalendarMonthCell.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | #import "MGCMonthMiniCalendarView.h" 33 | 34 | 35 | @interface MGCYearCalendarMonthCell : UICollectionViewCell 36 | 37 | @property (nonatomic) MGCMonthMiniCalendarView *calendarView; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Calendar.xcodeproj/project.xcworkspace/xcshareddata/Calendar.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | BCFB3967-52FC-4535-BB46-74C19D255A5F 9 | IDESourceControlProjectName 10 | Calendar 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | C52FA12F0F638351E8AE774D6995B04A15747832 14 | https://github.com/varun-naharia/Calendar.git 15 | 16 | IDESourceControlProjectPath 17 | Calendar.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | C52FA12F0F638351E8AE774D6995B04A15747832 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/varun-naharia/Calendar.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | C52FA12F0F638351E8AE774D6995B04A15747832 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | C52FA12F0F638351E8AE774D6995B04A15747832 36 | IDESourceControlWCCName 37 | Calendar 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /CalendarLib/MGCMonthPlannerViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCMonthPlannerViewController.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | #import "MGCMonthPlannerView.h" 33 | 34 | 35 | @interface MGCMonthPlannerViewController : UIViewController 36 | 37 | @property (nonatomic, retain) MGCMonthPlannerView* monthPlannerView; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /CalendarLib/MGCMonthPlannerViewDayCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCMonthPlannerViewDayCell.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | 33 | 34 | @interface MGCMonthPlannerViewDayCell : UICollectionViewCell 35 | 36 | @property (nonatomic) CGFloat headerHeight; 37 | @property (nonatomic) UILabel *dayLabel; 38 | @property (nonatomic) BOOL showsDot; 39 | @property (nonatomic) UIColor *dotColor; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /CalendarLib/MGCEventCellLayoutAttributes.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCEventCellLayoutAttributes.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | 33 | 34 | @interface MGCEventCellLayoutAttributes : UICollectionViewLayoutAttributes 35 | 36 | @property (nonatomic) CGFloat visibleHeight; // height of the visible portion of the cell 37 | @property (nonatomic) NSUInteger numberOfOtherCoveredAttributes; // number of events which share a time section with this attribute 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /CalendarLib/MGCAlignedGeometry.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCAlignedGeometry.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2016 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | 32 | // functions to align coordinates on pixel boundaries 33 | 34 | CGRect MGCAlignedRect(CGRect rect); 35 | CGRect MGCAlignedRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height); 36 | CGSize MGCAlignedSize(CGSize size); 37 | CGSize MGCAlignedSizeMake(CGFloat width, CGFloat height); 38 | CGPoint MGCAlignedPoint(CGPoint point); 39 | CGPoint MGCAlignedPointMake(CGFloat x, CGFloat y); 40 | CGFloat MGCAlignedFloat(CGFloat f); 41 | -------------------------------------------------------------------------------- /CalendarLib/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | // 2 | // Localizable.strings 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | 32 | "Warning" = "Warning"; 33 | 34 | "Access to the calendar was not authorized" = "Access to the calendar was not authorized"; 35 | 36 | "This is a repeating event." = "This is a repeating event."; 37 | 38 | "What do you want to modify?" = "What do you want to modify?"; 39 | 40 | "Cancel" = "Cancel"; 41 | 42 | "This event only" = "This event only"; 43 | 44 | "All future events" = "All future events"; 45 | 46 | "New Event" = "New Event"; 47 | 48 | "%lu more..." = "%lu more..."; 49 | -------------------------------------------------------------------------------- /CalendarLib/MGCMonthPlannerEKViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCMonthPlannerEKViewController.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | #import "MGCMonthPlannerViewController.h" 33 | 34 | 35 | @interface MGCMonthPlannerEKViewController : MGCMonthPlannerViewController 36 | 37 | @property (nonatomic) NSCalendar *calendar; 38 | @property (nonatomic) NSSet *visibleCalendars; 39 | @property (nonatomic, readonly) EKEventStore *eventStore; 40 | 41 | /** designated initializer */ 42 | - (instancetype)initWithEventStore:(EKEventStore*)eventStore; 43 | - (void)reloadEvents; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /CalendarLib/fr.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | // 2 | // Localizable.strings 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | 32 | "Warning" = "Attention"; 33 | 34 | "Access to the calendar was not authorized" = "L'accès de cette application au calendrier n'a pas été autorisée"; 35 | 36 | "This is a repeating event." = "Cet événement est récurrent."; 37 | 38 | "What do you want to modify?" = "Que souhaitez vous modifier ?"; 39 | 40 | "Cancel" = "Annuler"; 41 | 42 | "This event only" = "Seulement cet évènement"; 43 | 44 | "All future events" = "Tous les évènements à venir"; 45 | 46 | "New Event" = "Nouvel évènement"; 47 | 48 | "%lu more..." = "%lu de plus..."; 49 | -------------------------------------------------------------------------------- /CalendarLib/MGCEventCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCEventCell.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | 33 | 34 | @class MGCEventView; 35 | 36 | // This collection view cell is used by the day planner view's subviews timedEventsView 37 | // and allDayEventsView. 38 | // It is the parent view for event content views, which are subclasses of MGCEventView. 39 | @interface MGCEventCell : UICollectionViewCell 40 | 41 | @property (nonatomic) MGCEventView *eventView; // content view of the event cell 42 | @property (nonatomic) CGFloat visibleHeight; // height of the visible portion of the cell (set via MGCEventCellLayoutAttributes) 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /CalendarLib/MGCInteractiveEventView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCInteractiveEventCell.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | #import "MGCEventView.h" 33 | 34 | 35 | // This is the interactive view shown when the user taps and holds on an event view. 36 | // If permitted, the view can be dragged around in order to move the event. 37 | @interface MGCInteractiveEventView : UIView 38 | 39 | @property (nonatomic) MGCEventView *eventView; // event view - this is a copy of the view that was tapped 40 | @property (nonatomic) BOOL forbiddenSignVisible; // set to YES to show a prohibited sign above the view. It indicates the event cannot be moved to that date or time. 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /CalendarLib/MGCEventCellLayoutAttributes.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGCEventCellLayoutAttributes.m 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | 32 | #import "MGCEventCellLayoutAttributes.h" 33 | 34 | @implementation MGCEventCellLayoutAttributes 35 | 36 | - (BOOL)isEqual:(id)object 37 | { 38 | if (![super isEqual:object]) 39 | return NO; 40 | 41 | MGCEventCellLayoutAttributes* attribs = (MGCEventCellLayoutAttributes*)object; 42 | return (attribs.visibleHeight == self.visibleHeight); 43 | } 44 | 45 | - (id)copyWithZone:(NSZone*)zone 46 | { 47 | MGCEventCellLayoutAttributes *attribs = [super copyWithZone:zone]; 48 | attribs.visibleHeight = self.visibleHeight; 49 | return attribs; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /CalendarLib/MGCYearCalendarMonthHeaderView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGCYearCalendarMonthHeaderView.m 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import "MGCYearCalendarMonthHeaderView.h" 32 | 33 | 34 | @implementation MGCYearCalendarMonthHeaderView 35 | 36 | - (id)initWithFrame:(CGRect)frame 37 | { 38 | if (self = [super initWithFrame:frame]) { 39 | self.backgroundColor = [UIColor clearColor]; 40 | self.autoresizesSubviews = YES; 41 | 42 | _label = [[UILabel alloc]initWithFrame:self.bounds]; 43 | _label.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth; 44 | _label.numberOfLines = 0; 45 | [self addSubview:_label]; 46 | } 47 | return self; 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Pods/OSCache/OSCache/OSCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // OSCache.h 3 | // 4 | // Version 1.2.1 5 | // 6 | // Created by Nick Lockwood on 01/01/2014. 7 | // Copyright (C) 2014 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib License 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/OSCache 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | #import 34 | 35 | NS_ASSUME_NONNULL_BEGIN 36 | 37 | @interface OSCache : NSCache 38 | 39 | @property (nonatomic, readonly) NSUInteger count; 40 | @property (nonatomic, readonly) NSUInteger totalCost; 41 | 42 | - (id)objectForKeyedSubscript:(KeyType )key; 43 | - (void)setObject:(ObjectType)obj forKeyedSubscript:(KeyType )key; 44 | - (void)enumerateKeysAndObjectsUsingBlock:(void (^)(KeyType key, ObjectType obj, BOOL *stop))block; 45 | 46 | @end 47 | 48 | 49 | @protocol OSCacheDelegate 50 | @optional 51 | 52 | - (BOOL)cache:(OSCache *)cache shouldEvictObject:(id)entry; 53 | - (void)cache:(OSCache *)cache willEvictObject:(id)entry; 54 | 55 | @end 56 | 57 | NS_ASSUME_NONNULL_END 58 | -------------------------------------------------------------------------------- /CalendarLib/MGCYearCalendarMonthCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGCYearCalendarMonthCell.m 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import "MGCYearCalendarMonthCell.h" 32 | 33 | 34 | @implementation MGCYearCalendarMonthCell 35 | 36 | - (id)initWithFrame:(CGRect)frame 37 | { 38 | self = [super initWithFrame:frame]; 39 | if (self) 40 | { 41 | self.autoresizesSubviews = YES; 42 | self.backgroundColor = [UIColor clearColor]; 43 | 44 | _calendarView = [[MGCMonthMiniCalendarView alloc]initWithFrame:self.bounds]; 45 | _calendarView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth; 46 | [self.contentView addSubview:_calendarView]; 47 | } 48 | return self; 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /CalendarLib/MGCEventKitSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCEventKitSupport.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | 32 | #import 33 | 34 | 35 | typedef void(^EventSaveCompletionBlockType)(BOOL); 36 | 37 | 38 | @interface MGCEventKitSupport : NSObject 39 | 40 | @property (nonatomic, readonly) EKEventStore *eventStore; 41 | @property (nonatomic, readonly) BOOL accessGranted; 42 | 43 | - (instancetype)initWithEventStore:(EKEventStore*)eventStore; 44 | - (void)checkEventStoreAccessForCalendar:(void (^)(BOOL accessGranted))completion; 45 | - (void)saveEvent:(EKEvent*)event completion:(void (^)(BOOL saved))completion; 46 | 47 | @end 48 | 49 | 50 | @interface MGCEKEventViewController: EKEventViewController 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /CalendarLib/MGCMonthPlannerBackgroundView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCMonthPlannerBackgroundView.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | 33 | 34 | @interface MGCMonthPlannerBackgroundView : UICollectionReusableView 35 | 36 | @property (nonatomic) NSUInteger numberOfColumns; 37 | @property (nonatomic) NSUInteger numberOfRows; 38 | @property (nonatomic) NSUInteger firstColumn; 39 | @property (nonatomic) NSUInteger lastColumn; 40 | 41 | @property (nonatomic) BOOL drawVerticalLines; 42 | @property (nonatomic) BOOL drawHorizontalLines; 43 | 44 | @property (nonatomic) BOOL drawBottomDayLabelLines; 45 | @property (nonatomic) CGFloat dayCellHeaderHeight; 46 | 47 | @property (nonatomic) UIColor *gridColor; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /CalendarDemo/Calendar-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIcons 12 | 13 | CFBundleIcons~ipad 14 | 15 | CFBundleIdentifier 16 | $(PRODUCT_BUNDLE_IDENTIFIER) 17 | CFBundleInfoDictionaryVersion 18 | 6.0 19 | CFBundleName 20 | ${PRODUCT_NAME} 21 | CFBundlePackageType 22 | APPL 23 | CFBundleShortVersionString 24 | 1.0 25 | CFBundleSignature 26 | ???? 27 | CFBundleVersion 28 | 1.0 29 | LSRequiresIPhoneOS 30 | 31 | NSCalendarsUsageDescription 32 | This app has read and write access to your calendars 33 | UILaunchStoryboardName 34 | Launch Screen 35 | UIMainStoryboardFile 36 | main-iPhone 37 | UIMainStoryboardFile~ipad 38 | main-iPad 39 | UIRequiredDeviceCapabilities 40 | 41 | armv7 42 | 43 | UIRequiresFullScreen 44 | 45 | UISupportedInterfaceOrientations 46 | 47 | UIInterfaceOrientationPortrait 48 | UIInterfaceOrientationLandscapeLeft 49 | UIInterfaceOrientationLandscapeRight 50 | 51 | UISupportedInterfaceOrientations~ipad 52 | 53 | UIInterfaceOrientationPortrait 54 | UIInterfaceOrientationPortraitUpsideDown 55 | UIInterfaceOrientationLandscapeLeft 56 | UIInterfaceOrientationLandscapeRight 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /CalendarLib/MGCDayPlannerViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCDayPlannerViewController.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | #import "MGCDayPlannerView.h" 33 | @class MGCCalendarHeaderView; 34 | 35 | 36 | /*! 37 | * The MGCDayPlannerViewController class creates a controller object that manages a day planner view. 38 | */ 39 | @interface MGCDayPlannerViewController : UIViewController 40 | 41 | /*! Returns the day planner view managed by the controller object. */ 42 | @property(nonatomic, retain) MGCDayPlannerView *dayPlannerView; 43 | 44 | /*! Returns the calendar header view managed by the controller object. */ 45 | @property (nonatomic) MGCCalendarHeaderView *headerView; 46 | 47 | @property (nonatomic, assign) BOOL showsWeekHeaderView; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /CalendarLib/MGCMonthPlannerHeaderView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGCMonthPlannerHeaderView.m 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | 32 | #import "MGCMonthPlannerHeaderView.h" 33 | #import "MGCMonthPlannerViewLayout.h" 34 | 35 | 36 | @implementation MGCMonthPlannerHeaderView 37 | 38 | - (id)initWithFrame:(CGRect)frame 39 | { 40 | if (self = [super initWithFrame:frame]) { 41 | self.backgroundColor = [UIColor clearColor]; 42 | self.autoresizesSubviews = YES; 43 | 44 | _label = [[UILabel alloc]initWithFrame:self.bounds]; 45 | _label.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth; 46 | _label.numberOfLines = 0; 47 | _label.adjustsFontSizeToFitWidth = YES; 48 | _label.minimumScaleFactor = .85; 49 | [self addSubview:_label]; 50 | } 51 | return self; 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /CalendarLib/MGCEventView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGCEventView.m 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import "MGCEventView.h" 32 | 33 | 34 | @implementation MGCEventView 35 | 36 | - (instancetype)initWithFrame:(CGRect)frame 37 | { 38 | if (self = [super initWithFrame:frame]) { 39 | self.visibleHeight = CGFLOAT_MAX; 40 | self.backgroundColor = [UIColor grayColor]; 41 | self.clipsToBounds = YES; 42 | } 43 | return self; 44 | } 45 | 46 | - (void)prepareForReuse 47 | { 48 | self.selected = NO; 49 | } 50 | 51 | // if needed, implement in subclasses 52 | - (void)didTransitionToEventType:(MGCEventType)toType 53 | { 54 | } 55 | 56 | #pragma mark - NSCopying protocol 57 | 58 | - (id)copyWithZone:(NSZone*)zone 59 | { 60 | MGCEventView *cell = [[[self class] allocWithZone:zone] initWithFrame:self.frame]; 61 | return cell; 62 | } 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /CalendarLib/NSCalendar+MGCAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSCalendar+MGCAdditions.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | 33 | 34 | @interface NSCalendar (MGCAdditions) 35 | 36 | + (NSCalendar*)mgc_calendarFromPreferenceString:(NSString*)string; 37 | 38 | - (NSDate*)mgc_startOfDayForDate:(NSDate*)date; 39 | - (NSDate*)mgc_nextStartOfDayForDate:(NSDate*)date; 40 | - (NSDate*)mgc_startOfWeekForDate:(NSDate*)date; 41 | - (NSDate*)mgc_nextStartOfWeekForDate:(NSDate*)date; 42 | - (NSDate*)mgc_startOfMonthForDate:(NSDate*)date; 43 | - (NSDate*)mgc_nextStartOfMonthForDate:(NSDate*)date; 44 | - (NSDate*)mgc_startOfYearForDate:(NSDate*)date; 45 | - (NSUInteger)mgc_indexOfWeekInMonthForDate:(NSDate*)date; 46 | 47 | - (BOOL)mgc_isDate:(NSDate*)date1 sameDayAsDate:(NSDate*)date2; 48 | - (BOOL)mgc_isDate:(NSDate*)date1 sameMonthAsDate:(NSDate*)date2; 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /CalendarDemo/Settings.bundle/Root.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | Values 9 | 10 | 1 11 | 2 12 | 3 13 | 4 14 | 5 15 | 6 16 | 7 17 | 18 | Titles 19 | 20 | Sunday 21 | Monday 22 | Tuesday 23 | Wednesday 24 | Thursday 25 | Friday 26 | Saturday 27 | 28 | Type 29 | PSMultiValueSpecifier 30 | Title 31 | The week begins on 32 | Key 33 | firstDay 34 | DefaultValue 35 | 2 36 | 37 | 38 | Values 39 | 40 | gregorian 41 | buddhist 42 | chinese 43 | hebrew 44 | iso8601 45 | indian 46 | islamic 47 | islamicCivil 48 | japanese 49 | persian 50 | republicOfChina 51 | 52 | Titles 53 | 54 | Gregorian 55 | Buddhist 56 | Chinese 57 | Hebrew 58 | ISO8601 59 | Indian 60 | Islamic 61 | Islamic Civil 62 | Japanese 63 | Persian 64 | Republic Of China 65 | 66 | Type 67 | PSMultiValueSpecifier 68 | Title 69 | Calendar 70 | Key 71 | calendarIdentifier 72 | DefaultValue 73 | gregorian 74 | 75 | 76 | StringsTable 77 | Root 78 | 79 | 80 | -------------------------------------------------------------------------------- /CalendarLib/NSAttributedString+MGCAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSAttributedString+MGCAdditions.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2016 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | 33 | 34 | extern NSString * const MGCCircleMarkAttributeName; 35 | 36 | 37 | // MGCCircleMark can be used as an attribute for NSAttributedString to draw a circle mark behing the text 38 | @interface MGCCircleMark : NSObject 39 | 40 | @property (nonatomic) UIColor *borderColor; // default is clear 41 | @property (nonatomic) UIColor *color; // default is red 42 | @property (nonatomic) CGFloat margin; // padding on each side of the text 43 | @property (nonatomic) CGFloat yOffset; // vertical position adjustment 44 | 45 | @end 46 | 47 | 48 | @interface NSAttributedString (MGCAdditions) 49 | 50 | - (UIImage*)imageWithCircleMark:(MGCCircleMark*)mark; 51 | - (NSAttributedString*)attributedStringWithProcessedCircleMarksInRange:(NSRange)range; 52 | 53 | @end 54 | 55 | 56 | @interface NSMutableAttributedString (MGCAdditions) 57 | 58 | - (void)processCircleMarksInRange:(NSRange)range; 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /CalendarLib/MGCDateRange.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCDateRange.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | 33 | 34 | @interface MGCDateRange : NSObject 35 | 36 | @property (nonatomic, copy) NSDate *start; // start of the range 37 | @property (nonatomic, copy) NSDate *end; // end of the range (excluding) 38 | @property (nonatomic, readonly) BOOL isEmpty; // range is empty is start is equal to end 39 | 40 | + (instancetype)dateRangeWithStart:(NSDate*)start end:(NSDate*)end; 41 | - (instancetype)initWithStart:(NSDate*)start end:(NSDate*)end; 42 | 43 | - (BOOL)isEqualToDateRange:(MGCDateRange*)range; 44 | - (NSDateComponents*)components:(NSCalendarUnit)unitFlags forCalendar:(NSCalendar*)calendar; 45 | - (BOOL)containsDate:(NSDate*)date; 46 | - (void)intersectDateRange:(MGCDateRange*)range; 47 | - (BOOL)intersectsDateRange:(MGCDateRange*)range; 48 | - (BOOL)includesDateRange:(MGCDateRange*)range; 49 | - (void)unionDateRange:(MGCDateRange*)range; 50 | - (void)enumerateDaysWithCalendar:(NSCalendar*)calendar usingBlock:(void (^)(NSDate *day, BOOL *stop))block; 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /CalendarLib/MGCMonthPlannerViewLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCMonthPlannerViewLayout.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | 33 | 34 | static NSString* DayCellKind = @"DayCellKind"; 35 | static NSString* const MonthBackgroundViewKind = @"MonthBackgroundViewKind"; 36 | static NSString* const MonthRowViewKind = @"MonthRowViewKind"; 37 | static NSString* const MonthHeaderViewKind = @"MonthHeaderViewKind"; 38 | 39 | 40 | @protocol MGCMonthPlannerViewLayoutDelegate; 41 | 42 | 43 | @interface MGCMonthPlannerViewLayout : UICollectionViewLayout 44 | 45 | @property (nonatomic, weak) id delegate; 46 | @property (nonatomic) UIEdgeInsets monthInsets; 47 | @property (nonatomic) CGFloat rowHeight; 48 | @property (nonatomic) CGFloat dayHeaderHeight; 49 | @property (nonatomic) BOOL alignMonthHeaders; 50 | @property (nonatomic) BOOL showEvents; 51 | 52 | 53 | - (CGFloat)widthForColumnRange:(NSRange)range; 54 | - (CGFloat)columnWidth:(NSUInteger)colIndex; 55 | 56 | @end 57 | 58 | 59 | @protocol MGCMonthPlannerViewLayoutDelegate 60 | 61 | - (NSUInteger)collectionView:(UICollectionView*)collectionView layout:(MGCMonthPlannerViewLayout*)layout columnForDayAtIndexPath:(NSIndexPath*)indexPath; 62 | 63 | @optional 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /CalendarLib/MGCMonthPlannerWeekView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGCMonthPlannerWeekView.m 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import "MGCMonthPlannerWeekView.h" 32 | 33 | 34 | @interface MGCMonthPlannerWeekView () 35 | @end 36 | 37 | 38 | @implementation MGCMonthPlannerWeekView 39 | 40 | - (id)initWithFrame:(CGRect)frame 41 | { 42 | if (self = [super initWithFrame:frame]) { 43 | self.backgroundColor = [UIColor clearColor]; 44 | } 45 | return self; 46 | } 47 | 48 | - (void)setEventsView:(MGCEventsRowView*)eventsView 49 | { 50 | NSUInteger z = NSNotFound; 51 | if (_eventsView) { 52 | z = [self.subviews indexOfObject:_eventsView]; 53 | } 54 | 55 | if (z == NSNotFound) { 56 | //eventsView.frame = self.bounds; 57 | [self addSubview:eventsView]; 58 | } 59 | else { 60 | [_eventsView removeFromSuperview]; 61 | [self insertSubview:eventsView atIndex:z]; 62 | } 63 | _eventsView = eventsView; 64 | } 65 | 66 | -(UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event 67 | { 68 | UIView *hitView = [super hitTest:point withEvent:event]; 69 | return (hitView == self) ? nil : hitView; 70 | } 71 | 72 | - (void)prepareForReuse 73 | { 74 | } 75 | 76 | - (void)layoutSubviews 77 | { 78 | [super layoutSubviews]; 79 | self.eventsView.frame = self.bounds; 80 | } 81 | 82 | @end 83 | 84 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG 2 | 3 | ## v. 2.0 4 | 5 | - Deployment target is now iOS 8.0 6 | - The library is now fully compatible with both iPad and iPhone 7 | - Many new APIs for both the day planner and the month planner 8 | - Few optimizations and bug fixes 9 | 10 | ### Day Planner 11 | 12 | - `MGCDayPlannerView` : 13 | - new property `daySeparatorsColor` 14 | - new property `timeSeparatorsColor` 15 | - new property `currentTimeColor` 16 | - new property `eventIndicatorDotColor` 17 | - new property `hourRange` 18 | 19 | - `MGCDayPlannerViewDelegate` : 20 | - new method `dayPlannerView:attributedStringForTimeMark:time:` 21 | - new method `dayPlannerView:attributedStringForDayHeaderAtDate:` 22 | 23 | 24 | ### Month planner 25 | 26 | - `MGCMonthPlannerView` : 27 | - new property `dayCellHeaderHeight` 28 | - new property `dateFormat` 29 | - new property `gridStyle` 30 | - new property `monthHeaderStyle` 31 | - new property `monthInsets` 32 | - new property `style` 33 | - new property `eventsDotColor` 34 | - new method `reloadEventsAtDate:` 35 | - new property `allowsSelection` 36 | - new property `selectedEventDate` 37 | - new property `selectedEventIndex` 38 | - new property `selectedEventView` 39 | - new property `calendarBackgroundColor` 40 | - new property `weekDayBackgroundColor` 41 | - new property `weekendDayBackgroundColor` 42 | - new property `weekdaysLabelTextColor` 43 | - new property `monthLabelTextColor` 44 | - new property `monthLabelFont` 45 | - new property `weekdaysLabelFont` 46 | - new property `weekDaysStringArray` 47 | - new property `pagingMode` 48 | - new method `scrollToDate:alignment:animated:` 49 | - new property `canCreateEvents` 50 | - new property `canMoveEvents` 51 | 52 | - `MGCMonthPlannerViewDelegate`: 53 | - new method `monthPlannerView:attributedStringForDayHeaderAtDate:` 54 | 55 | ### Event Kit 56 | 57 | - EventKit specialized controllers (`MGCDayPlannerEKViewController` and `MGCMonthPlannerEKViewController`) : 58 | - added iPhone compatibility with the use of `UIPopoverPresentationController` for adaptive presentation of EventKit controllers 59 | - new protocol `MGCDayPlannerEKViewControllerDelegate` 60 | 61 | ### Contributors 62 | 63 | [@xEsk](https://github.com/xEsk) : [#5](https://github.com/jumartin/Calendar/pull/5) 64 | [@varun-naharia](https://github.com/varun-naharia) : [#14](https://github.com/jumartin/Calendar/pull/14) 65 | [@dk53](https://github.com/dk53) : [#17](https://github.com/jumartin/Calendar/pull/17) [#18](https://github.com/jumartin/Calendar/pull/18) 66 | [@arnaudWasappli](https://github.com/arnaudWasappli) : [#21](https://github.com/jumartin/Calendar/pull/21) 67 | 68 | Thanks! 69 | 70 | -------------------------------------------------------------------------------- /CalendarLib/MGCDayPlannerEKViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCDayPlannerEKViewController.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | #import 33 | #import "MGCDayPlannerViewController.h" 34 | 35 | 36 | @protocol MGCDayPlannerEKViewControllerDelegate; 37 | 38 | 39 | @interface MGCDayPlannerEKViewController : MGCDayPlannerViewController 40 | 41 | @property (nonatomic) NSCalendar *calendar; 42 | @property (nonatomic) NSSet *visibleCalendars; 43 | @property (nonatomic, readonly) EKEventStore *eventStore; 44 | @property (nonatomic, weak) id delegate; 45 | 46 | /** designated initializer */ 47 | - (instancetype)initWithEventStore:(EKEventStore*)eventStore; 48 | - (void)reloadEvents; 49 | 50 | @end 51 | 52 | 53 | @protocol MGCDayPlannerEKViewControllerDelegate 54 | 55 | 56 | @optional 57 | 58 | - (void)dayPlannerEKEViewController:(MGCDayPlannerEKViewController*)vc willPresentEventViewController:(EKEventViewController*)eventViewController; 59 | - (UINavigationController*)dayPlannerEKViewController:(MGCDayPlannerEKViewController*)vc navigationControllerForPresentingEventViewController:(EKEventViewController*)eventViewController; 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /CalendarLib/MGCEventCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGCEventCell.m 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import "MGCEventCell.h" 32 | #import "MGCEventView.h" 33 | #import "MGCEventCellLayoutAttributes.h" 34 | 35 | 36 | @implementation MGCEventCell 37 | 38 | - (id)initWithFrame:(CGRect)frame 39 | { 40 | if (self = [super initWithFrame:frame]) { 41 | self.visibleHeight = CGFLOAT_MAX; 42 | } 43 | return self; 44 | } 45 | 46 | - (void)setEventView:(MGCEventView*)eventView 47 | { 48 | if (eventView != _eventView) { 49 | [self.eventView removeFromSuperview]; 50 | [self.contentView addSubview:eventView]; 51 | [self setNeedsLayout]; 52 | 53 | _eventView = eventView; 54 | _eventView.visibleHeight = self.visibleHeight; 55 | } 56 | } 57 | 58 | - (void)setSelected:(BOOL)selected 59 | { 60 | [super setSelected:selected]; 61 | self.eventView.selected = selected; 62 | } 63 | 64 | - (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes 65 | { 66 | if ([layoutAttributes isKindOfClass:MGCEventCellLayoutAttributes.class]) { 67 | MGCEventCellLayoutAttributes *attribs = (MGCEventCellLayoutAttributes*)layoutAttributes; 68 | self.visibleHeight = attribs.visibleHeight; 69 | } 70 | } 71 | 72 | - (void)prepareForReuse 73 | { 74 | [super prepareForReuse]; 75 | } 76 | 77 | - (void)layoutSubviews 78 | { 79 | [super layoutSubviews]; 80 | self.eventView.frame = self.contentView.bounds; 81 | } 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /CalendarLib/MGCAlignedGeometry.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGCAlignedGeometry.m 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2016 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | 32 | #import 33 | #import "MGCAlignedGeometry.h" 34 | 35 | 36 | CGRect MGCAlignedRect(CGRect rect) 37 | { 38 | CGFloat scale = [UIScreen mainScreen].scale; 39 | return CGRectMake(floorf(rect.origin.x * scale) / scale, floorf(rect.origin.y * scale) / scale, ceilf(rect.size.width * scale) / scale, ceilf(rect.size.height * scale) / scale); 40 | } 41 | 42 | CGRect MGCAlignedRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height) 43 | { 44 | return MGCAlignedRect(CGRectMake(x, y, width, height)); 45 | } 46 | 47 | CGSize MGCAlignedSize(CGSize size) 48 | { 49 | CGFloat scale = [UIScreen mainScreen].scale; 50 | return CGSizeMake(ceilf(size.width * scale) / scale, ceilf(size.height * scale) / scale); 51 | } 52 | 53 | CGSize MGCAlignedSizeMake(CGFloat width, CGFloat height) 54 | { 55 | return MGCAlignedSize(CGSizeMake(width, height)); 56 | } 57 | 58 | CGPoint MGCAlignedPoint(CGPoint point) 59 | { 60 | CGFloat scale = [UIScreen mainScreen].scale; 61 | return CGPointMake(floorf(point.x * scale) / scale, floorf(point.y * scale) / scale); 62 | } 63 | 64 | CGPoint MGCAlignedPointMake(CGFloat x, CGFloat y) 65 | { 66 | return MGCAlignedPoint(CGPointMake(x, y)); 67 | } 68 | 69 | CGFloat MGCAlignedFloat(CGFloat f) 70 | { 71 | CGFloat scale = [UIScreen mainScreen].scale; 72 | return roundf(f * scale) / scale; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /CalendarLib/MGCAllDayEventsViewLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCAllDayEventsViewLayout.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | 33 | 34 | static NSString* const MoreEventsViewKind = @"MoreEventsViewKind"; 35 | 36 | typedef enum : NSUInteger 37 | { 38 | AllDayEventInsetNone = 0, 39 | AllDayEventInsetLeft = 1 << 0, 40 | AllDayEventInsetRight = 1 << 1, 41 | } AllDayEventInset; 42 | 43 | 44 | @protocol MGCAllDayEventsViewLayoutDelegate; 45 | 46 | 47 | // This collection view layout is responsible for the layout of event views in the all-day events part 48 | // of the day planner view. 49 | @interface MGCAllDayEventsViewLayout : UICollectionViewLayout 50 | 51 | @property (nonatomic, weak) id delegate; 52 | @property (nonatomic) CGFloat dayColumnWidth; // width of columns 53 | @property (nonatomic) CGFloat eventCellHeight; // height of an event cell 54 | @property (nonatomic) CGFloat maxContentHeight; // if the total content height, defined by the sum of the height of all stacked cells, is more than this value, then some cells will be hidden and a view at the bottom will indicate the number of hidden events 55 | 56 | - (NSUInteger)numberOfHiddenEventsInSection:(NSInteger)section; 57 | 58 | @end 59 | 60 | 61 | @protocol MGCAllDayEventsViewLayoutDelegate 62 | 63 | - (NSRange)collectionView:(UICollectionView*)view layout:(MGCAllDayEventsViewLayout*)layout dayRangeForEventAtIndexPath:(NSIndexPath*)indexPath; 64 | 65 | @optional 66 | 67 | - (AllDayEventInset)collectionView:(UICollectionView*)view layout:(MGCAllDayEventsViewLayout*)layout insetsForEventAtIndexPath:(NSIndexPath*)indexPath; 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /CalendarLib/MGCMonthMiniCalendarView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCMonthMiniCalendarView.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | 33 | 34 | @protocol MGCMonthMiniCalendarViewDelegate; 35 | 36 | 37 | @interface MGCMonthMiniCalendarView : UIView 38 | 39 | @property (nonatomic, copy) NSCalendar *calendar; // calendar used (one of Gregorian, Indian, Hebrew...) 40 | @property (nonatomic) NSDate *date; // date for which we want to display the month (not necessarly the first day). Default is today 41 | @property (nonatomic) BOOL showsMonthHeader; // set to NO to hide the month header. Default is YES 42 | @property (nonatomic) BOOL showsDayHeader; // set to NO to hide the week day header. Default is YES 43 | @property (nonatomic, copy) NSAttributedString *headerText; // text for the month header. Default is month followed by year (ex: May 2014) 44 | @property (nonatomic) UIFont *daysFont; // font for week day symbols. Default is system font with size of 13. 45 | @property (nonatomic) NSIndexSet *highlightedDays; // highlighted days show a circle around the day label 46 | @property (nonatomic) UIColor *highlightColor; // color of the circle for highlighted days. Default is black. 47 | @property (nonatomic, weak) id delegate; 48 | 49 | 50 | // returns the ideal size of the view. 51 | // If yearWise is YES, it does not take date into account, but rather calculates the number of rows 52 | // according to the maximum number of weeks per month in a year. 53 | - (CGSize)preferredSizeYearWise:(BOOL)yearWise; 54 | 55 | @end 56 | 57 | 58 | @protocol MGCMonthMiniCalendarViewDelegate 59 | 60 | @optional 61 | 62 | - (UIColor*)monthMiniCalendarView:(MGCMonthMiniCalendarView*)view backgroundColorForDayAtIndex:(NSUInteger)index; 63 | 64 | @end -------------------------------------------------------------------------------- /Pods/OrderedDictionary/README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/nicklockwood/OrderedDictionary.svg)](https://travis-ci.org/nicklockwood/OrderedDictionary) 2 | 3 | 4 | Purpose 5 | -------------- 6 | 7 | The order of objects stored in an NSDictionary is undefined. Often it is useful to be able to loop through a set of key/value pairs and have the objects returned in the order in which they were inserted. This library provides two classes, OrderedDictionary and MutableOrderedDictionary that implement that behaviour. 8 | 9 | 10 | Supported OS & SDK Versions 11 | ----------------------------- 12 | 13 | * Supported build target - iOS 8.0 / Mac OS 10.9 (Xcode 6.0, Apple LLVM compiler 6.0) 14 | * Earliest supported deployment target - iOS 5.0 / Mac OS 10.7 15 | * Earliest compatible deployment target - iOS 4.3 / Mac OS 10.6 16 | 17 | NOTE: 'Supported' means that the library has been tested with this version. 'Compatible' means that the library should work on this OS version (i.e. it doesn't rely on any unavailable SDK features) but is no longer being tested for compatibility and may require tweaking or bug fixes to run correctly. 18 | 19 | 20 | ARC Compatibility 21 | ------------------ 22 | 23 | OrderedDictionary requires ARC. If you wish to use OrderedDictionary in a non-ARC project, just add the -fobjc-arc compiler flag to the OrderedDictionary.m class. To do this, go to the Build Phases tab in your target settings, open the Compile Sources group, double-click OrderedDictionary.m in the list and type -fobjc-arc into the popover. 24 | 25 | If you wish to convert your whole project to ARC, comment out the #error line in OrderedDictionary.m, then run the Edit > Refactor > Convert to Objective-C ARC... tool in Xcode and make sure all files that you wish to use ARC for (including OrderedDictionary.m) are checked. 26 | 27 | 28 | Thread Safety 29 | -------------- 30 | 31 | Access to an OrderedDictionary is inherently thread safe because it is immutable. Access to a MutableOrderedDictionary is not thread safe unless you ensure that no thread attempts to read from the dictionary whilst another is writing to it. 32 | 33 | 34 | Installation 35 | -------------- 36 | 37 | To install OrderedDictionary into your app, drag the OrderedDictionary.h and .m files into your project. 38 | 39 | 40 | Release Notes 41 | --------------- 42 | 43 | Version 1.2 44 | 45 | - Now supports NSCoding 46 | - Now supports reading and writing from a property list (order and mutability preserved) 47 | - Added keyAtIndex: method 48 | - Added replaceObjectAtIndex:withObject: and setObject:atIndexedSubscript: methods 49 | - Added exchangeObjectAtIndex:withObjectAtIndex: method 50 | - setObject:forKeyedSubscript: now works with non-string keys 51 | - Now uses NSOrderedSet internally, for better performance 52 | - Added unit tests 53 | 54 | Version 1.1.1 55 | 56 | - Added enumerateKeysAndObjectsWithIndexUsingBlock: method 57 | - Now conforms to -Weverything warning level 58 | 59 | Version 1.1 60 | 61 | - Now requires ARC 62 | - Updated to remove warnings in latest iOS 63 | - Removed OrderedMutableDictionary variant 64 | - Now complies to -Wextra warning level 65 | - Added podspec 66 | 67 | Version 1.0 68 | 69 | - Initial release -------------------------------------------------------------------------------- /CalendarLib/MGCStandardEventView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCStandardEventView.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import "MGCEventView.h" 32 | 33 | 34 | /*! Presentation styles for the view */ 35 | typedef NS_OPTIONS(NSUInteger, MGCStandardEventViewStyle) { 36 | MGCStandardEventViewStyleDefault = 0, // transparent background 37 | MGCStandardEventViewStylePlain = 1 << 0, // plain background 38 | MGCStandardEventViewStyleDot = 1 << 1, // event details are preceded by a dot (e.g to indicate a timed event in the month planner view) 39 | MGCStandardEventViewStyleBorder = 1 << 2, // view shows a left border (e.g timed events in the day planner view) 40 | MGCStandardEventViewStyleSubtitle = 1 << 3, // view shows the subtitle string 41 | MGCStandardEventViewStyleDetail = 1 << 4 // view shows the detail string 42 | }; 43 | 44 | 45 | /*! 46 | * This subclass of MGCEventView can be used to display the basic properties of an event 47 | * in a way similar to iCal. 48 | * It is the view class used by the EventKit specialized day/month planner view controllers. 49 | */ 50 | @interface MGCStandardEventView : MGCEventView 51 | 52 | /*! Title of the event - displayed in bold */ 53 | @property (nonatomic, copy) NSString *title; 54 | 55 | /*! Subtitle - diplayed below the title or next to it if the view is not large enough. */ 56 | @property (nonatomic, copy) NSString *subtitle; 57 | 58 | /*! Detail - displayed with a smaller font and right aligned. */ 59 | @property (nonatomic, copy) NSString *detail; 60 | 61 | /*! The color is used for background or text, depending on the style. */ 62 | @property (nonatomic) UIColor *color; 63 | 64 | /*! Style of the view. */ 65 | @property (nonatomic) MGCStandardEventViewStyle style; 66 | 67 | /*! Font used to draw the event content. Defaults to system font. */ 68 | @property (nonatomic) UIFont *font; 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /CalendarLib/MGCInteractiveEventView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGCInteractiveEventCell.m 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import "MGCInteractiveEventView.h" 32 | 33 | 34 | @interface MGCInteractiveEventView () 35 | 36 | @property (nonatomic) CATextLayer *forbiddenSignLayer; 37 | 38 | @end 39 | 40 | 41 | @implementation MGCInteractiveEventView 42 | 43 | - (instancetype)initWithFrame:(CGRect)frame 44 | { 45 | if (self = [super initWithFrame:frame]) { 46 | _forbiddenSignVisible = NO; 47 | } 48 | return self; 49 | } 50 | 51 | - (void)setEventView:(MGCEventView*)eventView 52 | { 53 | if (eventView != _eventView) { 54 | [self.eventView removeFromSuperview]; 55 | [self addSubview:eventView]; 56 | 57 | eventView.selected = YES; 58 | [self setNeedsLayout]; 59 | 60 | _eventView = eventView; 61 | } 62 | } 63 | 64 | - (void)setForbiddenSignVisible:(BOOL)forbiddenSignVisible 65 | { 66 | if (_forbiddenSignVisible != forbiddenSignVisible) { 67 | self.forbiddenSignLayer.hidden = !forbiddenSignVisible; 68 | _forbiddenSignVisible = forbiddenSignVisible; 69 | } 70 | } 71 | 72 | - (CATextLayer*)forbiddenSignLayer 73 | { 74 | if (_forbiddenSignLayer == nil) { 75 | _forbiddenSignLayer = [CATextLayer layer]; 76 | _forbiddenSignLayer.string = @"\u26D4"; //@"\U0001F6AB"; //@"\u20E0" 77 | _forbiddenSignLayer.fontSize = 16; 78 | _forbiddenSignLayer.contentsScale = [[UIScreen mainScreen] scale]; 79 | _forbiddenSignLayer.alignmentMode = kCAAlignmentCenter; 80 | _forbiddenSignLayer.frame = CGRectMake(0,0,30,30); 81 | _forbiddenSignLayer.zPosition = 10; 82 | _forbiddenSignLayer.position = CGPointMake(0,0); 83 | 84 | [self.layer addSublayer:_forbiddenSignLayer]; 85 | } 86 | return _forbiddenSignLayer; 87 | } 88 | 89 | - (void)layoutSubviews 90 | { 91 | [super layoutSubviews]; 92 | self.eventView.frame = self.bounds; 93 | } 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /CalendarLib/MGCTimeRowsView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCTimeRowsView.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | #import "MGCDayPlannerView.h" // for MGCDayPlannerTimeMark enum 33 | 34 | 35 | @protocol MGCTimeRowsViewDelegate; 36 | 37 | 38 | // This view is used by the day planner view to draw the time lines. 39 | // It is contained in a scrollview, which itself is a subview of the day planner view. 40 | @interface MGCTimeRowsView : UIView 41 | 42 | @property (nonatomic) NSCalendar *calendar; // used to calculate current time 43 | @property (nonatomic) CGFloat hourSlotHeight; // height of a one-hour slot (default is 65) 44 | @property (nonatomic) CGFloat insetsHeight; // top and bottom margin height (default is 45) 45 | @property (nonatomic) CGFloat timeColumnWidth; // width of the time column on the left side (default is 40) 46 | @property (nonatomic) NSTimeInterval timeMark; // time from start of day for the mark that appears when an event is moved around - set to 0 to hide it 47 | @property (nonatomic) BOOL showsCurrentTime; // YES if shows red line for current time 48 | @property (nonatomic, readonly) BOOL showsHalfHourLines; // returns YES if hourSlotHeight > 100 49 | @property (nonatomic) NSRange hourRange; // range of displayed hours 50 | @property (nonatomic) UIFont *font; // font used for time marks 51 | @property (nonatomic) UIColor *timeColor; // color used for time marks and lines 52 | @property (nonatomic) UIColor *currentTimeColor; // color used for current time mark and line 53 | @property (nonatomic, weak) id delegate; 54 | 55 | @end 56 | 57 | 58 | @protocol MGCTimeRowsViewDelegate 59 | 60 | @optional 61 | 62 | - (NSAttributedString*)timeRowsView:(MGCTimeRowsView*)view attributedStringForTimeMark:(MGCDayPlannerTimeMark)mark time:(NSTimeInterval)ti; 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /CalendarLib/MGCDayColumnCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCDayColumnCell.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | 33 | 34 | typedef enum : NSUInteger 35 | { 36 | MGCDayColumnCellAccessoryNone = 0, 37 | MGCDayColumnCellAccessoryDot = 1 << 0, // draw a dot under the day label (e.g. to indicate events on that day) 38 | MGCDayColumnCellAccessoryMark = 1 << 1, // draw a mark around the day figure (e.g. to indicate today) 39 | MGCDayColumnCellAccessoryBorder = 1 << 2, // draw a border on the left side of the cell (day separator) 40 | MGCDayColumnCellAccessorySeparator = 1 << 3 // draw a thick border (week separator) 41 | } MGCDayColumnCellAccessoryType; 42 | 43 | 44 | // This collection view cell is used by the day planner view's subview dayColumnView. 45 | // It is responsible for drawing the day header and vertical separator between columns. 46 | // The day header displays the date, which can be marked, and eventually a dot below 47 | // that can indicate the presence of events. It can also show an activity indicator which 48 | // can be set visible while events are loading (see MGCDayPlannerView setActivityIndicatorVisible:forDate:) 49 | @interface MGCDayColumnCell : UICollectionViewCell 50 | 51 | @property (nonatomic, readonly) UILabel *dayLabel; // label displaying dates 52 | @property (nonatomic) MGCDayColumnCellAccessoryType accessoryTypes; // presentation style of the view 53 | @property (nonatomic) UIColor *markColor; // color of the mark around the date (default is black) 54 | @property (nonatomic) UIColor *dotColor; // color of the dot (default is blue) 55 | @property (nonatomic) UIColor *separatorColor; // color of the separator line (default is light gray) 56 | @property (nonatomic) CGFloat headerHeight; // height of the header 57 | 58 | - (void)setActivityIndicatorVisible:(BOOL)visible; 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /CalendarLib/Constant.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef CalendarDemo_Constant_h 4 | #define CalendarDemo_Constant_h 5 | 6 | //========================================================================================= 7 | /* CREATE ALL CONSTANT FOR APP */ 8 | //========================================================================================= 9 | 10 | 11 | #define APP_NAME @"CalendarDemo" 12 | 13 | #define IS_IPHONE_4S [[UIScreen mainScreen] bounds].size.height == 480 14 | #define IS_IPHONE_5 [[UIScreen mainScreen] bounds].size.height == 568 15 | #define IS_IPHONE_6 [[UIScreen mainScreen] bounds].size.height == 667 16 | #define IS_IPHONE_6_PLUS [[UIScreen mainScreen] bounds].size.height == 736 17 | 18 | #define DeviceHeight [UIScreen mainScreen].bounds.size.height 19 | #define DeviceWidth [UIScreen mainScreen].bounds.size.width 20 | #define IOS7VERSION ([[[UIDevice currentDevice] systemVersion] floatValue]>=7.0?YES:NO) 21 | 22 | 23 | #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) 24 | #define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) 25 | #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) 26 | #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) 27 | #define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending) 28 | 29 | #define RGBCOLOR(r, g, b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1] 30 | #define RGBA(r, g, b, a) [UIColor colorWithRed:(float)r / 255.0f green:(float)g / 255.0f blue:(float)b / 255.0f alpha:a] 31 | #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] 32 | 33 | 34 | 35 | //define font 36 | #define font10 [UIFont systemFontOfSize:10.0]; 37 | #define font12 [UIFont systemFontOfSize:12.0]; 38 | #define font13 [UIFont systemFontOfSize:13.0]; 39 | #define font14 [UIFont systemFontOfSize:14.0]; 40 | #define font15 [UIFont systemFontOfSize:15.0]; 41 | #define font16 [UIFont systemFontOfSize:16.0]; 42 | #define font17 [UIFont systemFontOfSize:17.0]; 43 | #define font18 [UIFont systemFontOfSize:18.0]; 44 | #define font24 [UIFont systemFontOfSize:24.0]; 45 | #define font12Bold [UIFont fontWithName:@"Helvetica-Bold" size:12.0]; 46 | #define font13Bold [UIFont fontWithName:@"Helvetica-Bold" size:13.0]; 47 | #define font14Bold [UIFont fontWithName:@"Helvetica-Bold" size:14.0]; 48 | #define font15Bold [UIFont fontWithName:@"Helvetica-Bold" size:15.0]; 49 | #define font17Bold [UIFont fontWithName:@"Helvetica-Bold" size:17.0]; 50 | #define font18Bold [UIFont fontWithName:@"Helvetica-Bold" size:18.0]; 51 | #define APPEngine [IMEngine shareEngine] 52 | 53 | 54 | #define IDIOM UI_USER_INTERFACE_IDIOM() 55 | #define IPAD UIUserInterfaceIdiomPad 56 | 57 | 58 | #define isiPad (IDIOM == IPAD ? YES:NO) 59 | 60 | #define kHeaderHeight 100 61 | 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /CalendarLib/MGCReusableObjectQueue.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCReusableObjectQueue.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | 33 | 34 | /*! 35 | * Any object than can be placed in an MGCReusableObjectQueue 36 | * should implement this protocol. 37 | */ 38 | @protocol MGCReusableObject 39 | 40 | /*! Reuse identifier - set by the queue. */ 41 | @property (nonatomic, copy) NSString *reuseIdentifier; 42 | 43 | @optional 44 | 45 | /*! Performs any clean up necessary to prepare the object for use again. 46 | * If implemented, it is called when an object is dequeued. 47 | */ 48 | - (void)prepareForReuse; 49 | 50 | @end 51 | 52 | 53 | /*! 54 | * Implements a queue allowing expensive objects like UIViews to be reused, 55 | * in order to reduce memory allocations. 56 | */ 57 | @interface MGCReusableObjectQueue : NSObject 58 | 59 | /*! Returns the total number of objects currently stored in the queue. */ 60 | @property (readonly) NSUInteger count; 61 | 62 | /*! Returns the total number of objects that were allocated by this queue - for debugging purposes */ 63 | @property (readonly) NSUInteger totalCreated; 64 | 65 | /*! Returns a default shared queue. */ 66 | + (instancetype)defaultQueue; 67 | 68 | /*! Enqueues an object, making it available for reuse. */ 69 | - (void)enqueueReusableObject:(id)object; 70 | 71 | /*! Returns an object whose class was previously registered with given identifier. 72 | * If an object is available in the queue, it is returned. Otherwise, a new object is allocated. 73 | */ 74 | - (id)dequeueReusableObjectWithReuseIdentifier:(NSString*)identifier; 75 | 76 | /*! Registers an object class in the queue, for a given identifier. 77 | * If objectClass is nil, all unused objects in the queue with given identifier are removed. 78 | */ 79 | - (void)registerClass:(Class)objectClass forObjectWithReuseIdentifier:(NSString*)identifier; 80 | 81 | /*! Removes all unused objects from the queue. */ 82 | - (void)removeAllObjects; 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /CalendarLib/MGCEventsRowView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCEventsRowView.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | #import "MGCEventView.h" 33 | #import "MGCReusableObjectQueue.h" 34 | 35 | 36 | @class MGCEventsRowView; 37 | 38 | @protocol MGCEventsRowViewDelegate 39 | 40 | - (NSUInteger)eventsRowView:(MGCEventsRowView*)view numberOfEventsForDayAtIndex:(NSUInteger)day; 41 | - (NSRange)eventsRowView:(MGCEventsRowView*)view rangeForEventAtIndexPath:(NSIndexPath*)indexPath; 42 | - (MGCEventView*)eventsRowView:(MGCEventsRowView*)view cellForEventAtIndexPath:(NSIndexPath*)indexPath; 43 | 44 | @optional 45 | 46 | - (CGFloat)eventsRowView:(MGCEventsRowView*)view widthForDayRange:(NSRange)range; 47 | - (BOOL)eventsRowView:(MGCEventsRowView*)view shouldSelectCellAtIndexPath:(NSIndexPath*)indexPath; 48 | - (void)eventsRowView:(MGCEventsRowView*)view didSelectCellAtIndexPath:(NSIndexPath*)indexPath; 49 | - (BOOL)eventsRowView:(MGCEventsRowView*)view shouldDeselectCellAtIndexPath:(NSIndexPath*)indexPath; 50 | - (void)eventsRowView:(MGCEventsRowView*)view didDeselectCellAtIndexPath:(NSIndexPath*)indexPath; 51 | - (void)eventsRowView:(MGCEventsRowView*)view willDisplayCell:(MGCEventView*)cell forEventAtIndexPath:(NSIndexPath*)indexPath; 52 | - (void)eventsRowView:(MGCEventsRowView*)view didEndDisplayingCell:(MGCEventView*)cell forEventAtIndexPath:(NSIndexPath*)indexPath; 53 | 54 | @end 55 | 56 | 57 | @interface MGCEventsRowView : UIScrollView 58 | 59 | @property (nonatomic, copy) NSString *reuseIdentifier; 60 | @property (nonatomic, copy) NSDate *referenceDate; 61 | @property (nonatomic) NSRange daysRange; 62 | @property (nonatomic) CGFloat dayWidth; 63 | @property (nonatomic) CGFloat itemHeight; 64 | @property (nonatomic, weak) id delegate; 65 | @property (nonatomic, readonly) NSUInteger maxVisibleLines; 66 | //@property (nonatomic) BOOL limitsToVisibleHeight; 67 | 68 | - (void)reload; 69 | - (NSArray*)cellsInRect:(CGRect)rect; 70 | - (NSIndexPath*)indexPathForCellAtPoint:(CGPoint)pt; 71 | - (MGCEventView*)cellAtIndexPath:(NSIndexPath*)indexPath; 72 | 73 | @end 74 | 75 | -------------------------------------------------------------------------------- /CalendarDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CalendarDemo - Graphical Calendars Library for iOS 4 | // 5 | // Copyright (c) 2014-2015 Julien Martin. All rights reserved. 6 | // 7 | 8 | #import "AppDelegate.h" 9 | 10 | 11 | //#define MEMORY_WARNING_SIMULATE 1 12 | 13 | // http://www.vinnycoyne.com/post/55595095421/ios-simulate-on-device-memory-warnings 14 | #if MEMORY_WARNING_SIMULATE 15 | #import 16 | #endif 17 | 18 | @implementation AppDelegate 19 | 20 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 21 | { 22 | //self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 23 | // Override point for customization after application launch. 24 | self.window.backgroundColor = [UIColor colorWithRed:(247/255.0) green:(247/255.0) blue:(247/255.0) alpha:1]; 25 | self.window.tintColor = [UIColor redColor]; 26 | //[self.window makeKeyAndVisible]; 27 | 28 | #if MEMORY_WARNING_SIMULATE 29 | 30 | // Debug code that lets us simulate memory warnings by pressing the device's volume buttons. 31 | // Don't ever ship this code, as it will be rejected by Apple. 32 | 33 | MPVolumeView *volume = [[MPVolumeView alloc] initWithFrame:CGRectZero]; 34 | [self.window addSubview:volume]; 35 | 36 | // Register to receive the button-press notifications 37 | 38 | __block id volumeObserver; 39 | 40 | volumeObserver = [[NSNotificationCenter defaultCenter] addObserverForName:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil queue:nil usingBlock:^(NSNotification *note) { 41 | NSLog(@"Manually simulating a memory warning."); 42 | [[UIApplication sharedApplication] performSelector:@selector(_performMemoryWarning)]; 43 | }]; 44 | 45 | #endif 46 | return YES; 47 | } 48 | 49 | - (void)applicationWillResignActive:(UIApplication *)application 50 | { 51 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 52 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 53 | } 54 | 55 | - (void)applicationDidEnterBackground:(UIApplication *)application 56 | { 57 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 58 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 59 | } 60 | 61 | - (void)applicationWillEnterForeground:(UIApplication *)application 62 | { 63 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 64 | } 65 | 66 | - (void)applicationDidBecomeActive:(UIApplication *)application 67 | { 68 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 69 | } 70 | 71 | - (void)applicationWillTerminate:(UIApplication *)application 72 | { 73 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /CalendarLib/MGCCalendarHeaderCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGCCalendarHeaderCell.m 3 | // Calendar 4 | // 5 | // Copyright © 2016 Julien Martin. All rights reserved. 6 | // 7 | 8 | #import "MGCCalendarHeaderCell.h" 9 | 10 | @interface MGCCalendarHeaderCell () 11 | 12 | @property (nonatomic, assign, getter=isToday) BOOL today; 13 | @property (nonatomic, assign, getter=isWeekend) BOOL weekend; 14 | 15 | //colors 16 | @property (nonatomic, strong) UIColor *selectedDayBackgroundColor; 17 | @property (nonatomic, strong) UIColor *selectedDayTextColor; 18 | @property (nonatomic, strong) UIColor *todayColor; 19 | @property (nonatomic, strong) UIColor *weekendColor; 20 | 21 | 22 | @end 23 | 24 | @implementation MGCCalendarHeaderCell 25 | 26 | - (instancetype)initWithCoder:(NSCoder*)aDecoder 27 | { 28 | self = [super initWithCoder:aDecoder]; 29 | if (self) { 30 | self.selectedDayBackgroundColor = [UIColor darkGrayColor]; 31 | self.selectedDayTextColor = [UIColor whiteColor]; 32 | self.todayColor = [UIColor redColor]; 33 | self.weekendColor = [UIColor grayColor]; 34 | } 35 | return self; 36 | } 37 | 38 | - (void)setDate:(NSDate *)date{ 39 | _date = date; 40 | 41 | NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init]; 42 | 43 | [dateFormatter setDateFormat:@"E"]; 44 | 45 | self.dayNameLabel.text = [dateFormatter stringFromDate:date]; 46 | 47 | [dateFormatter setDateFormat:@"d"]; 48 | 49 | self.dayNumberLabel.text = [dateFormatter stringFromDate:date]; 50 | 51 | //the cell is the current day 52 | self.today = [[NSCalendar currentCalendar] isDate:[NSDate date] inSameDayAsDate:date]; 53 | 54 | //tthe cell is a weekend day 55 | self.weekend = [[NSCalendar currentCalendar] isDateInWeekend:date]; 56 | } 57 | 58 | - (void)setSelected:(BOOL)selected{ 59 | 60 | [super setSelected:selected]; 61 | 62 | //force layout to color the view 63 | [self setNeedsLayout]; 64 | 65 | } 66 | 67 | - (void)layoutSubviews 68 | { 69 | [super layoutSubviews]; 70 | 71 | if (self.isSelected) { 72 | self.dayNumberLabel.backgroundColor = self.selectedDayBackgroundColor; 73 | self.dayNumberLabel.layer.masksToBounds = YES; 74 | self.dayNumberLabel.layer.cornerRadius = 15.0; 75 | self.dayNumberLabel.textColor = self.selectedDayTextColor; 76 | } 77 | else { 78 | self.dayNumberLabel.backgroundColor = [UIColor clearColor]; 79 | self.dayNumberLabel.textColor = self.selectedDayBackgroundColor; 80 | } 81 | 82 | if (self.isToday) { 83 | self.dayNumberLabel.textColor = self.todayColor; 84 | self.dayNameLabel.textColor = self.todayColor; 85 | } 86 | if (self.isWeekend && !self.isToday) { 87 | self.dayNumberLabel.textColor = self.weekendColor; 88 | self.dayNameLabel.textColor = self.weekendColor; 89 | } 90 | } 91 | 92 | - (void)prepareForReuse 93 | { 94 | [super prepareForReuse]; 95 | 96 | self.dayNameLabel.textColor = [UIColor blackColor]; 97 | self.dayNumberLabel.textColor = [UIColor blackColor]; 98 | self.today = NO; 99 | self.weekend = NO; 100 | self.selectedDayBackgroundColor = [UIColor darkGrayColor]; 101 | self.selectedDayTextColor = [UIColor whiteColor]; 102 | self.todayColor = [UIColor redColor]; 103 | self.weekendColor = [UIColor grayColor]; 104 | } 105 | 106 | @end 107 | -------------------------------------------------------------------------------- /CalendarLib/MGCEventView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCEventView.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | #import "MGCReusableObjectQueue.h" 33 | #import "MGCDayPlannerView.h" 34 | 35 | 36 | /*! 37 | * MGCEventView is used by MGCDayPlannerView and MGCMonthPlannerView to present the content of single events. 38 | * You can subclass this class or use the already existing subclass MGCStandardEventView, which supports the 39 | * display of basic event properties such as title and location. 40 | * You must register your custom class(es) with the day/month planner view object and when needed 41 | * call dequeueReusableViewWithIdentifier:forEvent... methods to retrieve an instance of the appropriate class, 42 | * depending on the event being displayed. 43 | * 44 | * Because event view objects may be copied by the day/month planner view, make sure your subclass conforms 45 | * to the NSCopying protocol and copies custom properties to new instances. 46 | */ 47 | @interface MGCEventView : UIView 48 | 49 | /*! @brief A string that identifies the purpose of the view. 50 | * @discussion This is set by the day/month planner view and should not be set directly. 51 | */ 52 | @property (nonatomic, copy) NSString *reuseIdentifier; 53 | 54 | /*! @brief The selection state of the view. 55 | * @discussion This should not be set directly. 56 | * To (de)select an event, use the selection methods of the day/month planner view. 57 | */ 58 | @property (nonatomic) BOOL selected; 59 | 60 | /*! @brief Height of the visible portion of the view. 61 | * @discussion If the view is partially hidden by an other event view, you can use this property 62 | * to determine the available height to show the event content. 63 | * You should not set this property directly. 64 | */ 65 | @property (nonatomic) CGFloat visibleHeight; 66 | 67 | /*! @brief This is called by the day planner view when an event view is dragged around and the 68 | * target event type is changing. 69 | * @discussion By implementing this method in your subclass, you can change the way the view 70 | * displays the content of the event. 71 | */ 72 | - (void)didTransitionToEventType:(MGCEventType)toType; 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /CalendarDemo/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "8.0", 8 | "subtype" : "736h", 9 | "scale" : "3x" 10 | }, 11 | { 12 | "orientation" : "landscape", 13 | "idiom" : "iphone", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "8.0", 16 | "subtype" : "736h", 17 | "scale" : "3x" 18 | }, 19 | { 20 | "orientation" : "portrait", 21 | "idiom" : "iphone", 22 | "extent" : "full-screen", 23 | "minimum-system-version" : "8.0", 24 | "subtype" : "667h", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "orientation" : "portrait", 29 | "idiom" : "iphone", 30 | "extent" : "full-screen", 31 | "minimum-system-version" : "7.0", 32 | "scale" : "2x" 33 | }, 34 | { 35 | "orientation" : "portrait", 36 | "idiom" : "iphone", 37 | "extent" : "full-screen", 38 | "minimum-system-version" : "7.0", 39 | "subtype" : "retina4", 40 | "scale" : "2x" 41 | }, 42 | { 43 | "orientation" : "portrait", 44 | "idiom" : "ipad", 45 | "extent" : "full-screen", 46 | "minimum-system-version" : "7.0", 47 | "scale" : "1x" 48 | }, 49 | { 50 | "orientation" : "landscape", 51 | "idiom" : "ipad", 52 | "extent" : "full-screen", 53 | "minimum-system-version" : "7.0", 54 | "scale" : "1x" 55 | }, 56 | { 57 | "orientation" : "portrait", 58 | "idiom" : "ipad", 59 | "extent" : "full-screen", 60 | "minimum-system-version" : "7.0", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "orientation" : "landscape", 65 | "idiom" : "ipad", 66 | "extent" : "full-screen", 67 | "minimum-system-version" : "7.0", 68 | "scale" : "2x" 69 | }, 70 | { 71 | "orientation" : "portrait", 72 | "idiom" : "iphone", 73 | "extent" : "full-screen", 74 | "scale" : "1x" 75 | }, 76 | { 77 | "orientation" : "portrait", 78 | "idiom" : "iphone", 79 | "extent" : "full-screen", 80 | "scale" : "2x" 81 | }, 82 | { 83 | "orientation" : "portrait", 84 | "idiom" : "iphone", 85 | "extent" : "full-screen", 86 | "subtype" : "retina4", 87 | "scale" : "2x" 88 | }, 89 | { 90 | "orientation" : "portrait", 91 | "idiom" : "ipad", 92 | "extent" : "to-status-bar", 93 | "scale" : "1x" 94 | }, 95 | { 96 | "orientation" : "portrait", 97 | "idiom" : "ipad", 98 | "extent" : "full-screen", 99 | "scale" : "1x" 100 | }, 101 | { 102 | "orientation" : "landscape", 103 | "idiom" : "ipad", 104 | "extent" : "to-status-bar", 105 | "scale" : "1x" 106 | }, 107 | { 108 | "orientation" : "landscape", 109 | "idiom" : "ipad", 110 | "extent" : "full-screen", 111 | "scale" : "1x" 112 | }, 113 | { 114 | "orientation" : "portrait", 115 | "idiom" : "ipad", 116 | "extent" : "to-status-bar", 117 | "scale" : "2x" 118 | }, 119 | { 120 | "orientation" : "portrait", 121 | "idiom" : "ipad", 122 | "extent" : "full-screen", 123 | "scale" : "2x" 124 | }, 125 | { 126 | "orientation" : "landscape", 127 | "idiom" : "ipad", 128 | "extent" : "to-status-bar", 129 | "scale" : "2x" 130 | }, 131 | { 132 | "orientation" : "landscape", 133 | "idiom" : "ipad", 134 | "extent" : "full-screen", 135 | "scale" : "2x" 136 | } 137 | ], 138 | "info" : { 139 | "version" : 1, 140 | "author" : "xcode" 141 | } 142 | } -------------------------------------------------------------------------------- /CalendarLib/MGCTimedEventsViewLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCTimedEventsViewLayout.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | 33 | static NSString* const DimmingViewKind = @"DimmingViewKind"; 34 | 35 | typedef enum : NSUInteger 36 | { 37 | TimedEventCoveringTypeClassic = 0, 38 | TimedEventCoveringTypeComplex = 1 << 0, 39 | } TimedEventCoveringType; 40 | 41 | 42 | @protocol MGCTimedEventsViewLayoutDelegate; 43 | @class MGCEventCellLayoutAttributes; 44 | 45 | 46 | // Custom invalidation context for MGCTimedEventsViewLayout 47 | @interface MGCTimedEventsViewLayoutInvalidationContext: UICollectionViewLayoutInvalidationContext 48 | 49 | @property (nonatomic) BOOL invalidateDimmingViews; // set to true if layout attributes of dimming views must be recomputed 50 | @property (nonatomic) BOOL invalidateEventCells; // set to true if layout attributes of event cells must be recomputed 51 | @property (nonatomic) NSMutableIndexSet *invalidatedSections; // sections whose layout attributes (dimming views or event cells) must be recomputed - if nil, recompute everything 52 | 53 | @end 54 | 55 | 56 | // This collection view layout is responsible for the layout of event views in the timed-events part 57 | // of the day planner view. 58 | @interface MGCTimedEventsViewLayout : UICollectionViewLayout 59 | 60 | @property (nonatomic, weak) id delegate; 61 | @property (nonatomic) CGSize dayColumnSize; 62 | @property (nonatomic) CGFloat minimumVisibleHeight; // if 2 cells overlap, and the height of the uncovered part of the upper cell is less than this value, the column is split 63 | @property (nonatomic) BOOL ignoreNextInvalidation; // for some reason, UICollectionView reloadSections: messes up with scrolling and animations so we have to stick with using reloadData even when only individual sections need to be invalidated. As a workaroud, we explicitly invalidate them with custom context, and set this flag to YES before calling reloadData 64 | @property (nonatomic) TimedEventCoveringType coveringType; // how to handle event covering 65 | 66 | @end 67 | 68 | 69 | @protocol MGCTimedEventsViewLayoutDelegate 70 | 71 | // x and width of returned rect are ignored 72 | - (CGRect)collectionView:(UICollectionView*)collectionView layout:(MGCTimedEventsViewLayout*)layout rectForEventAtIndexPath:(NSIndexPath*)indexPath; 73 | - (NSArray*)collectionView:(UICollectionView*)collectionView layout:(MGCTimedEventsViewLayout*)layout dimmingRectsForSection:(NSUInteger)section; 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /Pods/OrderedDictionary/OrderedDictionary/OrderedDictionary.h: -------------------------------------------------------------------------------- 1 | // 2 | // OrderedDictionary.h 3 | // 4 | // Version 1.2 5 | // 6 | // Created by Nick Lockwood on 21/09/2010. 7 | // Copyright 2010 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib license 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/OrderedDictionary 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | #import 34 | 35 | /** 36 | * Ordered subclass of NSDictionary. 37 | * Supports all the same methods as NSDictionary, plus a few 38 | * new methods for operating on entities by index rather than key. 39 | */ 40 | @interface OrderedDictionary : NSDictionary 41 | 42 | + (instancetype)dictionaryWithContentsOfFile:(NSString *)path; 43 | + (instancetype)dictionaryWithContentsOfURL:(NSURL *)url; 44 | 45 | /** Returns the nth key in the dictionary. */ 46 | - (id)keyAtIndex:(NSUInteger)index; 47 | /** Returns the nth object in the dictionary. */ 48 | - (id)objectAtIndex:(NSUInteger)index; 49 | - (id)objectAtIndexedSubscript:(NSUInteger)index; 50 | /** Returns the index of the specified key, or NSNotFound if key is not found. */ 51 | - (NSUInteger)indexOfKey:(id)key; 52 | /** Returns an enumerator for backwards traversal of the dictionary keys. */ 53 | - (NSEnumerator *)reverseKeyEnumerator; 54 | /** Returns an enumerator for backwards traversal of the dictionary objects. */ 55 | - (NSEnumerator *)reverseObjectEnumerator; 56 | /** Enumerates keys ands objects with index using block. */ 57 | - (void)enumerateKeysAndObjectsWithIndexUsingBlock:(void (^)(id key, id obj, NSUInteger idx, BOOL *stop))block; 58 | 59 | @end 60 | 61 | 62 | /** 63 | * Mutable subclass of OrderedDictionary. 64 | * Supports all the same methods as NSMutableDictionary, plus a few 65 | * new methods for operating on entities by index rather than key. 66 | * Note that although it has the same interface, MutableOrderedDictionary 67 | * is not a subclass of NSMutableDictionary, and cannot be used as one 68 | * without generating compiler warnings (unless you cast it). 69 | */ 70 | @interface MutableOrderedDictionary : OrderedDictionary 71 | 72 | + (instancetype)dictionaryWithCapacity:(NSUInteger)count; 73 | - (instancetype)initWithCapacity:(NSUInteger)count; 74 | 75 | - (void)addEntriesFromDictionary:(NSDictionary *)otherDictionary; 76 | - (void)removeAllObjects; 77 | - (void)removeObjectForKey:(id)key; 78 | - (void)removeObjectsForKeys:(NSArray *)keyArray; 79 | - (void)setDictionary:(NSDictionary *)otherDictionary; 80 | - (void)setObject:(id)object forKey:(id)key; 81 | - (void)setObject:(id)object forKeyedSubscript:(id )key; 82 | 83 | /** Inserts an object at a specific index in the dictionary. */ 84 | - (void)insertObject:(id)object forKey:(id)key atIndex:(NSUInteger)index; 85 | /** Replace an object at a specific index in the dictionary. */ 86 | - (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)object; 87 | - (void)setObject:(id)object atIndexedSubscript:(NSUInteger)index; 88 | /** Swap the indexes of two key/value pairs in the dictionary. */ 89 | - (void)exchangeObjectAtIndex:(NSUInteger)idx1 withObjectAtIndex:(NSUInteger)idx2; 90 | /** Removes the nth object in the dictionary. */ 91 | - (void)removeObjectAtIndex:(NSUInteger)index; 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /CalendarLib/MGCMonthPlannerBackgroundView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGCMonthPlannerBackgroundView.m 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import "MGCMonthPlannerBackgroundView.h" 32 | 33 | 34 | @implementation MGCMonthPlannerBackgroundView 35 | 36 | - (id)initWithFrame:(CGRect)frame 37 | { 38 | if (self = [super initWithFrame:frame]) { 39 | self.backgroundColor = [UIColor clearColor]; 40 | self.userInteractionEnabled = NO; 41 | self.gridColor = [UIColor colorWithRed:.6f green:.6f blue:.6f alpha:1.]; 42 | self.lastColumn = 7; 43 | self.drawHorizontalLines = YES; 44 | self.drawVerticalLines = YES; 45 | } 46 | return self; 47 | } 48 | 49 | - (void)layoutSubviews 50 | { 51 | [super layoutSubviews]; 52 | [self setNeedsDisplay]; 53 | } 54 | 55 | - (void)drawRect:(CGRect)rect 56 | { 57 | CGContextRef c = UIGraphicsGetCurrentContext(); 58 | 59 | CGFloat colWidth = self.numberOfColumns > 0 ? (self.bounds.size.width / self.numberOfColumns) : self.bounds.size.width; 60 | CGFloat rowHeight = self.numberOfRows > 0 ? (self.bounds.size.height / self.numberOfRows) : self.bounds.size.height; 61 | 62 | CGContextSetStrokeColorWithColor(c, self.gridColor.CGColor); 63 | CGContextSetLineWidth(c, .5); 64 | 65 | CGContextBeginPath(c); 66 | 67 | CGFloat x1, y1, x2, y2; 68 | 69 | if (self.drawHorizontalLines) { 70 | for (int i = 0; i <= self.numberOfRows && self.numberOfRows != 0; i++) { 71 | y2 = y1 = rowHeight * i; 72 | x1 = i == 0 ? self.firstColumn * colWidth : 0; 73 | x2 = i == self.numberOfRows ? self.lastColumn * colWidth : CGRectGetMaxX(rect); 74 | 75 | CGContextMoveToPoint(c, x1, y1); 76 | CGContextAddLineToPoint(c, x2, y2); 77 | } 78 | } 79 | 80 | if (self.dayCellHeaderHeight > 0.0f && self.drawBottomDayLabelLines) { 81 | for (int i = 0; i < self.numberOfRows && self.numberOfRows != 0; i++) { 82 | y2 = y1 = rowHeight * i + self.dayCellHeaderHeight; 83 | x1 = i == 0 ? self.firstColumn * colWidth : 0; 84 | x2 = (i == (self.numberOfRows - 1)) ? self.lastColumn * colWidth : CGRectGetMaxX(rect); 85 | 86 | CGContextMoveToPoint(c, x1, y1); 87 | CGContextAddLineToPoint(c, x2, y2); 88 | } 89 | } 90 | 91 | if (self.drawVerticalLines) { 92 | for (int j = 0; j <= self.numberOfColumns; j++) { 93 | x2 = x1 = colWidth * j; 94 | y1 = j < self.firstColumn ? rowHeight : 0; 95 | y2 = j <= self.lastColumn ? self.numberOfRows * rowHeight : (self.numberOfRows - 1) * rowHeight; 96 | 97 | CGContextMoveToPoint(c, x1, y1); 98 | CGContextAddLineToPoint(c, x2, y2); 99 | } 100 | } 101 | 102 | CGContextStrokePath(c); 103 | } 104 | 105 | @end 106 | -------------------------------------------------------------------------------- /CalendarLib/MGCMonthPlannerViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGCMonthPlannerViewController.m 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import "MGCMonthPlannerViewController.h" 32 | 33 | @interface MGCMonthPlannerViewController () 34 | 35 | @end 36 | 37 | @implementation MGCMonthPlannerViewController 38 | 39 | - (MGCMonthPlannerView*)monthPlannerView 40 | { 41 | return (MGCMonthPlannerView*)self.view; 42 | } 43 | 44 | - (void)setMonthPlannerView:(MGCMonthPlannerView*)monthPlannerView 45 | { 46 | [super setView:monthPlannerView]; 47 | 48 | if (!monthPlannerView.dataSource) 49 | monthPlannerView.dataSource = self; 50 | 51 | if (!monthPlannerView.delegate) 52 | monthPlannerView.delegate = self; 53 | } 54 | 55 | - (void)loadView 56 | { 57 | if (self.nibName) 58 | { 59 | [super loadView]; 60 | NSAssert(self.monthPlannerView != nil, @"NIB file did not set monthPlannerView property."); 61 | return; 62 | } 63 | 64 | MGCMonthPlannerView *monthPlannerView = [[MGCMonthPlannerView alloc]initWithFrame:CGRectZero]; 65 | monthPlannerView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth; 66 | self.monthPlannerView = monthPlannerView; 67 | } 68 | 69 | - (void)viewDidLoad 70 | { 71 | [super viewDidLoad]; 72 | // Do any additional setup after loading the view. 73 | } 74 | 75 | - (void)didReceiveMemoryWarning 76 | { 77 | [super didReceiveMemoryWarning]; 78 | // Dispose of any resources that can be recreated. 79 | } 80 | 81 | /* 82 | #pragma mark - Navigation 83 | 84 | // In a storyboard-based application, you will often want to do a little preparation before navigation 85 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 86 | // Get the new view controller using [segue destinationViewController]. 87 | // Pass the selected object to the new view controller. 88 | } 89 | */ 90 | 91 | #pragma mark - MGCMonthPlannerViewDataSource 92 | 93 | - (NSInteger)monthPlannerView:(MGCMonthPlannerView*)view numberOfEventsAtDate:(NSDate*)date 94 | { 95 | return 0; 96 | } 97 | 98 | - (MGCEventView*)monthPlannerView:(MGCMonthPlannerView*)view cellForEventAtIndex:(NSUInteger)index date:(NSDate*)date 99 | { 100 | assert(@"monthPlannerView:cellForEventAtIndex:date: has to implemented in MGCMonthPlannerViewController subclasses."); 101 | return nil; 102 | } 103 | 104 | - (MGCDateRange*)monthPlannerView:(MGCMonthPlannerView*)view dateRangeForEventAtIndex:(NSUInteger)index date:(NSDate*)date 105 | { 106 | assert(@"monthPlannerView:dateRangeForEventAtIndex:date: has to implemented in MGCMonthPlannerViewController subclasses."); 107 | return nil; 108 | } 109 | 110 | - (MGCEventView*)monthPlannerView:(MGCMonthPlannerView *)view cellForNewEventAtDate:(NSDate*)date 111 | { 112 | assert(@"monthPlannerView:cellForNewEventAtDate: has to implemented in MGCMonthPlannerViewController subclasses."); 113 | return nil; 114 | } 115 | 116 | 117 | @end 118 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CalendarLib 2 | 3 | [![Version](https://img.shields.io/cocoapods/v/CalendarLib.svg?style=flat)](http://cocoapods.org/pods/CalendarLib) 4 | [![License](https://img.shields.io/cocoapods/l/CalendarLib.svg?style=flat)](http://cocoapods.org/pods/CalendarLib) 5 | [![Platform](https://img.shields.io/cocoapods/p/CalendarLib.svg?style=flat)](http://cocoapods.org/pods/CalendarLib) 6 | 7 | CalendarLib is a set of views and controllers for displaying and scheduling events on iOS. 8 | 9 | **Warning:** 10 | 11 | **As some people may have noticed, this project has not got any update recently, and a lot of issues / pull requests remain unanswered. 12 | I’m very sorry for that, but I don’t have any time at the moment to take care of this repo, being very busy with other projects. 13 | I may come back to it in the future, but meanwhile, please don’t expect any update soon.** 14 | 15 | **Thanks anyway to all the contributors!** 16 | 17 | 18 | 19 | ![Day Planner View](https://raw.githubusercontent.com/jumartin/Calendar/master/CalendarDocs/DayPlannerView.png "Day planner view") 20 | ![Day Planner View](https://raw.githubusercontent.com/jumartin/Calendar/master/CalendarDocs/DayPlannerView2.png) 21 | ![Month Planner View](https://raw.githubusercontent.com/jumartin/Calendar/master/CalendarDocs/MonthPlannerView.png "Month planner view") 22 | ![Month Planner View](https://raw.githubusercontent.com/jumartin/Calendar/master/CalendarDocs/MonthPlannerView2.png) 23 | ![Year Calendar View](https://raw.githubusercontent.com/jumartin/Calendar/master/CalendarDocs/YearView.png "Year calendar view") 24 | 25 | ## Features 26 | 27 | - Create and schedule events with iCal-like views and controllers 28 | - 3 kinds of views are available (a day planner view, a month planner view and a year view) 29 | - Scroll infinitely through days / months, or restrict scrolling to a given date range 30 | - Restrict range of displayed hours in the day planner view 31 | - Page through weeks in the day planner view or months in the month planner view 32 | - Use a standard view for event cells or create your own custom views 33 | - Easily customize appearance and layout (date format, colors, fonts, size of headers, number of visible days...) 34 | - Create events by tap-and-hold on the view 35 | - Drag-and-drop events to another date or time 36 | - Scroll through days / months while dragging 37 | - Specialized controllers for EventKit data source but can easily work with any custom event provider 38 | - Background event loading for the EventKit controllers 39 | - Ability to show an activity indicator for days while events are loading 40 | - Restrict ability to create or move events to certain dates through datasource protocol methods 41 | - Zoom in/out the day planner view to increase or decrease the height of hour slots 42 | - Dim certain time ranges in the day planner view 43 | 44 | ## Compatibility 45 | 46 | iPad / iPhone with iOS 8 or higher. 47 | 48 | ## Installation 49 | 50 | ### CocoaPods 51 | 52 | The best way is to use [CocoaPods](https://cocoapods.org/pods/CalendarLib). Add the following line to your Podfile : 53 | 54 | ```ruby 55 | pod "CalendarLib" 56 | ``` 57 | 58 | ### The old way 59 | 60 | If you don't want to use CocoaPods, you need to copy the content of the CalendarLib folder into your project, as well as the source of the two dependencies : [OSCache](https://github.com/nicklockwood/OSCache) and [OrderedDictionary](https://github.com/nicklockwood/OrderedDictionary). 61 | 62 | ## Getting started 63 | 64 | 1. If you want to use EventKit as a data source, create an instance of `MGCDayPlannerEKViewController` or `MGCMonthPlannerEKViewController`, or subclass them for your own needs. 65 | 66 | Don't forget to add the following frameworks to the project: 67 | 68 | - **EventKit.framework** 69 | - **EventKitUI.framework** 70 | 71 | 2. If you want to use another event provider, subclass one of `MGCDayPlannerViewController` or `MGCMonthPlannerViewController` and implement the data source protocol methods. 72 | 73 | 3. If you want to use a custom event cell, subclass `MGCEventView` or `MGCStandardEventView` and register the class with the day / month planner view. 74 | 75 | See the demo project to get an idea of how to use the library and check the [documentation](http://cocoadocs.org/docsets/CalendarLib/) 76 | 77 | ## License 78 | 79 | CalendarLib is available under the MIT license. See the LICENSE file. 80 | 81 | ## Change-log 82 | 83 | A summary of each CalendarLib release can be found in the [CHANGELOG](CHANGELOG.md). 84 | -------------------------------------------------------------------------------- /CalendarDemo/MonthViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MonthViewController.m 3 | // CalendarDemo - Graphical Calendars Library for iOS 4 | // 5 | // Copyright (c) 2014-2015 Julien Martin. All rights reserved. 6 | // 7 | 8 | #import "MonthViewController.h" 9 | #import "NSCalendar+MGCAdditions.h" 10 | #import "NSAttributedString+MGCAdditions.h" 11 | #import "Constant.h" 12 | 13 | 14 | @implementation MonthViewController 15 | 16 | #pragma mark - UIViewController 17 | 18 | - (void)viewDidLoad 19 | { 20 | [super viewDidLoad]; 21 | //self.monthPlannerView.dateFormat = @"dd MMM\nYYYY"; 22 | } 23 | 24 | #pragma mark - MGCMonthPlannerViewController 25 | 26 | - (void)monthPlannerViewDidScroll:(MGCMonthPlannerView *)view 27 | { 28 | [super monthPlannerViewDidScroll:view]; 29 | 30 | NSDate *date = [self.monthPlannerView dayAtPoint:self.monthPlannerView.center]; 31 | if (date && [self.delegate respondsToSelector:@selector(calendarViewController:didShowDate:)]) { 32 | [self.delegate calendarViewController:self didShowDate:date]; 33 | } 34 | } 35 | 36 | - (NSAttributedString*)monthPlannerView:(MGCMonthPlannerView *)view attributedStringForDayHeaderAtDate:(NSDate *)date 37 | { 38 | //return nil; 39 | 40 | static NSDateFormatter *dateFormatter = nil; 41 | if (dateFormatter == nil) { 42 | dateFormatter = [NSDateFormatter new]; 43 | } 44 | 45 | dateFormatter.dateFormat = @"d"; 46 | NSString *dayStr = [dateFormatter stringFromDate:date]; 47 | 48 | NSString *str = dayStr; 49 | 50 | if (dayStr.integerValue == 1) { 51 | dateFormatter.dateFormat = @"MMM d"; 52 | str = [dateFormatter stringFromDate:date]; 53 | } 54 | 55 | UIFont *font = [UIFont systemFontOfSize:isiPad ? 15 : 12]; 56 | NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc]initWithString:str attributes:@{ NSFontAttributeName: font }]; 57 | 58 | if ([self.calendar mgc_isDate:date sameDayAsDate:[NSDate date]]) { 59 | UIFont *boldFont = [UIFont boldSystemFontOfSize:isiPad ? 15 : 12]; 60 | 61 | MGCCircleMark *mark = [MGCCircleMark new]; 62 | mark.yOffset = boldFont.descender - mark.margin; 63 | 64 | [attrStr addAttributes:@{ NSFontAttributeName: boldFont, NSForegroundColorAttributeName: [UIColor whiteColor], MGCCircleMarkAttributeName: mark} range:[str rangeOfString:dayStr]]; 65 | 66 | [attrStr processCircleMarksInRange:NSMakeRange(0, attrStr.length)]; 67 | } 68 | 69 | NSMutableParagraphStyle *para = [NSMutableParagraphStyle new]; 70 | para.alignment = NSTextAlignmentRight; 71 | para.tailIndent = -6; 72 | 73 | [attrStr addAttributes:@{ NSParagraphStyleAttributeName: para } range:NSMakeRange(0, attrStr.length)]; 74 | 75 | return attrStr; 76 | } 77 | 78 | #pragma mark - CalendarViewControllerNavigation 79 | 80 | - (NSDate*)centerDate 81 | { 82 | MGCDateRange *visibleRange = [self.monthPlannerView visibleDays]; 83 | if (visibleRange) 84 | { 85 | NSUInteger dayCount = [self.calendar components:NSCalendarUnitDay fromDate:visibleRange.start toDate:visibleRange.end options:0].day; 86 | NSDateComponents *comp = [NSDateComponents new]; 87 | comp.day = dayCount / 2; 88 | NSDate *centerDate = [self.calendar dateByAddingComponents:comp toDate:visibleRange.start options:0]; 89 | return [self.calendar mgc_startOfWeekForDate:centerDate]; 90 | } 91 | return nil; 92 | } 93 | 94 | - (void)moveToDate:(NSDate*)date animated:(BOOL)animated 95 | { 96 | if (!self.monthPlannerView.dateRange || [self.monthPlannerView.dateRange containsDate:date]) { 97 | [self.monthPlannerView scrollToDate:date alignment:MGCMonthPlannerScrollAlignmentWeekRow animated:animated]; 98 | } 99 | } 100 | 101 | - (void)moveToNextPageAnimated:(BOOL)animated 102 | { 103 | NSDate *date = [self.calendar mgc_nextStartOfMonthForDate:self.monthPlannerView.visibleDays.start]; 104 | [self moveToDate:date animated:animated]; 105 | } 106 | 107 | - (void)moveToPreviousPageAnimated:(BOOL)animated 108 | { 109 | NSDate *date = [self.calendar mgc_startOfMonthForDate:self.monthPlannerView.visibleDays.start]; 110 | if ([self.monthPlannerView.visibleDays.start isEqualToDate:date]) { 111 | NSDateComponents *comps = [NSDateComponents new]; 112 | comps.month = -1; 113 | date = [self.calendar dateByAddingComponents:comps toDate:date options:0]; 114 | } 115 | [self moveToDate:date animated:animated]; 116 | } 117 | 118 | @end 119 | -------------------------------------------------------------------------------- /CalendarLib/MGCMonthPlannerViewDayCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGCMonthPlannerViewDayCell.m 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import "MGCMonthPlannerViewDayCell.h" 32 | 33 | static const CGFloat kHeaderMargin = 1; 34 | static const CGFloat kDotSize = 8; 35 | 36 | 37 | @interface MGCMonthPlannerViewDayCell () 38 | 39 | @property (nonatomic) CAShapeLayer *dotLayer; 40 | 41 | @end 42 | 43 | 44 | @implementation MGCMonthPlannerViewDayCell 45 | 46 | - (id)initWithFrame:(CGRect)frame 47 | { 48 | if (self = [super initWithFrame:frame]) { 49 | self.headerHeight = 20; 50 | self.backgroundColor = [UIColor whiteColor]; 51 | 52 | self.dayLabel = [[UILabel alloc]initWithFrame:CGRectZero]; 53 | self.dayLabel.font = [UIFont systemFontOfSize:[UIFont smallSystemFontSize]]; 54 | self.dayLabel.numberOfLines = 1; 55 | self.dayLabel.adjustsFontSizeToFitWidth = YES; 56 | 57 | [self.contentView addSubview:self.dayLabel]; 58 | 59 | self.dotLayer = [CAShapeLayer layer]; 60 | self.dotLayer.path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, kDotSize, kDotSize)].CGPath;; 61 | self.dotLayer.fillColor = [UIColor redColor].CGColor; 62 | self.dotLayer.hidden = YES; 63 | [self.contentView.layer addSublayer:self.dotLayer]; 64 | 65 | UIView *view = [UIView new]; 66 | view.backgroundColor = [UIColor colorWithWhite:.7 alpha:.2]; 67 | self.selectedBackgroundView = view; 68 | } 69 | return self; 70 | } 71 | 72 | - (void)prepareForReuse 73 | { 74 | self.showsDot = NO; 75 | } 76 | 77 | - (void)setDotColor:(UIColor *)dotColor 78 | { 79 | self.dotLayer.fillColor = dotColor.CGColor; 80 | } 81 | 82 | - (UIColor*)dotColor 83 | { 84 | return [UIColor colorWithCGColor:self.dotLayer.fillColor]; 85 | } 86 | 87 | - (void)setShowsDot:(BOOL)showsDot 88 | { 89 | _showsDot = showsDot; 90 | 91 | [CATransaction begin]; 92 | [CATransaction setValue:(id)kCFBooleanTrue forKey: kCATransactionDisableActions]; 93 | self.dotLayer.hidden = !showsDot; 94 | [CATransaction commit]; 95 | } 96 | 97 | - (void)setHeaderHeight:(CGFloat)headerHeight 98 | { 99 | _headerHeight = headerHeight; 100 | [self setNeedsLayout]; 101 | } 102 | 103 | - (void)layoutSubviews 104 | { 105 | [super layoutSubviews]; 106 | 107 | CGRect headerFrame = CGRectMake(0, 0, self.contentView.bounds.size.width, self.headerHeight); 108 | self.dayLabel.frame = CGRectInset(headerFrame, kHeaderMargin, kHeaderMargin); 109 | 110 | CGRect contentFrame = CGRectMake(0, self.headerHeight, self.contentView.bounds.size.width, self.contentView.bounds.size.height - self.headerHeight); 111 | contentFrame = CGRectInset(contentFrame, kHeaderMargin, kHeaderMargin); 112 | 113 | CGFloat dotSize = fminf(fminf(contentFrame.size.height, contentFrame.size.width), kDotSize); 114 | CGRect dotFrame = CGRectMake(CGRectGetMidX(contentFrame)-dotSize*.5, CGRectGetMidY(contentFrame)-dotSize*.5, dotSize, dotSize); 115 | 116 | self.dotLayer.frame = dotFrame; 117 | 118 | } 119 | 120 | @end 121 | -------------------------------------------------------------------------------- /CalendarDemo/Launch Screen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 27 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /CalendarLib/NSAttributedString+MGCAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSAttributedString+MGCAdditions.m 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2016 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import "NSAttributedString+MGCAdditions.h" 32 | 33 | 34 | NSString * const MGCCircleMarkAttributeName = @"MGCCircleMarkAttributeName"; 35 | 36 | 37 | @implementation MGCCircleMark 38 | 39 | - (instancetype)init 40 | { 41 | if (self = [super init]) { 42 | _color = [UIColor redColor]; 43 | _borderColor = [UIColor clearColor]; 44 | _margin = 5.; 45 | } 46 | return self; 47 | } 48 | 49 | @end 50 | 51 | 52 | @implementation NSMutableAttributedString (MGCAdditions) 53 | 54 | - (void)processCircleMarksInRange:(NSRange)range 55 | { 56 | [self enumerateAttribute:MGCCircleMarkAttributeName inRange:range options:0 usingBlock:^(id _Nullable value, NSRange subrange, BOOL * _Nonnull stop) { 57 | 58 | if (value) { 59 | MGCCircleMark *circleMark = (MGCCircleMark*)value; 60 | 61 | NSAttributedString *subAttrStr = [self attributedSubstringFromRange:subrange]; 62 | UIImage *image = [subAttrStr imageWithCircleMark:circleMark]; 63 | 64 | NSTextAttachment *attachment = [NSTextAttachment new]; 65 | attachment.image = image; 66 | attachment.bounds = CGRectMake(circleMark.margin, circleMark.yOffset, attachment.image.size.width, attachment.image.size.height); 67 | NSAttributedString *imgStr = [NSAttributedString attributedStringWithAttachment:attachment]; 68 | 69 | [self replaceCharactersInRange:subrange withAttributedString:imgStr]; 70 | } 71 | }]; 72 | } 73 | 74 | @end 75 | 76 | 77 | @implementation NSAttributedString (MGCAdditions) 78 | 79 | - (UIImage*)imageWithCircleMark:(MGCCircleMark*)mark 80 | { 81 | CGSize maxSize = CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX); 82 | CGRect strRect = [self boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin context:nil]; 83 | CGFloat markWidth = fmaxf(strRect.size.width, strRect.size.height) + 2. * mark.margin; 84 | CGRect markRect = CGRectMake(0, 0, markWidth, markWidth); 85 | 86 | UIGraphicsBeginImageContextWithOptions(markRect.size, NO, 0.0f); 87 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 88 | CGContextSaveGState(ctx); 89 | 90 | CGContextSetStrokeColorWithColor(ctx, mark.borderColor.CGColor); 91 | CGContextSetFillColorWithColor(ctx, mark.color.CGColor); 92 | 93 | CGContextAddEllipseInRect(ctx, CGRectInset(markRect, 1, 1)); 94 | CGContextDrawPath(ctx, kCGPathFillStroke); 95 | 96 | strRect.origin = CGPointMake(markWidth/2. - strRect.size.width/2., markWidth/2. - strRect.size.height/2.); 97 | [self drawWithRect:strRect options:NSStringDrawingUsesLineFragmentOrigin context:nil]; 98 | 99 | CGContextRestoreGState(ctx); 100 | UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); 101 | UIGraphicsEndImageContext(); 102 | 103 | return img; 104 | } 105 | 106 | - (NSAttributedString*)attributedStringWithProcessedCircleMarksInRange:(NSRange)range 107 | { 108 | NSMutableAttributedString *attrStr = [self mutableCopy]; 109 | [attrStr processCircleMarksInRange:range]; 110 | return attrStr; 111 | } 112 | 113 | @end 114 | -------------------------------------------------------------------------------- /CalendarDemo/DayViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // DayViewController.h 3 | // Calendar 4 | // 5 | // Copyright © 2016 Julien Martin. All rights reserved. 6 | // 7 | 8 | #import "DayViewController.h" 9 | #import "MGCDateRange.h" 10 | #import "NSCalendar+MGCAdditions.h" 11 | #import "NSAttributedString+MGCAdditions.h" 12 | #import "Constant.h" 13 | #import "MGCCalendarHeaderView.h" 14 | 15 | @implementation DayViewController 16 | 17 | @dynamic delegate; 18 | 19 | #pragma mark - UIViewController 20 | 21 | - (void)viewDidLoad 22 | { 23 | [super viewDidLoad]; 24 | 25 | self.dayPlannerView.backgroundColor = [UIColor clearColor]; 26 | self.dayPlannerView.backgroundView = [UIView new]; 27 | self.dayPlannerView.backgroundView.backgroundColor = [UIColor whiteColor]; 28 | 29 | if (isiPad) { 30 | //NSLog(@"---------------- iPAD ------------------"); 31 | self.dayPlannerView.dateFormat = @"eee\nd MMM"; 32 | self.dayPlannerView.dayHeaderHeight = 50; 33 | } 34 | else{ 35 | //NSLog(@"---------------- iPhone ------------------"); 36 | self.dayPlannerView.dateFormat = @"eee\nd \nMMM"; 37 | self.dayPlannerView.dayHeaderHeight = 60; 38 | } 39 | } 40 | 41 | #pragma mark - MGCDayPlannerViewController 42 | 43 | - (BOOL)dayPlannerView:(MGCDayPlannerView*)view canCreateNewEventOfType:(MGCEventType)type atDate:(NSDate*)date 44 | { 45 | NSDateComponents *comps = [self.calendar components:NSCalendarUnitWeekday fromDate:date]; 46 | return comps.weekday != 1; 47 | } 48 | 49 | - (void)dayPlannerView:(MGCDayPlannerView*)view didScroll:(MGCDayPlannerScrollType)scrollType 50 | { 51 | NSDate *date = [view dateAtPoint:view.center rounded:YES]; 52 | if (date && [self.delegate respondsToSelector:@selector(calendarViewController:didShowDate:)]) { 53 | [self.delegate calendarViewController:self didShowDate:date]; 54 | } 55 | } 56 | 57 | - (BOOL)dayPlannerView:(MGCDayPlannerView*)view canMoveEventOfType:(MGCEventType)type atIndex:(NSUInteger)index date:(NSDate*)date toType:(MGCEventType)targetType date:(NSDate*)targetDate 58 | { 59 | NSDateComponents *comps = [self.calendar components:NSCalendarUnitWeekday fromDate:targetDate]; 60 | return (comps.weekday != 1 && comps.weekday != 7); 61 | } 62 | 63 | - (NSAttributedString*)dayPlannerView:(MGCDayPlannerView *)view attributedStringForDayHeaderAtDate:(NSDate *)date 64 | { 65 | 66 | static NSDateFormatter *dateFormatter = nil; 67 | if (dateFormatter == nil) { 68 | dateFormatter = [NSDateFormatter new]; 69 | dateFormatter.dateFormat = @"eee d"; 70 | } 71 | 72 | NSString *dayStr = [dateFormatter stringFromDate:date]; 73 | 74 | UIFont *font = [UIFont systemFontOfSize:15]; 75 | NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc]initWithString:dayStr attributes:@{ NSFontAttributeName: font }]; 76 | 77 | if ([self.calendar mgc_isDate:date sameDayAsDate:[NSDate date]]) { 78 | UIFont *boldFont = [UIFont boldSystemFontOfSize:15]; 79 | 80 | MGCCircleMark *mark = [MGCCircleMark new]; 81 | mark.yOffset = boldFont.descender - mark.margin; 82 | 83 | NSUInteger dayStringStart = [dayStr rangeOfString:@" "].location + 1; 84 | [attrStr addAttributes:@{ NSFontAttributeName: boldFont, NSForegroundColorAttributeName: [UIColor whiteColor], MGCCircleMarkAttributeName: mark } range:NSMakeRange(dayStringStart, dayStr.length - dayStringStart)]; 85 | 86 | [attrStr processCircleMarksInRange:NSMakeRange(0, attrStr.length)]; 87 | } 88 | 89 | NSMutableParagraphStyle *para = [NSMutableParagraphStyle new]; 90 | para.alignment = NSTextAlignmentCenter; 91 | [attrStr addAttribute:NSParagraphStyleAttributeName value:para range:NSMakeRange(0, attrStr.length)]; 92 | 93 | return attrStr; 94 | } 95 | 96 | #pragma mark - CalendarControllerNavigation 97 | 98 | - (void)moveToDate:(NSDate*)date animated:(BOOL)animated 99 | { 100 | if (!self.dayPlannerView.dateRange || [self.dayPlannerView.dateRange containsDate:date]) { 101 | [self.dayPlannerView scrollToDate:date options:MGCDayPlannerScrollDateTime animated:animated]; 102 | } 103 | } 104 | 105 | - (void)moveToNextPageAnimated:(BOOL)animated 106 | { 107 | NSDate *date; 108 | [self.dayPlannerView pageForwardAnimated:animated date:&date]; 109 | //NSLog(@"paging forward to %@", date); 110 | } 111 | 112 | - (void)moveToPreviousPageAnimated:(BOOL)animated 113 | { 114 | NSDate *date; 115 | [self.dayPlannerView pageBackwardsAnimated:animated date:&date]; 116 | //NSLog(@"paging backwards to %@", date); 117 | } 118 | 119 | - (NSDate*)centerDate 120 | { 121 | NSDate *date = [self.dayPlannerView dateAtPoint:self.dayPlannerView.center rounded:NO]; 122 | return date; 123 | } 124 | 125 | @end 126 | -------------------------------------------------------------------------------- /CalendarLib/MGCReusableObjectQueue.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGCReusableObjectQueue.m 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import "MGCReusableObjectQueue.h" 32 | 33 | 34 | @interface MGCReusableObjectQueue () 35 | 36 | @property (nonatomic) NSMutableDictionary *reusableObjectsSets; 37 | @property (nonatomic) NSMutableDictionary *objectClasses; 38 | @property (nonatomic, readwrite) NSUInteger totalCreated; 39 | 40 | @end 41 | 42 | 43 | @implementation MGCReusableObjectQueue 44 | 45 | 46 | - (instancetype)init 47 | { 48 | if (self = [super init]) { 49 | [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(removeAllObjects) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; 50 | _reusableObjectsSets = [NSMutableDictionary new]; 51 | _objectClasses = [NSMutableDictionary new]; 52 | } 53 | return self; 54 | } 55 | 56 | 57 | - (void)dealloc 58 | { 59 | [[NSNotificationCenter defaultCenter]removeObserver:self]; 60 | } 61 | 62 | + (instancetype)defaultQueue 63 | { 64 | static MGCReusableObjectQueue *queue; 65 | static dispatch_once_t onceToken; 66 | 67 | dispatch_once(&onceToken, ^{ 68 | queue = [MGCReusableObjectQueue new]; 69 | }); 70 | 71 | return queue; 72 | } 73 | 74 | - (NSUInteger)count 75 | { 76 | NSUInteger count = 0; 77 | for (NSString *identifier in self.reusableObjectsSets) { 78 | NSMutableSet *set = [self.reusableObjectsSets objectForKey:identifier]; 79 | count += set.count; 80 | } 81 | return count; 82 | } 83 | 84 | - (void)registerClass:(Class)objectClass forObjectWithReuseIdentifier:(NSString*)identifier 85 | { 86 | if (objectClass) { 87 | NSMutableSet *set = [self.reusableObjectsSets objectForKey:identifier]; 88 | if (!set) { 89 | set = [NSMutableSet set]; 90 | [self.reusableObjectsSets setObject:set forKey:identifier]; 91 | [self.objectClasses setObject:NSStringFromClass(objectClass) forKey:identifier]; 92 | } 93 | } 94 | else { 95 | [self.objectClasses removeObjectForKey:identifier]; 96 | [self.reusableObjectsSets removeObjectForKey:identifier]; 97 | } 98 | } 99 | 100 | - (void)enqueueReusableObject:(id)object 101 | { 102 | [[self.reusableObjectsSets objectForKey:object.reuseIdentifier]addObject:object]; 103 | } 104 | 105 | - (id)dequeueReusableObjectWithReuseIdentifier:(NSString *)identifier 106 | { 107 | id object = [[self.reusableObjectsSets objectForKey:identifier] anyObject]; 108 | if (object) { 109 | [[self.reusableObjectsSets objectForKey:identifier] removeObject:object]; 110 | if ([object respondsToSelector:@selector(prepareForReuse)]) { 111 | [object prepareForReuse]; 112 | } 113 | } 114 | else { 115 | object = [self newObjectWithReuseIdentifier:identifier]; 116 | if (!object) { 117 | [NSException raise:@"Reuse queue exception" format:@"No class was registered for identifier %@", identifier]; 118 | } 119 | self.totalCreated++; 120 | } 121 | 122 | return object; 123 | } 124 | 125 | - (id)newObjectWithReuseIdentifier:(NSString*)identifier 126 | { 127 | NSString *class = [self.objectClasses objectForKey:identifier]; 128 | if (class) { 129 | Class objectClass = NSClassFromString(class); 130 | id object = [[objectClass alloc]init]; 131 | [object setReuseIdentifier:identifier]; 132 | return object; 133 | } 134 | 135 | return nil; 136 | } 137 | 138 | - (void)removeAllObjects 139 | { 140 | [self.reusableObjectsSets removeAllObjects]; 141 | } 142 | 143 | 144 | @end 145 | -------------------------------------------------------------------------------- /CalendarLib/MGCYearCalendarView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGCYearCalendarView.h 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import 32 | #import "MGCDateRange.h" 33 | 34 | 35 | @protocol MGCYearCalendarViewDelegate; 36 | 37 | /** 38 | * You can use `CalendarYearView` to display a scrollable 12-months calendar. 39 | **/ 40 | @interface MGCYearCalendarView : UIView 41 | 42 | /*! 43 | @name Configuring a calendar year view 44 | ----------------------------------------------------------------------------------------------------------------------- 45 | */ 46 | 47 | /*! 48 | @property calendar 49 | @abstract The calendar used for formatting the months and dates. 50 | @discussion The default value is the logical calendar for the current user (as returned by `[NSCalendar currentCalendar]`) 51 | */ 52 | @property (nonatomic) NSCalendar *calendar; 53 | 54 | /*! 55 | @property delegate 56 | @abstract The object acting as the delegate of the Calendar Year View. 57 | @discussion The delegate must adopt the `CalendarYearViewDelegate` protocol. The Calendar View maintains a weak reference to the delegate object. 58 | @discussion The delegate object is responsible for managing presentation of dates headers and interaction with months cells. 59 | */ 60 | @property (nonatomic, weak) id delegate; 61 | 62 | /*! 63 | @property daysFont 64 | @abstract The font used to display the days ordinals. 65 | @discussion The default value is the system font with a size of 13. 66 | */ 67 | @property (nonatomic) UIFont *daysFont; 68 | 69 | /*! 70 | @property headerFont 71 | @abstract The font used to display the month header. 72 | @discussion The default value is the system font with a size of 25. 73 | @see [CalendarYearViewDelegate calendarYearView:headerTextForMonthAtDate:] 74 | */ 75 | @property (nonatomic) UIFont *headerFont; 76 | 77 | /*! 78 | @property visibleMonthsRange 79 | @abstract Returns the date range of all visible months. 80 | @discussion Returns nil if no months are shown. 81 | */ 82 | @property (nonatomic, readonly) MGCDateRange *visibleMonthsRange; 83 | 84 | /*! 85 | @property dateRange 86 | @abstract Scrollable range of years. Default is nil, for 'infinite' scrolling. 87 | @discussion The range start date is set to the first day of the year, range end to the first day of the year followind end. 88 | @discussion If the currently visible year is outside the new range, the calendar view scrolls to the range starting date. 89 | */ 90 | @property (nonatomic, copy) MGCDateRange *dateRange; 91 | 92 | 93 | - (NSDate*)dateForMonthAtPoint:(CGPoint)pt; 94 | 95 | /*! 96 | @name Scrolling a calendar year view 97 | ----------------------------------------------------------------------------------------------------------------------- 98 | */ 99 | 100 | /*! 101 | @abstract Scrolls the calendar until a certain date is visible. 102 | @param date The date to scroll into view. 103 | @param animated Specify YES to animate the scrolling behavior or NO to adjust the visible content immediately. 104 | @warning If `date` param is not in the scrollable range of dates, an exception is thrown. 105 | */ 106 | - (void)scrollToDate:(NSDate*)date animated:(BOOL)animated; 107 | 108 | @end 109 | 110 | ////////////////////////////////////////////////////////////////////////////////////////////// 111 | // CalendarYearViewDelegate 112 | @protocol MGCYearCalendarViewDelegate 113 | 114 | @optional 115 | 116 | - (CGFloat)heightForYearHeaderInCalendarYearView:(MGCYearCalendarView*)view; // set to 0 to hide year header 117 | - (NSAttributedString*)calendarYearView:(MGCYearCalendarView*)view headerTextForYearAtDate:(NSDate*)date; 118 | - (NSAttributedString*)calendarYearView:(MGCYearCalendarView*)view headerTextForMonthAtDate:(NSDate*)date; 119 | - (void)calendarYearViewDidScroll:(MGCYearCalendarView*)view; 120 | - (void)calendarYearView:(MGCYearCalendarView*)view didSelectMonthAtDate:(NSDate*)date; 121 | 122 | @end -------------------------------------------------------------------------------- /CalendarLib/MGCCalendarHeaderCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /CalendarLib/MGCDayPlannerViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGCDayPlannerViewController.m 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import "MGCDayPlannerViewController.h" 32 | #import "MGCDateRange.h" 33 | #import "MGCCalendarHeaderView.h" 34 | #import "Constant.h" 35 | 36 | @interface MGCDayPlannerViewController () 37 | 38 | @property (nonatomic, copy) NSDate *firstVisibleDayForRotation; 39 | 40 | @end 41 | 42 | @implementation MGCDayPlannerViewController 43 | 44 | - (MGCDayPlannerView*)dayPlannerView 45 | { 46 | return (MGCDayPlannerView*)self.view; 47 | } 48 | 49 | - (void)setDayPlannerView:(MGCDayPlannerView*)dayPlannerView 50 | { 51 | [super setView:dayPlannerView]; 52 | 53 | if (!dayPlannerView.dataSource) 54 | dayPlannerView.dataSource = self; 55 | 56 | if (!dayPlannerView.delegate) 57 | dayPlannerView.delegate = self; 58 | } 59 | 60 | #pragma mark - UIViewController 61 | 62 | - (void)loadView 63 | { 64 | MGCDayPlannerView *dayPlannerView = [[MGCDayPlannerView alloc]initWithFrame:CGRectZero]; 65 | dayPlannerView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth; 66 | self.dayPlannerView = dayPlannerView; 67 | self.dayPlannerView.autoresizesSubviews = YES; 68 | } 69 | 70 | - (void)viewDidLayoutSubviews{ 71 | [super viewDidLayoutSubviews]; 72 | 73 | if (!self.headerView && self.showsWeekHeaderView) { 74 | self.dayPlannerView.numberOfVisibleDays = 1; 75 | self.dayPlannerView.dayHeaderHeight = 90; 76 | self.dayPlannerView.visibleDays.start = [NSDate date]; 77 | [self setupHeaderView]; 78 | } 79 | } 80 | 81 | - (void)setupHeaderView{ 82 | self.headerView = [[MGCCalendarHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.dayPlannerView.frame.size.width, self.dayPlannerView.dayHeaderHeight) collectionViewLayout:[[UICollectionViewFlowLayout alloc] init] andDayPlannerView:self.dayPlannerView]; 83 | 84 | self.headerView.autoresizingMask = UIViewAutoresizingFlexibleWidth; 85 | 86 | [self.view addSubview:self.headerView]; 87 | } 88 | 89 | - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator{ 90 | [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; 91 | 92 | [coordinator animateAlongsideTransition:nil completion:^(id context) { 93 | 94 | if (self.headerView) { 95 | //force to scroll to a correct position after rotation 96 | [self.headerView didMoveToSuperview]; 97 | } 98 | 99 | }]; 100 | } 101 | 102 | - (void)didReceiveMemoryWarning 103 | { 104 | [super didReceiveMemoryWarning]; 105 | // Dispose of any resources that can be recreated. 106 | } 107 | 108 | 109 | /* 110 | #pragma mark - Navigation 111 | 112 | // In a storyboard-based application, you will often want to do a little preparation before navigation 113 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 114 | // Get the new view controller using [segue destinationViewController]. 115 | // Pass the selected object to the new view controller. 116 | } 117 | */ 118 | 119 | #pragma mark - MGCDayPlannerViewDataSource 120 | 121 | - (NSInteger)dayPlannerView:(MGCDayPlannerView *)view numberOfEventsOfType:(MGCEventType)type atDate:(NSDate *)date 122 | { 123 | return 0; 124 | } 125 | 126 | - (MGCEventView*)dayPlannerView:(MGCDayPlannerView*)view viewForEventOfType:(MGCEventType)type atIndex:(NSUInteger)index date:(NSDate*)date 127 | { 128 | NSLog(@"dayPlannerView:viewForEventOfType:atIndex:date: has to implemented in MGCDayPlannerViewController subclasses."); 129 | return nil; 130 | } 131 | 132 | - (MGCDateRange*)dayPlannerView:(MGCDayPlannerView*)view dateRangeForEventOfType:(MGCEventType)type atIndex:(NSUInteger)index date:(NSDate*)date 133 | { 134 | NSLog(@"dayPlannerView:dateRangeForEventOfType:atIndex:date: has to implemented in MGCDayPlannerViewController subclasses."); 135 | return nil; 136 | } 137 | 138 | #pragma mark - MGCDayPlannerViewDelegate 139 | 140 | - (void)dayPlannerView:(MGCDayPlannerView*)view willStartMovingCellForEventOfType:(MGCEventType)type atIndex:(NSUInteger)index date:(NSDate*)date 141 | { 142 | } 143 | 144 | - (void)dayPlannerView:(MGCDayPlannerView*)view didMoveEventToDate:(NSDate*)date type:(MGCEventType)type 145 | { 146 | } 147 | 148 | //when the user interacts with the bottom part move the header part 149 | - (void)dayPlannerView:(MGCDayPlannerView*)view didEndScrolling:(MGCDayPlannerScrollType)scrollType 150 | { 151 | [self.headerView selectDate:view.visibleDays.start]; 152 | } 153 | 154 | @end 155 | -------------------------------------------------------------------------------- /CalendarLib/MGCDateRange.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGCDateRange.m 3 | // Graphical Calendars Library for iOS 4 | // 5 | // Distributed under the MIT License 6 | // Get the latest version from here: 7 | // 8 | // https://github.com/jumartin/Calendar 9 | // 10 | // Copyright (c) 2014-2015 Julien Martin 11 | // 12 | // Permission is hereby granted, free of charge, to any person obtaining a copy 13 | // of this software and associated documentation files (the "Software"), to deal 14 | // in the Software without restriction, including without limitation the rights 15 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | // copies of the Software, and to permit persons to whom the Software is 17 | // furnished to do so, subject to the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be included in all 20 | // copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | // 30 | 31 | #import "MGCDateRange.h" 32 | #import "NSCalendar+MGCAdditions.h" 33 | 34 | #define NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger)) 35 | #define NSUINTROTATE(val, b) ((((NSUInteger)val) << b) | (((NSUInteger)val) >> (NSUINT_BIT - b))) 36 | 37 | 38 | static NSDateFormatter *dateFormatter; 39 | 40 | @interface MGCDateRange () 41 | 42 | @property (nonatomic, readonly) NSDateFormatter *dateFormatter; // for debugging only 43 | 44 | @end 45 | 46 | 47 | @implementation MGCDateRange 48 | 49 | - (void)checkIfValid 50 | { 51 | NSAssert([self.start compare:self.end] != NSOrderedDescending, @"End date earlier than start date in DateRange object!"); 52 | } 53 | 54 | + (instancetype)dateRangeWithStart:(NSDate*)start end:(NSDate*)end 55 | { 56 | return [[self alloc] initWithStart:start end:end]; 57 | } 58 | 59 | - (instancetype)initWithStart:(NSDate*)start end:(NSDate*)end 60 | { 61 | if (self = [super init]) { 62 | _start = [start copy]; 63 | _end = [end copy]; 64 | } 65 | 66 | [self checkIfValid]; 67 | 68 | return self; 69 | } 70 | 71 | // for debugging 72 | - (NSDateFormatter*)dateFormatter 73 | { 74 | if (!dateFormatter) { 75 | dateFormatter = [NSDateFormatter new]; 76 | dateFormatter.dateStyle = NSDateFormatterMediumStyle; 77 | dateFormatter.timeStyle = NSDateFormatterMediumStyle; 78 | } 79 | return dateFormatter; 80 | } 81 | 82 | - (NSDateComponents*)components:(NSCalendarUnit)unitFlags forCalendar:(NSCalendar*)calendar 83 | { 84 | [self checkIfValid]; 85 | 86 | return [calendar components:unitFlags fromDate:self.start toDate:self.end options:0]; 87 | } 88 | 89 | - (BOOL)containsDate:(NSDate*)date 90 | { 91 | [self checkIfValid]; 92 | 93 | return ([date compare:self.start] != NSOrderedAscending && [date compare:self.end] == NSOrderedAscending); 94 | } 95 | 96 | - (void)intersectDateRange:(MGCDateRange*)range 97 | { 98 | [self checkIfValid]; 99 | 100 | // range.end <= start || end <= range.start 101 | if ([range.end compare:self.start] != NSOrderedDescending || [self.end compare:range.start] != NSOrderedDescending) { 102 | self.end = self.start; 103 | return; 104 | } 105 | 106 | if ([self.start compare:range.start] == NSOrderedAscending) { 107 | self.start = range.start; 108 | } 109 | if ([range.end compare:self.end] == NSOrderedAscending) { 110 | self.end = range.end; 111 | } 112 | } 113 | 114 | - (BOOL)intersectsDateRange:(MGCDateRange*)range 115 | { 116 | if ([range.end compare:self.start] != NSOrderedDescending || [self.end compare:range.start] != NSOrderedDescending) 117 | return NO; 118 | return YES; 119 | } 120 | 121 | - (BOOL)includesDateRange:(MGCDateRange*)range 122 | { 123 | if ([range.start compare:self.start] == NSOrderedAscending || [self.end compare:range.end] == NSOrderedAscending) 124 | return NO; 125 | return YES; 126 | } 127 | 128 | - (void)unionDateRange:(MGCDateRange*)range 129 | { 130 | [self checkIfValid]; 131 | [range checkIfValid]; 132 | 133 | self.start = [self.start earlierDate:range.start]; 134 | self.end = [self.end laterDate:range.end]; 135 | } 136 | 137 | - (void)enumerateDaysWithCalendar:(NSCalendar*)calendar usingBlock:(void (^)(NSDate *day, BOOL *stop))block 138 | { 139 | NSDateComponents *comp = [NSDateComponents new]; 140 | comp.day = 1; 141 | 142 | NSDate *date = self.start; 143 | BOOL stop = NO; 144 | 145 | while (!stop && [date compare:self.end] == NSOrderedAscending) { 146 | block(date, &stop); 147 | date = [calendar dateByAddingComponents:comp toDate:self.start options:0]; 148 | comp.day++; 149 | } 150 | } 151 | 152 | - (BOOL)isEqualToDateRange:(MGCDateRange*)range 153 | { 154 | return range && [range.start isEqualToDate:self.start] && [range.end isEqualToDate:self.end]; 155 | } 156 | 157 | - (BOOL)isEmpty 158 | { 159 | return [self.start isEqualToDate:self.end]; 160 | } 161 | 162 | #pragma mark - NSObject 163 | 164 | - (id)copyWithZone:(NSZone*)zone 165 | { 166 | return [MGCDateRange dateRangeWithStart:self.start end:self.end]; 167 | } 168 | 169 | - (BOOL)isEqual:(id)object 170 | { 171 | if (self == object) 172 | return YES; 173 | 174 | if (![object isKindOfClass:[MGCDateRange class]]) 175 | return NO; 176 | 177 | return [self isEqualToDateRange:(MGCDateRange*)object]; 178 | } 179 | 180 | - (NSUInteger)hash 181 | { 182 | return NSUINTROTATE([self.start hash], NSUINT_BIT / 2) ^ [self.end hash]; 183 | } 184 | 185 | - (NSString*)description 186 | { 187 | return [NSString stringWithFormat:@"[%@ - %@[", [self.dateFormatter stringFromDate:self.start], [self.dateFormatter stringFromDate:self.end]]; 188 | } 189 | 190 | @end 191 | --------------------------------------------------------------------------------