InspectDetailView.m 33.6 KB
Newer Older
1
//
2
//  InspectDetailView.m
3 4
//  redstar
//
5
//  Created by admin on 15/11/12.
6 7 8
//  Copyright © 2015年 ZWF. All rights reserved.
//

9
#import "InspectDetailView.h"
10

11
@interface InspectDetailView ()
12 13 14 15
@property (nonatomic, strong) UILabel *shopname; // 商店名称
@property (nonatomic, strong) UILabel *startDate; // 起始时间
@property (nonatomic, strong) UILabel *overDate; // 截止时间
@property (nonatomic, strong) UILabel *progress; // 完成进度
16

17 18 19 20 21 22
@property (nonatomic, strong) UILabel *introLabel;

@property (nonatomic, strong) UILabel *surplus; // 剩余
@property (nonatomic, strong) UILabel *day; // 天
@property (nonatomic, strong) UIImageView *number; // 天

23 24
@property (nonatomic, strong) UIView *upLineView; // 天
@property (nonatomic, strong) UIView *downLineView; // 天
25 26
@end

27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

@implementation InspectDetailView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setup];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
42 43 44 45 46 47
    if (self) {
        [self setup];
    }
    return self;
}

48
#pragma mark - Private Methods
49 50
#pragma mark Private Methods
- (void)setup {
51
    
admin's avatar
admin committed
52

53 54 55
    self.upLineView.backgroundColor = kSeparateLineColor;
    self.downLineView.backgroundColor = kSeparateLineColor;

56 57 58 59 60 61 62 63 64 65 66 67 68 69
    self.shopname.text = @"商场名称";
    self.startDate.text = @"起始时间";
    self.overDate.text = @"截止时间";
    self.progress.text = @"完成进度";
    
    self.introLabel.text = @"巡检说明";
    
    self.day.text = @"天";
    self.number.image = [UIImage imageNamed:@"figure_bg"];
    self.surplus.text = @"剩余";
    self.unfoldBtn.titleLabel.font = [UIFont systemFontOfSize:12.0];
    self.arrowImageView.image = [UIImage imageNamed:@"grey-trilateral_down"];
}

admin's avatar
admin committed
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
//- (void)setProgressState:(ProgressState)progressState
//{
//    _progressState = progressState;
//    if (_progressState == ProgressStateUnSettled) {
//        self.progressLabel.text = [NSString stringWithFormat:@"未处理 %f", _multiplier];;
//        self.progressLabel.textColor = kProgressUnSettledColor;
//        self.alreadyLabel.textColor = kProgressUnSettledColor;
//        self.allLabel.textColor = kProgressUnSettledColor;
//        self.allView.backgroundColor = kProgressViewAllBackColor;
//        UIImage *image = [UIImage imageNamed:@"progress-bar"];
//        image = [image resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeTile];
//        self.alreadyView.image = image;
//    } else if (_progressState == ProgressStateDealWith) {
//        
//        self.progressLabel.text = [NSString stringWithFormat:@"进行中 %f", _multiplier];
//        self.progressLabel.textColor = kProgressDealWithColor;
//        self.alreadyLabel.textColor = kProgressDealWithColor;
//        self.allLabel.textColor = kProgressDealWithColor;
//        self.allView.backgroundColor = kProgressViewAllBackColor;
//        UIImage *image = [UIImage imageNamed:@"progress-bar"];
//        image = [image resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeTile];
//        self.alreadyView.image = image;
//    } else {
//        
//        self.progressLabel.text = [NSString stringWithFormat:@"已过期 %f", _multiplier];
//        self.progressLabel.textColor = kProgressOverDueColor;
//        self.alreadyLabel.textColor = kProgressOverDueColor;
//        self.allLabel.textColor = kProgressOverDueColor;
//        self.allView.backgroundColor = kProgressViewAllBackColor;
//        UIImage *image = [UIImage imageNamed:@"progress-bar"];
//        image = [image resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeTile];
//        self.alreadyView.image = image;
//    }
//}
104 105

#pragma mark - lazy loading
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
- (UIView *)upLineView
{
    if (!_upLineView) {
        _upLineView = [[UIView alloc] init];
        _upLineView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:_upLineView];
        
        NSLayoutConstraint *upLineTop = [NSLayoutConstraint constraintWithItem:_upLineView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
        [self addConstraint:upLineTop];
        
        NSLayoutConstraint *upLineLeft = [NSLayoutConstraint constraintWithItem:_upLineView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
        [self addConstraint:upLineLeft];
        
        NSLayoutConstraint *upLineRight = [NSLayoutConstraint constraintWithItem:_upLineView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
        [self addConstraint:upLineRight];
        
        NSLayoutConstraint *upLineHeight = [NSLayoutConstraint constraintWithItem:_upLineView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:1];
        [self  addConstraint:upLineHeight];
    }
    return _upLineView;
}

- (UIView *)downLineView
{
    if (!_downLineView) {
        _downLineView = [[UIView alloc] init];
        _downLineView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:_downLineView];
        
        NSLayoutConstraint *upLineBottom = [NSLayoutConstraint constraintWithItem:_downLineView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
        [self addConstraint:upLineBottom];
        
        NSLayoutConstraint *upLineLeft = [NSLayoutConstraint constraintWithItem:_downLineView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
        [self addConstraint:upLineLeft];
        
        NSLayoutConstraint *upLineRight = [NSLayoutConstraint constraintWithItem:_downLineView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
        [self addConstraint:upLineRight];
        
        NSLayoutConstraint *upLineHeight = [NSLayoutConstraint constraintWithItem:_downLineView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:1];
        [self  addConstraint:upLineHeight];
    }
    return _downLineView;
}


151 152 153 154 155 156 157
- (UILabel *)shopname
{
    if (!_shopname) {
        _shopname = [[UILabel alloc] init];
        _shopname.font = [UIFont systemFontOfSize:15.0];
        _shopname.textColor = kLightGray;
        _shopname.translatesAutoresizingMaskIntoConstraints = NO;
158
        [self addSubview:_shopname];
159
        
160 161
        NSLayoutConstraint *Top = [NSLayoutConstraint constraintWithItem:_shopname attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:10];
        [self addConstraint:Top];
162
        
163 164
        NSLayoutConstraint *Left = [NSLayoutConstraint constraintWithItem:_shopname attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
        [self addConstraint:Left];
165 166
        
        NSLayoutConstraint *Width = [NSLayoutConstraint constraintWithItem:_shopname attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:65];
167
        [self addConstraint:Width];
168 169
        
        NSLayoutConstraint *Height = [NSLayoutConstraint constraintWithItem:_shopname attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
170
        [self  addConstraint:Height];
171 172 173 174 175 176 177 178 179 180 181 182
    }
    return _shopname;
}


- (UILabel *)startDate
{
    if (!_startDate) {
        _startDate = [[UILabel alloc] init];
        _startDate.font = [UIFont systemFontOfSize:15.0];
        _startDate.textColor = kLightGray;
        _startDate.translatesAutoresizingMaskIntoConstraints = NO;
183
        [self  addSubview:_startDate];
184 185
        
        NSLayoutConstraint *Top = [NSLayoutConstraint constraintWithItem:_startDate attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.shopname attribute:NSLayoutAttributeBottom multiplier:1.0 constant:5];
186
        [self  addConstraint:Top];
187
        
188 189
        NSLayoutConstraint *Left = [NSLayoutConstraint constraintWithItem:_startDate attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
        [self  addConstraint:Left];
190 191
        
        NSLayoutConstraint *Width = [NSLayoutConstraint constraintWithItem:_startDate attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:65];
192
        [self  addConstraint:Width];
193 194
        
        NSLayoutConstraint *Height = [NSLayoutConstraint constraintWithItem:_startDate attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
195
        [self  addConstraint:Height];
196 197 198 199 200 201 202 203 204 205 206
    }
    return _startDate;
}

- (UILabel *)overDate
{
    if (!_overDate) {
        _overDate = [[UILabel alloc] init];
        _overDate.font = [UIFont systemFontOfSize:15.0];
        _overDate.textColor = kLightGray;
        _overDate.translatesAutoresizingMaskIntoConstraints = NO;
207
        [self  addSubview:_overDate];
208 209
        
        NSLayoutConstraint *Top = [NSLayoutConstraint constraintWithItem:_overDate attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.startDate attribute:NSLayoutAttributeBottom multiplier:1.0 constant:5];
210
        [self  addConstraint:Top];
211
        
212 213
        NSLayoutConstraint *Left = [NSLayoutConstraint constraintWithItem:_overDate attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
        [self  addConstraint:Left];
214 215
        
        NSLayoutConstraint *Width = [NSLayoutConstraint constraintWithItem:_overDate attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:65];
216
        [self  addConstraint:Width];
217 218
        
        NSLayoutConstraint *Height = [NSLayoutConstraint constraintWithItem:_overDate attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
219
        [self  addConstraint:Height];
220 221 222 223 224 225 226 227 228 229 230
    }
    return _overDate;
}

- (UILabel *)progress
{
    if (!_progress) {
        _progress = [[UILabel alloc] init];
        _progress.font = [UIFont systemFontOfSize:15.0];
        _progress.textColor = kLightGray;
        _progress.translatesAutoresizingMaskIntoConstraints = NO;
231
        [self  addSubview:_progress];
232 233
        
        NSLayoutConstraint *Top = [NSLayoutConstraint constraintWithItem:_progress attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.overDate attribute:NSLayoutAttributeBottom multiplier:1.0 constant:5];
234
        [self  addConstraint:Top];
235
        
236 237
        NSLayoutConstraint *Left = [NSLayoutConstraint constraintWithItem:_progress attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
        [self  addConstraint:Left];
238 239
        
        NSLayoutConstraint *Width = [NSLayoutConstraint constraintWithItem:_progress attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:65];
240
        [self  addConstraint:Width];
241 242
        
        NSLayoutConstraint *Height = [NSLayoutConstraint constraintWithItem:_progress attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
243
        [self  addConstraint:Height];
244 245 246 247 248 249 250 251 252 253 254 255 256
    }
    return _progress;
}

- (UIView *)allView
{
    if (!_allView) {
        _allView = [[UILabel alloc] init];
        _allView.translatesAutoresizingMaskIntoConstraints = NO;
        _allView.layer.cornerRadius = 3;
        _allView.layer.masksToBounds = YES;
        _allView.layer.borderWidth = 1;
        _allView.layer.borderColor = kUsernameBorderColor;
257
        [self  addSubview:_allView];
258 259
        
        NSLayoutConstraint *Top = [NSLayoutConstraint constraintWithItem:_allView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.progress attribute:NSLayoutAttributeBottom multiplier:1.0 constant:7];
260
        [self  addConstraint:Top];
261
        
262 263
        NSLayoutConstraint *Left = [NSLayoutConstraint constraintWithItem:_allView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
        [self  addConstraint:Left];
264
        
265 266
        NSLayoutConstraint *Right = [NSLayoutConstraint constraintWithItem:_allView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
        [self  addConstraint:Right];
267 268
        
        NSLayoutConstraint *Height = [NSLayoutConstraint constraintWithItem:_allView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:18];
269
        [self  addConstraint:Height];
270 271 272 273
    }
    return _allView;
}

admin's avatar
admin committed
274
- (UIImageView *)alreadyView
275 276
{
    if (!_alreadyView) {
admin's avatar
admin committed
277
        _alreadyView = [[UIImageView alloc] init];
278 279 280 281 282 283 284 285 286 287 288 289 290 291
        _alreadyView.layer.cornerRadius = 3;
        _alreadyView.layer.masksToBounds = YES;
        _alreadyView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.allView addSubview:_alreadyView];
        
        NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_alreadyView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.allView attribute:NSLayoutAttributeTop multiplier:1.0 constant:1];
        [self.allView addConstraint:overDateTop];
        
        NSLayoutConstraint *overDateLeft = [NSLayoutConstraint constraintWithItem:_alreadyView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.allView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:1];
        [self.allView addConstraint:overDateLeft];
        
        NSLayoutConstraint *overDateBottom = [NSLayoutConstraint constraintWithItem:_alreadyView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.allView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-1];
        [self.allView addConstraint:overDateBottom];
        
admin's avatar
admin committed
292 293 294

        
        NSLayoutConstraint *overDatewidth = [NSLayoutConstraint constraintWithItem:_alreadyView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.allView attribute:NSLayoutAttributeWidth multiplier:self.multiplier constant:-1];
295 296 297 298 299 300 301 302 303 304 305 306 307
        [self.allView addConstraint:overDatewidth];
        
    }
    return _alreadyView;
}

- (UILabel *)introLabel
{
    if (!_introLabel) {
        _introLabel = [[UILabel alloc] init];
        _introLabel.font = [UIFont systemFontOfSize:15.0];
        _introLabel.textColor = kLightGray;
        _introLabel.translatesAutoresizingMaskIntoConstraints = NO;
308
        [self  addSubview:_introLabel];
309 310
        
        NSLayoutConstraint *Top = [NSLayoutConstraint constraintWithItem:_introLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.allView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:7];
311
        [self  addConstraint:Top];
312
        
313 314
        NSLayoutConstraint *Left = [NSLayoutConstraint constraintWithItem:_introLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
        [self  addConstraint:Left];
315 316
        
        NSLayoutConstraint *Width = [NSLayoutConstraint constraintWithItem:_introLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:65];
317
        [self  addConstraint:Width];
318 319
        
        NSLayoutConstraint *Height = [NSLayoutConstraint constraintWithItem:_introLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
320
        [self  addConstraint:Height];
321 322 323 324 325 326 327 328 329 330 331
    }
    return _introLabel;
}

- (UILabel *)shopnameLabel
{
    if (!_shopnameLabel) {
        _shopnameLabel = [[UILabel alloc] init];
        _shopnameLabel.font = [UIFont systemFontOfSize:15.0];
        _shopnameLabel.textColor = kLightBlack;
        _shopnameLabel.translatesAutoresizingMaskIntoConstraints = NO;
332
        [self  addSubview:_shopnameLabel];
333
        
334 335
        NSLayoutConstraint *Top = [NSLayoutConstraint constraintWithItem:_shopnameLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeTop multiplier:1.0 constant:10];
        [self  addConstraint:Top];
336 337
        
        NSLayoutConstraint *Left = [NSLayoutConstraint constraintWithItem:_shopnameLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.shopname attribute:NSLayoutAttributeRight multiplier:1.0 constant:15];
338
        [self  addConstraint:Left];
339
        
admin's avatar
admin committed
340 341
//        NSLayoutConstraint *Right = [NSLayoutConstraint constraintWithItem:_shopnameLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
//        [self  addConstraint:Right];
342 343
        
        NSLayoutConstraint *Height = [NSLayoutConstraint constraintWithItem:_shopnameLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
344
        [self  addConstraint:Height];
345 346 347 348 349 350 351 352 353 354 355 356 357
    }
    return _shopnameLabel;
}


- (UILabel *)day
{
    if (!_day) {
        _day = [[UILabel alloc] init];
        _day.font = [UIFont systemFontOfSize:15.0];
        _day.textColor = kLightBlack;
        _day.textAlignment = NSTextAlignmentCenter;
        _day.translatesAutoresizingMaskIntoConstraints = NO;
358
        [self  addSubview:_day];
359 360
        
        NSLayoutConstraint *Top = [NSLayoutConstraint constraintWithItem:_day attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.shopnameLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:5];
361
        [self  addConstraint:Top];
362
        
363 364
        NSLayoutConstraint *Right = [NSLayoutConstraint constraintWithItem:_day attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
        [self  addConstraint:Right];
365 366
        
        NSLayoutConstraint *width = [NSLayoutConstraint constraintWithItem:_day attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
367
        [self  addConstraint:width];
368 369
        
        NSLayoutConstraint *Height = [NSLayoutConstraint constraintWithItem:_day attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
370
        [self  addConstraint:Height];
371 372 373 374 375 376 377 378 379 380
    }
    return _day;
}


- (UIImageView *)number
{
    if (!_number) {
        _number = [[UIImageView alloc] init];
        _number.translatesAutoresizingMaskIntoConstraints = NO;
381
        [self  addSubview:_number];
382 383
        
        NSLayoutConstraint *Top = [NSLayoutConstraint constraintWithItem:_number attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.shopnameLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:5];
384
        [self  addConstraint:Top];
385 386
        
        NSLayoutConstraint *Right = [NSLayoutConstraint constraintWithItem:_number attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.day attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
387
        [self  addConstraint:Right];
388 389
        
        NSLayoutConstraint *width = [NSLayoutConstraint constraintWithItem:_number attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:26];
390
        [self  addConstraint:width];
391 392
        
        NSLayoutConstraint *Height = [NSLayoutConstraint constraintWithItem:_number attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
393
        [self  addConstraint:Height];
394 395 396 397 398 399 400 401 402 403 404 405
    }
    return _number;
}

- (UILabel *)surplus
{
    if (!_surplus) {
        _surplus = [[UILabel alloc] init];
        _surplus.font = [UIFont systemFontOfSize:15.0];
        _surplus.textColor = kLightBlack;
        _surplus.textAlignment = NSTextAlignmentCenter;
        _surplus.translatesAutoresizingMaskIntoConstraints = NO;
406
        [self  addSubview:_surplus];
407 408
        
        NSLayoutConstraint *Top = [NSLayoutConstraint constraintWithItem:_surplus attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.shopnameLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:5];
409
        [self  addConstraint:Top];
410 411
        
        NSLayoutConstraint *Right = [NSLayoutConstraint constraintWithItem:_surplus attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.number attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
412
        [self  addConstraint:Right];
413 414
        
        NSLayoutConstraint *width = [NSLayoutConstraint constraintWithItem:_surplus attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:40];
415
        [self  addConstraint:width];
416 417
        
        NSLayoutConstraint *Height = [NSLayoutConstraint constraintWithItem:_surplus attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
418
        [self  addConstraint:Height];
419 420 421 422 423 424 425 426 427 428 429
    }
    return _surplus;
}


- (UILabel *)startDateLabel
{
    if (!_startDateLabel) {
        _startDateLabel = [[UILabel alloc] init];
        _startDateLabel.font = [UIFont systemFontOfSize:15.0];
        _startDateLabel.textColor = kLightBlack;
admin's avatar
admin committed
430
        _startDateLabel.textAlignment = NSTextAlignmentLeft;
431
        _startDateLabel.translatesAutoresizingMaskIntoConstraints = NO;
432
        [self  addSubview:_startDateLabel];
433 434
        
        NSLayoutConstraint *Top = [NSLayoutConstraint constraintWithItem:_startDateLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.shopnameLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:5];
435
        [self  addConstraint:Top];
436
        
admin's avatar
admin committed
437
        NSLayoutConstraint *Left = [NSLayoutConstraint constraintWithItem:_startDateLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:100];
438
        [self  addConstraint:Left];
439
        
admin's avatar
admin committed
440 441
//        NSLayoutConstraint *Right = [NSLayoutConstraint constraintWithItem:_startDateLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.surplus attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
//        [self  addConstraint:Right];
442 443
        
        NSLayoutConstraint *Height = [NSLayoutConstraint constraintWithItem:_startDateLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
444
        [self  addConstraint:Height];
445 446 447 448 449 450 451 452 453 454 455
    }
    return _startDateLabel;
}


- (UILabel *)overDateLabel
{
    if (!_overDateLabel) {
        _overDateLabel = [[UILabel alloc] init];
        _overDateLabel.font = [UIFont systemFontOfSize:15.0];
        _overDateLabel.textColor = kLightBlack;
admin's avatar
admin committed
456
        _overDateLabel.textAlignment = NSTextAlignmentLeft;
457
        _overDateLabel.translatesAutoresizingMaskIntoConstraints = NO;
458
        [self  addSubview:_overDateLabel];
459 460
        
        NSLayoutConstraint *Top = [NSLayoutConstraint constraintWithItem:_overDateLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.startDateLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:5];
461
        [self  addConstraint:Top];
462
        
admin's avatar
admin committed
463
        NSLayoutConstraint *Left = [NSLayoutConstraint constraintWithItem:_overDateLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.overDate attribute:NSLayoutAttributeLeft multiplier:1.0 constant:80];
464
        [self  addConstraint:Left];
465
        
admin's avatar
admin committed
466

467 468
        
        NSLayoutConstraint *Height = [NSLayoutConstraint constraintWithItem:_overDateLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
469
        [self  addConstraint:Height];
470 471 472 473 474 475 476 477 478 479
    }
    return _overDateLabel;
}

- (UILabel *)progressLabel
{
    if (!_progressLabel) {
        _progressLabel = [[UILabel alloc] init];
        _progressLabel.font = [UIFont systemFontOfSize:15.0];
        _progressLabel.translatesAutoresizingMaskIntoConstraints = NO;
480
        [self  addSubview:_progressLabel];
481 482
        
        NSLayoutConstraint *Top = [NSLayoutConstraint constraintWithItem:_progressLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.overDateLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:5];
483
        [self  addConstraint:Top];
484
        
admin's avatar
admin committed
485
        NSLayoutConstraint *Left = [NSLayoutConstraint constraintWithItem:_progressLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:100];
486
        [self  addConstraint:Left];
487 488
        
        NSLayoutConstraint *Right = [NSLayoutConstraint constraintWithItem:_progressLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.alreadyLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
489
        [self  addConstraint:Right];
490 491
        
        NSLayoutConstraint *Height = [NSLayoutConstraint constraintWithItem:_progressLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
492
        [self  addConstraint:Height];
493 494 495 496 497 498 499 500 501 502
    }
    return _progressLabel;
}

- (UILabel *)alreadyLabel
{
    if (!_alreadyLabel) {
        _alreadyLabel = [[UILabel alloc] init];
        _alreadyLabel.textAlignment = NSTextAlignmentRight;
        _alreadyLabel.translatesAutoresizingMaskIntoConstraints = NO;
503
        [self  addSubview:_alreadyLabel];
504 505
        
        NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_alreadyLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.overDateLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:5];
506
        [self  addConstraint:overDateTop];
507 508
        
        NSLayoutConstraint *overDateWidth = [NSLayoutConstraint constraintWithItem:_alreadyLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.allLabel attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0];
509
        [self  addConstraint:overDateWidth];
510 511
        
        NSLayoutConstraint *overDateRight = [NSLayoutConstraint constraintWithItem:_alreadyLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.allLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
512
        [self  addConstraint:overDateRight];
513 514
        
        NSLayoutConstraint *overDateHeight = [NSLayoutConstraint constraintWithItem:_alreadyLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
515
        [self  addConstraint:overDateHeight];
516 517 518 519 520 521 522 523 524
    }
    return _alreadyLabel;
}

- (UILabel *)allLabel
{
    if (!_allLabel) {
        _allLabel = [[UILabel alloc] init];
        _allLabel.translatesAutoresizingMaskIntoConstraints = NO;
525
        [self  addSubview:_allLabel];
526 527
        
        NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_allLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.overDateLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:5];
528
        [self  addConstraint:overDateTop];
529 530
        
        NSLayoutConstraint *overDateWidth = [NSLayoutConstraint constraintWithItem:_allLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:32];
531
        [self  addConstraint:overDateWidth];
532
        
533 534
        NSLayoutConstraint *overDateRight = [NSLayoutConstraint constraintWithItem:_allLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeRight multiplier:1.0 constant:-18];
        [self  addConstraint:overDateRight];
535 536
        
        NSLayoutConstraint *overDateHeight = [NSLayoutConstraint constraintWithItem:_allLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
537
        [self  addConstraint:overDateHeight];
538 539 540 541 542 543 544 545 546 547 548 549
    }
    return _allLabel;
}

- (UIButton *)unfoldBtn
{
    if (!_unfoldBtn) {
        _unfoldBtn = [[UIButton alloc] init];
        [_unfoldBtn setTitle:@"展开" forState:UIControlStateNormal];
        [_unfoldBtn setTitleColor:kLightGray forState:UIControlStateNormal];
        _unfoldBtn.tag = 2001;
        _unfoldBtn.translatesAutoresizingMaskIntoConstraints = NO;
550
        [self  addSubview:_unfoldBtn];
551 552
        
        NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_unfoldBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.allView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:10];
553
        [self  addConstraint:overDateTop];
554 555
        
        NSLayoutConstraint *overDateWidth = [NSLayoutConstraint constraintWithItem:_unfoldBtn attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:32];
556
        [self  addConstraint:overDateWidth];
557 558
        
        NSLayoutConstraint *overDateRight = [NSLayoutConstraint constraintWithItem:_unfoldBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.arrowImageView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
559
        [self  addConstraint:overDateRight];
560 561
        
        NSLayoutConstraint *overDateHeight = [NSLayoutConstraint constraintWithItem:_unfoldBtn attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
562
        [self  addConstraint:overDateHeight];
563 564 565 566 567 568 569 570 571
    }
    return _unfoldBtn;
}

- (UIImageView *)arrowImageView
{
    if (!_arrowImageView) {
        _arrowImageView = [[UIImageView alloc] init];
        _arrowImageView.translatesAutoresizingMaskIntoConstraints = NO;
572
        [self  addSubview:_arrowImageView];
573 574
        
        NSLayoutConstraint *Top = [NSLayoutConstraint constraintWithItem:_arrowImageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.allView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:19];
575
        [self  addConstraint:Top];
576
        
577 578
        NSLayoutConstraint *Right = [NSLayoutConstraint constraintWithItem:_arrowImageView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self  attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
        [self  addConstraint:Right];
579 580
        
        NSLayoutConstraint *width = [NSLayoutConstraint constraintWithItem:_arrowImageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:11];
581
        [self  addConstraint:width];
582 583
        
        NSLayoutConstraint *Height = [NSLayoutConstraint constraintWithItem:_arrowImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:8];
584
        [self  addConstraint:Height];
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613
    }
    return _arrowImageView;
}

- (UILabel *)dayLabel
{
    if (!_dayLabel) {
        _dayLabel = [[UILabel alloc] init];
        _dayLabel.translatesAutoresizingMaskIntoConstraints = NO;
        _dayLabel.textColor = kProgressUnSettledColor;
        _dayLabel.textAlignment = NSTextAlignmentCenter;
        _dayLabel.font = [UIFont boldSystemFontOfSize:20.0];
        [self.number addSubview:_dayLabel];
        
        NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_dayLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.number attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
        [self.number addConstraint:overDateTop];
        
        NSLayoutConstraint *overDateLeft = [NSLayoutConstraint constraintWithItem:_dayLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.number attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
        [self.number addConstraint:overDateLeft];
        
        NSLayoutConstraint *overDateRight = [NSLayoutConstraint constraintWithItem:_dayLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.number attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
        [self.number addConstraint:overDateRight];
        
        NSLayoutConstraint *overDateHeight = [NSLayoutConstraint constraintWithItem:_dayLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.number attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
        [self.number addConstraint:overDateHeight];
    }
    return _dayLabel;
}

614 615 616 617 618 619 620
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
621 622

@end