Skip to content
8 changes: 4 additions & 4 deletions Calendar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@
ORGANIZATIONNAME = "Julien Martin";
TargetAttributes = {
72B5D8ED180D73E0004ADB86 = {
DevelopmentTeam = 9L2H2A796T;
DevelopmentTeam = 537UN6KEVU;
};
};
};
Expand Down Expand Up @@ -599,7 +599,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -757,7 +757,7 @@
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 9L2H2A796T;
DEVELOPMENT_TEAM = 537UN6KEVU;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "CalendarDemo/Calendar-Prefix.pch";
INFOPLIST_FILE = "$(SRCROOT)/CalendarDemo/Calendar-Info.plist";
Expand All @@ -778,7 +778,7 @@
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 9L2H2A796T;
DEVELOPMENT_TEAM = 537UN6KEVU;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "CalendarDemo/Calendar-Prefix.pch";
INFOPLIST_FILE = "$(SRCROOT)/CalendarDemo/Calendar-Info.plist";
Expand Down
4 changes: 2 additions & 2 deletions CalendarDemo/MainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ - (DayViewController*)dayViewController
if (_dayViewController == nil) {
_dayViewController = [[DayViewController alloc]initWithEventStore:self.eventStore];
_dayViewController.calendar = self.calendar;
_dayViewController.showsWeekHeaderView = YES;
//_dayViewController.showsWeekHeaderView = YES;
_dayViewController.delegate = self;
_dayViewController.dayPlannerView.eventCoveringType = MGCDayPlannerCoveringTypeComplex;
//_dayViewController.dayPlannerView.eventCoveringType = MGCDayPlannerCoveringTypeComplex;
}
return _dayViewController;
}
Expand Down
4 changes: 2 additions & 2 deletions CalendarDemo/WeekSettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ - (IBAction)switchToggled:(UISwitch*)sender
{
if (sender == self.pagingSwitch) {
self.dayPlannerView.pagingEnabled = sender.on;
[self.dayPlannerView reloadDimmedTimeRanges];
//[self.dayPlannerView reloadDimmedTimeRanges];
}
else if (sender == self.zoomingSwitch) {
self.dayPlannerView.zoomingEnabled = sender.on;
Expand Down Expand Up @@ -302,7 +302,7 @@ - (IBAction)switchToggled:(UISwitch*)sender
}
else if (sender == self.dimmedTimeRangeSwitch) {
self.weekViewController.showDimmedTimeRanges = sender.on;
[self.dayPlannerView reloadDimmedTimeRanges];
//[self.dayPlannerView reloadDimmedTimeRanges];
}
}

Expand Down
2 changes: 0 additions & 2 deletions CalendarLib/Constant.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,5 @@

#define isiPad (IDIOM == IPAD ? YES:NO)

#define kHeaderHeight 100


#endif
6 changes: 2 additions & 4 deletions CalendarLib/MGCAllDayEventsViewLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,10 @@ - (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds
return shouldInvalidate;
}

// we keep this for iOS 8 compatibility. As of iOS 9, this is replaced by collectionView:targetContentOffsetForProposedContentOffset:
- (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset
{
id<UICollectionViewDelegate> delegate = (id<UICollectionViewDelegate>)self.collectionView.delegate;
return [delegate collectionView:self.collectionView targetContentOffsetForProposedContentOffset:proposedContentOffset];
CGFloat xOffset = roundf(proposedContentOffset.x / self.dayColumnWidth) * self.dayColumnWidth ;
return CGPointMake(xOffset, proposedContentOffset.y);
}


@end
2 changes: 1 addition & 1 deletion CalendarLib/MGCDayColumnCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ - (instancetype)initWithFrame:(CGRect)frame
_separatorColor = [UIColor lightGrayColor];
_headerHeight = 50;

_dayLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_dayLabel = [[UILabel alloc] initWithFrame:CGRectNull];
_dayLabel.numberOfLines = 0;
_dayLabel.adjustsFontSizeToFitWidth = YES;
_dayLabel.minimumScaleFactor = .7;
Expand Down
33 changes: 14 additions & 19 deletions CalendarLib/MGCDayPlannerEKViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -398,20 +398,20 @@ - (BOOL)dayPlannerView:(MGCDayPlannerView*)view canMoveEventOfType:(MGCEventType

- (void)dayPlannerView:(MGCDayPlannerView*)view moveEventOfType:(MGCEventType)type atIndex:(NSUInteger)index date:(NSDate*)date toType:(MGCEventType)targetType date:(NSDate*)targetDate
{
EKEvent *ev = [self eventOfType:type atIndex:index date:date];
EKEvent *ev = [self eventOfType:type atIndex:index date:date];

if (ev) {
NSDateComponents *duration = [self.calendar components:NSCalendarUnitMinute fromDate:ev.startDate toDate:ev.endDate options:0];
if (ev.allDay && targetType == MGCTimedEventType) {
duration.minute = 60;
}
NSDate *end = [self.calendar dateByAddingComponents:duration toDate:targetDate options:0];

// allDay property has to be set before start and end dates !
ev.allDay = (targetType == MGCAllDayEventType);
ev.startDate = targetDate;
ev.endDate = end;

if (ev) {
NSDateComponents *duration = [self.calendar components:NSMinuteCalendarUnit fromDate:ev.startDate toDate:ev.endDate options:0];
if (ev.allDay && targetType == MGCTimedEventType) {
duration.minute = view.durationForNewTimedEvent / 60;
}
NSDate *end = [self.calendar dateByAddingComponents:duration toDate:targetDate options:0];

// allDay property has to be set before start and end dates !
ev.allDay = (targetType == MGCAllDayEventType);
ev.startDate = targetDate;
ev.endDate = end;

[self.eventKitSupport saveEvent:ev completion:^(BOOL completion) {
[self.dayPlannerView endInteraction];
}];
Expand All @@ -435,13 +435,8 @@ - (void)dayPlannerView:(MGCDayPlannerView *)view createNewEventOfType:(MGCEventT

EKEvent *ev = [EKEvent eventWithEventStore:self.eventStore];
ev.startDate = date;

NSDateComponents *comps = [NSDateComponents new];
comps.day = ((NSInteger) view.durationForNewTimedEvent) / (60 * 60 * 24);
comps.hour = (((NSInteger) view.durationForNewTimedEvent) / (60 * 60)) - (comps.day * 24);
comps.minute = (((NSInteger) view.durationForNewTimedEvent) / 60) - (comps.day * 24 * 60) - (comps.hour * 60);
comps.second = ((NSInteger) round(view.durationForNewTimedEvent)) % 60;

comps.hour = 1;
ev.endDate = [self.calendar dateByAddingComponents:comps toDate:date options:0];
ev.allDay = (type == MGCAllDayEventType) ? YES : NO;

Expand Down
69 changes: 28 additions & 41 deletions CalendarLib/MGCDayPlannerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ typedef NS_ENUM(NSUInteger, MGCDayPlannerTimeMark) {
};


typedef NS_ENUM(NSUInteger, MGCDayPlannerCoveringType) {
MGCDayPlannerCoveringTypeClassic = 0,
MGCDayPlannerCoveringTypeComplex = 1
};


/*!
* You can use an instance of MGCDayPlannerView to display events as a schedule.
*
Expand Down Expand Up @@ -116,6 +110,16 @@ typedef NS_ENUM(NSUInteger, MGCDayPlannerCoveringType) {
*/
@property (nonatomic) CGFloat timeColumnWidth;

/*!
@abstract Set the font of the left column showing hours.
*/
@property (nonatomic) UIFont *timeColumnFont;

/*
@abstract Set the color of the left column showing hours.
*/
@property (nonatomic) UIColor *timeColumnLabelColor;

/*!
@abstract Returns the height of the top row showing days.
@discussion The default value is 40.
Expand Down Expand Up @@ -144,6 +148,12 @@ typedef NS_ENUM(NSUInteger, MGCDayPlannerCoveringType) {
*/
@property (nonatomic) UIColor *currentTimeColor;

/*!
@abstract Whether you want to display the current time or not
@discussion The default value is true.
*/
@property (nonatomic) BOOL showCurrentTime;

/*!
@abstract Returns the color of the dot in the header indicating that a day has events.
@discussion The default value is blue.
Expand All @@ -158,6 +168,11 @@ typedef NS_ENUM(NSUInteger, MGCDayPlannerCoveringType) {
*/
@property (nonatomic) BOOL showsAllDayEvents;

/*!
@abstract Set a view in place of the allDayEvents View that's present by default.
*/
@property (nonatomic) UIView *allDayEventsBackgroundView;

/*!
@abstract The view that provides the background appearance.
@discussion The view (if any) in this property is positioned underneath all of the other content
Expand Down Expand Up @@ -190,11 +205,6 @@ typedef NS_ENUM(NSUInteger, MGCDayPlannerCoveringType) {
*/
@property (nonatomic) NSRange hourRange;

/*!
@abstract Color of dimmed time ranges.
*/
@property (nonatomic) UIColor *dimmingColor;

/*!
@abstract Determines whether zooming is enabled for this day planner view.
If set to YES, the user can decrease or increase the height of the one-hour slot by pinching in and out on the view.
Expand All @@ -217,12 +227,6 @@ typedef NS_ENUM(NSUInteger, MGCDayPlannerCoveringType) {
*/
@property (nonatomic) BOOL canMoveEvents;

/*!
@abstract The duration of newly created timed events
@discussion The default duration is 1 hour.
*/
@property (nonatomic) NSTimeInterval durationForNewTimedEvent;

/*!
@abstract The object that acts as the delegate of the day planner view.
@discussion The delegate must adopt the `MGCDayPlannerViewDelegate` protocol.
Expand All @@ -238,13 +242,6 @@ typedef NS_ENUM(NSUInteger, MGCDayPlannerCoveringType) {
*/
@property (nonatomic, weak) id<MGCDayPlannerViewDataSource> dataSource;

/*!
@abstract How to handle multiple overlapping events at displaying.
@discussion `MGCDayPlannerCoveringTypeClassic` is recommended for 2-3 covering events.
`MGCDayPlannerCoveringTypeComplex` is recommended for more. The first one tries to maximize the event box sizes. The latter one maximizes the disjunct space by splitting days into columns as neccessary.
@discussion Default value is `MGCDayPlannerCoveringTypeClassic`.
*/
@property (nonatomic) MGCDayPlannerCoveringType eventCoveringType;

/*!
@group Navigating through a day planner view
Expand Down Expand Up @@ -476,12 +473,6 @@ typedef NS_ENUM(NSUInteger, MGCDayPlannerCoveringType) {
*/
- (void)endInteraction;

/*!
@abstract Reloads all dimmed time ranges.
@discussion Delegate methods dayPlannerView:numberOfDimmedTimeRangesAtDate: and dayPlannerView:dimmedTimeRangeAtIndex:date: are called for every visible day.
*/
- (void)reloadDimmedTimeRanges;

@end


Expand Down Expand Up @@ -590,17 +581,6 @@ typedef NS_ENUM(NSUInteger, MGCDayPlannerCoveringType) {
*/
- (NSAttributedString*)dayPlannerView:(MGCDayPlannerView*)view attributedStringForDayHeaderAtDate:(NSDate*)date;

/*!
@abstract Asks the delegate for the number of dimmed timed ranges at given date.
*/
- (NSInteger)dayPlannerView:(MGCDayPlannerView*)view numberOfDimmedTimeRangesAtDate:(NSDate*)date;

/*!
@abstract Asks the delegate for the dimmed time range at given date and index.
*/
- (MGCDateRange*)dayPlannerView:(MGCDayPlannerView*)view dimmedTimeRangeAtIndex:(NSUInteger)index date:(NSDate*)date;


/*!
@group Responding to scrolling
*/
Expand Down Expand Up @@ -632,6 +612,13 @@ typedef NS_ENUM(NSUInteger, MGCDayPlannerCoveringType) {
*/
- (void)dayPlannerView:(MGCDayPlannerView*)view willDisplayDate:(NSDate*)date;

/*!
@abstract Tells the delegate that the specified day is being displayed in the day planner view.
@param view The day planner view object notifying about the display change.
@param date The day about to be displayed.
*/
- (void)dayPlannerView:(MGCDayPlannerView*)view didDisplayDate:(NSDate*)date;

/*!
@abstract Tells the delegate that the specified day is not displayed anymore in the day planner view.
@param view The day planner view object notifying about the display change.
Expand Down
Loading