chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TLUserDetailViewController.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/2/26.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class TLUser;
|
||||
@interface TLUserDetailViewController : ZZFlexibleLayoutViewController
|
||||
|
||||
- (instancetype)initWithUserId:(NSString *)userId;
|
||||
- (instancetype)initWithUserModel:(TLUser *)userModel;
|
||||
- (instancetype)init __attribute__((unavailable("请使用 initWithUserId: 或 initWithUserModel:")));
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,173 @@
|
||||
//
|
||||
// TLUserDetailViewController.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/2/26.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLUserDetailViewController.h"
|
||||
#import "TLUserSettingViewController.h"
|
||||
#import "TLFriendHelper.h"
|
||||
#import "TLUserDetailBaseKVCell.h"
|
||||
#import "TLChatViewController.h"
|
||||
#import "TLLaunchManager.h"
|
||||
#import "TLUserHelper.h"
|
||||
#import "MWPhotoBrowser.h"
|
||||
|
||||
typedef NS_ENUM(NSInteger, TLUserDetailVCSectionType) {
|
||||
TLUserDetailVCSectionTypeBaseInfo,
|
||||
TLUserDetailVCSectionTypeCustom,
|
||||
TLUserDetailVCSectionTypeDetailInfo,
|
||||
TLUserDetailVCSectionTypeFunction,
|
||||
};
|
||||
|
||||
@interface TLUserDetailViewController ()
|
||||
|
||||
/// 用户id
|
||||
@property (nonatomic, strong, readonly) NSString *userId;
|
||||
/// 用户数据模型
|
||||
@property (nonatomic, strong) TLUser *userModel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLUserDetailViewController
|
||||
|
||||
- (instancetype)initWithUserId:(NSString *)userId
|
||||
{
|
||||
if (self = [super init]) {
|
||||
_userId = userId;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithUserModel:(TLUser *)userModel
|
||||
{
|
||||
if (self = [super init]) {
|
||||
_userId = userModel.userID;
|
||||
_userModel = userModel;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)loadView
|
||||
{
|
||||
[super loadView];
|
||||
[self setTitle:LOCSTR(@"详细资料")];
|
||||
[self.collectionView setBackgroundColor:[UIColor colorGrayBG]];
|
||||
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(0);
|
||||
}];
|
||||
|
||||
@weakify(self);
|
||||
[self addRightBarButtonWithImage:TLImage(@"nav_more") actionBlick:^{
|
||||
@strongify(self);
|
||||
TLUserSettingViewController *detailSetiingVC = [[TLUserSettingViewController alloc] initWithUserModel:self.userModel];
|
||||
PushVC(detailSetiingVC);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self requestUserDataWithUserId:self.userId];
|
||||
}
|
||||
|
||||
#pragma mark - # Request
|
||||
- (void)requestUserDataWithUserId:(NSString *)userId
|
||||
{
|
||||
if (self.userModel) {
|
||||
[self loadUIWithUserModel:self.userModel];
|
||||
}
|
||||
|
||||
// 请求完整的数据模型
|
||||
_userModel = [[TLFriendHelper sharedFriendHelper] getFriendInfoByUserID:userId];
|
||||
[self loadUIWithUserModel:self.userModel];
|
||||
}
|
||||
|
||||
#pragma mark - # UI
|
||||
- (void)loadUIWithUserModel:(TLUser *)userModel
|
||||
{
|
||||
@weakify(self);
|
||||
|
||||
self.clear();
|
||||
|
||||
// 基本信息
|
||||
self.addSection(TLUserDetailVCSectionTypeBaseInfo).sectionInsets(UIEdgeInsetsMake(15, 0, 0, 0));
|
||||
self.addCell(@"TLUserDetailBaseInfoCell").toSection(TLUserDetailVCSectionTypeBaseInfo).withDataModel(userModel).eventAction(^ id(NSInteger eventType, id data) {
|
||||
@strongify(self);
|
||||
TLUser *userModel = data;
|
||||
NSURL *url = TLURL(userModel.avatarURL);
|
||||
MWPhoto *photo = [MWPhoto photoWithURL:url];
|
||||
MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithPhotos:@[photo]];
|
||||
UINavigationController *broserNavC = [[UINavigationController alloc] initWithRootViewController:browser];
|
||||
[self presentViewController:broserNavC animated:NO completion:nil];
|
||||
return nil;
|
||||
});
|
||||
|
||||
// 自定义信息
|
||||
self.addSection(TLUserDetailVCSectionTypeCustom).sectionInsets(UIEdgeInsetsMake(15, 0, 0, 0));
|
||||
// 电话号码
|
||||
if (userModel.detailInfo.phoneNumber.length > 0) {
|
||||
TLUserDetailKVModel *model = createUserDetailKVModel(LOCSTR(@"电话号码"), userModel.detailInfo.phoneNumber);
|
||||
model.hiddenArrow = YES;
|
||||
self.addCell(@"TLUserDetailPhoneKVCell").toSection(TLUserDetailVCSectionTypeCustom).withDataModel(model);
|
||||
}
|
||||
// 备注及标签
|
||||
if (userModel.detailInfo.tags.count == 0) {
|
||||
self.addCell(@"TLUserDetailTitleCell").toSection(TLUserDetailVCSectionTypeCustom).withDataModel(LOCSTR(@"设置备注和标签"));
|
||||
}
|
||||
else {
|
||||
NSString *tags = [userModel.detailInfo.tags componentsJoinedByString:@","];
|
||||
self.addCell(@"TLUserDetailTagsKVCell").toSection(TLUserDetailVCSectionTypeCustom).withDataModel(createUserDetailKVModel(LOCSTR(@"标签"), tags));
|
||||
}
|
||||
|
||||
// 详细信息
|
||||
self.addSection(TLUserDetailVCSectionTypeDetailInfo).sectionInsets(UIEdgeInsetsMake(15, 0, 0, 0));
|
||||
// 地区
|
||||
if (userModel.detailInfo.location.length > 0) {
|
||||
TLUserDetailKVModel *model = createUserDetailKVModel(LOCSTR(@"地区"), userModel.detailInfo.location);
|
||||
model.selectable = NO;
|
||||
model.hiddenArrow = YES;
|
||||
self.addCell(@"TLUserDetailNormalKVCell").toSection(TLUserDetailVCSectionTypeDetailInfo).withDataModel(model);
|
||||
}
|
||||
// 相册
|
||||
if (userModel.detailInfo.albumArray.count > 0) {
|
||||
TLUserDetailKVModel *model = createUserDetailKVModel(LOCSTR(@"个人相册"), userModel.detailInfo.albumArray);
|
||||
self.addCell(@"TLUserDetailAlbumCell").toSection(TLUserDetailVCSectionTypeDetailInfo).withDataModel(model);
|
||||
}
|
||||
// 其他
|
||||
self.addCell(@"TLUserDetailTitleCell").toSection(TLUserDetailVCSectionTypeDetailInfo).withDataModel(LOCSTR(@"更多"));
|
||||
|
||||
// 功能
|
||||
self.addSection(TLUserDetailVCSectionTypeFunction).sectionInsets(UIEdgeInsetsMake(20, 0, 40, 0));
|
||||
// 发消息
|
||||
self.addCell(@"TLUserDetailChatButtonCell").toSection(TLUserDetailVCSectionTypeFunction).withDataModel(LOCSTR(@"发消息")).eventAction(^ id(NSInteger eventType, id data) {
|
||||
@strongify(self);
|
||||
TLChatViewController *chatVC = [[TLChatViewController alloc] initWithUserId:self.userModel.userID];
|
||||
|
||||
if ([TLLaunchManager sharedInstance].tabBarController.selectedIndex != 0) {
|
||||
[self.navigationController popToRootViewControllerAnimated:NO];
|
||||
UINavigationController *navC = [TLLaunchManager sharedInstance].tabBarController.childViewControllers[0];
|
||||
[[TLLaunchManager sharedInstance].tabBarController setSelectedIndex:0];
|
||||
[chatVC setHidesBottomBarWhenPushed:YES];
|
||||
[navC pushViewController:chatVC animated:YES];
|
||||
}
|
||||
else {
|
||||
PushVC(chatVC);
|
||||
}
|
||||
return nil;
|
||||
});
|
||||
// 语音聊天
|
||||
if (![userModel.userID isEqualToString:[TLUserHelper sharedHelper].userID]) {
|
||||
self.addCell(@"TLUserDetailViewChatButtonCell").toSection(TLUserDetailVCSectionTypeFunction).withDataModel(LOCSTR(@"视频聊天")).eventAction(^ id(NSInteger eventType, id data) {
|
||||
[TLUIUtility showInfoHint:@"暂未实现"];
|
||||
return nil;
|
||||
});
|
||||
}
|
||||
|
||||
[self reloadView];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// TLUserDetailAlbumCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/2/29.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLUserDetailBaseKVCell.h"
|
||||
|
||||
@interface TLUserDetailAlbumCell : TLUserDetailBaseKVCell
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,102 @@
|
||||
//
|
||||
// TLUserDetailAlbumCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/2/29.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLUserDetailAlbumCell.h"
|
||||
|
||||
#define HEIGHT_ALBUM_ITEM 60
|
||||
#define SPACE_ALBUM_ITEM 8
|
||||
|
||||
@interface TLUserDetailAlbumCell ()
|
||||
|
||||
@property (nonatomic, strong) UICollectionView *collectionView;
|
||||
@property (nonatomic, strong) ZZFLEXAngel *angel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLUserDetailAlbumCell
|
||||
|
||||
+ (CGFloat)viewHeightByDataModel:(id)dataModel
|
||||
{
|
||||
return 90.0f;
|
||||
}
|
||||
|
||||
- (void)setViewDataModel:(TLUserDetailKVModel *)dataModel
|
||||
{
|
||||
[super setViewDataModel:dataModel];
|
||||
NSArray *data = dataModel.data;
|
||||
|
||||
NSInteger maxCount = (SCREEN_WIDTH - 118) / (HEIGHT_ALBUM_ITEM + SPACE_ALBUM_ITEM);
|
||||
|
||||
data = data.count > maxCount ? [data subarrayWithRange:NSMakeRange(0, maxCount)] : data;
|
||||
|
||||
self.angel.clear();
|
||||
self.angel.addSection(0).minimumInteritemSpacing(SPACE_ALBUM_ITEM).minimumLineSpacing(SPACE_ALBUM_ITEM);
|
||||
self.angel.addCells(@"TLUserDetailAlbumItemCell").toSection(0).withDataModelArray(data);
|
||||
[self.collectionView reloadData];
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.collectionView = self.detailContentView.addCollectionView(1)
|
||||
.backgroundColor([UIColor clearColor])
|
||||
.userInteractionEnabled(NO)
|
||||
.masonry(^ (MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.right.mas_equalTo(-15);
|
||||
make.height.mas_equalTo(HEIGHT_ALBUM_ITEM);
|
||||
make.centerY.mas_equalTo(0);
|
||||
})
|
||||
.view;
|
||||
|
||||
[(UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
|
||||
|
||||
self.angel = [[ZZFLEXAngel alloc] initWithHostView:self.collectionView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface TLUserDetailAlbumItemCell :UICollectionViewCell <ZZFlexibleLayoutViewProtocol>
|
||||
|
||||
@property (nonatomic, strong) UIImageView *imageView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLUserDetailAlbumItemCell
|
||||
|
||||
+ (CGSize)viewSizeByDataModel:(id)dataModel
|
||||
{
|
||||
return CGSizeMake(HEIGHT_ALBUM_ITEM, HEIGHT_ALBUM_ITEM);
|
||||
}
|
||||
|
||||
- (void)setViewDataModel:(id)dataModel
|
||||
{
|
||||
if (dataModel) {
|
||||
[self.imageView tt_setImageWithURL:TLURL(dataModel) placeholderImage:[UIImage imageWithColor:[UIColor colorGrayBG]]];
|
||||
}
|
||||
else {
|
||||
[self.imageView setImage:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.imageView = self.contentView.addImageView(1)
|
||||
.contentMode(UIViewContentModeScaleAspectFill).clipsToBounds(YES)
|
||||
.masonry(^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(0);
|
||||
})
|
||||
.view;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// TLUserDetailBaseInfoCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/2/29.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TLUser.h"
|
||||
|
||||
@interface TLUserDetailBaseInfoCell : UICollectionViewCell <ZZFlexibleLayoutViewProtocol>
|
||||
|
||||
@property (nonatomic, strong) TLUser *userModel;
|
||||
|
||||
@end
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
//
|
||||
// TLUserDetailBaseInfoCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/2/29.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLUserDetailBaseInfoCell.h"
|
||||
#import "TLUser.h"
|
||||
#import "TLMacros.h"
|
||||
|
||||
#define MINE_SPACE_X 14.0f
|
||||
#define MINE_SPACE_Y 12.0f
|
||||
|
||||
@interface TLUserDetailBaseInfoCell ()
|
||||
|
||||
@property (nonatomic, strong) UIButton *avatarView;
|
||||
@property (nonatomic, strong) UILabel *shownameLabel;
|
||||
@property (nonatomic, strong) UILabel *usernameLabel;
|
||||
@property (nonatomic, strong) UILabel *nikenameLabel;
|
||||
|
||||
@property (nonatomic, copy) id (^eventAction)(NSInteger, id);
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLUserDetailBaseInfoCell
|
||||
|
||||
+ (CGFloat)viewHeightByDataModel:(id)dataModel
|
||||
{
|
||||
return 90.0f;
|
||||
}
|
||||
|
||||
- (void)setViewDataModel:(id)dataModel
|
||||
{
|
||||
[self setUserModel:dataModel];
|
||||
}
|
||||
|
||||
- (void)setViewEventAction:(id (^)(NSInteger, id))eventAction
|
||||
{
|
||||
self.eventAction = eventAction;
|
||||
}
|
||||
|
||||
- (void)viewIndexPath:(NSIndexPath *)indexPath sectionItemCount:(NSInteger)count
|
||||
{
|
||||
if (indexPath.row == 0) {
|
||||
self.addSeparator(ZZSeparatorPositionTop);
|
||||
}
|
||||
|
||||
if (indexPath.row == count - 1) {
|
||||
self.addSeparator(ZZSeparatorPositionBottom);
|
||||
}
|
||||
else {
|
||||
self.addSeparator(ZZSeparatorPositionBottom).beginAt(15);
|
||||
}
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self setBackgroundColor:[UIColor whiteColor]];
|
||||
|
||||
[self p_initUI];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setUserModel:(TLUser *)userModel
|
||||
{
|
||||
_userModel = userModel;
|
||||
if (userModel.avatarPath) {
|
||||
[self.avatarView setImage:[UIImage imageNamed:userModel.avatarPath] forState:UIControlStateNormal];
|
||||
}
|
||||
else{
|
||||
[self.avatarView tt_setImageWithURL:TLURL(userModel.avatarURL) forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:DEFAULT_AVATAR_PATH]];
|
||||
}
|
||||
[self.shownameLabel setText:userModel.showName];
|
||||
if (userModel.username.length > 0) {
|
||||
[self.usernameLabel setText:[NSString stringWithFormat:@"%@:%@", LOCSTR(@"微信号"), userModel.username]];
|
||||
if (userModel.nikeName.length > 0) {
|
||||
[self.nikenameLabel setText:[NSString stringWithFormat:@"%@:%@", LOCSTR(@"昵称"), userModel.nikeName]];
|
||||
}
|
||||
}
|
||||
else if (userModel.nikeName.length > 0){
|
||||
[self.nikenameLabel setText:[NSString stringWithFormat:@"%@:%@", LOCSTR(@"昵称"), userModel.nikeName]];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - # UI
|
||||
- (void)p_initUI
|
||||
{
|
||||
@weakify(self);
|
||||
|
||||
// 头像
|
||||
self.avatarView = self.contentView.addButton(1)
|
||||
.cornerRadius(5)
|
||||
.eventBlock(UIControlEventTouchUpInside, ^(UIButton *sender) {
|
||||
@strongify(self);
|
||||
if (self.eventAction) {
|
||||
self.eventAction(0, self.userModel);
|
||||
}
|
||||
})
|
||||
.masonry(^ (MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(14);
|
||||
make.top.mas_equalTo(12);
|
||||
make.bottom.mas_equalTo(-12);
|
||||
})
|
||||
.view;
|
||||
|
||||
[self.avatarView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(self.avatarView.mas_height);
|
||||
}];
|
||||
|
||||
// 用户昵称
|
||||
self.shownameLabel = self.contentView.addLabel(2)
|
||||
.font([UIFont systemFontOfSize:17.0f])
|
||||
.masonry(^ (MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.avatarView.mas_right).mas_offset(MINE_SPACE_Y);
|
||||
make.top.mas_equalTo(self.avatarView.mas_top).mas_offset(3);
|
||||
})
|
||||
.view;
|
||||
[self.shownameLabel setContentCompressionResistancePriority:100 forAxis:UILayoutConstraintAxisHorizontal];
|
||||
|
||||
// 用户名
|
||||
self.usernameLabel = self.contentView.addLabel(3)
|
||||
.font([UIFont systemFontOfSize:14.0f])
|
||||
.textColor([UIColor grayColor])
|
||||
.masonry(^ (MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.shownameLabel);
|
||||
make.top.mas_equalTo(self.shownameLabel.mas_bottom).mas_offset(5);
|
||||
})
|
||||
.view;
|
||||
|
||||
// 昵称
|
||||
self.nikenameLabel = self.contentView.addLabel(4)
|
||||
.textColor([UIColor grayColor])
|
||||
.font([UIFont systemFontOfSize:14.0f])
|
||||
.masonry(^ (MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.shownameLabel);
|
||||
make.top.mas_equalTo(self.usernameLabel.mas_bottom).mas_offset(3);
|
||||
})
|
||||
.view;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// TLUserDetailBaseKVCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/7.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class TLUserDetailKVModel;
|
||||
TLUserDetailKVModel *createUserDetailKVModel(NSString *title, id data);
|
||||
|
||||
@interface TLUserDetailKVModel : NSObject
|
||||
|
||||
@property (nonatomic, strong) NSString *title;
|
||||
|
||||
@property (nonatomic, strong) id data;
|
||||
|
||||
@property (nonatomic, assign) BOOL hiddenArrow;
|
||||
|
||||
@property (nonatomic, assign) BOOL selectable;
|
||||
|
||||
@end
|
||||
|
||||
@interface TLUserDetailBaseKVCell : UICollectionViewCell <ZZFlexibleLayoutViewProtocol>
|
||||
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
|
||||
@property (nonatomic, strong) UIView *detailContentView;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// TLUserDetailBaseKVCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/7.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLUserDetailBaseKVCell.h"
|
||||
|
||||
TLUserDetailKVModel *createUserDetailKVModel(NSString *title, id data)
|
||||
{
|
||||
TLUserDetailKVModel *model = [[TLUserDetailKVModel alloc] init];
|
||||
model.title = title;
|
||||
model.data = data;
|
||||
return model;
|
||||
}
|
||||
|
||||
@interface TLUserDetailBaseKVCell ()
|
||||
|
||||
@property (nonatomic, strong) UIView *arrowView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLUserDetailBaseKVCell
|
||||
|
||||
+ (CGFloat)viewHeightByDataModel:(id)dataModel
|
||||
{
|
||||
return 44.0f;
|
||||
}
|
||||
|
||||
- (void)setViewDataModel:(TLUserDetailKVModel *)dataModel
|
||||
{
|
||||
[self.titleLabel setText:dataModel.title];
|
||||
[self.arrowView setHidden:dataModel.hiddenArrow];
|
||||
[self setSelectedBackgrounColor:dataModel.selectable ? [UIColor colorGrayLine] : nil];
|
||||
}
|
||||
|
||||
- (void)viewIndexPath:(NSIndexPath *)indexPath sectionItemCount:(NSInteger)count
|
||||
{
|
||||
if (indexPath.row == 0) {
|
||||
self.addSeparator(ZZSeparatorPositionTop);
|
||||
}
|
||||
|
||||
if (indexPath.row == count - 1) {
|
||||
self.addSeparator(ZZSeparatorPositionBottom);
|
||||
}
|
||||
else {
|
||||
self.addSeparator(ZZSeparatorPositionBottom).beginAt(15);
|
||||
}
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self setBackgroundColor:[UIColor whiteColor]];
|
||||
|
||||
self.titleLabel = self.contentView.addLabel(1)
|
||||
.font([UIFont systemFontOfSize:16])
|
||||
.masonry(^ (MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(15);
|
||||
make.centerY.mas_equalTo(0);
|
||||
make.width.mas_equalTo(80);
|
||||
})
|
||||
.view;
|
||||
|
||||
self.arrowView = self.contentView.addImageView(2)
|
||||
.image([UIImage imageNamed:@"right_arrow"])
|
||||
.masonry(^ (MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(0);
|
||||
make.size.mas_equalTo(CGSizeMake(8, 13));
|
||||
make.right.mas_equalTo(-15);
|
||||
})
|
||||
.view;
|
||||
|
||||
self.detailContentView = self.contentView.addView(3)
|
||||
.masonry(^ (MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.titleLabel.mas_right);
|
||||
make.right.mas_equalTo(self.arrowView.mas_left);
|
||||
make.top.bottom.mas_equalTo(0);
|
||||
})
|
||||
.view;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLUserDetailKVModel
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
self.selectable = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// TLUserDetailButtonCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/7.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface TLUserDetailChatButtonCell : UICollectionViewCell <ZZFlexibleLayoutViewProtocol>
|
||||
|
||||
@property (nonatomic, strong) UIButton *button;
|
||||
|
||||
@end
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// TLUserDetailButtonCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/7.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLUserDetailChatButtonCell.h"
|
||||
|
||||
@interface TLUserDetailChatButtonCell ()
|
||||
|
||||
@property (nonatomic, copy) id (^eventAction)(NSInteger, id);
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLUserDetailChatButtonCell
|
||||
|
||||
+ (CGFloat)viewHeightByDataModel:(id)dataModel
|
||||
{
|
||||
return 62.0f;
|
||||
}
|
||||
|
||||
- (void)setViewDataModel:(id)dataModel
|
||||
{
|
||||
[self.button setTitle:dataModel forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
- (void)setViewEventAction:(id (^)(NSInteger, id))eventAction
|
||||
{
|
||||
self.eventAction = eventAction;
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
@weakify(self);
|
||||
self.button = self.contentView.addButton(1)
|
||||
.backgroundColor([UIColor colorGreenDefault]).titleColor([UIColor whiteColor]).titleFont([UIFont systemFontOfSize:18])
|
||||
.backgroundColorHL([UIColor colorGreenHL]).titleColorHL([[UIColor whiteColor] colorWithAlphaComponent:0.7])
|
||||
.cornerRadius(5).borderWidth(1).borderColor([UIColor colorGrayLine].CGColor)
|
||||
.masonry(^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(15);
|
||||
make.right.mas_equalTo(-15);
|
||||
make.top.mas_equalTo(0);
|
||||
make.bottom.mas_equalTo(-15);
|
||||
})
|
||||
.eventBlock(UIControlEventTouchUpInside, ^(UIButton *sender) {
|
||||
@strongify(self);
|
||||
if (self.eventAction) {
|
||||
self.eventAction(0, nil);
|
||||
}
|
||||
})
|
||||
.view;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// TLUserDetailNormalKVCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/7.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLUserDetailBaseKVCell.h"
|
||||
|
||||
@interface TLUserDetailNormalKVCell : TLUserDetailBaseKVCell
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// TLUserDetailNormalKVCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/7.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLUserDetailNormalKVCell.h"
|
||||
|
||||
@interface TLUserDetailNormalKVCell ()
|
||||
|
||||
@property (nonatomic, strong) UILabel *detailLabel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLUserDetailNormalKVCell
|
||||
|
||||
- (void)setViewDataModel:(TLUserDetailKVModel *)dataModel
|
||||
{
|
||||
[super setViewDataModel:dataModel];
|
||||
|
||||
[self.detailLabel setText:dataModel.data];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.detailLabel = self.detailContentView.addLabel(1001)
|
||||
.font([UIFont systemFontOfSize:16])
|
||||
.masonry(^ (MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(0);
|
||||
})
|
||||
.view;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// TLUserDetailPhoneKVCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/7.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLUserDetailBaseKVCell.h"
|
||||
|
||||
@interface TLUserDetailPhoneKVCell : TLUserDetailBaseKVCell
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// TLUserDetailPhoneKVCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/7.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLUserDetailPhoneKVCell.h"
|
||||
|
||||
@interface TLUserDetailPhoneKVCell ()
|
||||
|
||||
@property (nonatomic, strong) UIButton *phoneButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLUserDetailPhoneKVCell
|
||||
|
||||
- (void)setViewDataModel:(TLUserDetailKVModel *)dataModel
|
||||
{
|
||||
[super setViewDataModel:dataModel];
|
||||
|
||||
[self.phoneButton setTitle:dataModel.data forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.phoneButton = self.detailContentView.addButton(1)
|
||||
.titleColor([UIColor colorBlueMoment]).titleFont([UIFont systemFontOfSize:16])
|
||||
.masonry(^ (MASConstraintMaker *make) {
|
||||
make.left.top.bottom.mas_equalTo(0);
|
||||
})
|
||||
.eventBlock(UIControlEventTouchUpInside, ^(UIButton *sender) {
|
||||
NSString *phone = sender.currentTitle;
|
||||
NSString *urlString = [NSString stringWithFormat:@"tel:%@", phone];
|
||||
[[UIApplication sharedApplication] openURL:TLURL(urlString)];
|
||||
})
|
||||
.view;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// TLUserDetailTagsKVCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/7.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLUserDetailBaseKVCell.h"
|
||||
|
||||
@interface TLUserDetailTagsKVCell : TLUserDetailBaseKVCell
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// TLUserDetailTagsKVCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/7.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLUserDetailTagsKVCell.h"
|
||||
|
||||
@interface TLUserDetailTagsKVCell ()
|
||||
|
||||
@property (nonatomic, strong) UIButton *phoneButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLUserDetailTagsKVCell
|
||||
|
||||
- (void)setViewDataModel:(TLUserDetailKVModel *)dataModel
|
||||
{
|
||||
[super setViewDataModel:dataModel];
|
||||
|
||||
[self.phoneButton setTitle:dataModel.data forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.phoneButton = self.detailContentView.addButton(1)
|
||||
.titleColor([UIColor colorGreenDefault]).titleFont([UIFont systemFontOfSize:16])
|
||||
.userInteractionEnabled(NO)
|
||||
.masonry(^ (MASConstraintMaker *make) {
|
||||
make.left.top.bottom.mas_equalTo(0);
|
||||
})
|
||||
.eventBlock(UIControlEventTouchUpInside, ^(UIButton *sender) {
|
||||
NSString *phone = sender.currentTitle;
|
||||
NSString *urlString = [NSString stringWithFormat:@"tel:%@", phone];
|
||||
[[UIApplication sharedApplication] openURL:TLURL(urlString)];
|
||||
})
|
||||
.view;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// TLUserDetailTitleCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/7.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface TLUserDetailTitleCell : UICollectionViewCell <ZZFlexibleLayoutViewProtocol>
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// TLUserDetailTitleCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/7.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLUserDetailTitleCell.h"
|
||||
|
||||
@interface TLUserDetailTitleCell ()
|
||||
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLUserDetailTitleCell
|
||||
|
||||
+ (CGFloat)viewHeightByDataModel:(id)dataModel
|
||||
{
|
||||
return 44.0f;
|
||||
}
|
||||
|
||||
- (void)setViewDataModel:(id)dataModel
|
||||
{
|
||||
[self.titleLabel setText:dataModel];
|
||||
}
|
||||
|
||||
- (void)viewIndexPath:(NSIndexPath *)indexPath sectionItemCount:(NSInteger)count
|
||||
{
|
||||
if (indexPath.row == 0) {
|
||||
self.addSeparator(ZZSeparatorPositionTop);
|
||||
}
|
||||
|
||||
if (indexPath.row == count - 1) {
|
||||
self.addSeparator(ZZSeparatorPositionBottom);
|
||||
}
|
||||
else {
|
||||
self.addSeparator(ZZSeparatorPositionBottom).beginAt(15);
|
||||
}
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self setBackgroundColor:[UIColor whiteColor]];
|
||||
[self setSelectedBackgrounColor:[UIColor colorGrayLine]];
|
||||
|
||||
UIImageView *arrowView = self.contentView.addImageView(2)
|
||||
.image([UIImage imageNamed:@"right_arrow"])
|
||||
.masonry(^ (MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(0);
|
||||
make.size.mas_equalTo(CGSizeMake(8, 13));
|
||||
make.right.mas_equalTo(-15);
|
||||
})
|
||||
.view;
|
||||
|
||||
self.titleLabel = self.contentView.addLabel(1)
|
||||
.font([UIFont systemFontOfSize:16])
|
||||
.masonry(^ (MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(15);
|
||||
make.centerY.mas_equalTo(0);
|
||||
make.right.mas_lessThanOrEqualTo(arrowView.mas_left).mas_offset(-15);
|
||||
})
|
||||
.view;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// TLUserDetailViewChatButtonCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/7.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLUserDetailChatButtonCell.h"
|
||||
|
||||
@interface TLUserDetailViewChatButtonCell : TLUserDetailChatButtonCell
|
||||
|
||||
@end
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TLUserDetailViewChatButtonCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/7.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLUserDetailViewChatButtonCell.h"
|
||||
|
||||
@implementation TLUserDetailViewChatButtonCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.button.zz_make.backgroundColor([UIColor whiteColor]).titleColor([UIColor blackColor])
|
||||
.backgroundColorHL([UIColor lightGrayColor]).titleColorHL([[UIColor blackColor] colorWithAlphaComponent:0.7]);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user