Initial commit
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// NTESChatroomListCell.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/12/14.
|
||||
// Copyright © 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface NTESChatroomListCell : UICollectionViewCell
|
||||
|
||||
- (void)refresh:(NIMChatroom *)data;
|
||||
|
||||
@end
|
||||
+192
@@ -0,0 +1,192 @@
|
||||
//
|
||||
// NTESChatroomListCell.m
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/12/14.
|
||||
// Copyright © 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESChatroomListCell.h"
|
||||
#import "UIImageView+WebCache.h"
|
||||
#import "UIView+NTES.h"
|
||||
|
||||
@interface NTESChatroomListCellInfoView : UIView
|
||||
- (void)refresh:(id)data;
|
||||
@end
|
||||
|
||||
@interface NTESChatroomListCell()
|
||||
|
||||
@property (nonatomic,strong) UIImageView *coverImageView;
|
||||
|
||||
@property (nonatomic,strong) NTESChatroomListCellInfoView *infoView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTESChatroomListCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
self.layer.borderColor = [UIColor blackColor].CGColor;
|
||||
self.layer.borderWidth = .5f;
|
||||
[self addSubview:self.coverImageView];
|
||||
[self addSubview:self.infoView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)refresh:(NIMChatroom *)chatroom{
|
||||
NSInteger index = chatroom.roomId.hash % 8;
|
||||
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"chatroom_cover_page_%zd",index]];
|
||||
[self.coverImageView sd_setImageWithURL:nil placeholderImage:image];
|
||||
[self.infoView refresh:chatroom];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews{
|
||||
[super layoutSubviews];
|
||||
self.coverImageView.size = CGSizeMake(self.width, self.height);
|
||||
self.infoView.bottom = self.height;
|
||||
}
|
||||
|
||||
#pragma mark - Get
|
||||
- (UIImageView *)coverImageView{
|
||||
if (!_coverImageView) {
|
||||
_coverImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
|
||||
_coverImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
_coverImageView.clipsToBounds = YES;
|
||||
_coverImageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
}
|
||||
return _coverImageView;
|
||||
}
|
||||
|
||||
- (NTESChatroomListCellInfoView *)infoView{
|
||||
if (!_infoView) {
|
||||
_infoView = [[NTESChatroomListCellInfoView alloc] initWithFrame:CGRectMake(0, 0, self.width, 44)];
|
||||
_infoView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
}
|
||||
return _infoView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface NTESChatroomListCellInfoView()
|
||||
|
||||
@property (nonatomic, strong) UILabel *statusLabel;
|
||||
|
||||
@property (nonatomic, strong) UIImageView *iconImageView; //人数icon
|
||||
|
||||
@property (nonatomic, strong) UILabel *countLabel; //在线人数
|
||||
|
||||
@property (nonatomic, strong) UIView *titleBackgroundView; //聊天室房间名背景
|
||||
|
||||
@property (nonatomic, strong) UILabel *titleLabel; //聊天室房间名
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTESChatroomListCellInfoView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
self.backgroundColor = UIColorFromRGBA(0x0, .6f);
|
||||
[self addSubview:self.statusLabel];
|
||||
[self addSubview:self.titleBackgroundView];
|
||||
[self addSubview:self.titleLabel];
|
||||
[self addSubview:self.iconImageView];
|
||||
[self addSubview:self.countLabel];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)refresh:(NIMChatroom *)chatroom{
|
||||
self.statusLabel.text = @"正在直播";
|
||||
[self.statusLabel sizeToFit];
|
||||
float onlineUserCount = (float)chatroom.onlineUserCount;
|
||||
NSString *countText;
|
||||
if (onlineUserCount > 10000) {
|
||||
countText = [NSString stringWithFormat:@"%.1f万",onlineUserCount / 10000];
|
||||
}else{
|
||||
countText = @(chatroom.onlineUserCount).stringValue;
|
||||
}
|
||||
self.countLabel.text = countText;
|
||||
[self.countLabel sizeToFit];
|
||||
self.titleLabel.text = chatroom.name;
|
||||
[self.titleLabel sizeToFit];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews{
|
||||
[super layoutSubviews];
|
||||
CGFloat spacing = 8.f;
|
||||
self.statusLabel.centerY = (self.height - self.titleBackgroundViewHeight) * .5;
|
||||
self.statusLabel.left = spacing;
|
||||
self.countLabel.right = self.width - spacing;
|
||||
self.countLabel.centerY = self.statusLabel.centerY;
|
||||
self.iconImageView.right = self.countLabel.left - spacing;
|
||||
self.iconImageView.centerY = self.statusLabel.centerY;
|
||||
self.titleBackgroundView.width = self.width;
|
||||
self.titleBackgroundView.bottom = self.height;
|
||||
self.titleLabel.width = self.width - 2 *spacing;
|
||||
self.titleLabel.left = spacing;
|
||||
self.titleLabel.centerY = self.titleBackgroundView.centerY;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Get
|
||||
|
||||
- (UILabel *)statusLabel{
|
||||
if (!_statusLabel) {
|
||||
_statusLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
_statusLabel.font = [UIFont systemFontOfSize:10.f];
|
||||
_statusLabel.textColor = [UIColor whiteColor];
|
||||
}
|
||||
return _statusLabel;
|
||||
}
|
||||
|
||||
- (UIImageView *)iconImageView{
|
||||
if (!_iconImageView) {
|
||||
_iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 12, 12)];
|
||||
[_iconImageView setImage:[UIImage imageNamed:@"chatroom_onlinecount_room"]];
|
||||
}
|
||||
return _iconImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)countLabel{
|
||||
if (!_countLabel) {
|
||||
_countLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
_countLabel.font = [UIFont systemFontOfSize:10.f];
|
||||
_countLabel.textColor = [UIColor whiteColor];
|
||||
}
|
||||
return _countLabel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (CGFloat)titleBackgroundViewHeight{
|
||||
return 28.f;
|
||||
}
|
||||
|
||||
- (CGFloat)titleLabelLeft{
|
||||
return 15.f;
|
||||
}
|
||||
|
||||
- (UIView *)titleBackgroundView{
|
||||
if (!_titleBackgroundView) {
|
||||
_titleBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, self.titleBackgroundViewHeight)];
|
||||
_titleBackgroundView.backgroundColor = [UIColor whiteColor];
|
||||
}
|
||||
return _titleBackgroundView;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel{
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
_titleLabel.font = [UIFont systemFontOfSize:13.f];
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// NTESChatroomMemberCell.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/12/18.
|
||||
// Copyright © 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface NTESChatroomMemberCell : UITableViewCell
|
||||
|
||||
- (void)refresh:(NIMChatroomMember *)member;
|
||||
|
||||
@end
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
//
|
||||
// NTESChatroomMemberCell.m
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/12/18.
|
||||
// Copyright © 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESChatroomMemberCell.h"
|
||||
#import "NIMAvatarImageView.h"
|
||||
#import "UIView+NTES.h"
|
||||
#import "NTESDataManager.h"
|
||||
|
||||
@interface NTESChatroomMemberCell()
|
||||
|
||||
@property (nonatomic, strong) NIMAvatarImageView *avatarImageView;
|
||||
|
||||
@property (nonatomic, strong) UIImageView *roleImageView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTESChatroomMemberCell
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
||||
{
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
[self addSubview:self.avatarImageView];
|
||||
[self addSubview:self.roleImageView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)refresh:(NIMChatroomMember *)member{
|
||||
[self.avatarImageView nim_setImageWithURL:[NSURL URLWithString:member.roomAvatar] placeholderImage:[NTESDataManager sharedInstance].defaultUserAvatar];
|
||||
self.textLabel.text = member.roomNickname;
|
||||
[self.textLabel sizeToFit];
|
||||
[self refreshRole:member];
|
||||
}
|
||||
|
||||
- (void)refreshRole:(NIMChatroomMember *)member
|
||||
{
|
||||
UIImage *image;
|
||||
switch (member.type) {
|
||||
case NIMChatroomMemberTypeCreator:
|
||||
image = [UIImage imageNamed:@"chatroom_role_master"];
|
||||
break;
|
||||
case NIMChatroomMemberTypeManager:
|
||||
image = [UIImage imageNamed:@"chatroom_role_manager"];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
self.roleImageView.image = image;
|
||||
self.roleImageView.hidden = !image;
|
||||
[self.roleImageView sizeToFit];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews{
|
||||
[super layoutSubviews];
|
||||
CGFloat spacing = 10.f;
|
||||
if (!self.roleImageView.hidden){
|
||||
self.roleImageView.left = spacing;
|
||||
self.roleImageView.centerY = self.height * .5f;
|
||||
self.avatarImageView.left = self.roleImageView.right + spacing;
|
||||
}
|
||||
else{
|
||||
self.avatarImageView.left = spacing;
|
||||
}
|
||||
self.avatarImageView.centerY = self.height * .5f;
|
||||
self.textLabel.left = self.avatarImageView.right + spacing;
|
||||
self.textLabel.centerY = self.height * .5f;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Get
|
||||
- (NIMAvatarImageView *)avatarImageView{
|
||||
if (!_avatarImageView) {
|
||||
_avatarImageView = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(0, 0, 36, 36)];
|
||||
}
|
||||
return _avatarImageView;
|
||||
}
|
||||
|
||||
- (UIImageView *)roleImageView
|
||||
{
|
||||
if (!_roleImageView) {
|
||||
_roleImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
|
||||
}
|
||||
return _roleImageView;
|
||||
}
|
||||
|
||||
@end
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// NTESChatroomSegmentedControl.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/12/16.
|
||||
// Copyright © 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface NTESChatroomSegmentedControl : UIView
|
||||
|
||||
@property(nonatomic) NSInteger selectedSegmentIndex;
|
||||
|
||||
- (void)insertSegmentWithTitle:(NSString *)title;
|
||||
|
||||
- (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state atIndex:(NSInteger)index;
|
||||
|
||||
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state atIndex:(NSInteger)index;
|
||||
|
||||
- (void)setFont:(UIFont *)font atIndex:(NSInteger)index;
|
||||
|
||||
//只有UIControlEventValueChanged有效
|
||||
- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;
|
||||
|
||||
@end
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
//
|
||||
// NTESChatroomSegmentedControl.m
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/12/16.
|
||||
// Copyright © 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESChatroomSegmentedControl.h"
|
||||
#import "UIView+NTES.h"
|
||||
|
||||
@interface NTESChatroomSegmentedControl()
|
||||
|
||||
@property (nonatomic,strong) NSMutableArray<UIButton *> *segments;
|
||||
|
||||
@property (nonatomic,strong) NSMutableArray<NSInvocation *> *invocations;
|
||||
|
||||
@property (nonatomic,assign) NSInteger selectedIndex;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTESChatroomSegmentedControl
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
_segments = [[NSMutableArray alloc] init];
|
||||
_invocations = [[NSMutableArray alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)insertSegmentWithTitle:(NSString *)title{
|
||||
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[button addTarget:self action:@selector(onSegmentTouchUpInside:) forControlEvents:UIControlEventTouchUpInside];
|
||||
button.tag = self.segments.count;
|
||||
[button setTitle:title forState:UIControlStateNormal];
|
||||
[self addSubview:button];
|
||||
[self.segments addObject:button];
|
||||
[self refresh];
|
||||
}
|
||||
|
||||
- (void)setSelectedSegmentIndex:(NSInteger)index
|
||||
{
|
||||
self.selectedIndex = index;
|
||||
[self refresh];
|
||||
}
|
||||
|
||||
- (NSInteger)selectedSegmentIndex
|
||||
{
|
||||
return self.selectedIndex;
|
||||
}
|
||||
|
||||
- (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state atIndex:(NSInteger)index
|
||||
{
|
||||
UIButton *button = self.segments[index];
|
||||
[button setBackgroundImage:image forState:state];
|
||||
}
|
||||
|
||||
|
||||
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state atIndex:(NSInteger)index
|
||||
{
|
||||
UIButton *button = self.segments[index];
|
||||
[button setTitleColor:color forState:state];
|
||||
}
|
||||
|
||||
- (void)setFont:(UIFont *)font atIndex:(NSInteger)index
|
||||
{
|
||||
UIButton *button = self.segments[index];
|
||||
button.titleLabel.font = font;
|
||||
}
|
||||
|
||||
|
||||
- (void)onSegmentTouchUpInside:(id)sender
|
||||
{
|
||||
NSInteger index = [(UIButton *)sender tag];
|
||||
if (index != self.selectedIndex) { //value changed
|
||||
self.selectedIndex = index;
|
||||
[self refresh];
|
||||
[self invokeValueChangedAction];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents
|
||||
{
|
||||
if (controlEvents == UIControlEventValueChanged) {
|
||||
UIView *view = self;
|
||||
NSMethodSignature *sig = [[target class] instanceMethodSignatureForSelector:action];
|
||||
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:sig];
|
||||
[inv setTarget:target];
|
||||
[inv setSelector:action];
|
||||
[inv setArgument:&view atIndex:2];
|
||||
[_invocations addObject:inv];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)refresh
|
||||
{
|
||||
for (UIButton *button in self.segments) {
|
||||
button.selected = NO;
|
||||
}
|
||||
self.segments[self.selectedIndex].selected = YES;
|
||||
}
|
||||
|
||||
- (void)invokeValueChangedAction
|
||||
{
|
||||
for (NSInvocation *inv in _invocations) {
|
||||
[inv invoke];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)layoutSubviews{
|
||||
[super layoutSubviews];
|
||||
CGFloat left = 0.0f;
|
||||
CGFloat width = self.width / self.segments.count;
|
||||
CGFloat height = self.height;
|
||||
for (UIButton *button in self.segments) {
|
||||
button.size = CGSizeMake(width, height);
|
||||
button.left = left;
|
||||
left += button.width;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// NTESLiveActionView.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 16/1/26.
|
||||
// Copyright © 2016年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESChatroomSegmentedControl.h"
|
||||
#import "NTESPageView.h"
|
||||
|
||||
@protocol NTESLiveActionViewDataSource <NSObject>
|
||||
|
||||
@required
|
||||
- (NSInteger)numberOfPages;
|
||||
|
||||
- (UIView *)viewInPage:(NSInteger)index;
|
||||
|
||||
- (CGFloat)liveViewHeight;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@protocol NTESLiveActionViewDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
- (void)onSegmentControlChanged:(NTESChatroomSegmentedControl *)control;
|
||||
|
||||
- (void)onTouchActionBackground;
|
||||
|
||||
@end
|
||||
|
||||
@interface NTESLiveActionView : UIView
|
||||
|
||||
@property (nonatomic, strong) NTESPageView *pageView;
|
||||
|
||||
@property (nonatomic, strong) NTESChatroomSegmentedControl *segmentedControl;
|
||||
|
||||
@property (nonatomic,weak) id<NTESLiveActionViewDataSource> datasource;
|
||||
|
||||
@property (nonatomic,weak) id<NTESLiveActionViewDelegate> delegate;
|
||||
|
||||
- (instancetype)initWithDataSource:(id<NTESLiveActionViewDataSource>) datasource;
|
||||
|
||||
- (void)reloadData;
|
||||
|
||||
@end
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
//
|
||||
// NTESLiveActionView.m
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 16/1/26.
|
||||
// Copyright © 2016年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESLiveActionView.h"
|
||||
#import "UIView+NTES.h"
|
||||
#import "UIImage+NTESColor.h"
|
||||
|
||||
|
||||
@interface NTESChatroomSegmentedItem : NSObject
|
||||
|
||||
@property (nonatomic, copy) NSString *showName;
|
||||
|
||||
@end
|
||||
|
||||
@interface NTESLiveActionView()<NTESPageViewDelegate,NTESPageViewDataSource>
|
||||
|
||||
@property (nonatomic, copy) NSArray<NTESChatroomSegmentedItem *> *segmentedItems;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTESLiveActionView
|
||||
|
||||
- (instancetype)initWithDataSource:(id<NTESLiveActionViewDataSource>)datasource
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_datasource = datasource;
|
||||
[self addSubview:self.segmentedControl];
|
||||
[self addSubview:self.pageView];
|
||||
UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap:)];
|
||||
[self addGestureRecognizer:gesture];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)reloadData
|
||||
{
|
||||
[self.pageView reloadData];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Action Delegate
|
||||
|
||||
- (void)onSegmentControlChanged:(id)sender
|
||||
{
|
||||
if ([self.delegate respondsToSelector:@selector(onSegmentControlChanged:)]) {
|
||||
[self.delegate onSegmentControlChanged:sender];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onTap:(UIGestureRecognizer *)gesture
|
||||
{
|
||||
if ([self.delegate respondsToSelector:@selector(onTouchActionBackground)]) {
|
||||
[self.delegate onTouchActionBackground];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (NSInteger)numberOfPages:(NTESPageView *)pageView
|
||||
{
|
||||
return [self.datasource numberOfPages];
|
||||
}
|
||||
|
||||
- (UIView *)pageView:(NTESPageView *)pageView viewInPage: (NSInteger)index
|
||||
{
|
||||
return [self.datasource viewInPage:index];
|
||||
}
|
||||
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
self.segmentedControl.height = self.segmentedControlHeight;
|
||||
CGFloat liveViewHeight = [self.datasource liveViewHeight];
|
||||
self.segmentedControl.top = liveViewHeight;
|
||||
CGFloat pageViewHeight = self.height - liveViewHeight - self.segmentedControl.height;
|
||||
self.pageView.height = pageViewHeight;
|
||||
self.pageView.bottom = self.height;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma mark - Get
|
||||
|
||||
#define SegmentDefaultHeight 40.f
|
||||
|
||||
- (CGFloat)segmentedControlHeight
|
||||
{
|
||||
return SegmentDefaultHeight;
|
||||
}
|
||||
|
||||
- (NTESPageView *)pageView{
|
||||
if (!_pageView) {
|
||||
_pageView = [[NTESPageView alloc] initWithFrame:CGRectMake(0, 0, self.width, 0)];
|
||||
_pageView.dataSource = self;
|
||||
_pageView.pageViewDelegate = self;
|
||||
_pageView.scrollView.scrollEnabled = NO;
|
||||
_pageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
}
|
||||
return _pageView;
|
||||
}
|
||||
|
||||
- (NTESChatroomSegmentedControl *)segmentedControl{
|
||||
if (!_segmentedControl) {
|
||||
_segmentedControl = [[NTESChatroomSegmentedControl alloc] initWithFrame:CGRectMake(0, 0, self.width,0)];
|
||||
_segmentedControl.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
UIImage *imageSelected = [[UIImage imageNamed:@"icon_chatroom_seg_bkg"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 1, 0, 1) resizingMode:UIImageResizingModeStretch];
|
||||
UIImage *imageNormal = [[UIImage imageWithColor:[UIColor whiteColor]] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 1, 0, 1) resizingMode:UIImageResizingModeStretch];
|
||||
for (NSInteger index = 0; index < self.segmentedItems.count; index++) {
|
||||
NTESChatroomSegmentedItem *item = self.segmentedItems[index];
|
||||
[_segmentedControl insertSegmentWithTitle:item.showName];
|
||||
[_segmentedControl setBackgroundImage:imageNormal forState:UIControlStateNormal atIndex:index];
|
||||
[_segmentedControl setBackgroundImage:imageNormal forState:UIControlStateHighlighted atIndex:index];
|
||||
[_segmentedControl setBackgroundImage:imageSelected forState:UIControlStateSelected atIndex:index];
|
||||
[_segmentedControl setTitleColor:UIColorFromRGB(0x333333) forState:UIControlStateNormal atIndex:index];
|
||||
[_segmentedControl setTitleColor:UIColorFromRGB(0x238efa) forState:UIControlStateSelected atIndex:index];
|
||||
[_segmentedControl setFont:[UIFont systemFontOfSize:17.f] atIndex:index];
|
||||
}
|
||||
[_segmentedControl addTarget:self action:@selector(onSegmentControlChanged:) forControlEvents:UIControlEventValueChanged];
|
||||
}
|
||||
return _segmentedControl;
|
||||
}
|
||||
|
||||
|
||||
- (NSArray<NTESChatroomSegmentedItem *> *)segmentedItems{
|
||||
if (!_segmentedItems) {
|
||||
NSMutableArray *items = [[NSMutableArray alloc] init];
|
||||
NSString *showNameKey = @"showName";
|
||||
NSArray *vcs = @[
|
||||
@{
|
||||
showNameKey : @"直播互动"
|
||||
},
|
||||
@{
|
||||
showNameKey : @"主播"
|
||||
},
|
||||
@{
|
||||
showNameKey : @"在线成员"
|
||||
},
|
||||
];
|
||||
for (NSDictionary *dict in vcs) {
|
||||
NTESChatroomSegmentedItem *item = [[NTESChatroomSegmentedItem alloc] init];
|
||||
item.showName = dict[showNameKey];
|
||||
[items addObject:item];
|
||||
}
|
||||
_segmentedItems = [NSArray arrayWithArray:items];
|
||||
}
|
||||
return _segmentedItems;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation NTESChatroomSegmentedItem
|
||||
@end
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// NTESLiveBroadcastView.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/12/17.
|
||||
// Copyright © 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface NTESLiveBroadcastView : UIView
|
||||
|
||||
- (void)refresh:(NIMChatroom *)room;
|
||||
|
||||
@end
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// NTESLiveBroadcastView.m
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/12/17.
|
||||
// Copyright © 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESLiveBroadcastView.h"
|
||||
#import "UIView+NTES.h"
|
||||
|
||||
@interface NTESLiveBroadcastView ()
|
||||
|
||||
@property (nonatomic, strong) UIImageView *iconImageView;
|
||||
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
|
||||
@property (nonatomic, strong) UITextView *contentTextView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTESLiveBroadcastView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self addSubview:self.iconImageView];
|
||||
[self addSubview:self.titleLabel];
|
||||
[self addSubview:self.contentTextView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)refresh:(NIMChatroom *)room{
|
||||
self.contentTextView.text = room.announcement.length ? room.announcement : @"暂无公告";
|
||||
[self.contentTextView sizeToFit];
|
||||
self.titleLabel.text = @"直播公告";
|
||||
[self.titleLabel sizeToFit];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews{
|
||||
[super layoutSubviews];
|
||||
CGFloat spacing = 10.f;
|
||||
self.iconImageView.top = spacing;
|
||||
self.iconImageView.left = spacing;
|
||||
self.titleLabel.width = (self.width - self.iconImageView.right) - 2 * spacing;
|
||||
[self.titleLabel sizeToFit];
|
||||
self.titleLabel.centerY = self.iconImageView.centerY;
|
||||
self.titleLabel.left = self.iconImageView.right + spacing;
|
||||
self.contentTextView.width = self.width - spacing * 2;
|
||||
self.contentTextView.height = self.height - self.titleLabel.height - spacing * 2;
|
||||
self.contentTextView.left = spacing;
|
||||
self.contentTextView.top = self.iconImageView.bottom + spacing * 2;
|
||||
}
|
||||
|
||||
- (UIImageView *)iconImageView{
|
||||
if (!_iconImageView) {
|
||||
_iconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"chatroom_announce"]];
|
||||
}
|
||||
return _iconImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel{
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
_titleLabel.adjustsFontSizeToFitWidth = YES;
|
||||
_titleLabel.numberOfLines = 3;
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
-(UITextView *)contentTextView{
|
||||
if (!_contentTextView) {
|
||||
_contentTextView = [[UITextView alloc] initWithFrame:CGRectZero];
|
||||
_contentTextView.backgroundColor = [UIColor clearColor];
|
||||
_contentTextView.font = [UIFont systemFontOfSize:14.f];
|
||||
_contentTextView.editable = NO;
|
||||
_contentTextView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
|
||||
}
|
||||
return _contentTextView;
|
||||
}
|
||||
|
||||
@end
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// NTESLiveMasterInfoView.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/12/17.
|
||||
// Copyright © 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface NTESLiveMasterInfoView : UIView
|
||||
|
||||
- (void)refresh:(NIMChatroomMember *)member chatroom:(NIMChatroom *)chatroom;
|
||||
|
||||
@end
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
//
|
||||
// NTESLiveMasterInfoView.m
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/12/17.
|
||||
// Copyright © 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESLiveMasterInfoView.h"
|
||||
#import "NIMAvatarImageView.h"
|
||||
#import "UIView+NTES.h"
|
||||
#import "NTESDataManager.h"
|
||||
|
||||
@interface NTESLiveMasterInfoView()
|
||||
|
||||
@property (nonatomic, strong) NIMAvatarImageView *avatarImageView;
|
||||
|
||||
@property (nonatomic, strong) UILabel *nameLabel;
|
||||
|
||||
@property (nonatomic, strong) UIImageView *countIconImageView;
|
||||
|
||||
@property (nonatomic, strong) UILabel *countLabel;
|
||||
|
||||
@property (nonatomic, strong) UIView *topSep;
|
||||
|
||||
@property (nonatomic, strong) UIView *bottomSep;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTESLiveMasterInfoView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
self.backgroundColor = UIColorFromRGB(0xffffff);
|
||||
[self addSubview:self.avatarImageView];
|
||||
[self addSubview:self.nameLabel];
|
||||
[self addSubview:self.countIconImageView];
|
||||
[self addSubview:self.countLabel];
|
||||
[self addSubview:self.topSep];
|
||||
[self addSubview:self.bottomSep];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)refresh:(NIMChatroomMember *)member chatroom:(NIMChatroom *)chatroom{
|
||||
NSURL *avatarUrl = [NSURL URLWithString:member.roomAvatar];
|
||||
[self.avatarImageView nim_setImageWithURL:avatarUrl];
|
||||
NSString *masterName = member.roomNickname;
|
||||
self.nameLabel.text = [NSString stringWithFormat:@"主播 : %@",masterName];
|
||||
[self.nameLabel sizeToFit];
|
||||
self.countLabel.text = @(chatroom.onlineUserCount).stringValue;
|
||||
[self.countLabel sizeToFit];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews{
|
||||
[super layoutSubviews];
|
||||
CGFloat spacing = 10.f;
|
||||
self.avatarImageView.left = spacing;
|
||||
self.avatarImageView.centerY = self.height * .5f;
|
||||
self.nameLabel.top = self.avatarImageView.top;
|
||||
self.nameLabel.left = self.avatarImageView.right + spacing;
|
||||
self.countIconImageView.bottom = self.avatarImageView.bottom;
|
||||
self.countIconImageView.left = self.avatarImageView.right + spacing;
|
||||
self.countLabel.centerY = self.countIconImageView.centerY;
|
||||
self.countLabel.left = self.countIconImageView.right + spacing;
|
||||
self.topSep.width = self.width;
|
||||
self.bottomSep.width = self.width;
|
||||
self.bottomSep.bottom = self.height;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Get
|
||||
- (CGFloat)avatarWidth
|
||||
{
|
||||
return 55.f;
|
||||
}
|
||||
|
||||
- (NIMAvatarImageView *)avatarImageView
|
||||
{
|
||||
if (!_avatarImageView)
|
||||
{
|
||||
_avatarImageView = [[NIMAvatarImageView alloc] initWithFrame:
|
||||
CGRectMake(0, 0, self.avatarWidth, self.avatarWidth)];
|
||||
}
|
||||
return _avatarImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)nameLabel
|
||||
{
|
||||
if (!_nameLabel)
|
||||
{
|
||||
_nameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
_nameLabel.font = [UIFont systemFontOfSize:15.f];
|
||||
}
|
||||
return _nameLabel;
|
||||
}
|
||||
|
||||
- (UIImageView *)countIconImageView
|
||||
{
|
||||
if (!_countIconImageView)
|
||||
{
|
||||
_countIconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
|
||||
[_countIconImageView setImage:[UIImage imageNamed:@"chatroom_onlinecount_room"]];
|
||||
}
|
||||
return _countIconImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)countLabel
|
||||
{
|
||||
if (!_countLabel)
|
||||
{
|
||||
_countLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
_countLabel.font = [UIFont systemFontOfSize:13.f];
|
||||
}
|
||||
return _countLabel;
|
||||
}
|
||||
|
||||
|
||||
- (UIView *)topSep
|
||||
{
|
||||
if (!_topSep)
|
||||
{
|
||||
_topSep = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, .5f)];
|
||||
_topSep.backgroundColor = UIColorFromRGB(0xcbd0d8);
|
||||
}
|
||||
return _topSep;
|
||||
}
|
||||
|
||||
- (UIView *)bottomSep
|
||||
{
|
||||
if (!_bottomSep)
|
||||
{
|
||||
_bottomSep = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, .5f)];
|
||||
_bottomSep.backgroundColor = UIColorFromRGB(0xcbd0d8);
|
||||
}
|
||||
return _bottomSep;
|
||||
}
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// NTESChatroomTextContentView.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 16/1/13.
|
||||
// Copyright © 2016年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
#import "NIMSessionMessageContentView.h"
|
||||
|
||||
@class M80AttributedLabel;
|
||||
|
||||
@interface NTESChatroomTextContentView : NIMSessionMessageContentView
|
||||
|
||||
@property (nonatomic, strong) M80AttributedLabel *textLabel;
|
||||
|
||||
@end
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// NTESChatroomTextContentView.m
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 16/1/13.
|
||||
// Copyright © 2016年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESChatroomTextContentView.h"
|
||||
#import "M80AttributedLabel+NIMKit.h"
|
||||
#import "NIMMessageModel.h"
|
||||
#import "NIMGlobalMacro.h"
|
||||
|
||||
@interface NTESChatroomTextContentView()<M80AttributedLabelDelegate>
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTESChatroomTextContentView
|
||||
|
||||
- (instancetype)initSessionMessageContentView
|
||||
{
|
||||
if (self = [super initSessionMessageContentView]) {
|
||||
_textLabel = [[M80AttributedLabel alloc] initWithFrame:CGRectZero];
|
||||
_textLabel.autoDetectLinks = NO;
|
||||
_textLabel.delegate = self;
|
||||
_textLabel.numberOfLines = 0;
|
||||
_textLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
||||
_textLabel.font = [UIFont systemFontOfSize:Chatroom_Message_Font_Size];
|
||||
_textLabel.backgroundColor = [UIColor clearColor];
|
||||
_textLabel.textColor = [UIColor blackColor];
|
||||
[self addSubview:_textLabel];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)refresh:(NIMMessageModel *)model{
|
||||
[super refresh:model];
|
||||
NSString *text = self.model.message.text;
|
||||
[_textLabel nim_setText:text];
|
||||
}
|
||||
|
||||
|
||||
- (void)layoutSubviews{
|
||||
[super layoutSubviews];
|
||||
UIEdgeInsets contentInsets = self.model.contentViewInsets;
|
||||
CGSize contentsize = self.model.contentSize;
|
||||
CGRect labelFrame = CGRectMake(contentInsets.left, contentInsets.top, contentsize.width, contentsize.height);
|
||||
self.textLabel.frame = labelFrame;
|
||||
}
|
||||
|
||||
|
||||
- (UIImage *)chatBubbleImageForState:(UIControlState)state outgoing:(BOOL)outgoing{
|
||||
return nil;
|
||||
}
|
||||
|
||||
#pragma mark - M80AttributedLabelDelegate
|
||||
- (void)m80AttributedLabel:(M80AttributedLabel *)label
|
||||
clickedOnLink:(id)linkData{
|
||||
NIMKitEvent *event = [[NIMKitEvent alloc] init];
|
||||
event.eventName = NIMKitEventNameTapLabelLink;
|
||||
event.messageModel = self.model;
|
||||
event.data = linkData;
|
||||
[self.delegate onCatchEvent:event];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user