Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- static NSString *MyIdentifier = @"cell1";
- NSDictionary *categoryDictionary= [[appdelegate categoriesArray] objectAtIndex:indexPath.row];
- categoryTableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
- rect=cell.labelProgressView.frame;
- cell.backgroundColor = [UIColor PGColorBackground];
- cell.buttonView.hidden=YES;
- //Set background colors and icons
- switch ([[categoryDictionary valueForKey:@"categoryID"] intValue])
- {
- case 1:
- [cell.buttonView setBackgroundColor: [UIColor PGColorAttractions]] ;
- [cell.labelProgressView setBackgroundColor: [UIColor PGColorAttractions]] ;
- [cell.ivCategoryBannerImage setImage: [UIImage imageNamed:@"attraction-bg"]];
- cell.ivcategoryLogoImage.image =[UIImage imageNamed:@"attractionWhite"];
- break;
- case 2:
- [cell.buttonView setBackgroundColor: [UIColor PGColorRestaurants]];
- [cell.labelProgressView setBackgroundColor: [UIColor PGColorRestaurants]];
- [cell.ivCategoryBannerImage setImage: [UIImage imageNamed:@"restaurant-bg"]];
- cell.ivcategoryLogoImage.image =[UIImage imageNamed:@"restaurantWhite"];
- break;
- case 3:
- [cell.buttonView setBackgroundColor: [UIColor PGColorShopping]];
- [cell.labelProgressView setBackgroundColor:[UIColor PGColorShopping]];
- [cell.ivCategoryBannerImage setImage: [UIImage imageNamed:@"shopping-bg"]];
- cell.ivcategoryLogoImage.image =[UIImage imageNamed:@"shoppingWhite"];
- break;
- case 4:
- [cell.buttonView setBackgroundColor: [UIColor PGColorAccomodations]];
- [cell.labelProgressView setBackgroundColor:[UIColor PGColorAccomodations]];
- [cell.ivCategoryBannerImage setImage: [UIImage imageNamed:@"accomodation-bg"]];
- cell.ivcategoryLogoImage.image =[UIImage imageNamed:@"accomodationWhite"];
- break;
- case 5:
- [cell.buttonView setBackgroundColor: [UIColor PGColorArtGalleries]];
- [cell.labelProgressView setBackgroundColor:[UIColor PGColorArtGalleries]];
- [cell.ivCategoryBannerImage setImage: [UIImage imageNamed:@"artGallery-bg"]];
- cell.ivcategoryLogoImage.image =[UIImage imageNamed:@"artGalleryWhite"];
- break;
- default:
- break;
- }
- //DOWNLOAD Button
- [cell.buttonViewDownload setBackgroundColor:[UIColor clearColor]];
- cell.buttonViewDownload.layer.borderColor=[UIColor whiteColor].CGColor;
- cell.buttonViewDownload.layer.borderWidth=1.0f;
- [cell.buttonViewDownload.titleLabel setFont:[UIFont fontWithName:@"OpenSans-Bold" size:10]];
- [cell.buttonViewDownload setTag:[[categoryDictionary valueForKey:@"categoryID"] intValue]];
- //VIEW Button
- cell.buttonView.layer.borderColor=[UIColor whiteColor].CGColor;
- cell.buttonView.layer.borderWidth=1.0f;
- [cell.buttonView.titleLabel setFont:[UIFont fontWithName:@"OpenSans-Bold" size:10]];
- [cell.buttonView setTag:[[categoryDictionary valueForKey:@"categoryID"] intValue]];
- [cell.buttonView addTarget:self action:@selector(viewbuttonClicked:) forControlEvents:UIControlEventTouchUpInside];
- //CATEGORY label
- NSString *categoryName =[[NSString stringWithFormat:@"%@",[categoryDictionary valueForKey:@"categoryNameen"]] uppercaseString];
- NSMutableAttributedString *attributedString;
- attributedString = [[NSMutableAttributedString alloc] initWithString:categoryName];
- [attributedString addAttribute:NSKernAttributeName
- value:[NSNumber numberWithFloat:8.0]
- range:NSMakeRange(0, [categoryName length])];
- [attributedString addAttribute:NSFontAttributeName
- value:[UIFont fontWithName:@"OpenSans-Bold" size:19]
- range:NSMakeRange(0, [categoryName length])];
- [cell.labelCategory setAttributedText:attributedString];
- cell.selectionStyle=UITableViewCellAccessoryNone;
- //Set State
- cell.ivCategoryBannerImage.alpha =0.1f;
- BOOL isAvailable = [[categoryDictionary valueForKey:@"isAvailable"] boolValue];
- BOOL userTappedDownload = [[categoryDictionary valueForKey:@"userTappedDownload"] boolValue];
- NSLog(@"isAvailable: %d", isAvailable);
- NSLog(@"userTappedDownload: %d", isAvailable);
- if (isAvailable && userTappedDownload)
- {
- cell.buttonView.hidden=NO;
- [cell.buttonView setTitle:@"VIEW" forState:UIControlStateNormal];
- cell.buttonViewDownload.hidden=YES;
- cell.ivCategoryBannerImage.alpha =1.0f;
- rect.size.width=208.0f;
- }
- else if(!isAvailable && !userTappedDownload)
- {
- rect.size.width=0.1f;
- [cell.buttonViewDownload setTitle:[NSString stringWithFormat:@"DOWNLOAD (%@ KB)",[categoryDictionary valueForKey:@"totalImagesSize"]] forState:0];
- }
- else if(!isAvailable && userTappedDownload)
- {
- rect.size.width=[[categoryDictionary valueForKey:@"totalImagesAvailable"] intValue];
- [cell.buttonViewDownload setTitle:@"DOWNLOADING CONTENT" forState:UIControlStateNormal];
- cell.buttonViewDownload.userInteractionEnabled = NO;
- }
- return cell;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement