Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
kovpas committed Jan 11, 2013
2 parents b5c3091 + 5175d9a commit 34deda2
Show file tree
Hide file tree
Showing 20 changed files with 426 additions and 233 deletions.
39 changes: 14 additions & 25 deletions PMCalendar/Theme/apple calendar.plist
Expand Up @@ -9,10 +9,10 @@
<key>Width</key>
<integer>320</integer>
<key>Height</key>
<integer>310</integer>
<integer>309</integer>
</dict>
<key>Header height</key>
<integer>46</integer>
<integer>45</integer>
<key>Outer padding</key>
<dict>
<key>Height</key>
Expand Down Expand Up @@ -45,21 +45,6 @@
<dict>
<key>Background</key>
<dict>
<key> grad</key>
<array>
<dict>
<key>Color</key>
<string>226,226,228</string>
<key>Position</key>
<integer>0</integer>
</dict>
<dict>
<key>Color</key>
<string>204,203,208</string>
<key>Position</key>
<integer>1</integer>
</dict>
</array>
<key>Color</key>
<string>background.png</string>
<key>Shadow</key>
Expand All @@ -69,12 +54,12 @@
<key>Offset</key>
<dict>
<key>Width</key>
<integer>1</integer>
<integer>0</integer>
<key>Height</key>
<integer>1</integer>
</dict>
<key>Blur radius</key>
<integer>2</integer>
<integer>9</integer>
</dict>
</dict>
</dict>
Expand Down Expand Up @@ -160,6 +145,8 @@
<string>115,137,165</string>
<key>Shadow</key>
<dict>
<key>Type</key>
<string>inner</string>
<key>Color</key>
<string>0,0,0</string>
<key>Offset</key>
Expand All @@ -182,11 +169,11 @@
<key>Insets</key>
<dict>
<key>Top</key>
<integer>-2</integer>
<integer>-1</integer>
<key>Left</key>
<integer>-1</integer>
<key>Bottom</key>
<integer>1</integer>
<integer>0</integer>
<key>Right</key>
<integer>0</integer>
</dict>
Expand Down Expand Up @@ -226,6 +213,8 @@
<string>25,128,229</string>
<key>Shadow</key>
<dict>
<key>Type</key>
<string>inner</string>
<key>Color</key>
<string>0,0,0</string>
<key>Offset</key>
Expand All @@ -248,11 +237,11 @@
<key>Insets</key>
<dict>
<key>Top</key>
<integer>-2</integer>
<integer>-1</integer>
<key>Left</key>
<integer>-1</integer>
<key>Bottom</key>
<integer>1</integer>
<integer>0</integer>
<key>Right</key>
<integer>0</integer>
</dict>
Expand Down Expand Up @@ -528,11 +517,11 @@
<key>Insets</key>
<dict>
<key>Top</key>
<integer>-2</integer>
<integer>-1</integer>
<key>Left</key>
<integer>-1</integer>
<key>Bottom</key>
<integer>1</integer>
<integer>0</integer>
<key>Right</key>
<integer>0</integer>
</dict>
Expand Down
Binary file modified PMCalendar/Theme/background.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified PMCalendar/Theme/background@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions PMCalendar/Theme/default.plist
Expand Up @@ -318,20 +318,20 @@
<key>Bottom</key>
<integer>2</integer>
<key>Right</key>
<integer>3</integer>
<integer>4</integer>
</dict>
<key>Shadow</key>
<dict>
<key>Blur radius</key>
<integer>5</integer>
<integer>3</integer>
<key>Color</key>
<string>0,0,0</string>
<key>Offset</key>
<dict>
<key>Width</key>
<integer>2</integer>
<integer>1</integer>
<key>Height</key>
<integer>3</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
Expand Down
11 changes: 11 additions & 0 deletions PMCalendar/src/NSDate+Helpers.h
Expand Up @@ -43,6 +43,11 @@
*/
- (NSDate *) monthStartDate;

/**
* Returns start of day for the current (self) date.
*/
- (NSDate *) midnightDate;

/**
* Returns the number of days in the current (self) month.
*/
Expand All @@ -67,4 +72,10 @@
*/
- (NSString *) dateStringWithFormat:(NSString *) format;

/**
* Checks if a given date is before or after the current (self) date.
*/
- (BOOL) isBefore:(NSDate *) date;
- (BOOL) isAfter:(NSDate *) date;

@end
21 changes: 21 additions & 0 deletions PMCalendar/src/NSDate+Helpers.m
Expand Up @@ -59,6 +59,17 @@ - (NSDate *) monthStartDate
return monthStartDate;
}

- (NSDate *) midnightDate
{
NSDate *midnightDate = nil;
[[NSCalendar currentCalendar] rangeOfUnit:NSDayCalendarUnit
startDate:&midnightDate
interval:NULL
forDate:self];

return midnightDate;
}

- (NSUInteger) numberOfDaysInMonth
{
return [[NSCalendar currentCalendar] rangeOfUnit:NSDayCalendarUnit
Expand Down Expand Up @@ -88,4 +99,14 @@ - (NSInteger) daysSinceDate:(NSDate *) date
return [self timeIntervalSinceDate:date] / (60 * 60 * 24);
}

- (BOOL) isBefore:(NSDate *) date
{
return [self timeIntervalSinceDate:date] < 0;
}

- (BOOL) isAfter:(NSDate *) date
{
return [self timeIntervalSinceDate:date] > 0;
}

@end
7 changes: 5 additions & 2 deletions PMCalendar/src/PMCalendarBackgroundView.m
Expand Up @@ -14,6 +14,7 @@

@interface PMCalendarBackgroundView ()

@property (nonatomic, assign) CGRect initialFrame;
- (void)redrawComponent;

@end
Expand All @@ -22,6 +23,7 @@ @implementation PMCalendarBackgroundView

@synthesize arrowDirection = _arrowDirection;
@synthesize arrowPosition = _arrowPosition;
@synthesize initialFrame = _initialFrame;

#pragma mark - UIView overridden methods -

Expand All @@ -44,6 +46,7 @@ - (id)initWithFrame:(CGRect)frame
name:kPMCalendarRedrawNotification
object:nil];
self.backgroundColor = [UIColor clearColor];
self.initialFrame = frame;

return self;
}
Expand Down Expand Up @@ -215,8 +218,8 @@ -(void)drawRect:(CGRect)rect

// backgound box. doesn't include arrow:
CGRect boxBounds = CGRectMake(0, 0
, self.bounds.size.width - arrowSize.height
, self.bounds.size.height - arrowSize.height);
, self.frame.size.width - arrowSize.height
, self.frame.size.height - arrowSize.height);

CGFloat width = boxBounds.size.width - (shadowPadding.left + shadowPadding.right);
CGFloat height = boxBounds.size.height - (shadowPadding.top + shadowPadding.bottom);
Expand Down
44 changes: 38 additions & 6 deletions PMCalendar/src/PMCalendarController.h
Expand Up @@ -45,21 +45,27 @@
- (id) initWithThemeName:(NSString *) themeName andSize:(CGSize) size;

/**
* Allows you to present a calendar from a rect in a particular view.
* "arrowDirections" is a bitfield which specifies what arrow directions are allowed
* Allows you to present a calendar from a rect in a particular view.
* "arrowDirections" is a bitfield which specifies what arrow directions are allowed
* when laying out the calendar.
* If "isPopover" is set to YES, calendar will be presented with dimming view below it,
* which invokes delegate's "shouldDismiss" and "didDismiss" by tapping on it.
* "isPopover" is particulary handy for calendars like apple's calendar from Calendar.app
* which couldn't be dismissed and alows interaction below it.
*/
- (void)presentCalendarFromRect:(CGRect) rect
- (void)presentCalendarFromRect:(CGRect) rect
inView:(UIView *) view
permittedArrowDirections:(PMCalendarArrowDirection) arrowDirections
isPopover:(BOOL) isPopover
animated:(BOOL) animated;

/**
* Like the above, but is a convenience for presentation from a "UIView" instance.
* This allows to calculate position of the calendar during rotation, so it positions itself properly.
*/
- (void)presentCalendarFromView:(UIView *) anchorView
- (void)presentCalendarFromView:(UIView *) anchorView
permittedArrowDirections:(PMCalendarArrowDirection) arrowDirections
isPopover:(BOOL) isPopover
animated:(BOOL) animated;

/**
Expand All @@ -81,7 +87,7 @@
@property (nonatomic, strong) PMPeriod *period;

/**
* TBI: this property is planned to reflect PMPeriod of dates allowed to select from.
* Reflects PMPeriod allowed to select from.
* This also limits user's iteration.
*
* I.e. if allowed period is set to 23.02.2001 - 19.08.2020, user will not be able to see
Expand Down Expand Up @@ -119,8 +125,12 @@
*/
@property (nonatomic, assign) CGSize size;

@end
/**
* Returns whether the popover is visible (presented) or not.
*/
@property (nonatomic, assign, readonly, getter = isCalendarVisible) BOOL calendarVisible;

@end

@protocol PMCalendarControllerDelegate <NSObject>

Expand All @@ -145,3 +155,25 @@
- (void)calendarController:(PMCalendarController *)calendarController didChangePeriod:(PMPeriod *)newPeriod;

@end

@interface PMCalendarController (PMCalendarControllerDeprecated)

/**
* Allows you to present a calendar from a rect in a particular view.
* "arrowDirections" is a bitfield which specifies what arrow directions are allowed
* when laying out the calendar.
*/
- (void)presentCalendarFromRect:(CGRect) rect
inView:(UIView *) view
permittedArrowDirections:(PMCalendarArrowDirection) arrowDirections
animated:(BOOL) animated;

/**
* Like the above, but is a convenience for presentation from a "UIView" instance.
* This allows to calculate position of the calendar during rotation, so it positions itself properly.
*/
- (void)presentCalendarFromView:(UIView *) anchorView
permittedArrowDirections:(PMCalendarArrowDirection) arrowDirections
animated:(BOOL) animated;

@end

0 comments on commit 34deda2

Please sign in to comment.