daily pastebin goal
15%
SHARE
TWEET

Untitled

a guest Jan 16th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  2.  
  3.     static NSString *CellIdentifier = @"Cell";
  4.  
  5.  
  6.     TDBadgedCell *cell = [[TDBadgedCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
  7.    
  8. // Customize the appearance of table view cells.
  9. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  10.  
  11.     static NSString *CellIdentifier = @"Cell";
  12.  
  13.     DDBadgeViewCell *cell = (DDBadgeViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  14.     if (cell == nil) {
  15.         cell = [[DDBadgeViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  16.     }
  17.    
  18. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  19. {
  20.     //static NSString *CellIdentifier = @"MeetingCell";
  21.  
  22.     static NSString *CellIdentifier = @"Cell";
  23.     DDBadgeViewCell *cell = (DDBadgeViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  24.     if (cell == nil) {
  25.         cell = [[DDBadgeViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  26.     }
  27.  
  28.  
  29.     //UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  30.  
  31.  
  32.     NSString *description =@":";
  33.     NSString *name =@"";
  34.     NSString *fileStatus=@"";
  35.  
  36.     name = [[self agenda] getFileNameWithSection:[indexPath section] Row:[indexPath row]];
  37.     description = [[self agenda] getFileDescriptionWithSection:[indexPath section] Row:[indexPath row]];
  38.  
  39.     fileStatus = [[self agenda] getFileStatusWithFileName:name];
  40.  
  41.     NSString * cellLabel = [NSString stringWithFormat:@" %@ : %@",description,name];
  42.  
  43.     //alloc row images
  44.     UIImage *docImage = [UIImage imageNamed:@"ICON - Word@2x.png"];
  45.     UIImage *xlsImage = [UIImage imageNamed:@"ICON - Excel@2x.png"];
  46.    // UIImage *picImage = [UIImage imageNamed:@"ICON - Image@2x.png"];
  47.     UIImage *pdfImage = [UIImage imageNamed:@"pdf icon@2x copy.png"];
  48.     UIImage *pptImage = [UIImage imageNamed:@"ICON - PPT@2x.png"];
  49.  
  50.  
  51.     //Determine what status to display for a file
  52.     //No need to that since wee use push notification
  53.     if ([fileStatus isEqualToString:@"new"]){
  54.         cellLabel = [NSString stringWithFormat:@"%@ (%@)",cellLabel,@"New"];
  55.         cell.badgeText = [NSString stringWithFormat:@"Update"];
  56.         cell.badgeColor = [UIColor orangeColor];
  57.     }else if ([fileStatus isEqualToString:@"outdated"]){
  58.         cellLabel = [NSString stringWithFormat:@"%@ (%@)",cellLabel,@"Outdated"];
  59.         cell.badgeText = [NSString stringWithFormat:@"Update"];
  60.         cell.badgeColor = [UIColor orangeColor];
  61.     }else if ([fileStatus isEqualToString:@"updated"]){
  62.         cellLabel = [NSString stringWithFormat:@"%@ (%@)",cellLabel,@"Latest"];
  63.     }
  64.  
  65.  
  66.  
  67.  
  68.     UIFont *font1 = [UIFont fontWithName:@"Century Gothic" size:15.0f];
  69.     cell.textLabel.font=font1;
  70.     //if there is no file user can not tocuh the row
  71.     if ([name length]==0) {
  72.         cell.userInteractionEnabled = NO;
  73.         cell.accessoryType = UITableViewCellAccessoryNone;
  74.         cell.textLabel.text = description;
  75.  
  76.     }else{
  77.         //set cell title
  78.  
  79.         cell.textLabel.text = cellLabel;
  80.     }
  81.     //set row images
  82.     if ([name rangeOfString:@"docx"].location != NSNotFound) {
  83.  
  84.         cell.imageView.image= docImage;
  85.  
  86.     }else if ([name rangeOfString:@"xlsx"].location != NSNotFound){
  87.         cell.imageView.image= xlsImage;
  88.  
  89.     }
  90.     else if ([name rangeOfString:@"pdf"].location != NSNotFound){
  91.         cell.imageView.image= pdfImage;
  92.     }
  93.     else if ([name rangeOfString:@"ppt"].location != NSNotFound){
  94.         cell.imageView.image= pptImage;
  95.     }
  96.  
  97.     cell.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"rounded corner box center@2x.png"]];
  98.     // At end of function, right before return cell
  99.     cell.textLabel.backgroundColor = [UIColor clearColor];
  100.  
  101.  
  102.     NSLog(@"%@",cell.textLabel.text);
  103.     return cell;
  104.  
  105. }
  106.  
  107. #pragma mark - Table view delegate
  108.  
  109. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  110. {
  111.     // Navigation logic may go here. Create and push another view controller.
  112.     /*
  113.      <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
  114.      // ...
  115.      // Pass the selected object to the new view controller.
  116.      [self.navigationController pushViewController:detailViewController animated:YES];.0
  117.  
  118.      */
  119.  
  120.     NSLog(@"didselect row is called %d",indexPath.row);
  121.  
  122. }
  123.  
  124. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
  125. {
  126.     if ([[DBSession sharedSession] isLinked]) {
  127.     if([[segue identifier] isEqualToString:@"pushDocumentView"])
  128.     {
  129.         NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
  130.         NSInteger section =[indexPath section];
  131.         NSInteger row = [indexPath row];
  132.         NSString *fileName = [[self agenda] getFileNameWithSection:section Row:row];
  133.  
  134.         NSDictionary * agendaDic = [[[self agenda]revision] objectForKey:fileName];
  135.         NSString *fileStatus  =[agendaDic objectForKey:@"status"];
  136.  
  137.  
  138.         DocumentViewController *docViewController  = [segue destinationViewController];
  139.         //This will display on the Document Viewer
  140.         docViewController.fileName=fileName;
  141.         //This will determine remote or local copy display
  142.         docViewController.fileStatus=fileStatus;
  143.  
  144.     }
  145.     }else {
  146.         [self displayError];
  147.         [self setWorking:NO];
  148.     }
  149. }
  150.    
  151. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  152. {
  153.     // Navigation logic may go here. Create and push another view controller.
  154.     /*
  155.      <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
  156.      // ...
  157.      // Pass the selected object to the new view controller.
  158.      [self.navigationController pushViewController:detailViewController animated:YES];.0
  159.  
  160.      */
  161.  
  162.  
  163.     [self performSegueWithIdentifier:@"yoursegue" sender:self];
  164.  
  165.     NSLog(@"didselect row is called %d",indexPath.row);
  166.  
  167. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top