Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- static NSString *CellIdentifier = @"Cell";
- TDBadgedCell *cell = [[TDBadgedCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
- // Customize the appearance of table view cells.
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- static NSString *CellIdentifier = @"Cell";
- DDBadgeViewCell *cell = (DDBadgeViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[DDBadgeViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- //static NSString *CellIdentifier = @"MeetingCell";
- static NSString *CellIdentifier = @"Cell";
- DDBadgeViewCell *cell = (DDBadgeViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[DDBadgeViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
- }
- //UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- NSString *description =@":";
- NSString *name =@"";
- NSString *fileStatus=@"";
- name = [[self agenda] getFileNameWithSection:[indexPath section] Row:[indexPath row]];
- description = [[self agenda] getFileDescriptionWithSection:[indexPath section] Row:[indexPath row]];
- fileStatus = [[self agenda] getFileStatusWithFileName:name];
- NSString * cellLabel = [NSString stringWithFormat:@" %@ : %@",description,name];
- //alloc row images
- UIImage *docImage = [UIImage imageNamed:@"ICON - Word@2x.png"];
- UIImage *xlsImage = [UIImage imageNamed:@"ICON - Excel@2x.png"];
- // UIImage *picImage = [UIImage imageNamed:@"ICON - Image@2x.png"];
- UIImage *pdfImage = [UIImage imageNamed:@"pdf icon@2x copy.png"];
- UIImage *pptImage = [UIImage imageNamed:@"ICON - PPT@2x.png"];
- //Determine what status to display for a file
- //No need to that since wee use push notification
- if ([fileStatus isEqualToString:@"new"]){
- cellLabel = [NSString stringWithFormat:@"%@ (%@)",cellLabel,@"New"];
- cell.badgeText = [NSString stringWithFormat:@"Update"];
- cell.badgeColor = [UIColor orangeColor];
- }else if ([fileStatus isEqualToString:@"outdated"]){
- cellLabel = [NSString stringWithFormat:@"%@ (%@)",cellLabel,@"Outdated"];
- cell.badgeText = [NSString stringWithFormat:@"Update"];
- cell.badgeColor = [UIColor orangeColor];
- }else if ([fileStatus isEqualToString:@"updated"]){
- cellLabel = [NSString stringWithFormat:@"%@ (%@)",cellLabel,@"Latest"];
- }
- UIFont *font1 = [UIFont fontWithName:@"Century Gothic" size:15.0f];
- cell.textLabel.font=font1;
- //if there is no file user can not tocuh the row
- if ([name length]==0) {
- cell.userInteractionEnabled = NO;
- cell.accessoryType = UITableViewCellAccessoryNone;
- cell.textLabel.text = description;
- }else{
- //set cell title
- cell.textLabel.text = cellLabel;
- }
- //set row images
- if ([name rangeOfString:@"docx"].location != NSNotFound) {
- cell.imageView.image= docImage;
- }else if ([name rangeOfString:@"xlsx"].location != NSNotFound){
- cell.imageView.image= xlsImage;
- }
- else if ([name rangeOfString:@"pdf"].location != NSNotFound){
- cell.imageView.image= pdfImage;
- }
- else if ([name rangeOfString:@"ppt"].location != NSNotFound){
- cell.imageView.image= pptImage;
- }
- cell.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"rounded corner box center@2x.png"]];
- // At end of function, right before return cell
- cell.textLabel.backgroundColor = [UIColor clearColor];
- NSLog(@"%@",cell.textLabel.text);
- return cell;
- }
- #pragma mark - Table view delegate
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // Navigation logic may go here. Create and push another view controller.
- /*
- <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
- // ...
- // Pass the selected object to the new view controller.
- [self.navigationController pushViewController:detailViewController animated:YES];.0
- */
- NSLog(@"didselect row is called %d",indexPath.row);
- }
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
- {
- if ([[DBSession sharedSession] isLinked]) {
- if([[segue identifier] isEqualToString:@"pushDocumentView"])
- {
- NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
- NSInteger section =[indexPath section];
- NSInteger row = [indexPath row];
- NSString *fileName = [[self agenda] getFileNameWithSection:section Row:row];
- NSDictionary * agendaDic = [[[self agenda]revision] objectForKey:fileName];
- NSString *fileStatus =[agendaDic objectForKey:@"status"];
- DocumentViewController *docViewController = [segue destinationViewController];
- //This will display on the Document Viewer
- docViewController.fileName=fileName;
- //This will determine remote or local copy display
- docViewController.fileStatus=fileStatus;
- }
- }else {
- [self displayError];
- [self setWorking:NO];
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // Navigation logic may go here. Create and push another view controller.
- /*
- <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
- // ...
- // Pass the selected object to the new view controller.
- [self.navigationController pushViewController:detailViewController animated:YES];.0
- */
- [self performSegueWithIdentifier:@"yoursegue" sender:self];
- NSLog(@"didselect row is called %d",indexPath.row);
- }
Add Comment
Please, Sign In to add comment