updated demo for message dates

This commit is contained in:
Jesse Squires
2013-03-19 21:42:57 -04:00
parent 1b5115bdc0
commit 0276472c03
2 changed files with 19 additions and 1 deletions

View File

@@ -11,5 +11,6 @@
@interface DemoViewController : JSMessagesViewController
@property (strong, nonatomic) NSMutableArray *messages;
@property (strong, nonatomic) NSMutableArray *dates;
@end
@end

View File

@@ -19,14 +19,24 @@
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Messages";
self.dateLabelPolicy = JSMessagesViewDateLabelPolicyEveryThree;
self.messages = [[NSMutableArray alloc] initWithObjects:
@"Testing some messages here.",
@"This work is based on Sam Soffes' SSMessagesViewController.",
@"This is a complete re-write and refactoring.",
@"It's easy to implement. Sound effects and images included. Animations are smooth and messages can be of arbitrary size!",
nil];
self.dates = [[NSMutableArray alloc] initWithObjects:
[NSDate distantPast],
[NSDate distantPast],
[NSDate distantPast],
[NSDate distantPast],
nil];
}
#pragma mark - Table view data source
@@ -46,10 +56,17 @@
return [self.messages objectAtIndex:indexPath.row];
}
- (NSDate *)dateForRowAtIndexPath:(NSIndexPath *)indexPath
{
return [self.dates objectAtIndex:indexPath.row];
}
- (void)sendPressed:(UIButton *)sender withText:(NSString *)text
{
[self.messages addObject:text];
[self.dates addObject:[NSDate date]];
if((self.messages.count - 1) % 2)
[JSMessageSoundEffect playMessageSentSound];
else