Initial commit
This commit is contained in:
+86
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// NTESContactDefines.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/2/26.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef NIM_NTESContactDefines_h
|
||||
#define NIM_NTESContactDefines_h
|
||||
|
||||
@protocol NTESContactItemCollection <NSObject>
|
||||
@required
|
||||
//显示的title名
|
||||
- (NSString*)title;
|
||||
|
||||
//返回集合里的成员
|
||||
- (NSArray*)members;
|
||||
|
||||
//重用id
|
||||
- (NSString*)reuseId;
|
||||
|
||||
//需要构造的cell类名
|
||||
- (NSString*)cellName;
|
||||
|
||||
@end
|
||||
|
||||
@protocol NTESContactItem<NSObject>
|
||||
@required
|
||||
//userId和Vcname必有一个有值,根据有值的状态push进不同的页面
|
||||
- (NSString*)vcName;
|
||||
|
||||
//userId和Vcname必有一个有值,根据有值的状态push进不同的页面
|
||||
- (NSString*)userId;
|
||||
|
||||
//返回行高
|
||||
- (CGFloat)uiHeight;
|
||||
|
||||
//重用id
|
||||
- (NSString*)reuseId;
|
||||
|
||||
//需要构造的cell类名
|
||||
- (NSString*)cellName;
|
||||
|
||||
//badge
|
||||
- (NSString *)badge;
|
||||
|
||||
//显示名
|
||||
- (NSString *)nick;
|
||||
|
||||
//占位图
|
||||
- (UIImage *)icon;
|
||||
|
||||
//头像url
|
||||
- (NSString *)avatarUrl;
|
||||
|
||||
//accessoryView
|
||||
- (BOOL)showAccessoryView;
|
||||
|
||||
@optional
|
||||
- (NSString *)selName;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@protocol NTESContactCell <NSObject>
|
||||
|
||||
- (void)refreshWithContactItem:(id<NTESContactItem>)item;
|
||||
|
||||
- (void)addDelegate:(id)delegate;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NIM_NTESContactCellLayoutConstant_h
|
||||
#define NIM_NTESContactCellLayoutConstant_h
|
||||
|
||||
static const CGFloat NTESContactUtilRowHeight = 57;//util类Cell行高
|
||||
static const CGFloat NTESContactDataRowHeight = 50;//data类Cell行高
|
||||
static const NSInteger NTESContactAvatarLeft = 10;//没有选择框的时候,头像到左边的距离
|
||||
static const NSInteger NTESContactAvatarAndAccessorySpacing = 10;//头像和选择框之间的距离
|
||||
|
||||
#endif
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// NTESContactUtilCell.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/2/26.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "NTESContactDefines.h"
|
||||
|
||||
@protocol NTESContactUtilCellDelegate <NSObject>
|
||||
|
||||
- (void)onPressUtilImage:(NSString *)content;
|
||||
|
||||
@end
|
||||
|
||||
@interface NTESContactUtilCell : UITableViewCell
|
||||
|
||||
@property (nonatomic,weak) id<NTESContactUtilCellDelegate> delegate;
|
||||
|
||||
- (void)refreshWithContactItem:(id<NTESContactItem>)item;
|
||||
|
||||
@end
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// NTESContactUtilCell.m
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/2/26.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESContactUtilCell.h"
|
||||
#import "UIView+NTES.h"
|
||||
#import "NTESBadgeView.h"
|
||||
|
||||
@interface NTESContactUtilCell()
|
||||
|
||||
@property (nonatomic,strong) NTESBadgeView *badgeView;
|
||||
|
||||
@property (nonatomic,strong) id<NTESContactItem> data;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTESContactUtilCell
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
_badgeView = [NTESBadgeView viewWithBadgeTip:@""];
|
||||
[self addSubview:_badgeView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)refreshWithContactItem:(id<NTESContactItem>)item{
|
||||
self.data = item;
|
||||
self.textLabel.text = item.nick;
|
||||
self.imageView.image = item.icon;
|
||||
self.imageView.userInteractionEnabled = YES;
|
||||
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onPressUtilImage:)];
|
||||
[self.imageView addGestureRecognizer: recognizer];
|
||||
[self.textLabel sizeToFit];
|
||||
|
||||
NSString *badge = [item badge];
|
||||
self.badgeView.hidden = badge.integerValue == 0;
|
||||
self.badgeView.badgeValue = badge;
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
||||
[super setSelected:selected animated:animated];
|
||||
}
|
||||
|
||||
- (void)onPressUtilImage:(id)sender{
|
||||
if ([self.delegate respondsToSelector:@selector(onPressUtilImage:)]) {
|
||||
[self.delegate onPressUtilImage:self.data.nick];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addDelegate:(id)delegate{
|
||||
self.delegate = delegate;
|
||||
}
|
||||
|
||||
#define BadgeValueRight 50
|
||||
- (void)layoutSubviews{
|
||||
[super layoutSubviews];
|
||||
self.imageView.left = NTESContactAvatarLeft;
|
||||
self.imageView.centerY = self.height * .5f;
|
||||
self.badgeView.right = self.width - BadgeValueRight;
|
||||
self.badgeView.centerY = self.height * .5f;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// NTESContactUtilItem.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/2/26.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "NTESContactDefines.h"
|
||||
#import "NTESGroupedContacts.h"
|
||||
|
||||
@interface NTESContactUtilItem : NSObject<NTESContactItemCollection>
|
||||
|
||||
@property (nonatomic,copy) NSArray *members;
|
||||
|
||||
@end
|
||||
|
||||
@interface NTESContactUtilMember : NSObject<NTESContactItem, NTESGroupMemberProtocol>
|
||||
|
||||
@property (nonatomic,copy) NSString *nick;
|
||||
|
||||
@property (nonatomic,copy) NSString *badge;
|
||||
|
||||
@property (nonatomic,copy) UIImage *icon;
|
||||
|
||||
@property (nonatomic,copy) NSString *vcName;
|
||||
|
||||
@property (nonatomic,copy) NSString *userId;
|
||||
|
||||
@property (nonatomic,copy) NSString *selName;
|
||||
|
||||
@end
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// ContactUtilItem.m
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/2/26.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESContactUtilItem.h"
|
||||
|
||||
@implementation NTESContactUtilItem
|
||||
|
||||
- (NSString*)reuseId{
|
||||
return @"NTESContactUtilItem";
|
||||
}
|
||||
|
||||
- (NSString*)cellName{
|
||||
return @"NTESContactUtilCell";
|
||||
}
|
||||
|
||||
- (NSString*)title{
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTESContactUtilMember
|
||||
|
||||
- (NSString *)avatarUrl{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (CGFloat)uiHeight{
|
||||
return NTESContactUtilRowHeight;
|
||||
}
|
||||
|
||||
- (NSString*)reuseId{
|
||||
return @"NTESContactUtilItem";
|
||||
}
|
||||
|
||||
- (NSString*)cellName{
|
||||
return @"NTESContactUtilCell";
|
||||
}
|
||||
|
||||
- (NSString *)groupTitle {
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSString *)memberId{
|
||||
return self.userId;
|
||||
}
|
||||
|
||||
- (BOOL)showAccessoryView{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (id)sortKey {
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// NTESUserListCell.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/8/18.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class NIMAvatarImageView;
|
||||
@class ContactDataMember;
|
||||
|
||||
|
||||
@protocol NTESUserListCellDelegate <NSObject>
|
||||
|
||||
- (void)didTouchUserListAvatar:(NSString *)userId;
|
||||
|
||||
@end
|
||||
|
||||
@interface NTESUserListCell : UITableViewCell
|
||||
|
||||
@property (nonatomic,strong) NIMAvatarImageView * avatarImageView;
|
||||
|
||||
@property (nonatomic,weak) id<NTESUserListCellDelegate> delegate;
|
||||
|
||||
- (void)refreshWithMember:(ContactDataMember *)member;
|
||||
|
||||
@end
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// NTESUserListCell.m
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/8/18.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESUserListCell.h"
|
||||
#import "NIMAvatarImageView.h"
|
||||
#import "UIView+NTES.h"
|
||||
#import "NTESContactDataMember.h"
|
||||
#import "NTESSessionUtil.h"
|
||||
|
||||
@interface NTESUserListCell()
|
||||
|
||||
@property (nonatomic,strong) NTESContactDataMember *member;
|
||||
|
||||
@property (nonatomic,strong) UIView *sep;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTESUserListCell
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
_avatarImageView = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
|
||||
[_avatarImageView addTarget:self action:@selector(onTouchAvatar:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:_avatarImageView];
|
||||
_sep = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
_sep.backgroundColor = [UIColor lightGrayColor];
|
||||
_sep.height = .5f;
|
||||
[self addSubview:_sep];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)refreshWithMember:(NTESContactDataMember *)member{
|
||||
self.member = member;
|
||||
self.textLabel.text = [NTESSessionUtil showNick:member.info.infoId inSession:nil];
|
||||
[self.textLabel sizeToFit];
|
||||
NSURL *url;
|
||||
if (member.info.avatarUrlString.length) {
|
||||
url = [NSURL URLWithString:member.info.avatarUrlString];
|
||||
}
|
||||
[_avatarImageView nim_setImageWithURL:url placeholderImage:member.info.avatarImage options:SDWebImageRetryFailed];
|
||||
}
|
||||
|
||||
|
||||
- (void)onTouchAvatar:(id)sender{
|
||||
if ([self.delegate respondsToSelector:@selector(didTouchUserListAvatar:)]) {
|
||||
[self.delegate didTouchUserListAvatar:self.member.info.infoId];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{
|
||||
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated{
|
||||
|
||||
}
|
||||
|
||||
|
||||
- (void)layoutSubviews{
|
||||
[super layoutSubviews];
|
||||
CGFloat scale = self.width / 320;
|
||||
CGFloat maxTextLabelWidth = 210 * scale;
|
||||
self.textLabel.width = MIN(self.textLabel.width, maxTextLabelWidth);
|
||||
|
||||
static const NSInteger NTESContactAccessoryLeft = 10;//选择框到左边的距离
|
||||
static const NSInteger NTESContactAvatarAndTitleSpacing = 20;//头像和文字之间的间距
|
||||
|
||||
CGFloat avatarLeft = 15.f;
|
||||
self.avatarImageView.left = avatarLeft;
|
||||
self.avatarImageView.centerY = self.height * .5f;
|
||||
self.textLabel.left = self.avatarImageView.right + NTESContactAvatarAndTitleSpacing;
|
||||
self.sep.width = self.width - avatarLeft - self.avatarImageView.width - NTESContactAvatarAndTitleSpacing;
|
||||
self.sep.left = avatarLeft + NTESContactAccessoryLeft + self.avatarImageView.width;
|
||||
self.sep.bottom = self.height - self.sep.height;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user