Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions TimesSquare/TSQCalendarRowCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ - (void)createDayButtons;
NSMutableArray *dayButtons = [NSMutableArray arrayWithCapacity:self.daysInWeek];
for (NSUInteger index = 0; index < self.daysInWeek; index++) {
UIButton *button = [[UIButton alloc] initWithFrame:self.contentView.bounds];
[button addTarget:self action:@selector(dateButtonPressed:) forControlEvents:UIControlEventTouchDown];
[button addTarget:self action:@selector(dateButtonTouchDown:) forControlEvents:UIControlEventTouchDown];
[button addTarget:self action:@selector(dateButtonTouchDragExit:) forControlEvents:UIControlEventTouchDragExit];
[button addTarget:self action:@selector(dateButtonTouchCancel:) forControlEvents:UIControlEventTouchCancel];
[button addTarget:self action:@selector(dateButtonTouchUpInside:) forControlEvents:UIControlEventTouchUpInside];
[dayButtons addObject:button];
[self.contentView addSubview:button];
[self configureButton:button];
Expand Down Expand Up @@ -181,14 +184,41 @@ - (void)setBottomRow:(BOOL)bottomRow;
[self setNeedsLayout];
}

- (IBAction)dateButtonPressed:(id)sender;
- (void)resetDateButtonDisplay:(UIButton*)aButton;
{
aButton.backgroundColor = nil;
[aButton setTitleColor:self.textColor forState:UIControlStateNormal];
}

- (void)markDateButtonSelected:(UIButton*)aButton;
{
aButton.backgroundColor = [UIColor darkGrayColor];
[aButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}

- (IBAction)dateButtonTouchUpInside:(id)sender;
{
NSDateComponents *offset = [NSDateComponents new];
offset.day = [self.dayButtons indexOfObject:sender];
NSDate *selectedDate = [self.calendar dateByAddingComponents:offset toDate:self.beginningDate options:0];
self.calendarView.selectedDate = selectedDate;
}

- (IBAction)dateButtonTouchDown:(id)sender;
{
[self markDateButtonSelected:sender];
}

- (IBAction)dateButtonTouchDragExit:(id)sender;
{
[self resetDateButtonDisplay:sender];
}

- (IBAction)dateButtonTouchCancel:(id)sender;
{
[self resetDateButtonDisplay:sender];
}

- (IBAction)todayButtonPressed:(id)sender;
{
NSDateComponents *offset = [NSDateComponents new];
Expand Down