Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding TapKu Calendar. Adding calendar view controller with fake data…
… as a test.
- Loading branch information
Showing
85 changed files
with
2,356 additions
and
25 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
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
Oops, something went wrong.