changing #define to ivars to fix smallActivityCell

This commit is contained in:
Roy Yang 2012-07-28 23:43:50 -07:00
parent 1d203cdb47
commit e0e4804816
5 changed files with 57 additions and 19 deletions

View file

@ -12,10 +12,20 @@
@interface ActivityCell : UITableViewCell {
OHAttributedLabel *activityLabel;
UIImageView *faviconView;
int topMargin;
int bottomMargin;
int leftMargin;
int rightMargin;
int avatarSize;
}
@property (nonatomic, strong) OHAttributedLabel *activityLabel;
@property (nonatomic, strong) UIImageView *faviconView;
@property (readwrite) int topMargin;
@property (readwrite) int bottomMargin;
@property (readwrite) int leftMargin;
@property (readwrite) int rightMargin;
@property (readwrite) int avatarSize;
- (int)setActivity:(NSDictionary *)activity withUserProfile:(NSDictionary *)userProfile withWidth:(int)width;
- (NSString *)stripFormatting:(NSString *)str;

View file

@ -14,6 +14,11 @@
@synthesize activityLabel;
@synthesize faviconView;
@synthesize topMargin;
@synthesize bottomMargin;
@synthesize leftMargin;
@synthesize rightMargin;
@synthesize avatarSize;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
@ -31,19 +36,19 @@
activity.automaticallyAddLinksForType = NO;
self.activityLabel = activity;
[self.contentView addSubview:activity];
topMargin = 15;
bottomMargin = 15;
leftMargin = 20;
rightMargin = 20;
avatarSize = 48;
}
return self;
}
- (void)layoutSubviews {
#define topMargin 15
#define bottomMargin 15
#define leftMargin 20
#define rightMargin 20
#define avatarSize 48
- (void)layoutSubviews {
[super layoutSubviews];
// determine outer bounds

View file

@ -407,7 +407,7 @@
- (void)showUserProfile {
appDelegate.activeUserProfileId = [NSString stringWithFormat:@"%@", [appDelegate.dictUserProfile objectForKey:@"user_id"]];
appDelegate.activeUserProfileName = [NSString stringWithFormat:@"%@", [appDelegate.dictUserProfile objectForKey:@"username"]];
appDelegate.activeUserProfileName = @"You";
[appDelegate showUserProfileModal:self.navigationItem.leftBarButtonItem];
}

View file

@ -11,20 +11,32 @@
#import "UIImageView+AFNetworking.h"
#import <QuartzCore/QuartzCore.h>
#define topMargin 10
#define bottomMargin 10
#define leftMargin 10
#define rightMargin 10
#define avatarSize 32
@implementation SmallActivityCell
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
activityLabel = nil;
faviconView = nil;
// create favicon and label in view
UIImageView *favicon = [[UIImageView alloc] initWithFrame:CGRectZero];
self.faviconView = favicon;
[self.contentView addSubview:favicon];
OHAttributedLabel *activity = [[OHAttributedLabel alloc] initWithFrame:CGRectZero];
activity.backgroundColor = [UIColor whiteColor];
activity.automaticallyAddLinksForType = NO;
self.activityLabel = activity;
[self.contentView addSubview:activity];
topMargin = 10;
bottomMargin = 10;
leftMargin = 10;
rightMargin = 10;
avatarSize = 32;
}
return self;
}

View file

@ -131,6 +131,17 @@
[MBProgressHUD hideHUDForView:self.view animated:YES];
self.userProfile = [results objectForKey:@"user_profile"];
NSString *currentUserId = [NSString stringWithFormat:@"%@", [self.appDelegate.dictUserProfile objectForKey:@"user_id"]];
NSString *profileUserId = [NSString stringWithFormat:@"%@", [self.userProfile objectForKey:@"user_id"]];
// check follow button status
if ([currentUserId isEqualToString:profileUserId]) {
NSMutableDictionary *newUserProfile = [self.userProfile mutableCopy];
[newUserProfile setValue:@"You" forKey:@"username"];
self.userProfile = newUserProfile;
}
self.activitiesArray = [results objectForKey:@"activities"];
[self.profileBadge refreshWithProfile:self.userProfile];