ifish/Ifish/controllers/HotBar/Views/IfishHistoryView.m

174 lines
5.0 KiB
Objective-C

//
// IfishHistoryView.m
// Ifish
//
// Created by 罗艺 on 2018/8/27.
// Copyright © 2018年 lianlian. All rights reserved.
//
#import "IfishHistoryView.h"
#import "IfishChatView.h"
#import "IfishHistroyVo.h"
#import "PNChart.h"
#import "SVProgressHUD.h"
@interface IfishHistoryView()
Strong UIButton *bgButton;
//Strong UIView *bgView;
Strong IfishChatView *chartView;
Strong IfishChatView *chartHolder;
Strong UILabel *titleLabel;
Strong UIButton *predayButton;
Strong UIButton *nextdayButton;
Strong UIImageView *bgImage;
@property(nonatomic,strong)NSMutableArray*line1;
@end
@implementation IfishHistoryView
- (instancetype)init
{
self = [super init];
if (self) {
[self addSubview:self.bgButton];
[self addSubview:self.bgImage];
[self.bgImage addSubview:self.titleLabel];
[self.bgImage addSubview:self.chartHolder];
[self addSubview:self.predayButton];
[self addSubview:self.nextdayButton];
[self loadLayout];
}
return self;
}
- (UIButton *)bgButton{
if (!_bgButton) {
_bgButton = InitObject(UIButton);
[_bgButton setBackgroundColor:RGBA(0, 0, 0, 0.3)];
[_bgButton addTarget:self action:@selector(bgButtonClick:) forControlEvents:UIControlEventTouchUpInside];
}
return _bgButton;
}
- (UIImageView *)bgImage{
if (!_bgImage) {
_bgImage = InitObject(UIImageView);
[_bgImage setImage:IMAGEBYENAME(@"history_bg_new")];
_bgImage.layer.masksToBounds = YES;
_bgImage.layer.cornerRadius = kSizeFrom750(32);
}
return _bgImage;
}
- (IfishChatView *)chartHolder{
if (!_chartHolder) {
_chartHolder = InitObject(IfishChatView);
_chartHolder.backgroundColor = [UIColor clearColor];
}
return _chartHolder;
}
- (UILabel *)titleLabel{
if (!_titleLabel) {
_titleLabel = InitObject(UILabel);
_titleLabel.textAlignment = NSTextAlignmentCenter;
_titleLabel.textColor = RGB(51, 51, 51);
_titleLabel.font = [UIFont systemFontOfSize:14];
}
return _titleLabel;
}
- (UIButton *)predayButton{
if (!_predayButton) {
_predayButton = InitObject(UIButton);
[_predayButton addTarget:self action:@selector(dayChangeClick:) forControlEvents:UIControlEventTouchUpInside];
_predayButton.tag = 10;
}
return _predayButton;
}
- (UIButton *)nextdayButton{
if (!_nextdayButton) {
_nextdayButton = InitObject(UIButton);
[_nextdayButton addTarget:self action:@selector(dayChangeClick:) forControlEvents:UIControlEventTouchUpInside];
_nextdayButton.tag = 11;
}
return _nextdayButton;
}
-(void)loadLayout{
[self.bgButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.bgImage);
make.top.mas_equalTo(kSizeFrom750(20));
make.height.mas_equalTo(kSizeFrom750(40));
}];
[self.bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kSizeFrom750(720));
make.center.mas_equalTo(self);
make.height.mas_equalTo(kSizeFrom750(678));
}];
[self.chartHolder mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.width.mas_equalTo(self.bgImage);
make.height.mas_equalTo(kSizeFrom750(580));
}];
[self.predayButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kSizeFrom750(20));
make.height.mas_equalTo(kSizeFrom750(80));
make.width.mas_equalTo(kSizeFrom750(140));
make.bottom.mas_equalTo(self.bgImage.mas_bottom);
}];
[self.nextdayButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.centerY.mas_equalTo(self.predayButton);
make.right.mas_equalTo(-kSizeFrom750(20));
}];
[self.bgImage layoutIfNeeded];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
-(IfishChatView *)chartView{
if (_chartView==nil) {
_chartView=[[IfishChatView alloc]init];
_chartView.frame=self.chartHolder.bounds;
_chartView.backgroundColor=[UIColor clearColor];
[self.chartHolder addSubview:_chartView];
}
return _chartView;
}
-(void)setDatas:(NSArray *)datas{
_datas=datas;
if (datas.count<1) {
// [SVProgressHUD showInfoWithStatus:@"暂无数据"];
return;
}
if (self.chartView) {
[self.chartView removeFromSuperview];
_chartView=nil;
}
[self.chartView loadDatasWithArray:datas];
// [self.chartView reloadHeater];
self.titleLabel.text=self.curdateStr;
// [self initLineChart];
}
#pragma mark --buttonClick
-(void)bgButtonClick:(UIButton *)sender{
self.hidden=YES;
}
-(void)dayChangeClick:(UIButton *)sender{
[self.myDeleget clickBottomBarWithIdx:sender.tag];
}
@end