forked from hons82/THCalendarDatePicker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5b26f75
Showing
52 changed files
with
1,978 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
_Store | ||
*/build/* | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
profile | ||
*.moved-aside | ||
DerivedData | ||
.idea/ | ||
*.hmap | ||
|
||
#CocoaPods | ||
Pods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# License | ||
|
||
## MIT License | ||
|
||
Copyright (c) 2014 Tribus Hannes (http://hons82.blogspot.it) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
THCalendarDatePicker | ||
=== | ||
|
||
[![Pod Version](http://img.shields.io/cocoapods/v/THCalendarDatePicker.svg?style=flat)](http://cocoadocs.org/docsets/THCalendarDatePicker/) | ||
[![Pod Platform](http://img.shields.io/cocoapods/p/THCalendarDatePicker.svg?style=flat)](http://cocoadocs.org/docsets/THCalendarDatePicker/) | ||
[![Pod License](http://img.shields.io/cocoapods/l/THCalendarDatePicker.svg?style=flat)](http://opensource.org/licenses/MIT) | ||
|
||
This control is based on the [datepicker-ios](https://github.com/ccwasden/datepicker-ios) control combined with the [KNSemiModalViewController](https://github.com/kentnguyen/KNSemiModalViewController). | ||
|
||
The original controller was not aware of orientation changes and was missing some customization features that I needed for my project, so I decided to rewrite part of the controller to fit to my needs | ||
|
||
# Screenshots | ||
|
||
![iPhone Portrait](/Screenshots/Screenshot1.png?raw=true) | ||
![iPhone Landscape](/Screenshots/Screenshot2.png?raw=true) | ||
|
||
# Installation | ||
|
||
### CocoaPods | ||
|
||
Install with [CocoaPods](http://cocoapods.org) by adding the following to your Podfile: | ||
|
||
``` ruby | ||
platform :ios, '6.1' | ||
pod 'THCalendarDatePicker', '~> 0.0.1' | ||
``` | ||
|
||
**Note**: We follow http://semver.org for versioning the public API. | ||
|
||
### Manually | ||
|
||
Or copy the `THCalendarDatePicker/` directory from this repo into your project. | ||
|
||
# Usage | ||
|
||
Have a look at the Example Project. | ||
|
||
#Contributions | ||
|
||
...are really welcome. | ||
|
||
|
||
# License | ||
|
||
Source code of this project is available under the standard MIT license. Please see [the license file](LICENSE.md). | ||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// THDateDay.h | ||
// THCalendarDatePicker | ||
// | ||
// Created by chase wasden on 2/10/13. | ||
// Adapted by Hannes Tribus on 31/07/14. | ||
// Copyright (c) 2014 3Bus. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@class THDateDay; | ||
|
||
@protocol THDateDayDelegate <NSObject> | ||
-(void)dateDayTapped:(THDateDay *)dateDay; | ||
@end | ||
|
||
@interface THDateDay : UIView | ||
|
||
@property (weak, nonatomic) id<THDateDayDelegate> delegate; | ||
|
||
@property (weak, nonatomic) IBOutlet UIButton *dateButton; | ||
@property (strong, nonatomic) NSDate *date; | ||
@property (strong, nonatomic) UIColor *selectedBackgroundColor; | ||
@property (strong, nonatomic) UIColor *currentDateColor; | ||
|
||
|
||
-(void)setLightText:(BOOL)light; | ||
- (IBAction)dateButtonTapped:(id)sender; | ||
-(void)setSelected:(BOOL)selected; | ||
-(void)indicateDayHasItems:(BOOL)indicate; | ||
@property (weak, nonatomic) IBOutlet UIImageView *hasItemsIndicator; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// | ||
// THDateDay.m | ||
// THCalendarDatePicker | ||
// | ||
// Created by chase wasden on 2/10/13. | ||
// Adapted by Hannes Tribus on 31/07/14. | ||
// Copyright (c) 2014 3Bus. All rights reserved. | ||
// | ||
|
||
|
||
#import "THDateDay.h" | ||
|
||
@implementation THDateDay | ||
|
||
@synthesize selectedBackgroundColor = _selectedBackgroundColor; | ||
|
||
- (id)initWithFrame:(CGRect)frame | ||
{ | ||
self = [super initWithFrame:frame]; | ||
if (self) { | ||
// Initialization code | ||
_selectedBackgroundColor = [UIColor colorWithRed:89/255.0 green:118/255.0 blue:169/255.0 alpha:1]; | ||
} | ||
return self; | ||
} | ||
|
||
-(void)setLightText:(BOOL)light { | ||
if(light) { | ||
UIColor * color = [UIColor colorWithWhite:.84 alpha:1]; | ||
[self.dateButton setTitleColor:color forState:UIControlStateNormal]; | ||
self.hasItemsIndicator.image = [UIImage imageNamed:@"calendar_littledot-disabled"]; | ||
} | ||
else { | ||
UIColor * color = [UIColor colorWithWhite:.3 alpha:1]; | ||
[self.dateButton setTitleColor:color forState:UIControlStateNormal]; | ||
self.hasItemsIndicator.image = [UIImage imageNamed:@"calendar_littledot"]; | ||
} | ||
} | ||
|
||
- (IBAction)dateButtonTapped:(id)sender { | ||
[self.delegate dateDayTapped:self]; | ||
} | ||
|
||
-(void)setSelected:(BOOL)selected{ | ||
if(selected) { | ||
[self setBackgroundColor:self.selectedBackgroundColor]; | ||
[self.dateButton setSelected:YES]; | ||
[self.dateButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | ||
} | ||
else { | ||
[self setBackgroundColor:[UIColor whiteColor]]; | ||
[self.dateButton setSelected:NO]; | ||
[self.dateButton setTitleColor:[UIColor colorWithWhite:.3 alpha:1] forState:UIControlStateNormal]; | ||
} | ||
if (self.currentDateColor && [self isToday]) { | ||
[self.dateButton setTitleColor:self.currentDateColor forState:/*selected ? UIControlStateSelected :*/ UIControlStateNormal]; | ||
} | ||
} | ||
|
||
-(void)indicateDayHasItems:(BOOL)indicate { | ||
self.hasItemsIndicator.hidden = !indicate; | ||
} | ||
|
||
- (BOOL)isToday | ||
{ | ||
NSDateComponents *otherDay = [[NSCalendar currentCalendar] components:NSEraCalendarUnit|NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:self.date]; | ||
NSDateComponents *today = [[NSCalendar currentCalendar] components:NSEraCalendarUnit|NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:[NSDate date]]; | ||
return ([today day] == [otherDay day] && | ||
[today month] == [otherDay month] && | ||
[today year] == [otherDay year] && | ||
[today era] == [otherDay era]); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none"> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/> | ||
</dependencies> | ||
<objects> | ||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> | ||
<view contentMode="scaleToFill" id="3" customClass="THDateDay"> | ||
<rect key="frame" x="0.0" y="0.0" width="44" height="44"/> | ||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> | ||
<subviews> | ||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" id="4"> | ||
<rect key="frame" x="2" y="0.0" width="42" height="39"/> | ||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> | ||
<state key="normal" title="25"> | ||
<color key="titleColor" white="0.16154233870000001" alpha="1" colorSpace="calibratedWhite"/> | ||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> | ||
</state> | ||
<state key="selected"> | ||
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/> | ||
</state> | ||
<connections> | ||
<action selector="dateButtonTapped:" destination="3" eventType="touchUpInside" id="22"/> | ||
</connections> | ||
</button> | ||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" image="calendar_littledot" id="27"> | ||
<rect key="frame" x="14" y="27" width="18" height="18"/> | ||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/> | ||
</imageView> | ||
</subviews> | ||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> | ||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/> | ||
<connections> | ||
<outlet property="dateButton" destination="4" id="21"/> | ||
<outlet property="hasItemsIndicator" destination="27" id="28"/> | ||
</connections> | ||
</view> | ||
</objects> | ||
<resources> | ||
<image name="calendar_littledot" width="36" height="36"/> | ||
</resources> | ||
</document> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// THDatePickerViewController.h | ||
// THCalendarDatePicker | ||
// | ||
// Created by chase wasden on 2/10/13. | ||
// Adapted by Hannes Tribus on 31/07/14. | ||
// Copyright (c) 2014 3Bus. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import <QuartzCore/QuartzCore.h> | ||
#import <KNSemiModalViewController/UIViewController+KNSemiModal.h> | ||
|
||
#import "THDateDay.h" | ||
|
||
@class THDatePickerViewController; | ||
@protocol THDatePickerDelegate <NSObject> | ||
-(void)datePickerDonePressed:(THDatePickerViewController *)datePicker; | ||
-(void)datePickerCancelPressed:(THDatePickerViewController *)datePicker; | ||
@end | ||
|
||
@interface THDatePickerViewController : UIViewController <THDateDayDelegate> | ||
|
||
+(THDatePickerViewController *)datePicker; | ||
|
||
@property (strong, nonatomic) NSDate * date; | ||
@property (weak, nonatomic) id<THDatePickerDelegate> delegate; | ||
@property (strong, nonatomic) UIColor *selectedBackgroundColor; | ||
@property (strong, nonatomic) UIColor *currentDateColor; | ||
|
||
- (void)setDateHasItemsCallback:(BOOL (^)(NSDate * date))callback; | ||
- (void)setAllowClearDate:(BOOL)allow; | ||
- (void)setAutoCloseOnSelectDate:(BOOL)autoClose; | ||
|
||
@end |
Oops, something went wrong.