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

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

#import "Utilities.h"
@implementation RankingTableViewCell

- (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) setRankingData : (RankingObject *) 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.lblName.text = object.userName;
    self.lblDistance.text = [NSString stringWithFormat:@"%0.1f km", object.distance];
    self.lblStep.text = [NSString stringWithFormat:@"%d 歩", object.steps];
    self.lblTime.text = [Utilities convertSecondToShortTime:object.time];
}
@end
