- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary * startup = [self.entries objectAtIndex: indexPath.row];
CLLocationDistance distance = 0;
float miles = 0;
NSDictionary * val;
if([startup objectForKey: @"startup"] &&
[startup objectForKey: @"startup"] != (id) [NSNull null]) {
val = [startup objectForKey: @"startup"];
}
else {
val = startup;
}
if ([startup objectForKey: @"longitude"] &&
[startup objectForKey: @"longitude"] != (id)[NSNull null] &&
[startup objectForKey: @"latitude"] &&
[startup objectForKey: @"latitude"] != (id)[NSNull null] )
{
CLLocationDegrees latitude = [[startup objectForKey: @"latitude"] doubleValue];
CLLocationDegrees longitude = [[startup objectForKey: @"longitude"] doubleValue];
distance = [self myDistanceFromLatitude: latitude longitude: longitude];
miles = [self convertToMiles: distance];
}
NSString * photo_url = @"";
NSString * funding_t = @"n/a";
NSString * pitch = @"";
NSString * name = @"";
NSInteger startup_id;
NSString * team_size = @"0";
NSString * revenue = @"";
NSString * raising = @"";
NSString * category = @"n/a";
NSArray * categories1;
if ([val objectForKey: @"current_funding"] &&
[val objectForKey: @"current_funding"] != (id)[NSNull null])
{
funding_t = [val objectForKey: @"current_funding"];
}
if ([val objectForKey: @"pitch"] &&
[val objectForKey: @"pitch"] != (id)[NSNull null])
{
pitch = [val objectForKey: @"pitch"];
}
if ([val objectForKey: @"name"] &&
[val objectForKey: @"name"] != (id)[NSNull null])
{
name = [val objectForKey: @"name"];
}
if ([val objectForKey: @"id"] &&
[val objectForKey: @"id"] != (id)[NSNull null])
{
if ([[val objectForKey: @"id"] intValue] > 0)
{
startup_id = [[val objectForKey: @"id"] intValue];
}
}
if ([val objectForKey: @"team_size"] &&
[val objectForKey: @"team_size"] != (id)[NSNull null])
{
if ([[val objectForKey: @"team_size"] intValue] > 0)
{
team_size = [[val objectForKey: @"team_size"] stringValue];
}
}
if ([val objectForKey: @"round_raising"] &&
[val objectForKey: @"round_raising"] != (id)[NSNull null])
{
raising = [val objectForKey: @"round_raising"];
}
if ([val objectForKey: @"revenue"] &&
[val objectForKey: @"revenue"] != (id)[NSNull null])
{
revenue = [val objectForKey: @"revenue"];
}
if ([val objectForKey: @"categories"] &&
[val objectForKey: @"categories"] != (id)[NSNull null])
{
categories1 = [val objectForKey: @"categories"];
if([categories1 count] >= 1)
{
category = [[categories1 objectAtIndex: 0] objectForKey: @"name"];
}
}
if ([val objectForKey: @"photo_url"] &&
[val objectForKey: @"photo_url"] != (id)[NSNull null])
{
photo_url = [val objectForKey: @"photo_url"];
}
CGSize newSize = CGSizeMake(308, 175);
static NSString *cellID = @"Cell Identifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (!cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell.contentView setBackgroundColor: [UIColor clearColor]];
UIImage * box = [UIImage imageNamed: @"box.png"];
UIView * cellbackgroundview = [[UIView alloc] initWithFrame: CGRectMake(7, 0, box.size.width, box.size.height)];
[cellbackgroundview setBackgroundColor: [UIColor colorWithPatternImage: box]];
UILabel * nameLabel = [[UILabel alloc] initWithFrame: CGRectMake( 0, 15, box.size.width, 19.0f)];
nameLabel.text = name;
[nameLabel setTextColor: [UIColor colorWithRed: 79.0f/255.0f green:79.0f/255.0f blue:79.0f/255.0f alpha:1.0f]];
[nameLabel setFont: [UIFont fontWithName: @"HelveticaNeue-Bold" size: 18.0f]];
[nameLabel setBackgroundColor: [UIColor clearColor]];
nameLabel.textAlignment = NSTextAlignmentCenter;
nameLabel.tag = 1;
UILabel * pitchLabel = [[UILabel alloc] initWithFrame: CGRectMake( 0, 40, box.size.width, 14.0f)];
pitchLabel.text = pitch;
pitchLabel.textAlignment = NSTextAlignmentCenter;
[pitchLabel setTextColor: [UIColor colorWithRed: 79.0f/255.0f green:79.0f/255.0f blue:79.0f/255.0f alpha:1.0f]];
[pitchLabel setFont: [UIFont fontWithName: @"HelveticaNeue-Light" size: 12.0f]];
[pitchLabel setBackgroundColor: [UIColor clearColor]];
pitchLabel.tag = 2;
UIImageView * midview;
midview = [[UIImageView alloc] initWithFrame: CGRectMake(-3, 64, 308, 175)];
midview.tag = 3;
midview.userInteractionEnabled = YES;
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotodeck:)];
tapRecognizer.numberOfTapsRequired = 1;
tapRecognizer.delegate = self;
[midview addGestureRecognizer:tapRecognizer];
UIImage * play = [UIImage imageNamed: @"nearby_play.png"];
UIImageView * playview = [[UIImageView alloc] initWithFrame: CGRectMake(120, 120, play.size.width, play.size.height)];
[playview setImage: play];
[cellbackgroundview addSubview: nameLabel];
[cellbackgroundview addSubview: pitchLabel];
[cellbackgroundview addSubview: midview];
[cellbackgroundview addSubview: playview];
float lwidth = (box.size.width - 10) / 3;
float toppos1 = box.size.height - 43;
UIImage * limg = [UIImage imageNamed: @"like.png"];
UIButton * likebtn = [UIButton buttonWithType:UIButtonTypeCustom];
[likebtn setImage: limg forState: UIControlStateNormal];
[likebtn setTitleColor: [UIColor colorWithRed: 174.0f/255.0f green: 174.0f/255.0f blue: 174.0f/255.0f alpha:1.0] forState: UIControlStateNormal];
[likebtn.titleLabel setFont: [UIFont fontWithName: @"HelveticaNeue-Bold" size: 14.0f]];
[likebtn addTarget:self action:@selector(like:) forControlEvents:UIControlEventTouchUpInside];
likebtn.userInteractionEnabled = YES;
likebtn.backgroundColor = [UIColor clearColor];
likebtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 20);
[likebtn setTitle: @"Like" forState:UIControlStateNormal];
likebtn.tag = 4;
likebtn.frame = CGRectMake(15, toppos1, lwidth, 40);
UIImage * limg1 = [UIImage imageNamed: @"chatbox.png"];
UIButton * chatbtn = [UIButton buttonWithType:UIButtonTypeCustom];
[chatbtn setTitleColor: [UIColor colorWithRed: 174.0f/255.0f green: 174.0f/255.0f blue: 174.0f/255.0f alpha:1.0] forState: UIControlStateNormal];
[chatbtn setImage: limg1 forState: UIControlStateNormal];
[chatbtn addTarget:self action:@selector(chat:)
forControlEvents:UIControlEventTouchUpInside];
chatbtn.tag = 5;
chatbtn.userInteractionEnabled = YES;
chatbtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 20);
[chatbtn.titleLabel setFont: [UIFont fontWithName: @"HelveticaNeue-Bold" size: 14.0f]];
[chatbtn setTitle: @"Chat" forState:UIControlStateNormal];
chatbtn.frame = CGRectMake(likebtn.frame.origin.x + likebtn.frame.size.width, toppos1, lwidth, 40);
UIImage * limg2 = [UIImage imageNamed: @"share.png"];
UIButton * sharebtn = [UIButton buttonWithType:UIButtonTypeCustom];
[sharebtn setImage: limg2 forState: UIControlStateNormal];
[sharebtn setTitleColor: [UIColor colorWithRed: 174.0f/255.0f green: 174.0f/255.0f blue: 174.0f/255.0f alpha:1.0] forState: UIControlStateNormal];
[sharebtn.titleLabel setFont: [UIFont fontWithName: @"HelveticaNeue-Bold" size: 14.0f]];
[sharebtn addTarget:self action:@selector(share:)
forControlEvents:UIControlEventTouchUpInside];
sharebtn.tag = 6;
sharebtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 20);
[sharebtn setTitle: @"Share" forState:UIControlStateNormal];
sharebtn.frame = CGRectMake(chatbtn.frame.origin.x + chatbtn.frame.size.width, toppos1, lwidth, 40);
float width = (box.size.width - 10)/3;
float toppos = midview.frame.origin.y + midview.frame.size.height + 10;
UILabel * aLabel3 = [[UILabel alloc] initWithFrame: CGRectMake( 13,
toppos,
width,
20)];
aLabel3.text = @"Industry";
[aLabel3 setTextColor: [UIColor colorWithRed: 79.0f/255.0f green: 79.0f/255.0f blue: 79.0f/255.0f alpha:1.0f]];
aLabel3.textAlignment = NSTextAlignmentCenter;
aLabel3.frame = CGRectIntegral(aLabel3.frame);
[aLabel3 setFont: [UIFont fontWithName: @"HelveticaNeue-Light" size: 14.0f]];
aLabel3.backgroundColor = [UIColor clearColor];
UILabel * aLabel4 = [[UILabel alloc] initWithFrame: CGRectMake( aLabel3.frame.origin.x + aLabel3.frame.size.width, toppos, width, 20)];
aLabel4.text = @"Funding";
[aLabel4 setTextColor: [UIColor colorWithRed: 79.0f/255.0f green: 79.0f/255.0f blue: 79.0f/255.0f alpha:1.0f]];
aLabel4.textAlignment = NSTextAlignmentCenter;
aLabel4.frame = CGRectIntegral(aLabel4.frame);
[aLabel4 setFont: [UIFont fontWithName: @"HelveticaNeue-Light" size: 14.0f]];
aLabel4.backgroundColor = [UIColor clearColor];
UILabel * aLabel5 = [[UILabel alloc] initWithFrame: CGRectMake( aLabel4.frame.origin.x + aLabel4.frame.size.width, toppos, width, 20)];
aLabel5.text = @"Revenue";
aLabel5.frame = CGRectIntegral(aLabel5.frame);
[aLabel5 setTextColor: [UIColor colorWithRed: 79.0f/255.0f green: 79.0f/255.0f blue: 79.0f/255.0f alpha:1.0f]];
aLabel5.textAlignment = NSTextAlignmentCenter;
[aLabel5 setFont: [UIFont fontWithName: @"HelveticaNeue-Light" size: 14.0f]];
aLabel5.backgroundColor = [UIColor clearColor];
float width2 = width;
UILabel * aLabel3a = [[UILabel alloc] initWithFrame: CGRectMake( aLabel3.frame.origin.x, aLabel3.frame.origin.y + aLabel3.frame.size.height + 5, width2, 20)];
aLabel3a.text = category;
[aLabel3a setTextColor: [UIColor colorWithRed: 79.0f/255.0f green: 79.0f/255.0f blue: 79.0f/255.0f alpha:1.0f]];
aLabel3a.textAlignment = NSTextAlignmentCenter;
aLabel3a.frame = CGRectIntegral(aLabel3a.frame);
aLabel3a.adjustsFontSizeToFitWidth = YES;
aLabel3a.tag = 7;
[aLabel3a setFont: [UIFont fontWithName: @"HelveticaNeue-Bold" size: 14.0f]];
aLabel3a.backgroundColor = [UIColor clearColor];
UILabel * aLabel4a = [[UILabel alloc] initWithFrame: CGRectMake( aLabel3a.frame.origin.x + aLabel3a.frame.size.width, aLabel3.frame.origin.y + aLabel3.frame.size.height + 5, width2, 20)];
aLabel4a.text = funding_t;
aLabel4a.textAlignment = NSTextAlignmentCenter;
aLabel4a.adjustsFontSizeToFitWidth = YES;
aLabel4a.frame = CGRectIntegral(aLabel4a.frame);
aLabel4a.tag = 8;
[aLabel4a setTextColor: [UIColor colorWithRed: 79.0f/255.0f green: 79.0f/255.0f blue: 79.0f/255.0f alpha:1.0f]];
[aLabel4a setFont: [UIFont fontWithName: @"HelveticaNeue-Bold" size: 14.0f]];
aLabel4a.backgroundColor = [UIColor clearColor];
UILabel * aLabel5a = [[UILabel alloc] initWithFrame: CGRectMake( aLabel4a.frame.origin.x + aLabel4a.frame.size.width, aLabel3.frame.origin.y + aLabel3.frame.size.height + 5, width2, 20)];
aLabel5a.text = revenue;
[aLabel5a setTextColor: [UIColor colorWithRed: 79.0f/255.0f green: 79.0f/255.0f blue: 79.0f/255.0f alpha:1.0f]];
aLabel5a.textAlignment = NSTextAlignmentCenter;
aLabel5a.adjustsFontSizeToFitWidth = YES;
aLabel5a.tag = 9;
aLabel5a.frame = CGRectIntegral(aLabel5a.frame);
[aLabel5a setFont: [UIFont fontWithName: @"HelveticaNeue-Bold" size: 14.0f]];
aLabel5a.backgroundColor = [UIColor clearColor];
UIImage * rimg = [UIImage imageNamed: @"ribbon.png"];
UIView * rview = [[UIView alloc] initWithFrame: CGRectMake(box.size.width - 48, -3, rimg.size.width, rimg.size.height)];
[rview setBackgroundColor: [UIColor colorWithPatternImage: rimg]];
UILabel * disLabel = [[UILabel alloc] initWithFrame: CGRectMake(0, 10, rimg.size.width, 16)];
disLabel.numberOfLines = 0;
disLabel.textAlignment = NSTextAlignmentCenter;
[disLabel setFont: [UIFont fontWithName: @"HelveticaNeue-Bold" size: 14.0f]];
disLabel.backgroundColor = [UIColor clearColor];
disLabel.tag = 10;
disLabel.textColor = [UIColor whiteColor];
[rview addSubview: disLabel];
UILabel * disLabel2 = [[UILabel alloc] initWithFrame: CGRectMake(0, disLabel.frame.size.height - 5, rimg.size.width, rimg.size.height)];
disLabel2.text = @"miles";
disLabel2.numberOfLines = 0;
disLabel2.textAlignment = NSTextAlignmentCenter;
[disLabel2 setFont: [UIFont fontWithName: @"HelveticaNeue-Light" size: 12.0f]];
disLabel2.backgroundColor = [UIColor clearColor];
disLabel2.textColor = [UIColor whiteColor];
[rview addSubview: disLabel2];
/*
UIImage * progress = [UIImage imageNamed: @"progressback.png"];
UIImageView * progressimg = [[UIImageView alloc] initWithImage: progress];
progressimg.frame = CGRectMake(aLabel3.frame.origin.x + 12, aLabel3a.frame.origin.y + aLabel3a.frame.size.height + 15, progress.size.width, progress.size.height);
UILabel * aLabel3b = [[UILabel alloc] initWithFrame: CGRectMake( progressimg.frame.origin.x - 10, progressimg.frame.origin.y + progressimg.frame.size.height + 15, width, 20)];
aLabel3b.text = @"Investors";
[aLabel3b setTextColor: [UIColor colorWithRed: 79.0f/255.0f green: 79.0f/255.0f blue: 79.0f/255.0f alpha:1.0f]];
aLabel3b.textAlignment = NSTextAlignmentCenter;
[aLabel3b setFont: [UIFont fontWithName: @"HelveticaNeue-Light" size: 14.0f]];
aLabel3b.backgroundColor = [UIColor clearColor];
UILabel * aLabel4b = [[UILabel alloc] initWithFrame: CGRectMake( aLabel3b.frame.origin.x + aLabel3b.frame.size.width, aLabel3b.frame.origin.y, width, 20)];
aLabel4b.text = @"Raising";
[aLabel4b setTextColor: [UIColor colorWithRed: 79.0f/255.0f green: 79.0f/255.0f blue: 79.0f/255.0f alpha:1.0f]];
aLabel4b.textAlignment = NSTextAlignmentCenter;
[aLabel4b setFont: [UIFont fontWithName: @"HelveticaNeue-Light" size: 14.0f]];
aLabel4b.backgroundColor = [UIColor clearColor];
UILabel * aLabel5b = [[UILabel alloc] initWithFrame: CGRectMake( aLabel4b.frame.origin.x + aLabel4b.frame.size.width, aLabel3b.frame.origin.y, width, 20)];
aLabel5b.text = @"Team";
[aLabel5b setTextColor: [UIColor colorWithRed: 79.0f/255.0f green: 79.0f/255.0f blue: 79.0f/255.0f alpha:1.0f]];
aLabel5b.textAlignment = NSTextAlignmentCenter;
[aLabel5b setFont: [UIFont fontWithName: @"HelveticaNeue-Light" size: 14.0f]];
aLabel5b.backgroundColor = [UIColor clearColor];
UILabel * aLabel3ab = [[UILabel alloc] initWithFrame: CGRectMake( aLabel3b.frame.origin.x, aLabel3b.frame.origin.y + aLabel3b.frame.size.height + 5, width2, 20)];
aLabel3ab.text = @"Mobile App";
[aLabel3ab setTextColor: [UIColor colorWithRed: 79.0f/255.0f green: 79.0f/255.0f blue: 79.0f/255.0f alpha:1.0f]];
aLabel3ab.textAlignment = NSTextAlignmentCenter;
[aLabel3ab setFont: [UIFont fontWithName: @"HelveticaNeue-Bold" size: 14.0f]];
aLabel3ab.backgroundColor = [UIColor clearColor];
UILabel * aLabel4ab = [[UILabel alloc] initWithFrame: CGRectMake( aLabel3ab.frame.origin.x + aLabel3ab.frame.size.width, aLabel3b.frame.origin.y + aLabel3b.frame.size.height + 5, width2, 20)];
aLabel4ab.text = @"Funding";
aLabel4ab.textAlignment = NSTextAlignmentCenter;
[aLabel4ab setTextColor: [UIColor colorWithRed: 79.0f/255.0f green: 79.0f/255.0f blue: 79.0f/255.0f alpha:1.0f]];
[aLabel4ab setFont: [UIFont fontWithName: @"HelveticaNeue-Bold" size: 14.0f]];
aLabel4ab.backgroundColor = [UIColor clearColor];
UILabel * aLabel5ab = [[UILabel alloc] initWithFrame: CGRectMake( aLabel4a.frame.origin.x + aLabel4a.frame.size.width, aLabel3b.frame.origin.y + aLabel3b.frame.size.height + 5, width2, 20)];
aLabel5ab.text = team_size;
[aLabel5ab setTextColor: [UIColor colorWithRed: 79.0f/255.0f green: 79.0f/255.0f blue: 79.0f/255.0f alpha:1.0f]];
aLabel5ab.textAlignment = NSTextAlignmentCenter;
[aLabel5ab setFont: [UIFont fontWithName: @"HelveticaNeue-Bold" size: 14.0f]];
aLabel5ab.backgroundColor = [UIColor clearColor];
*/
[cell.contentView addSubview: cellbackgroundview];
[cell.contentView addSubview: aLabel3];
[cell.contentView addSubview: aLabel4];
[cell.contentView addSubview: aLabel5];
[cell.contentView addSubview: aLabel3a];
[cell.contentView addSubview: aLabel4a];
[cell.contentView addSubview: aLabel5a];
/*
[cell addSubview: progressimg];
[cell addSubview: aLabel3b];
[cell addSubview: aLabel4b];
[cell addSubview: aLabel5b];
[cell addSubview: aLabel3ab];
[cell addSubview: aLabel4ab];
[cell addSubview: aLabel5ab];
*/
[cell.contentView addSubview: rview];
[cell.contentView addSubview: likebtn];
[cell.contentView addSubview: chatbtn];
[cell.contentView addSubview: sharebtn];
}
((UILabel *)[cell viewWithTag:1]).text = name;
((UILabel *)[cell viewWithTag:2]).text = pitch;
((UIButton *)[cell viewWithTag:4]).tag = startup_id;
((UIButton *)[cell viewWithTag:5]).tag = indexPath.row;
((UIButton *)[cell viewWithTag:6]).tag = indexPath.row;
((UILabel *)[cell viewWithTag:7]).text = category;
((UILabel *)[cell viewWithTag:8]).text = funding_t;
((UILabel *)[cell viewWithTag:9]).text = revenue;
((UILabel *)[cell viewWithTag:10]).text = [NSString stringWithFormat: @"%1.1f", miles];
if(photo_url.length >= 1)
{
NSURL *url = [[NSURL alloc] initWithString: photo_url];
[((UIImageView *)[cell viewWithTag:3]) setImageWithURL:url placeholderImage:[UIImage imageNamed:@"default_startup_img"]];
[((UIImageView *)[cell viewWithTag:3]).image imageCroppedToFitSize: newSize];
}
else {
[((UIImageView *)[cell viewWithTag:3]) setImage: [UIImage imageNamed: @"default_startup_img"]];
}
((UIImageView *)[cell viewWithTag:3]).tag = indexPath.row;
return cell;
}