123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- /************************************************************
- * * EaseMob CONFIDENTIAL
- * __________________
- * Copyright (C) 2013-2014 EaseMob Technologies. All rights reserved.
- *
- * NOTICE: All information contained herein is, and remains
- * the property of EaseMob Technologies.
- * Dissemination of this information or reproduction of this material
- * is strictly forbidden unless prior written permission is obtained
- * from EaseMob Technologies.
- */
- #import "CustomerListCell.h"
- @implementation CustomerListCell
- - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- self.contentView.backgroundColor = [UIColor whiteColor];
-
- self.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
-
- [self layoutAllComponents];
- }
- return self;
- }
- #pragma mark - Generate Properties
- - (APAvatarImageView *)headView {
- if (!_headView) {
- _headView = [[APAvatarImageView alloc] init];
- _headView.borderColor = [UIColor whiteColor];
- _headView.borderWidth = 0.0;
- _headView.cornerRadius = 3.0;
- }
- return _headView;
- }
- - (UILabel *)nickLabel {
- if (!_nickLabel) {
- _nickLabel = [[UILabel alloc] init];
- _nickLabel.font = [UIFont systemFontOfSize:14.0];
- _nickLabel.textColor = [UIColor blackColor];
- // _nickLabel.backgroundColor = [UIColor redColor];
- }
- return _nickLabel;
- }
- - (UILabel *)messageLabel {
- if (!_messageLabel) {
- _messageLabel = [[UILabel alloc] init];
- _messageLabel.font = [UIFont systemFontOfSize:13.0];
- _messageLabel.textColor = UIColorFromRGB(0x999999);
- }
- return _messageLabel;
- }
- - (UILabel *)timeLabel {
- if (!_timeLabel) {
- _timeLabel = [[UILabel alloc] init];
- _timeLabel.font = [UIFont systemFontOfSize:12.0];
- _timeLabel.textAlignment = NSTextAlignmentRight;
- _timeLabel.textColor = [UIColor lightGrayColor];
- // _timeLabel.backgroundColor = [UIColor redColor];
- }
- return _timeLabel;
- }
- - (UILabel *)unreadLabel {
- if (!_unreadLabel) {
- _unreadLabel = [[UILabel alloc] init];
- _unreadLabel.textColor = [UIColor whiteColor];
- _unreadLabel.backgroundColor = UIColorFromRGB(0x00c8a9);
- _unreadLabel.textAlignment = NSTextAlignmentCenter;
- _unreadLabel.font = [UIFont systemFontOfSize:11];
- _unreadLabel.layer.cornerRadius = 8;
- _unreadLabel.clipsToBounds = YES;
- }
- return _unreadLabel;
- }
- #pragma mark - Layout
- - (void)layoutAllComponents {
- WeakSelf(weakSelf);
-
- [self.contentView addSubview:self.headView];
- [self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(weakSelf.contentView).with.offset(15);
- make.centerY.equalTo(weakSelf.contentView);
- make.size.mas_equalTo(CGSizeMake(36, 36));
- }];
-
- [self.contentView addSubview:self.timeLabel];
- [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(weakSelf.contentView).with.offset(-12);
- make.top.equalTo(weakSelf.headView.mas_top).with.offset(-2);
- make.size.mas_equalTo(CGSizeMake(100, 20));
- }];
-
- [self.contentView addSubview:self.nickLabel];
- [self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(weakSelf.headView.mas_right).with.offset(14);
- make.right.equalTo(weakSelf.timeLabel.mas_left).with.offset(4);
- make.top.equalTo(weakSelf.headView.mas_top).with.offset(-2);
- make.height.mas_equalTo(20);
- }];
-
- [self.contentView addSubview:self.messageLabel];
- [self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(weakSelf.headView.mas_right).with.offset(14);
- make.right.equalTo(weakSelf.contentView).with.offset(-12);
- make.bottom.equalTo(weakSelf.headView.mas_bottom).with.offset(4);
- make.height.mas_equalTo(20);
- }];
-
- [self.contentView addSubview:self.unreadLabel];
- [self.unreadLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(weakSelf.headView.mas_right).with.offset(-6);
- make.top.equalTo(weakSelf.headView.mas_top).with.offset(-6);
- make.width.mas_greaterThanOrEqualTo(16);
- make.height.mas_equalTo(16);
- }];
- }
- #pragma mark - Unread Label
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- if (![_unreadLabel isHidden]) {
- _unreadLabel.backgroundColor = [UIColor redColor];
- }
- }
- - (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{
- [super setHighlighted:highlighted animated:animated];
- if (![_unreadLabel isHidden]) {
- _unreadLabel.backgroundColor = [UIColor redColor];
- }
- }
- @end
|