Permalink
Browse files

bold if due today or past due

  • Loading branch information...
1 parent 598780d commit 34dbef44442286c410bfd9e994402454008b5301 Greg Allen committed Feb 5, 2010
Showing with 475 additions and 5 deletions.
  1. +71 −0 NSDateHelper.h
  2. +359 −0 NSDateHelper.m
  3. +17 −3 RTMHelper.m
  4. +7 −1 SimpleRTM.xcodeproj/project.pbxproj
  5. +7 −0 SimpleRTMAppDelegate.m
  6. +2 −0 TransparentTableViewCell.h
  7. +12 −1 TransparentTableViewCell.m
View
71 NSDateHelper.h
@@ -0,0 +1,71 @@
+//
+// NSDateHelper.h
+// Enormego Cocoa Helpers
+//
+// Created by Shaun Harrison on 10/15/08.
+// Copyright 2008 enormego. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+@interface NSDate (Helper)
+
++ (NSDate*)dateFromOffSetDays:(NSInteger)offset;
+
+
+// Returns an NSDate based on a string with formatting options passed to NSDateFormatter
++ (NSDate*)dateWithString:(NSString*)dateString formatString:(NSString*)dateFormatterString;
+
+// Returns an NSDate with an ISO8610 format, aka ATOM: yyyy-MM-dd'T'HH:mm:ssZZZ
++ (NSDate*)dateWithISO8601String:(NSString*)str;
+
+// Returns an NSDate with a 'yyyy-MM-dd' string
++ (NSDate*)dateWithDateString:(NSString*)str;
+
+// Returns an NSDate with a 'yyyy-MM-dd HH:mm:ss' string
++ (NSDate*)dateWithDateTimeString:(NSString*)str;
+
+// Returns an NSDate with a 'dd MMM yyyy HH:mm:ss' string
++ (NSDate*)dateWithLongDateTimeString:(NSString*)str;
+
+// Returns an NSDate with an RSS formatted string: 'EEE, d MMM yyyy HH:mm:ss ZZZ' string
++ (NSDate*)dateWithRSSDateString:(NSString*)str;
+
+// Returns an NSDate with an alternative RSS formatted string: 'd MMM yyyy HH:mm:ss ZZZ' string
++ (NSDate*)dateWithAltRSSDateString:(NSString*)str;
+
+
+// Pass in an string compatible with NSDateFormatter
+- (NSString*)formattedDateWithFormatString:(NSString*)dateFormatterString;
+
+
+// Returns date formatted to: EEE, d MMM 'at' h:mma
+- (NSString*)formattedDate;
+
+// Returns date formatted to: NSDateFormatterShortStyle
+- (NSString*)formattedTime;
+
+// Returns date formatted to: Weekday if within last 7 days, Yesterday/Tomorrow, or NSDateFormatterShortStyle for everything else
+- (NSString*)relativeFormattedDate;
+
+// Returns date formatted to: Weekday if within last 7 days, Yesterday/Today/Tomorrow, or NSDateFormatterShortStyle for everything else
+// If date is today, returns no Date, instead returns NSDateFormatterShortStyle for time
+- (NSString*)relativeFormattedDateOnly;
+
+// Returns date formatted to: Weekday if within last 7 days, Yesterday/Today/Tomorrow, or NSDateFormatterFullStyle for everything else
+// Also returns NSDateFormatterShortStyle for time
+- (NSString*)relativeFormattedDateTime;
+
+// Returns date formatted to: Weekday if within last 7 days, Yesterday/Today/Tomorrow, or NSDateFormatterFullStyle for everything else
+- (NSString*)relativeLongFormattedDate;
+
+// Returns date formatted for ISO8601/ATOM: yyyy-MM-dd'T'HH:mm:ssZZZ
+- (NSString*)iso8601Formatted;
+
+// Checks whether current date is past date
+- (BOOL)isPastDate;
+
+
+-(NSDate*) dateOnly;
+@end
View
359 NSDateHelper.m
@@ -0,0 +1,359 @@
+//
+// NSDateHelper.m
+// Enormego Cocoa Helpers
+//
+// Created by Shaun Harrison on 10/15/08.
+// Copyright 2008 enormego. All rights reserved.
+//
+
+#import "NSDateHelper.h"
+
+@implementation NSDate (Helper)
++ (NSDate*)dateFromOffSetDays:(NSInteger)offset;
+{
+ NSDate* yourDate = [NSDate new];
+ NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
+ NSDateComponents *todayComponents = [gregorian components:(NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit) fromDate:yourDate];
+ NSInteger theDay = [todayComponents day];
+ NSInteger theMonth = [todayComponents month];
+ NSInteger theYear = [todayComponents year];
+
+ // now build a NSDate object for yourDate using these components
+ NSDateComponents *components = [[NSDateComponents alloc] init];
+ [components setDay:theDay];
+ [components setMonth:theMonth];
+ [components setYear:theYear];
+ NSDate *thisDate = [gregorian dateFromComponents:components];
+ [components release];
+
+ // now build a NSDate object for the next day
+ NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
+ [offsetComponents setDay:offset];
+ NSDate *nextDate = [gregorian dateByAddingComponents:offsetComponents toDate: yourDate options:0];
+ [offsetComponents release];
+ [gregorian release];
+
+ return nextDate;
+}
+
+
+
++ (NSDate*)dateWithString:(NSString*)dateString formatString:(NSString*)dateFormatterString {
+ if(!dateString) return nil;
+
+ NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
+ [formatter setDateFormat:dateFormatterString];
+ return [formatter dateFromString:dateString];
+}
+
++ (NSDate*)dateWithISO8601String:(NSString*)dateString {
+ if(!dateString) return nil;
+ if([dateString hasSuffix:@" 00:00"]) {
+ dateString = [[dateString substringToIndex:(dateString.length-6)] stringByAppendingString:@"GMT"];
+ } else if ([dateString hasSuffix:@"Z"]) {
+ dateString = [[dateString substringToIndex:(dateString.length-1)] stringByAppendingString:@"GMT"];
+ }
+
+ return [[self class] dateWithString:dateString formatString:@"yyyy-MM-ddTHH:mm:ssZZZ"];
+}
+
++ (NSDate*)dateWithDateString:(NSString*)dateString {
+ return [[self class] dateWithString:dateString formatString:@"yyyy-MM-dd"];
+}
+
++ (NSDate*)dateWithDateTimeString:(NSString*)dateString {
+ return [[self class] dateWithString:dateString formatString:@"yyyy-MM-dd HH:mm:ss"];
+}
+
++ (NSDate*)dateWithLongDateTimeString:(NSString*)dateString {
+ return [[self class] dateWithString:dateString formatString:@"dd MMM yyyy HH:mm:ss"];
+}
+
++ (NSDate*)dateWithRSSDateString:(NSString*)dateString {
+ if ([dateString hasSuffix:@"Z"]) {
+ dateString = [[dateString substringToIndex:(dateString.length-1)] stringByAppendingString:@"GMT"];
+ }
+
+ return [[self class] dateWithString:dateString formatString:@"EEE, d MMM yyyy HH:mm:ss ZZZ"];
+}
+
++ (NSDate*)dateWithAltRSSDateString:(NSString*)dateString {
+ if ([dateString hasSuffix:@"Z"]) {
+ dateString = [[dateString substringToIndex:(dateString.length-1)] stringByAppendingString:@"GMT"];
+ }
+
+ return [[self class] dateWithString:dateString formatString:@"d MMM yyyy HH:mm:ss ZZZ"];
+}
+
+- (NSString*)formattedDateWithFormatString:(NSString*)dateFormatterString {
+ if(!dateFormatterString) return nil;
+
+ NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
+ [formatter setDateFormat:dateFormatterString];
+ [formatter setAMSymbol:@"am"];
+ [formatter setPMSymbol:@"pm"];
+ return [formatter stringFromDate:self];
+}
+
+- (NSString*)formattedDate {
+ return [self formattedDateWithFormatString:@"EEE, d MMM 'at' h:mma"];
+}
+
+- (NSString*)relativeFormattedDate {
+ // Initialize the formatter.
+ NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
+ [formatter setDateStyle:NSDateFormatterShortStyle];
+ [formatter setTimeStyle:NSDateFormatterNoStyle];
+
+ // Initialize the calendar and flags.
+ unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit;
+ NSCalendar* calendar = [NSCalendar currentCalendar];
+
+ // Create reference date for supplied date.
+ NSDateComponents *comps = [calendar components:unitFlags fromDate:self];
+ [comps setHour:0];
+ [comps setMinute:0];
+ [comps setSecond:0];
+
+ NSDate* suppliedDate = [calendar dateFromComponents:comps];
+
+ // Iterate through the eight days (tomorrow, today, and the last six).
+ int i;
+ for (i = -1; i < 7; i++) {
+ // Initialize reference date.
+ comps = [calendar components:unitFlags fromDate:[NSDate date]];
+ [comps setHour:0];
+ [comps setMinute:0];
+ [comps setSecond:0];
+ [comps setDay:[comps day] - i];
+ NSDate* referenceDate = [calendar dateFromComponents:comps];
+ // Get week day (starts at 1).
+ int weekday = [[calendar components:unitFlags fromDate:referenceDate] weekday] - 1;
+
+ if ([suppliedDate compare:referenceDate] == NSOrderedSame && i == 0) {
+ // Today
+ [formatter setDateStyle:NSDateFormatterNoStyle];
+ [formatter setTimeStyle:NSDateFormatterShortStyle];
+ break;
+ } else if ([suppliedDate compare:referenceDate] == NSOrderedSame && i == 1) {
+ // Yesterday
+ [formatter setDateStyle:NSDateFormatterNoStyle];
+ return @"Yesterday";
+ } else if ([suppliedDate compare:referenceDate] == NSOrderedSame) {
+ // Day of the week
+ return [[formatter weekdaySymbols] objectAtIndex:weekday];
+ }
+ }
+
+ // It's not in those eight days.
+ return [formatter stringFromDate:self];
+}
+
+- (NSString*)relativeFormattedDateOnly {
+ // Initialize the formatter.
+ NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
+ [formatter setDateStyle:NSDateFormatterShortStyle];
+ [formatter setTimeStyle:NSDateFormatterNoStyle];
+
+ // Initialize the calendar and flags.
+ unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit;
+ NSCalendar* calendar = [NSCalendar currentCalendar];
+
+ // Create reference date for supplied date.
+ NSDateComponents *comps = [calendar components:unitFlags fromDate:self];
+ [comps setHour:0];
+ [comps setMinute:0];
+ [comps setSecond:0];
+
+ NSDate* suppliedDate = [calendar dateFromComponents:comps];
+
+ // Iterate through the eight days (tomorrow, today, and the last six).
+ int i;
+ for (i = -1; i < 7; i++) {
+ // Initialize reference date.
+ comps = [calendar components:unitFlags fromDate:[NSDate date]];
+ [comps setHour:0];
+ [comps setMinute:0];
+ [comps setSecond:0];
+ [comps setDay:[comps day] - i];
+ NSDate* referenceDate = [calendar dateFromComponents:comps];
+ // Get week day (starts at 1).
+ int weekday = [[calendar components:unitFlags fromDate:referenceDate] weekday] - 1;
+
+ if ([suppliedDate compare:referenceDate] == NSOrderedSame && i == 0) {
+ // Today
+ [formatter setDateStyle:NSDateFormatterNoStyle];
+ return @"Today";
+ } else if ([suppliedDate compare:referenceDate] == NSOrderedSame && i == 1) {
+ // Yesterday
+ [formatter setDateStyle:NSDateFormatterNoStyle];
+ return @"Yesterday";
+ } else if ([suppliedDate compare:referenceDate] == NSOrderedSame && i == -1) {
+ // Yesterday
+ [formatter setDateStyle:NSDateFormatterNoStyle];
+ return@"Tomorrow";
+ } else if ([suppliedDate compare:referenceDate] == NSOrderedSame) {
+ // Day of the week
+ return [[formatter weekdaySymbols] objectAtIndex:weekday];
+ }
+ }
+
+ // It's not in those eight days.
+ return [formatter stringFromDate:self];
+}
+
+- (NSString*)relativeFormattedDateTime {
+ // Initialize the formatter.
+ NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
+ [formatter setDateStyle:NSDateFormatterShortStyle];
+ [formatter setTimeStyle:NSDateFormatterShortStyle];
+ [formatter setAMSymbol:@"am"];
+ [formatter setPMSymbol:@"pm"];
+
+ // Initialize the calendar and flags.
+ unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit;
+ NSCalendar* calendar = [NSCalendar currentCalendar];
+
+ // Create reference date for supplied date.
+ NSDateComponents *comps = [calendar components:unitFlags fromDate:self];
+ [comps setHour:0];
+ [comps setMinute:0];
+ [comps setSecond:0];
+
+ NSDate* suppliedDate = [calendar dateFromComponents:comps];
+
+ // Iterate through the eight days (tomorrow, today, and the last six).
+ int i;
+ for (i = -1; i < 7; i++) {
+ // Initialize reference date.
+ comps = [calendar components:unitFlags fromDate:[NSDate date]];
+ [comps setHour:0];
+ [comps setMinute:0];
+ [comps setSecond:0];
+ [comps setDay:[comps day] - i];
+ NSDate* referenceDate = [calendar dateFromComponents:comps];
+ // Get week day (starts at 1).
+ int weekday = [[calendar components:unitFlags fromDate:referenceDate] weekday] - 1;
+
+ if ([suppliedDate compare:referenceDate] == NSOrderedSame && i == 0) {
+ // Today
+ [formatter setDateStyle:NSDateFormatterNoStyle];
+ return [NSString stringWithFormat:@"Today, %@", [formatter stringFromDate:self]];
+ } else if ([suppliedDate compare:referenceDate] == NSOrderedSame && i == 1) {
+ // Yesterday
+ [formatter setDateStyle:NSDateFormatterNoStyle];
+ return [NSString stringWithFormat:@"Yesterday, %@", [formatter stringFromDate:self]];
+ } else if ([suppliedDate compare:referenceDate] == NSOrderedSame) {
+ // Day of the week
+ NSString* day = [[formatter weekdaySymbols] objectAtIndex:weekday];
+ [formatter setDateStyle:NSDateFormatterNoStyle];
+ return [NSString stringWithFormat:@"%@, %@", day, [formatter stringFromDate:self]];
+ }
+ }
+
+ // It's not in those eight days.
+ [formatter setDateStyle:NSDateFormatterShortStyle];
+ [formatter setTimeStyle:NSDateFormatterNoStyle];
+ NSString* date = [formatter stringFromDate:self];
+
+ [formatter setDateStyle:NSDateFormatterNoStyle];
+ [formatter setTimeStyle:NSDateFormatterShortStyle];
+ NSString* time = [formatter stringFromDate:self];
+
+ return [NSString stringWithFormat:@"%@, %@", date, time];
+}
+
+- (NSString*)relativeLongFormattedDate {
+ // Initialize the formatter.
+ NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
+ [formatter setDateStyle:NSDateFormatterFullStyle];
+ [formatter setTimeStyle:NSDateFormatterNoStyle];
+
+ // Initialize the calendar and flags.
+ unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit;
+ NSCalendar* calendar = [NSCalendar currentCalendar];
+
+ // Create reference date for supplied date.
+ NSDateComponents *comps = [calendar components:unitFlags fromDate:self];
+ [comps setHour:0];
+ [comps setMinute:0];
+ [comps setSecond:0];
+
+ NSDate* suppliedDate = [calendar dateFromComponents:comps];
+
+ // Iterate through the eight days (tomorrow, today, and the last six).
+ int i;
+ for (i = -1; i < 7; i++) {
+ // Initialize reference date.
+ comps = [calendar components:unitFlags fromDate:[NSDate date]];
+ [comps setHour:0];
+ [comps setMinute:0];
+ [comps setSecond:0];
+ [comps setDay:[comps day] - i];
+ NSDate* referenceDate = [calendar dateFromComponents:comps];
+ // Get week day (starts at 1).
+ int weekday = [[calendar components:unitFlags fromDate:referenceDate] weekday] - 1;
+
+ if ([suppliedDate compare:referenceDate] == NSOrderedSame && i == 0) {
+ // Today
+ [formatter setDateStyle:NSDateFormatterNoStyle];
+ return @"Today";
+ } else if ([suppliedDate compare:referenceDate] == NSOrderedSame && i == 1) {
+ // Yesterday
+ [formatter setDateStyle:NSDateFormatterNoStyle];
+ return @"Yesterday";
+ } else if ([suppliedDate compare:referenceDate] == NSOrderedSame && i == -1) {
+ // Tomorrow
+ [formatter setDateStyle:NSDateFormatterNoStyle];
+ return @"Tomorrow";
+ } else if ([suppliedDate compare:referenceDate] == NSOrderedSame) {
+ // Day of the week
+ return [[formatter weekdaySymbols] objectAtIndex:weekday];
+ }
+ }
+
+ // It's not in those eight days.
+ return [formatter stringFromDate:self];
+}
+
+- (NSString*)formattedTime {
+ // Initialize the formatter.
+ NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
+ [formatter setDateStyle:NSDateFormatterNoStyle];
+ [formatter setTimeStyle:NSDateFormatterShortStyle];
+
+ return [formatter stringFromDate:self];
+}
+
+- (NSString*)iso8601Formatted {
+ return [self formattedDateWithFormatString:@"yyyy-MM-dd'T'HH:mm:ssZ"];
+}
+
+- (BOOL)isPastDate {
+ NSDate* now = [NSDate date];
+ if([[now earlierDate:self] isEqualToDate:self]) {
+ return YES;
+ } else {
+ return NO;
+ }
+}
+
+-(NSDate*) dateOnly{
+ // start by retrieving day, weekday, month and year components for today
+ NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
+ NSDateComponents *todayComponents = [gregorian components:(NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit) fromDate:self];
+ NSInteger theDay = [todayComponents day];
+ NSInteger theMonth = [todayComponents month];
+ NSInteger theYear = [todayComponents year];
+
+ // now build a NSDate object for the input date using these components
+ NSDateComponents *components = [[NSDateComponents alloc] init];
+ [components setDay:theDay];
+ [components setMonth:theMonth];
+ [components setYear:theYear];
+ NSDate *thisDate = [gregorian dateFromComponents:components];
+ [components release];
+ return thisDate;
+}
+
+@end
View
20 RTMHelper.m
@@ -7,6 +7,7 @@
//
#import "RTMHelper.h"
+#import "NSDateHelper.h"
static int compare (id obj1, id obj2, void *context) {
return [[obj1 objectForKey:@"priority"] compare:[obj2 objectForKey:@"priority"]];
@@ -31,14 +32,27 @@ -(NSMutableArray*)getFlatTaskList:(NSDictionary *)rtmResponse {
NSArray* taskSeriesListReversed = [[taskSeriesList reverseObjectEnumerator] allObjects];
for (NSDictionary *taskSeries in taskSeriesListReversed) {
NSDictionary *t = [taskSeries objectForKey:@"task"];
+ id *due;
+ NSLog(@"%@", [t objectForKey:@"due"]);
+ if (![[t objectForKey:@"due"] isEqualToString:@""]) {
+ NSString *dueDate = [[t objectForKey:@"due"] substringToIndex:10];
+ due = [NSDate dateWithDateString:dueDate];
+ NSLog(@"%@", dueDate);
+ NSLog(@"%@", due);
+ } else {
+ due = @"";
+ }
+
+
+
NSDictionary *task = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:[list objectForKey:@"id"], [taskSeries objectForKey:@"id"],
- [t objectForKey:@"id"], [taskSeries objectForKey:@"name"], [t objectForKey:@"priority"] ,nil]
- forKeys:[NSArray arrayWithObjects:@"list_id", @"taskseries_id", @"task_id", @"name", @"priority", nil]];
+ [t objectForKey:@"id"], [taskSeries objectForKey:@"name"], [t objectForKey:@"priority"], due ,nil]
+ forKeys:[NSArray arrayWithObjects:@"list_id", @"taskseries_id", @"task_id", @"name", @"priority", @"due", nil]];
[tasks addObject:task];
}
}
-
+ NSLog(@"%@", tasks);
return [self sortTasks:tasks];
}
View
8 SimpleRTM.xcodeproj/project.pbxproj
@@ -23,6 +23,7 @@
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
C9041E77111280A200D0C6A3 /* RTMHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = C9041E76111280A200D0C6A3 /* RTMHelper.m */; };
+ C9A02F2C111BF11F00ACBFE1 /* NSDateHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = C9A02F2A111BF11F00ACBFE1 /* NSDateHelper.m */; };
C9AF1F771116999500BC2280 /* TransparentTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C9AF1F751116999500BC2280 /* TransparentTableViewCell.m */; };
C9AF203E1116A44D00BC2280 /* rtm.icns in Resources */ = {isa = PBXBuildFile; fileRef = C9AF203D1116A44D00BC2280 /* rtm.icns */; };
C9F70849111653CE00D3BB5B /* YRKSpinningProgressIndicator.m in Sources */ = {isa = PBXBuildFile; fileRef = C9F70848111653CE00D3BB5B /* YRKSpinningProgressIndicator.m */; };
@@ -73,6 +74,8 @@
8D1107320486CEB800E47090 /* SimpleRTM.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SimpleRTM.app; sourceTree = BUILT_PRODUCTS_DIR; };
C9041E75111280A200D0C6A3 /* RTMHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTMHelper.h; sourceTree = "<group>"; };
C9041E76111280A200D0C6A3 /* RTMHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RTMHelper.m; sourceTree = "<group>"; };
+ C9A02F2A111BF11F00ACBFE1 /* NSDateHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSDateHelper.m; sourceTree = "<group>"; };
+ C9A02F2B111BF11F00ACBFE1 /* NSDateHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSDateHelper.h; sourceTree = "<group>"; };
C9AF1F751116999500BC2280 /* TransparentTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TransparentTableViewCell.m; sourceTree = "<group>"; };
C9AF1F761116999500BC2280 /* TransparentTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TransparentTableViewCell.h; sourceTree = "<group>"; };
C9AF203D1116A44D00BC2280 /* rtm.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = rtm.icns; sourceTree = "<group>"; };
@@ -103,10 +106,12 @@
256AC3D90F4B6AC300CF3369 /* SimpleRTMAppDelegate.m */,
C9041E75111280A200D0C6A3 /* RTMHelper.h */,
C9041E76111280A200D0C6A3 /* RTMHelper.m */,
- C9AF1F751116999500BC2280 /* TransparentTableViewCell.m */,
C9AF1F761116999500BC2280 /* TransparentTableViewCell.h */,
+ C9AF1F751116999500BC2280 /* TransparentTableViewCell.m */,
C9F70847111653CE00D3BB5B /* YRKSpinningProgressIndicator.h */,
C9F70848111653CE00D3BB5B /* YRKSpinningProgressIndicator.m */,
+ C9A02F2B111BF11F00ACBFE1 /* NSDateHelper.h */,
+ C9A02F2A111BF11F00ACBFE1 /* NSDateHelper.m */,
);
name = Classes;
sourceTree = "<group>";
@@ -270,6 +275,7 @@
C9041E77111280A200D0C6A3 /* RTMHelper.m in Sources */,
C9F70849111653CE00D3BB5B /* YRKSpinningProgressIndicator.m in Sources */,
C9AF1F771116999500BC2280 /* TransparentTableViewCell.m in Sources */,
+ C9A02F2C111BF11F00ACBFE1 /* NSDateHelper.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
7 SimpleRTMAppDelegate.m
@@ -176,6 +176,13 @@ -(id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn
[cell setTextColor:[NSColor whiteColor]];
}
+ id due = [task objectForKey:@"due"];
+ if ([due isKindOfClass:[NSDate class]] && ([due isPastDate] || [[NSDate date] isEqualToDate:due])) {
+ [cell setBold:YES];
+ } else {
+ [cell setBold:NO];
+ }
+
return [task objectForKey:@"name"];
}
View
2 TransparentTableViewCell.h
@@ -12,6 +12,8 @@
{
BOOL mIsEditingOrSelecting;
BOOL customTextColor;
+ BOOL shouldBold;
}
+
@end
View
13 TransparentTableViewCell.m
@@ -8,6 +8,8 @@
#import "TransparentTableViewCell.h"
+
+
@implementation TransparentTableViewCell
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
@@ -25,7 +27,12 @@ - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
if (!customTextColor) {
[attributes setObject:textColor forKey:NSForegroundColorAttributeName];
}
- [attributes setObject:[NSFont systemFontOfSize:11] forKey:NSFontAttributeName];
+ if (shouldBold) {
+ [attributes setObject:[NSFont boldSystemFontOfSize:11] forKey:NSFontAttributeName];
+ } else {
+ [attributes setObject:[NSFont systemFontOfSize:11] forKey:NSFontAttributeName];
+ }
+
NSMutableAttributedString *string = [[[NSMutableAttributedString alloc] initWithString:[self title] attributes:attributes] autorelease];
[self setAttributedStringValue:string];
@@ -88,4 +95,8 @@ - (void)setTextColor:(NSColor *)color {
[super setTextColor:color];
}
+- (void)setBold:(BOOL)bold {
+ shouldBold = bold;
+}
+
@end

0 comments on commit 34dbef4

Please sign in to comment.