//
//  SNSRecentTopicTableViewCell.m
//  LifeLog
//
//  Created by nvtu on 8/10/17.
//  Copyright © 2017 PhongNV. All rights reserved.
//

#import "SNSRecentTopicTableViewCell.h"
#import <SDWebImage/UIImageView+WebCache.h>

#import "Utilities.h"

@implementation SNSRecentTopicTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void) setMemberData : (MemberObject *) object {
    if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) {
        [self.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]];
    }
    else {
        [self.imgAvatar setImage:[UIImage imageNamed:@"avatar_default"]];
    }
    self.lblUsername.text   = @"";
    self.lblDateTime.text   = @"";
    self.lblDes.text        = object.userName;
    self.lblMode.text       = @"";
    self.lblDistance.text   = @"";
    self.lblDuration.text   = @"";
}

-(void) setTweetsData : (TweetObject *) object {
    if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) {
        [self.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]];
    }
    else {
        [self.imgAvatar setImage:[UIImage imageNamed:@"avatar_default"]];
    }
    self.lblDateTime.text   = [Utilities stringFromDate:object.createDate withFormat:@"YYYY/MM/dd    hh:mm" locale:@""];
    self.lblUsername.text   = object.userName;
    self.lblDes.text        = object.content;
    self.lblMode.text       = object.mode;
    self.lblDistance.text   = [NSString stringWithFormat:@"%.0f m", object.distance];
    self.lblDuration.text   = object.time;
}

@end
