|
|
|
|
//
|
|
|
|
|
// HomeMovementTableViewCell.m
|
|
|
|
|
// tongxin
|
|
|
|
|
//
|
|
|
|
|
// Created by ecell on 2023/6/20.
|
|
|
|
|
// Copyright © 2023 xTT. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "HomeMovementTableViewCell.h"
|
|
|
|
|
#import "XFGradientProgressView.h"
|
|
|
|
|
#import "UIViewExt.h"
|
|
|
|
|
|
|
|
|
|
@interface HomeMovementTableViewCell ()
|
|
|
|
|
|
|
|
|
|
@property (nonatomic ,weak) UILabel *numLabel;
|
|
|
|
|
@property (nonatomic ,weak) UILabel *calorieLabel;
|
|
|
|
|
@property (nonatomic ,weak) UILabel *distanceLabel;
|
|
|
|
|
|
|
|
|
|
/// 步数
|
|
|
|
|
@property (nonatomic ,weak) XFGradientProgressView *numProgress;
|
|
|
|
|
/// 热量
|
|
|
|
|
@property (nonatomic ,weak) XFGradientProgressView *calorieProgress;
|
|
|
|
|
/// 总里程
|
|
|
|
|
@property (nonatomic ,weak) XFGradientProgressView *distanceProgress;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation HomeMovementTableViewCell
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
|
|
|
|
{
|
|
|
|
|
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
|
|
|
|
if (self)
|
|
|
|
|
{
|
|
|
|
|
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
|
|
|
self.backgroundColor = KKClearColor;
|
|
|
|
|
[self subCellView];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)setStepData:(NSDictionary *)stepData
|
|
|
|
|
{
|
|
|
|
|
_stepData = stepData;
|
|
|
|
|
self.numLabel.text = F(@"%@", stepData[@"num"]);
|
|
|
|
|
self.calorieLabel.text = F(@"%@", [self notRounding:stepData[@"calorie"] afterPoint:3]);
|
|
|
|
|
self.distanceLabel.text = F(@"%@", [self notRounding:stepData[@"distance"] afterPoint:3]);
|
|
|
|
|
NSNumber *step = stepData[@"num"];
|
|
|
|
|
CGFloat a = step.floatValue/10000;
|
|
|
|
|
[self.numProgress StartAnimationToProgress:a durationTime:0 sImgName:@"icon_step"];
|
|
|
|
|
[self.distanceProgress StartAnimationToProgress:a durationTime:0 sImgName:@"icon_distance"];
|
|
|
|
|
[self.calorieProgress StartAnimationToProgress:a durationTime:0 sImgName:@"icon_calories"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)subCellView
|
|
|
|
|
{
|
|
|
|
|
UIView *bgView = [UICommon ui_view:CGRectZero backgroundColor:KKWhiteColorColor cornerRadius:10 borderWidth:0 borderColor:KKWhiteColorColor];
|
|
|
|
|
[self.contentView addSubview:bgView];
|
|
|
|
|
[bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.right.equalTo(self.contentView).inset(15);
|
|
|
|
|
make.top.equalTo(self.contentView).offset(15);
|
|
|
|
|
make.height.mas_equalTo(166);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
UILabel *titleLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:FontBold_(14) textColor:KKTextColor text:@"运动数据" Radius:0];
|
|
|
|
|
[bgView addSubview:titleLabel];
|
|
|
|
|
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.equalTo(bgView).offset(10);
|
|
|
|
|
make.top.equalTo(bgView).offset(13);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
// UIImageView *bgImg = [UIImageView new];
|
|
|
|
|
// bgImg.frame = CGRectMake(18, 43, 125, 110);
|
|
|
|
|
// bgImg.image = ImageName_(@"circle_bg");
|
|
|
|
|
// [bgView addSubview:bgImg];
|
|
|
|
|
//// [bgImg mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
//// make.top.equalTo(titleLabel.mas_bottom).offset(17);
|
|
|
|
|
//// make.left.equalTo(bgView).offset(18);
|
|
|
|
|
//// make.size.mas_equalTo(CGSizeMake(125, 110));
|
|
|
|
|
//// }];
|
|
|
|
|
|
|
|
|
|
/// 步数
|
|
|
|
|
XFGradientProgressView *numProgress = [[XFGradientProgressView alloc] initWithFrame:CGRectMake(23, 40, 115, 115) startColor:RGB(35, 128, 255) endColor:RGB(35, 128, 255) backProgressColor:RGBA(35, 128, 255, .4)];
|
|
|
|
|
self.numProgress = numProgress;
|
|
|
|
|
[bgView addSubview:numProgress];
|
|
|
|
|
[numProgress StartAnimationToProgress:0 durationTime:0 sImgName:@"icon_step"];
|
|
|
|
|
|
|
|
|
|
/// 热量
|
|
|
|
|
XFGradientProgressView *distanceProgress = [[XFGradientProgressView alloc] initWithFrame:CGRectMake(numProgress.left+12.5, numProgress.top+10, numProgress.width-25, numProgress.height-20) startColor:RGB(253, 161, 40) endColor:RGB(253, 161, 40) backProgressColor:RGBA(253, 161, 40, .4)];
|
|
|
|
|
self.distanceProgress = distanceProgress;
|
|
|
|
|
[bgView addSubview:distanceProgress];
|
|
|
|
|
[distanceProgress StartAnimationToProgress:0 durationTime:0 sImgName:@"icon_distance"];
|
|
|
|
|
|
|
|
|
|
/// 总里程
|
|
|
|
|
XFGradientProgressView *calorieProgress = [[XFGradientProgressView alloc] initWithFrame:CGRectMake(distanceProgress.left+12.5, distanceProgress.top+10, distanceProgress.width-25, distanceProgress.height-19) startColor:RGB(255, 0, 96) endColor:RGB(255, 0, 96) backProgressColor:RGBA(255, 0, 96, .4)];
|
|
|
|
|
self.calorieProgress = calorieProgress;
|
|
|
|
|
[bgView addSubview:calorieProgress];
|
|
|
|
|
[calorieProgress StartAnimationToProgress:0 durationTime:0 sImgName:@"icon_calories"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// UIImageView *img1 = [UIImageView new];
|
|
|
|
|
// img1.image = ImageName_(@"circle_step");
|
|
|
|
|
// [bgView addSubview:img1];
|
|
|
|
|
// [img1 mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
// make.top.equalTo(titleLabel.mas_bottom).offset(17);
|
|
|
|
|
// make.left.equalTo(bgView).offset(18);
|
|
|
|
|
// make.size.mas_equalTo(CGSizeMake(125, 110));
|
|
|
|
|
// }];
|
|
|
|
|
//
|
|
|
|
|
// UIImageView *img2 = [UIImageView new];
|
|
|
|
|
// img2.image = ImageName_(@"circle_distance");
|
|
|
|
|
// [bgView addSubview:img2];
|
|
|
|
|
// [img2 mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
// make.top.equalTo(img1).offset(12.5);
|
|
|
|
|
// make.left.equalTo(img1).offset(12.5);
|
|
|
|
|
// make.right.equalTo(img1.mas_right).inset(12.5);
|
|
|
|
|
// make.bottom.equalTo(img1.mas_bottom).inset(10);
|
|
|
|
|
// }];
|
|
|
|
|
// UIImageView *img3 = [UIImageView new];
|
|
|
|
|
// img3.image = ImageName_(@"circle_calories");
|
|
|
|
|
// [bgView addSubview:img3];
|
|
|
|
|
// [img3 mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
// make.top.equalTo(img2).offset(12.5);
|
|
|
|
|
// make.left.equalTo(img2).offset(12.5);
|
|
|
|
|
// make.right.equalTo(img2.mas_right).inset(12.5);
|
|
|
|
|
// make.bottom.equalTo(img2.mas_bottom).inset(10);
|
|
|
|
|
// }];
|
|
|
|
|
|
|
|
|
|
NSArray *titleArr = @[@"步数",@"热量",@"总里程"];
|
|
|
|
|
NSArray *unitArr = @[@"步 ",@"千卡",@"公里"];
|
|
|
|
|
NSArray *colorArr = @[mainColor,RGB(255, 0, 96),RGB(253, 161, 40)];
|
|
|
|
|
CGFloat hh = 166/3;
|
|
|
|
|
for (int i = 0; i < titleArr.count; i++)
|
|
|
|
|
{
|
|
|
|
|
UILabel *tLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentLeft font:Font_(16) textColor:KKTextColor text:titleArr[i] Radius:0];
|
|
|
|
|
[bgView addSubview:tLabel];
|
|
|
|
|
[tLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.equalTo(bgView).offset(175);
|
|
|
|
|
make.top.equalTo(bgView).offset(i*hh);
|
|
|
|
|
make.height.mas_equalTo(hh);
|
|
|
|
|
make.width.mas_equalTo(50);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
UIImageView *point = [UIImageView new];
|
|
|
|
|
point.backgroundColor = colorArr[i];
|
|
|
|
|
point.layer.cornerRadius = 2.5;
|
|
|
|
|
point.layer.masksToBounds = YES;
|
|
|
|
|
[bgView addSubview:point];
|
|
|
|
|
[point mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.right.equalTo(tLabel.mas_left).inset(8);
|
|
|
|
|
make.centerY.equalTo(tLabel);
|
|
|
|
|
make.size.mas_equalTo(CGSizeMake(5, 5));
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
if (i < titleArr.count-1)
|
|
|
|
|
{
|
|
|
|
|
UIImageView *line = [UIImageView new];
|
|
|
|
|
line.backgroundColor = RGB(235, 235, 235);
|
|
|
|
|
[bgView addSubview:line];
|
|
|
|
|
[line mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.equalTo(point.mas_left);
|
|
|
|
|
make.right.equalTo(bgView.mas_right).inset(12);
|
|
|
|
|
make.top.equalTo(tLabel.mas_bottom);
|
|
|
|
|
make.height.mas_equalTo(1);
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UILabel *unitLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:Font_(12) textColor:RGB(133, 133, 133) text:unitArr[i] Radius:0];
|
|
|
|
|
[bgView addSubview:unitLabel];
|
|
|
|
|
[unitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.right.equalTo(bgView.mas_right).inset(18);
|
|
|
|
|
make.centerY.equalTo(tLabel);
|
|
|
|
|
make.width.mas_equalTo(25);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UILabel *textLabel = [UICommon ui_label:CGRectZero lines:1 align:NSTextAlignmentRight font:FontBold_(24) textColor:KKTextColor text:@"0" Radius:0];
|
|
|
|
|
if (i == 0)
|
|
|
|
|
self.numLabel = textLabel;
|
|
|
|
|
else if (i == 1)
|
|
|
|
|
self.calorieLabel = textLabel;
|
|
|
|
|
else if (i == 2)
|
|
|
|
|
self.distanceLabel = textLabel;
|
|
|
|
|
[bgView addSubview:textLabel];
|
|
|
|
|
[textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.right.equalTo(unitLabel.mas_left).inset(10);
|
|
|
|
|
make.left.equalTo(tLabel.mas_right).offset(10);
|
|
|
|
|
make.centerY.equalTo(tLabel);
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*)notRounding:(id)price afterPoint:(NSInteger)position
|
|
|
|
|
{
|
|
|
|
|
//生成format格式
|
|
|
|
|
NSString*format = [NSString stringWithFormat:@"%%.%ldf",(long)position];
|
|
|
|
|
CGFloat value = 0.;
|
|
|
|
|
//string 和 number 兼容
|
|
|
|
|
if([price respondsToSelector:@selector(doubleValue)])
|
|
|
|
|
{
|
|
|
|
|
value = [price doubleValue];
|
|
|
|
|
}
|
|
|
|
|
NSString *number = [NSString stringWithFormat:format,value];
|
|
|
|
|
// 去掉小数点后面的无效0
|
|
|
|
|
NSString * outNumber = [NSString stringWithFormat:@"%@",[[NSDecimalNumber decimalNumberWithString:number] stringValue]];
|
|
|
|
|
return outNumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|