单军华
2018-03-28 f99cf1d5cc50407394501853be06cb39f38a092c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
//
//  FileDownCell.m
//  terminalMgr
//
//  Created by WindShan on 2017/3/16.
//  Copyright © 2017年 WindShan. All rights reserved.
//
 
#import "FileDownCell.h"
#import "GloriaLabel.h"
#import "UIImageView+WebCache.h"
#import "commenProgressView.h"
 
@interface FileDownCell()
{
 
}
 
@property (nonatomic, strong)     UIImageView * file_havedown_item_bk;
@property (nonatomic, strong)     GloriaLabel * fileName;
@property (nonatomic, strong)     GloriaLabel * fileDownTime;
@property (nonatomic, strong)     UIButton    * startBtn; // 查看
@property (nonatomic, strong)     UIButton    * deleteBtn;
@end
 
@implementation FileDownCell
 
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
 
-(void)lookAction
{
    if ( _delegate && [_delegate respondsToSelector:@selector(didCellHandleSection:)])
    {
        self.model.handleCmd = @"4";
        [_delegate didCellHandleSection:self.model];
    }
}
 
-(void)deleteAction
{
    if ( _delegate && [_delegate respondsToSelector:@selector(didCellHandleSection:)])
    {
        self.model.handleCmd = @"3";
        [_delegate didCellHandleSection:self.model];
    }
}
 
-(UIButton*)deleteBtn
{
    if(!_deleteBtn)
    {
        _deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _deleteBtn.frame = CGRectMake(0, SCREEN_HEIGHT-100, 118, 30);
        [_deleteBtn setBackgroundImage:[UIImage imageNamed:@"file_havedown_delete_btn" ] forState:UIControlStateNormal];
        [_deleteBtn setTitle:@"删除" forState:UIControlStateNormal];
        [_deleteBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //_deleteBtn.backgroundColor = [UIColor redColor];    //上左下右
        _deleteBtn.tag = 100;
        
        _deleteBtn.titleLabel.font = [UIFont systemFontOfSize: 12.0];
        [_deleteBtn addTarget:self action:@selector(deleteAction) forControlEvents:UIControlEventTouchUpInside];
        
        //[_deleteBtn setTintColor:RgbColor(253,137,8)];
        
        [self.contentView addSubview:_deleteBtn];
    }
    
    return _deleteBtn;
}
 
 
-(UIButton*)startBtn
{
    if(!_startBtn)
    {
        _startBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _startBtn.frame = CGRectMake(0, SCREEN_HEIGHT-100, 118, 30);
        [_startBtn setBackgroundImage:[UIImage imageNamed:@"file_havedown_look_btn" ] forState:UIControlStateNormal];
        [_startBtn setTitle:@"查看" forState:UIControlStateNormal];
        [_startBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //_startBtn.backgroundColor = [UIColor redColor];    //上左下右
        _startBtn.tag = 101;
        
        _startBtn.titleLabel.font = [UIFont systemFontOfSize: 12.0];
        [_startBtn addTarget:self action:@selector(lookAction) forControlEvents:UIControlEventTouchUpInside];
 
        //[_startBtn setTintColor:RgbColor(253,137,8)];
        
        [self.contentView addSubview:_startBtn];
    }
    
    return _startBtn;
}
 
- (GloriaLabel *) fileName
{
    if(!_fileName)
    {
        _fileName = [[GloriaLabel alloc] initWithFrame:CGRectMake(8+10+45, 5,SCREEN_WIDTH/2, 30)];
        _fileName.font = [UIFont systemFontOfSize:14];
        _fileName.textAlignment = UITextAlignmentLeft;
        _fileName.textColor = kUIColorFromRGB(0x6e6e6e);
        [self.contentView addSubview:_fileName];
    }
    
    return _fileName;
}
 
- (GloriaLabel *) fileDownTime
{
    if(!_fileDownTime)
    {
        _fileDownTime = [[GloriaLabel alloc] initWithFrame:CGRectMake(8+10+45, 5,SCREEN_WIDTH/2, 30)];
        _fileDownTime.font = [UIFont systemFontOfSize:12];
        _fileDownTime.textAlignment = UITextAlignmentLeft;
        _fileDownTime.textColor = kUIColorFromRGB(0xa9a9a9);
        [self.contentView addSubview:_fileDownTime];
    }
    
    return _fileDownTime;
}
 
- (UIImageView *)file_havedown_item_bk
{
    if (!_file_havedown_item_bk)
    {
        _file_havedown_item_bk =  [[UIImageView alloc] initWithFrame:CGRectMake(8, 5, SCREEN_WIDTH-16, 70)];
        [self.contentView addSubview:_file_havedown_item_bk];
    }
    
    return _file_havedown_item_bk;
}
 
 
//@property (nonatomic, strong)     UIImageView * bkImage;
//@property (nonatomic, strong)     UIImageView * iconImage;
//@property (nonatomic, strong)     UIImageView * nameCircleImage;
//@property (nonatomic, strong)     UIImageView * statusCircleImage;
//@property (nonatomic, strong)     GloriaLabel * deviceName;
//@property (nonatomic, strong)     GloriaLabel * FileStatus;
 
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat bkImageW = 271;
    if(IsiPhone4 || IsiPhone5)
    {
        bkImageW = 230;
    }
 
    // 271
    self.file_havedown_item_bk.frame = CGRectMake((SCREEN_WIDTH-bkImageW-45*2-4)/2, 5, bkImageW, 55);
    
    self.fileName.frame = CGRectMake((SCREEN_WIDTH-bkImageW-45*2-4)/2+10, 15, bkImageW-20, 20);
    self.fileDownTime.frame = CGRectMake((SCREEN_WIDTH-bkImageW-45*2-4)/2+10, 35, bkImageW-20, 20);
    self.startBtn.frame = CGRectMake((SCREEN_WIDTH-bkImageW-45*2-4)/2+bkImageW+1, 5, 45, 55);
    // 45
    self.deleteBtn.frame = CGRectMake((SCREEN_WIDTH-bkImageW-45*2-4)/2+bkImageW+1+1+45, 5, 45, 55);
 
}
 
/** 设置数据*/
- (void)setItemView:(FileStatus*)model
{
    self.model = model;
    self.contentView.backgroundColor = [UIColor clearColor];
    
    self.file_havedown_item_bk.image = [UIImage imageNamed:@"file_havedown_item_bk"];
    
    [self.fileName setText:[NSString stringWithFormat:@"文件名:%@",self.model.name]];
    [self.fileDownTime setText: [DateUtil stringFromLong:self.model.created]];
}
@end