Skip to content

Commit

Permalink
Adding TapKu Calendar. Adding calendar view controller with fake data…
Browse files Browse the repository at this point in the history
… as a test.
  • Loading branch information
jsakuda committed May 20, 2012
1 parent af31f78 commit 0bb05bc
Show file tree
Hide file tree
Showing 85 changed files with 2,356 additions and 25 deletions.
61 changes: 61 additions & 0 deletions HI Capacity.xcodeproj/project.pbxproj
Expand Up @@ -7,6 +7,15 @@
objects = { objects = {


/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
09A4459C1567A6CD00634C53 /* NSDate+TKCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 09A4458E1567A6CD00634C53 /* NSDate+TKCategory.m */; };
09A4459D1567A6CD00634C53 /* TapkuLibrary.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 09A4458F1567A6CD00634C53 /* TapkuLibrary.bundle */; };
09A4459E1567A6CD00634C53 /* TKCalendarMonthTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 09A445911567A6CD00634C53 /* TKCalendarMonthTableViewController.m */; };
09A4459F1567A6CD00634C53 /* TKCalendarMonthView.m in Sources */ = {isa = PBXBuildFile; fileRef = 09A445931567A6CD00634C53 /* TKCalendarMonthView.m */; };
09A445A01567A6CD00634C53 /* TKCalendarMonthViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 09A445951567A6CD00634C53 /* TKCalendarMonthViewController.m */; };
09A445A11567A6CD00634C53 /* TKGlobal.m in Sources */ = {isa = PBXBuildFile; fileRef = 09A445971567A6CD00634C53 /* TKGlobal.m */; };
09A445A21567A6CD00634C53 /* UIImage+TKCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 09A445991567A6CD00634C53 /* UIImage+TKCategory.m */; };
09A445A31567A6CD00634C53 /* UIView+TKCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 09A4459B1567A6CD00634C53 /* UIView+TKCategory.m */; };
09A445B11568645D00634C53 /* CalendarViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 09A445B01568645D00634C53 /* CalendarViewController.m */; };
A39E33ED155FA29F0076ED6D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A39E33EC155FA29F0076ED6D /* UIKit.framework */; }; A39E33ED155FA29F0076ED6D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A39E33EC155FA29F0076ED6D /* UIKit.framework */; };
A39E33EF155FA29F0076ED6D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A39E33EE155FA29F0076ED6D /* Foundation.framework */; }; A39E33EF155FA29F0076ED6D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A39E33EE155FA29F0076ED6D /* Foundation.framework */; };
A39E33F1155FA29F0076ED6D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A39E33F0155FA29F0076ED6D /* CoreGraphics.framework */; }; A39E33F1155FA29F0076ED6D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A39E33F0155FA29F0076ED6D /* CoreGraphics.framework */; };
Expand Down Expand Up @@ -47,6 +56,23 @@
/* End PBXContainerItemProxy section */ /* End PBXContainerItemProxy section */


/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
09A4458D1567A6CD00634C53 /* NSDate+TKCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+TKCategory.h"; sourceTree = "<group>"; };
09A4458E1567A6CD00634C53 /* NSDate+TKCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+TKCategory.m"; sourceTree = "<group>"; };
09A4458F1567A6CD00634C53 /* TapkuLibrary.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = TapkuLibrary.bundle; sourceTree = "<group>"; };
09A445901567A6CD00634C53 /* TKCalendarMonthTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TKCalendarMonthTableViewController.h; sourceTree = "<group>"; };
09A445911567A6CD00634C53 /* TKCalendarMonthTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TKCalendarMonthTableViewController.m; sourceTree = "<group>"; };
09A445921567A6CD00634C53 /* TKCalendarMonthView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TKCalendarMonthView.h; sourceTree = "<group>"; };
09A445931567A6CD00634C53 /* TKCalendarMonthView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TKCalendarMonthView.m; sourceTree = "<group>"; };
09A445941567A6CD00634C53 /* TKCalendarMonthViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TKCalendarMonthViewController.h; sourceTree = "<group>"; };
09A445951567A6CD00634C53 /* TKCalendarMonthViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TKCalendarMonthViewController.m; sourceTree = "<group>"; };
09A445961567A6CD00634C53 /* TKGlobal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TKGlobal.h; sourceTree = "<group>"; };
09A445971567A6CD00634C53 /* TKGlobal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TKGlobal.m; sourceTree = "<group>"; };
09A445981567A6CD00634C53 /* UIImage+TKCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+TKCategory.h"; sourceTree = "<group>"; };
09A445991567A6CD00634C53 /* UIImage+TKCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+TKCategory.m"; sourceTree = "<group>"; };
09A4459A1567A6CD00634C53 /* UIView+TKCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+TKCategory.h"; sourceTree = "<group>"; };
09A4459B1567A6CD00634C53 /* UIView+TKCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+TKCategory.m"; sourceTree = "<group>"; };
09A445AF1568645D00634C53 /* CalendarViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CalendarViewController.h; sourceTree = "<group>"; };
09A445B01568645D00634C53 /* CalendarViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CalendarViewController.m; sourceTree = "<group>"; };
A39E33E8155FA29F0076ED6D /* HI Capacity.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "HI Capacity.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A39E33E8155FA29F0076ED6D /* HI Capacity.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "HI Capacity.app"; sourceTree = BUILT_PRODUCTS_DIR; };
A39E33EC155FA29F0076ED6D /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; A39E33EC155FA29F0076ED6D /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
A39E33EE155FA29F0076ED6D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; A39E33EE155FA29F0076ED6D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -120,9 +146,33 @@
/* End PBXFrameworksBuildPhase section */ /* End PBXFrameworksBuildPhase section */


/* Begin PBXGroup section */ /* Begin PBXGroup section */
09A4458C1567A6CD00634C53 /* TapkuLibrary */ = {
isa = PBXGroup;
children = (
09A4458D1567A6CD00634C53 /* NSDate+TKCategory.h */,
09A4458E1567A6CD00634C53 /* NSDate+TKCategory.m */,
09A4458F1567A6CD00634C53 /* TapkuLibrary.bundle */,
09A445901567A6CD00634C53 /* TKCalendarMonthTableViewController.h */,
09A445911567A6CD00634C53 /* TKCalendarMonthTableViewController.m */,
09A445921567A6CD00634C53 /* TKCalendarMonthView.h */,
09A445931567A6CD00634C53 /* TKCalendarMonthView.m */,
09A445941567A6CD00634C53 /* TKCalendarMonthViewController.h */,
09A445951567A6CD00634C53 /* TKCalendarMonthViewController.m */,
09A445961567A6CD00634C53 /* TKGlobal.h */,
09A445971567A6CD00634C53 /* TKGlobal.m */,
09A445981567A6CD00634C53 /* UIImage+TKCategory.h */,
09A445991567A6CD00634C53 /* UIImage+TKCategory.m */,
09A4459A1567A6CD00634C53 /* UIView+TKCategory.h */,
09A4459B1567A6CD00634C53 /* UIView+TKCategory.m */,
);
name = TapkuLibrary;
path = vendor/TapkuLibrary;
sourceTree = "<group>";
};
A39E33DD155FA29E0076ED6D = { A39E33DD155FA29E0076ED6D = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
09A4458C1567A6CD00634C53 /* TapkuLibrary */,
A39E34281564E0D40076ED6D /* MKNetworkKit */, A39E34281564E0D40076ED6D /* MKNetworkKit */,
A39E33F2155FA29F0076ED6D /* HI Capacity */, A39E33F2155FA29F0076ED6D /* HI Capacity */,
A39E3413155FA29F0076ED6D /* HI CapacityTests */, A39E3413155FA29F0076ED6D /* HI CapacityTests */,
Expand Down Expand Up @@ -168,6 +218,8 @@
C8407A6C15662EFA001CAB68 /* PostsViewController.m */, C8407A6C15662EFA001CAB68 /* PostsViewController.m */,
C8407A6E15663806001CAB68 /* PostContentViewController.h */, C8407A6E15663806001CAB68 /* PostContentViewController.h */,
C8407A6F15663806001CAB68 /* PostContentViewController.m */, C8407A6F15663806001CAB68 /* PostContentViewController.m */,
09A445AF1568645D00634C53 /* CalendarViewController.h */,
09A445B01568645D00634C53 /* CalendarViewController.m */,
); );
path = "HI Capacity"; path = "HI Capacity";
sourceTree = "<group>"; sourceTree = "<group>";
Expand Down Expand Up @@ -316,6 +368,7 @@
A39E33F7155FA29F0076ED6D /* InfoPlist.strings in Resources */, A39E33F7155FA29F0076ED6D /* InfoPlist.strings in Resources */,
A39E3400155FA29F0076ED6D /* MainStoryboard_iPhone.storyboard in Resources */, A39E3400155FA29F0076ED6D /* MainStoryboard_iPhone.storyboard in Resources */,
A39E3403155FA29F0076ED6D /* MainStoryboard_iPad.storyboard in Resources */, A39E3403155FA29F0076ED6D /* MainStoryboard_iPad.storyboard in Resources */,
09A4459D1567A6CD00634C53 /* TapkuLibrary.bundle in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
Expand Down Expand Up @@ -363,6 +416,14 @@
A39E34501564E4830076ED6D /* HTTPEngine.m in Sources */, A39E34501564E4830076ED6D /* HTTPEngine.m in Sources */,
C8407A6D15662EFA001CAB68 /* PostsViewController.m in Sources */, C8407A6D15662EFA001CAB68 /* PostsViewController.m in Sources */,
C8407A7015663806001CAB68 /* PostContentViewController.m in Sources */, C8407A7015663806001CAB68 /* PostContentViewController.m in Sources */,
09A4459C1567A6CD00634C53 /* NSDate+TKCategory.m in Sources */,
09A4459E1567A6CD00634C53 /* TKCalendarMonthTableViewController.m in Sources */,
09A4459F1567A6CD00634C53 /* TKCalendarMonthView.m in Sources */,
09A445A01567A6CD00634C53 /* TKCalendarMonthViewController.m in Sources */,
09A445A11567A6CD00634C53 /* TKGlobal.m in Sources */,
09A445A21567A6CD00634C53 /* UIImage+TKCategory.m in Sources */,
09A445A31567A6CD00634C53 /* UIView+TKCategory.m in Sources */,
09A445B11568645D00634C53 /* CalendarViewController.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
Expand Down
21 changes: 21 additions & 0 deletions HI Capacity/CalendarViewController.h
@@ -0,0 +1,21 @@
//
// CalendarViewController.h
// HI Capacity
//
// Created by Julie Ann Sakuda on 5/19/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "TKCalendarMonthTableViewController.h"

@interface CalendarViewController : TKCalendarMonthTableViewController {

}

@property (retain,nonatomic) NSMutableArray *dataArray;
@property (retain,nonatomic) NSMutableDictionary *dataDictionary;

- (void) generateRandomDataForStartDate:(NSDate*)start endDate:(NSDate*)end;

@end
120 changes: 120 additions & 0 deletions HI Capacity/CalendarViewController.m
@@ -0,0 +1,120 @@
//
// CalendarViewController.m
// HI Capacity
//
// Created by Julie Ann Sakuda on 5/19/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "CalendarViewController.h"
#import "NSDate+TKCategory.h"

@interface CalendarViewController ()

@end

@implementation CalendarViewController

@synthesize dataArray, dataDictionary;


- (void)viewDidLoad{
[super viewDidLoad];
[self.monthView selectDate:[NSDate month]];
}

- (void)viewWillAppear:(BOOL)animated {
// [[[self navigationController] navigationBar] setHidden:YES];
}

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
//NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//[dateFormatter setDateFormat:@"dd.MM.yy"];
//NSDate *d = [dateFormatter dateFromString:@"02.05.11"];
//[dateFormatter release];
//[self.monthView selectDate:d];
}

- (NSArray*) calendarMonthView:(TKCalendarMonthView*)monthView marksFromDate:(NSDate*)startDate toDate:(NSDate*)lastDate {
[self generateRandomDataForStartDate:startDate endDate:lastDate];
return dataArray;
}
- (void) calendarMonthView:(TKCalendarMonthView*)monthView didSelectDate:(NSDate*)date{

// CHANGE THE DATE TO YOUR TIMEZONE
TKDateInformation info = [date dateInformationWithTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
NSDate *myTimeZoneDay = [NSDate dateFromDateInformation:info timeZone:[NSTimeZone systemTimeZone]];

NSLog(@"Date Selected: %@",myTimeZoneDay);

[self.tableView reloadData];
}

- (void) calendarMonthView:(TKCalendarMonthView*)mv monthDidChange:(NSDate*)d animated:(BOOL)animated{
[super calendarMonthView:mv monthDidChange:d animated:animated];
[self.tableView reloadData];
}


- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
return 1;

}
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSArray *ar = [dataDictionary objectForKey:[self.monthView dateSelected]];
if(ar == nil) return 0;
return [ar count];
}
- (UITableViewCell *) tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];



NSArray *ar = [dataDictionary objectForKey:[self.monthView dateSelected]];
cell.textLabel.text = [ar objectAtIndex:indexPath.row];

return cell;

}


- (void) generateRandomDataForStartDate:(NSDate*)start endDate:(NSDate*)end{
// this function sets up dataArray & dataDictionary
// dataArray: has boolean markers for each day to pass to the calendar view (via the delegate function)
// dataDictionary: has items that are associated with date keys (for tableview)


NSLog(@"Delegate Range: %@ %@ %d",start,end,[start daysBetweenDate:end]);

self.dataArray = [NSMutableArray array];
self.dataDictionary = [NSMutableDictionary dictionary];

NSDate *d = start;
while(YES){

int r = arc4random();
if(r % 3==1){
[self.dataDictionary setObject:[NSArray arrayWithObjects:@"Item one",@"Item two",nil] forKey:d];
[self.dataArray addObject:[NSNumber numberWithBool:YES]];

}else if(r%4==1){
[self.dataDictionary setObject:[NSArray arrayWithObjects:@"Item one",nil] forKey:d];
[self.dataArray addObject:[NSNumber numberWithBool:YES]];

}else
[self.dataArray addObject:[NSNumber numberWithBool:NO]];


TKDateInformation info = [d dateInformationWithTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
info.day++;
d = [NSDate dateFromDateInformation:info timeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
if([d compare:end]==NSOrderedDescending) break;
}

}

@end

0 comments on commit 0bb05bc

Please sign in to comment.