forked from omz/AppSales-Mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDashboardAppCell.m
97 lines (83 loc) · 2.88 KB
/
DashboardAppCell.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//
// DashboardAppCell.m
// AppSales
//
// Created by Ole Zorn on 19.07.11.
// Copyright 2011 omz:software. All rights reserved.
//
#import "DashboardAppCell.h"
#import "ColorButton.h"
#import "Product.h"
#import "IconManager.h"
#import "AppIconView.h"
@implementation DashboardAppCell
@synthesize product, colorButton;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
CGSize contentSize = self.contentView.bounds.size;
nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(44, 10, contentSize.width - 49, 20)];
nameLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
nameLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
nameLabel.font = [UIFont systemFontOfSize:16.0];
nameLabel.backgroundColor = [UIColor clearColor];
//nameLabel.shadowColor = [UIColor whiteColor];
//nameLabel.highlightedTextColor = [UIColor whiteColor];
//nameLabel.shadowOffset = CGSizeMake(0, 1);
colorButton = [[ColorButton alloc] initWithFrame:CGRectMake(5, 5, 30, 30)];
colorButton.showOutline = NO;
colorButton.color = [UIColor grayColor];
[self.contentView addSubview:colorButton];
iconView = [[AppIconView alloc] initWithFrame:CGRectInset(colorButton.frame, 3, 3)];
[self.contentView addSubview:iconView];
[self.contentView addSubview:nameLabel];
//self.backgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CellBackground.png"]] autorelease];
//self.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CellBackgroundSelected.png"]] autorelease];
}
return self;
}
- (void)setProduct:(Product *)newProduct
{
[newProduct retain];
[product release];
product = newProduct;
if (!product) {
nameLabel.text = NSLocalizedString(@"All Apps", nil);
colorButton.hidden = YES;
iconView.productID = nil;
} else {
nameLabel.text = [product displayName];
colorButton.hidden = NO;
colorButton.color = product.color;
if (self.product.parentSKU) {
iconView.productID = nil;
iconView.image = [UIImage imageNamed:@"InApp.png"];
} else {
iconView.productID = self.product.productID;
}
}
}
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
[super setHighlighted:highlighted animated:animated];
colorButton.selected = NO;
colorButton.highlighted = NO;
//nameLabel.shadowColor = (self.highlighted || self.selected) ? [UIColor blackColor] : [UIColor whiteColor];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
colorButton.selected = NO;
colorButton.highlighted = NO;
//nameLabel.shadowColor = (self.highlighted || self.selected) ? [UIColor blackColor] : [UIColor whiteColor];
}
- (void)dealloc
{
[product release];
[iconView release];
[colorButton release];
[nameLabel release];
[super dealloc];
}
@end