chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:35:01 +08:00
commit a2e318a963
2974 changed files with 158180 additions and 0 deletions
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_friend@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_friend@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_audiocall@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_bottle@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_facefriend@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_favourite@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_game@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_newmessage@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_newmessage@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_groupmessage@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_moment@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_myablum@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_mycard@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_myqrcode@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_nearby@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_photo@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_radar@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_scan@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_scan@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_shake@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_sticker@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_voip@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "receipt_payment_icon@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "receipt_payment_icon@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_wechatout@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "contacts_add_wechatout@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,16 @@
//
// TLAddMenuCell.h
// TLChat
//
// Created by 李伯坤 on 16/3/11.
// Copyright © 2016年 李伯坤. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TLAddMenuItem.h"
@interface TLAddMenuCell : UITableViewCell
@property (nonatomic, strong) TLAddMenuItem *item;
@end
@@ -0,0 +1,69 @@
//
// TLAddMenuCell.m
// TLChat
//
// Created by 李伯坤 on 16/3/11.
// Copyright © 2016年 李伯坤. All rights reserved.
//
#import "TLAddMenuCell.h"
@interface TLAddMenuCell()
@property (nonatomic, strong) UIImageView *iconView;
@property (nonatomic, strong) UILabel *titleLabel;
@end
@implementation TLAddMenuCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self setBackgroundColor:[UIColor colorBlackForAddMenu]];
UIView *selectedView = [[UIView alloc] init];
[selectedView setBackgroundColor:[UIColor colorBlackForAddMenuHL]];
[self setSelectedBackgroundView:selectedView];
[self p_initUI];
}
return self;
}
- (void)layoutSubviews
{
[super layoutSubviews];
self.addSeparator(ZZSeparatorPositionBottom).beginAt(15).endAt(-15).color([UIColor colorGrayLine]);
}
- (void)setItem:(TLAddMenuItem *)item
{
_item = item;
[self.iconView setImage:[UIImage imageNamed:item.iconPath]];
[self.titleLabel setText:item.title];
}
#pragma mark - Private Methods
- (void)p_initUI
{
self.iconView = self.contentView.addImageView(1)
.masonry(^(MASConstraintMaker *make) {
make.left.mas_equalTo(self).mas_offset(15.0f);
make.centerY.mas_equalTo(self);
make.height.and.width.mas_equalTo(32);
})
.view;
self.titleLabel = self.contentView.addLabel(2)
.font([UIFont systemFontOfSize:16.0f])
.textColor([UIColor whiteColor])
.masonry(^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.iconView.mas_right).mas_offset(10.0f);
make.centerY.mas_equalTo(self.iconView);
})
.view;
}
@end
@@ -0,0 +1,30 @@
//
// TLAddMenuItem.h
// TLChat
//
// Created by 李伯坤 on 16/3/11.
// Copyright © 2016年 李伯坤. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSInteger, TLAddMneuType) {
TLAddMneuTypeGroupChat = 0,
TLAddMneuTypeAddFriend,
TLAddMneuTypeScan,
TLAddMneuTypeWallet,
};
@interface TLAddMenuItem : NSObject
@property (nonatomic, assign) TLAddMneuType type;
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *iconPath;
@property (nonatomic, strong) NSString *className;
+ (TLAddMenuItem *)createWithType:(TLAddMneuType)type title:(NSString *)title iconPath:(NSString *)iconPath className:(NSString *)className;
@end
@@ -0,0 +1,23 @@
//
// TLAddMenuItem.m
// TLChat
//
// Created by 李伯坤 on 16/3/11.
// Copyright © 2016年 李伯坤. All rights reserved.
//
#import "TLAddMenuItem.h"
@implementation TLAddMenuItem
+ (TLAddMenuItem *)createWithType:(TLAddMneuType)type title:(NSString *)title iconPath:(NSString *)iconPath className:(NSString *)className
{
TLAddMenuItem *item = [[TLAddMenuItem alloc] init];
item.type = type;
item.title = title;
item.iconPath = iconPath;
item.className = className;
return item;
}
@end
@@ -0,0 +1,41 @@
//
// TLAddMenuView.h
// TLChat
//
// Created by 李伯坤 on 16/3/11.
// Copyright © 2016年 李伯坤. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TLAddMenuItem.h"
@class TLAddMenuView;
@protocol TLAddMenuViewDelegate <NSObject>
- (void)addMenuView:(TLAddMenuView *)addMenuView didSelectedItem:(TLAddMenuItem *)item;
@end
@interface TLAddMenuView : UIView
@property (nonatomic, assign) id<TLAddMenuViewDelegate>delegate;
@property (nonatomic, copy) void (^itemSelectedAction)(TLAddMenuView *addMenuView, TLAddMenuItem *item);
/**
* 显示AddMenu
*
* @param view 父View
*/
- (void)showInView:(UIView *)view;
/**
* 是否正在显示
*/
- (BOOL)isShow;
/**
* 隐藏
*/
- (void)dismiss;
@end
@@ -0,0 +1,140 @@
//
// TLAddMenuView.m
// TLChat
//
// Created by 李伯坤 on 16/3/11.
// Copyright © 2016年 李伯坤. All rights reserved.
//
#import "TLAddMenuView.h"
#import "TLAddMenuCell.h"
#import "TLAppConfig.h"
#define WIDTH_TABLEVIEW 140.0f
#define HEIGHT_TABLEVIEW_CELL 45.0f
@interface TLAddMenuView () <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *data;
@end
@implementation TLAddMenuView
- (id)init
{
if (self = [super init]) {
[self setBackgroundColor:[UIColor clearColor]];
[self addSubview:self.tableView];
UIPanGestureRecognizer *panGR = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(dismiss)];
[self addGestureRecognizer:panGR];
[self.tableView registerClass:[TLAddMenuCell class] forCellReuseIdentifier:@"TLAddMenuCell"];
self.data = [TLAppConfig sharedConfig].addMenuItems;
}
return self;
}
- (void)showInView:(UIView *)view
{
[view addSubview:self];
[self setNeedsDisplay];
[self setFrame:view.bounds];
CGRect rect = CGRectMake(view.width - WIDTH_TABLEVIEW - 5, NAVBAR_HEIGHT + STATUSBAR_HEIGHT + 10, WIDTH_TABLEVIEW, self.data.count * HEIGHT_TABLEVIEW_CELL);
[self.tableView setFrame:rect];
}
- (BOOL)isShow
{
return self.superview != nil;
}
- (void)dismiss
{
[UIView animateWithDuration:0.2 animations:^{
[self setAlpha:0.0f];
} completion:^(BOOL finished) {
if (finished) {
[self removeFromSuperview];
[self setAlpha:1.0];
}
}];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[self dismiss];
}
#pragma mark - # Delegate
//MARK: UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.data.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
TLAddMenuItem *item = [self.data objectAtIndex:indexPath.row];
TLAddMenuCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TLAddMenuCell"];
[cell setItem:item];
return cell;
}
//MARK: UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
TLAddMenuItem *item = [self.data objectAtIndex:indexPath.row];
if (self.itemSelectedAction) {
self.itemSelectedAction(self, item);
}
if (_delegate && [_delegate respondsToSelector:@selector(addMenuView:didSelectedItem:)]) {
[_delegate addMenuView:self didSelectedItem:item];
}
[tableView deselectRowAtIndexPath:indexPath animated:NO];
[self dismiss];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return HEIGHT_TABLEVIEW_CELL;
}
#pragma mark - # Private Methods
- (void)drawRect:(CGRect)rect
{
CGFloat startX = self.width - 27;
CGFloat startY = STATUSBAR_HEIGHT + NAVBAR_HEIGHT + 3;
CGFloat endY = STATUSBAR_HEIGHT + NAVBAR_HEIGHT + 10;
CGFloat width = 6;
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextMoveToPoint(context, startX, startY);
CGContextAddLineToPoint(context, startX + width, endY);
CGContextAddLineToPoint(context, startX - width, endY);
CGContextClosePath(context);
[[UIColor colorBlackForAddMenu] setFill];
[[UIColor colorBlackForAddMenu] setStroke];
CGContextDrawPath(context, kCGPathFillStroke);
}
#pragma mark - # Getters
- (UITableView *)tableView
{
if (_tableView == nil) {
_tableView = [[UITableView alloc] init];
[_tableView setScrollEnabled:NO];
[_tableView setDelegate:self];
[_tableView setDataSource:self];
[_tableView setBackgroundColor:[UIColor colorBlackForAddMenu]];
[_tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
[_tableView.layer setMasksToBounds:YES];
[_tableView.layer setCornerRadius:3.0f];
}
return _tableView;
}
@end
@@ -0,0 +1,34 @@
//
// TLConversationAngel.h
// TLChat
//
// Created by 李伯坤 on 2017/12/26.
// Copyright © 2017年 李伯坤. All rights reserved.
//
#import <ZZFLEX/ZZFlexibleLayoutFramework.h>
typedef NS_ENUM(NSInteger, TLConversationSectionTag) {
TLConversationSectionTagAlert,
TLConversationSectionTagTopArticle,
TLConversationSectionTagPlay,
TLConversationSectionTagTopConversation,
TLConversationSectionTagConv,
};
typedef NS_ENUM(NSInteger, TLConversationCellTag) {
TLConversationCellTagNoNet,
};
@interface TLConversationAngel : ZZFLEXAngel <
UITableViewDelegate
>
@property (nonatomic, copy) void (^badgeStatusChangeAction)(NSString *badge);
- (instancetype)initWithHostView:(__kindof UIScrollView *)hostView badgeStatusChangeAction:(void (^)(NSString *badge))badgeStatusChangeAction;
- (void)reloadBadge;
@end
@@ -0,0 +1,105 @@
//
// TLConversationAngel.m
// TLChat
//
// Created by 李伯坤 on 2017/12/26.
// Copyright © 2017年 李伯坤. All rights reserved.
//
#import "TLConversationAngel.h"
#import <ZZFLEX/ZZFLEXAngel+Private.h>
#import <ZZFLEX/ZZFlexibleLayoutSectionModel.h>
#import "TLConversation.h"
#import "TLMessageManager+ConversationRecord.h"
#import "TLConversationCell.h"
@implementation TLConversationAngel
- (instancetype)initWithHostView:(__kindof UIScrollView *)hostView badgeStatusChangeAction:(void (^)(NSString *))badgeStatusChangeAction
{
if (self = [super initWithHostView:hostView]) {
self.badgeStatusChangeAction = badgeStatusChangeAction;
}
return self;
}
- (void)reloadBadge
{
if (!self.badgeStatusChangeAction) {
return;
}
NSInteger count = 0;
NSArray *data = self.dataModelArray.all();
for (TLConversation *conversation in data) {
if ([conversation isKindOfClass:[TLConversation class]]) {
if (conversation.unreadCount > 0) {
count += conversation.unreadCount;
}
}
}
NSString *badge = count > 0 ? @(count).stringValue : nil;
self.badgeStatusChangeAction(badge);
}
#pragma mark - # Delegate
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
ZZFlexibleLayoutSectionModel *sectionModel = [self sectionModelAtIndex:indexPath.section];
if (sectionModel.sectionTag == TLConversationSectionTagTopConversation
|| sectionModel.sectionTag == TLConversationSectionTagConv) {
@weakify(self);
TLConversation *conversation = self.dataModel.atIndexPath(indexPath);
UITableViewRowAction *delAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault
title:@"删除"
handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
@strongify(self);
[self p_tableView:tableView deleteItemAtIndexPath:indexPath];
}];
UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal
title:conversation.isRead ? @"标为未读" : @"标为已读"
handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
@strongify(self);
TLConversation *conversation = self.dataModel.atIndexPath(indexPath);
TLConversationCell *cell = [tableView cellForRowAtIndexPath:indexPath];
conversation.isRead ? [cell markAsUnread] : [cell markAsRead];
[tableView setEditing:NO animated:YES];
[self reloadBadge];
}];
return @[delAction, moreAction];
}
return nil;
}
#pragma mark - # Private Methods
- (void)p_tableView:(UITableView *)tableView deleteItemAtIndexPath:(NSIndexPath *)indexPath
{
ZZFlexibleLayoutSectionModel *sectionModel = [self sectionModelAtIndex:indexPath.section];
ZZFlexibleLayoutViewModel *viewModel = [sectionModel objectAtIndex:indexPath.row];
TLConversation *conversation = viewModel.dataModel;
if (!conversation) {
[TLUIUtility showErrorHint:@"获取会话信息时出现异常"];
return;
}
// 从数据库中删除
BOOL ok = [[TLMessageManager sharedInstance] deleteConversationByPartnerID:conversation.partnerID];
if (!ok) {
[TLUIUtility showAlertWithTitle:@"错误" message:@"从数据库中删除会话信息失败"];
return;
}
// 删除列表数据源
self.deleteCell.byDataModel(conversation);
// 删除列表cell
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
// 分割线
if (indexPath.row >= 0 && indexPath.row == sectionModel.itemsArray.count) {
NSIndexPath *lastIndexPath = [NSIndexPath indexPathForRow:indexPath.row - 1 inSection:indexPath.section];
TLConversationCell *cell = [tableView cellForRowAtIndexPath:lastIndexPath];
[cell setBottomSeperatorStyle:TLConversationCellSeperatorStyleFill];
}
}
@end
@@ -0,0 +1,14 @@
//
// TLConversationViewController.h
// TLChat
//
// Created by 李伯坤 on 16/1/23.
// Copyright © 2016年 李伯坤. All rights reserved.
//
#import "TLViewController.h"
@interface TLConversationViewController : TLViewController
@end
@@ -0,0 +1,243 @@
//
// TLConversationViewController.m
// TLChat
//
// Created by 李伯坤 on 16/1/23.
// Copyright © 2016年 李伯坤. All rights reserved.
//
#import "TLConversationViewController.h"
#import "TLConversationAngel.h"
#import "TLNetworkStatusManager.h"
#import "TLMessageManager+ConversationRecord.h"
#import "TLConversation+TLUser.h"
#import "TLFriendHelper.h"
#import "TLAddMenuView.h"
#import "TLSearchController.h"
#import "TLContactsSearchResultViewController.h"
#import "TLChatViewController+Conversation.h"
#import "TLUserDetailViewController.h"
@interface TLConversationViewController () <TLMessageManagerConvVCDelegate>
{
TLNetworkStatusManager *networkStatusManger;
}
/// 列表
@property (nonatomic, strong) UITableView *tableView;
/// 列表数据及控制中心
@property (nonatomic, strong) TLConversationAngel *listAngel;
@property (nonatomic, strong) NSMutableArray *data;
@property (nonatomic, strong) TLSearchController *searchController;
@property (nonatomic, strong) TLAddMenuView *addMenuView;
@end
@implementation TLConversationViewController
- (id)init
{
if (self = [super init]) {
initTabBarItem(self.tabBarItem, LOCSTR(@"微信"), @"tabbar_mainframe", @"tabbar_mainframeHL");
}
return self;
}
- (void)loadView
{
[super loadView];
[self p_setNavTitleWithStatusString:nil];
// 初始化界面视图控件
[self p_loadUI];
// 初始化列表模块
[self p_initListModule];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self p_startNetworkMonitoring];
[[TLMessageManager sharedInstance] setConversationDelegate:self];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//TODO: 临时写法
[self updateConversationData];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
if (self.addMenuView.isShow) {
[self.addMenuView dismiss];
}
}
#pragma mark - # Delegate
//MARK: TLMessageManagerConvVCDelegate
- (void)updateConversationData
{
[[TLMessageManager sharedInstance] conversationRecord:^(NSArray *data) {
for (TLConversation *conversation in data) {
if (conversation.convType == TLConversationTypePersonal) {
TLUser *user = [[TLFriendHelper sharedFriendHelper] getFriendInfoByUserID:conversation.partnerID];
[conversation updateUserInfo:user];
}
else if (conversation.convType == TLConversationTypeGroup) {
TLGroup *group = [[TLFriendHelper sharedFriendHelper] getGroupInfoByGroupID:conversation.partnerID];
[conversation updateGroupInfo:group];
}
}
[self p_updateConvsationModuleWithData:data];
}];
}
#pragma mark - # Private Methods
- (void)p_loadUI
{
// 列表
self.tableView = self.view.addTableView(1)
.backgroundColor([UIColor whiteColor])
.tableHeaderView(self.searchController.searchBar)
.tableFooterView([UIView new])
.separatorStyle(UITableViewCellSeparatorStyleNone)
.masonry(^ (MASConstraintMaker *make) {
make.edges.mas_equalTo(0);
})
.view;
// 顶部logo
self.tableView.addImageView(1001)
.image(TLImage(@"conv_wechat_icon"))
.masonry(^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.tableView);
make.bottom.mas_equalTo(self.tableView.mas_top).mas_offset(-35);
});
// 右侧按钮
@weakify(self);
[self addRightBarButtonWithImage:TLImage(@"nav_add") actionBlick:^{
@strongify(self);
if (self.addMenuView.isShow) {
[self.addMenuView dismiss];
}
else {
[self.addMenuView showInView:self.navigationController.view];
}
}];
}
- (void)p_initListModule
{
@weakify(self);
self.listAngel = [[TLConversationAngel alloc] initWithHostView:self.tableView badgeStatusChangeAction:^(NSString *badge) {
@strongify(self);
[self.tabBarItem setBadgeValue:badge];
}];
// 搜索,网络失败
self.listAngel.addSection(TLConversationSectionTagAlert);
// 置顶文章
self.listAngel.addSection(TLConversationSectionTagTopArticle);
// 播放内容
self.listAngel.addSection(TLConversationSectionTagPlay);
// 置顶会话
self.listAngel.addSection(TLConversationSectionTagTopConversation);
// 普通会话
self.listAngel.addSection(TLConversationSectionTagConv);
[self.tableView reloadData];
}
/// 更新会话模块的信息
- (void)p_updateConvsationModuleWithData:(NSArray *)data
{
@weakify(self);
self.listAngel.sectionForTag(TLConversationSectionTagConv).clear();
self.listAngel.addCells(@"TLConversationCell").toSection(TLConversationSectionTagConv).withDataModelArray(data).selectedAction(^ (TLConversation *conversation) {
@strongify(self);
[conversation setUnreadCount:0];
[self.listAngel reloadBadge];
TLChatViewController *chatVC = [[TLChatViewController alloc] initWithConversation:conversation];
PushVC(chatVC);
});
[self.tableView reloadData];
}
/// 开始网络监控
- (void)p_startNetworkMonitoring
{
networkStatusManger = [[TLNetworkStatusManager alloc] init];
[networkStatusManger startNetworkStatusMonitoring];
@weakify(self);
[networkStatusManger setNetworkChangedBlock:^(TLNetworkStatus status){
@strongify(self);
self.listAngel.sectionForTag(TLConversationSectionTagAlert).clear();
if (status == TLNetworkStatusNone) {
[self.navigationItem setTitle:LOCSTR(@"未连接")];
self.listAngel.addCell(@"TLConversationNoNetCell").toSection(TLConversationSectionTagAlert).viewTag(TLConversationCellTagNoNet);
}
else {
[self p_setNavTitleWithStatusString:nil];
}
[self.tableView reloadData];
}];
}
- (void)p_setNavTitleWithStatusString:(NSString *)statusString
{
NSString *title = LOCSTR(@"微信");
title = statusString.length > 0 ? [title stringByAppendingFormat:@"(%@)", statusString] : title;
[self.navigationItem setTitle:LOCSTR(title)];
}
#pragma mark - # Getter
- (TLSearchController *)searchController
{
if (!_searchController) {
TLContactsSearchResultViewController *searchVC = [[TLContactsSearchResultViewController alloc] init];
@weakify(self);
[searchVC setItemSelectedAction:^(TLContactsSearchResultViewController *searchVC, TLUser *userModel) {
@strongify(self);
[self.searchController setActive:NO];
TLUserDetailViewController *detailVC = [[TLUserDetailViewController alloc] initWithUserModel:userModel];
PushVC(detailVC);
}];
_searchController = [TLSearchController createWithResultsContrller:searchVC];
[_searchController setEnableVoiceInput:YES];
}
return _searchController;
}
- (TLAddMenuView *)addMenuView
{
if (!_addMenuView) {
_addMenuView = [[TLAddMenuView alloc] init];
@weakify(self);
[_addMenuView setItemSelectedAction:^(TLAddMenuView *addMenuView, TLAddMenuItem *item) {
@strongify(self);
if (item.className.length > 0) {
id vc = [[NSClassFromString(item.className) alloc] init];
PushVC(vc);
}
else {
[TLUIUtility showAlertWithTitle:item.title message:@"功能暂未实现"];
}
}];
}
return _addMenuView;
}
@end
@@ -0,0 +1,35 @@
//
// TLConversationCell.h
// TLChat
//
// Created by 李伯坤 on 16/1/23.
// Copyright © 2016年 李伯坤. All rights reserved.
#import <UIKit/UIKit.h>
#import "TLConversation.h"
#define HEIGHT_CONVERSATION_CELL 64.0f
typedef NS_ENUM(NSInteger, TLConversationCellSeperatorStyle) {
TLConversationCellSeperatorStyleDefault,
TLConversationCellSeperatorStyleFill,
};
@interface TLConversationCell : UITableViewCell <ZZFlexibleLayoutViewProtocol>
/// 会话Model
@property (nonatomic, strong) TLConversation *conversation;
@property (nonatomic, assign) TLConversationCellSeperatorStyle bottomSeperatorStyle;
/**
* 标记为未读
*/
- (void)markAsUnread;
/**
* 标记为已读
*/
- (void)markAsRead;
@end
@@ -0,0 +1,218 @@
//
// TLConversationCell.m
// TLChat
//
// Created by 李伯坤 on 16/1/23.
// Copyright © 2016年 李伯坤. All rights reserved.
//
#import "TLConversationCell.h"
#import "NSDate+TLChat.h"
#import "TLMacros.h"
#import "NSFileManager+TLChat.h"
#import <TLTabBarController/TLBadge.h>
@interface TLConversationCell()
/// 头像
@property (nonatomic, strong) UIImageView *avatarView;
/// 用户名
@property (nonatomic, strong) UILabel *nameLabel;
/// 正文
@property (nonatomic, strong) UILabel *detailLabel;
/// 时间
@property (nonatomic, strong) UILabel *timeLabel;
/// 免打扰标识
@property (nonatomic, strong) UIImageView *remindImageView;
/// 气泡
@property (nonatomic, strong) TLBadge *badge;
@end
@implementation TLConversationCell
+ (CGFloat)viewHeightByDataModel:(id)dataModel
{
return HEIGHT_CONVERSATION_CELL;
}
- (void)setViewDataModel:(id)dataModel
{
[self setConversation:dataModel];
}
- (void)viewIndexPath:(NSIndexPath *)indexPath sectionItemCount:(NSInteger)count
{
self.bottomSeperatorStyle = (indexPath.row == count - 1 ? TLConversationCellSeperatorStyleFill : TLConversationCellSeperatorStyleDefault);
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self p_initViews];
}
return self;
}
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
if (self.bottomSeperatorStyle == TLConversationCellSeperatorStyleDefault) {
self.addSeparator(ZZSeparatorPositionBottom).beginAt(15);
}
else {
self.addSeparator(ZZSeparatorPositionBottom);
}
}
- (void)setBottomSeperatorStyle:(TLConversationCellSeperatorStyle)bottomSeperatorStyle
{
_bottomSeperatorStyle = bottomSeperatorStyle;
[self setNeedsDisplay];
}
#pragma mark - Public Methods
- (void)setConversation:(TLConversation *)conversation
{
_conversation = conversation;
if (conversation.avatarPath.length > 0) {
NSString *path = [NSFileManager pathUserAvatar:conversation.avatarPath];
[self.avatarView setImage:[UIImage imageNamed:path]];
}
else {
[self.avatarView tt_setImageWithURL:TLURL(conversation.avatarURL) placeholderImage:[UIImage imageNamed:DEFAULT_AVATAR_PATH]];
}
[self.nameLabel setText:conversation.partnerName];
[self.detailLabel setText:conversation.content];
[self.timeLabel setText:conversation.date.conversaionTimeInfo];
[self.remindImageView setHidden:NO];
switch (conversation.remindType) {
case TLMessageRemindTypeNormal:
[self.remindImageView setHidden:YES];
break;
case TLMessageRemindTypeClosed:
[self.remindImageView setImage:[UIImage imageNamed:@"conv_remind_close"]];
break;
case TLMessageRemindTypeNotLook:
[self.remindImageView setImage:[UIImage imageNamed:@"conv_remind_notlock"]];
break;
case TLMessageRemindTypeUnlike:
[self.remindImageView setImage:[UIImage imageNamed:@"conv_remind_unlike"]];
break;
}
// 更新气泡
[self updateBadge];
}
/// 标记为未读
- (void)markAsUnread
{
self.conversation.unreadCount = 1;
[self updateBadge];
}
/// 标记为已读
- (void)markAsRead
{
self.conversation.unreadCount = 0;
[self updateBadge];
}
- (void)updateBadge
{
CGSize size = [TLBadge badgeSizeWithValue:self.conversation.badgeValue];
[self.badge setBadgeValue:self.conversation.badgeValue];
[self.badge mas_updateConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(size);
}];
}
#pragma mark - # Overide
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
self.badge.backgroundColor = [UIColor redColor];
}
-(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
[super setHighlighted:highlighted animated:animated];
self.badge.backgroundColor = [UIColor redColor];
}
#pragma mark - # Private Methods
- (void)p_initViews
{
// 头像
self.avatarView = self.contentView.addImageView(1001)
.cornerRadius(3.0f)
.masonry(^ (MASConstraintMaker *make) {
make.left.mas_equalTo(15);
make.top.mas_equalTo(10);
make.bottom.mas_equalTo(- 10);
})
.view;
[self.avatarView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(self.avatarView.mas_height);
}];
// 时间
self.timeLabel = self.contentView.addLabel(2001)
.font([UIFont fontConversationTime]).textColor([UIColor colorTextGray1])
.masonry(^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.avatarView).mas_offset(2);
make.right.mas_equalTo(self.contentView).mas_offset(-9.5);
})
.view;
[self.timeLabel setContentCompressionResistancePriority:300 forAxis:UILayoutConstraintAxisHorizontal];
// 用户名
self.nameLabel = self.contentView.addLabel(1002)
.font([UIFont fontConversationUsername])
.masonry(^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.avatarView.mas_right).mas_offset(10);
make.top.mas_equalTo(self.avatarView).mas_offset(1.5);
make.right.mas_lessThanOrEqualTo(self.timeLabel.mas_left).mas_offset(-5);
})
.view;
[self.nameLabel setContentCompressionResistancePriority:100 forAxis:UILayoutConstraintAxisHorizontal];
// 免打扰标识
self.remindImageView = self.contentView.addImageView(2002)
.alpha(0.4)
.masonry(^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.timeLabel);
make.bottom.mas_equalTo(self.avatarView);
})
.view;
[self.remindImageView setContentCompressionResistancePriority:310 forAxis:UILayoutConstraintAxisHorizontal];
// 正文
self.detailLabel = self.contentView.addLabel(3)
.font([UIFont fontConversationDetail])
.textColor([UIColor colorTextGray])
.masonry(^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.nameLabel.mas_bottom).mas_offset(4);
make.left.mas_equalTo(self.nameLabel);
make.right.mas_lessThanOrEqualTo(self.remindImageView.mas_left);
})
.view;
[self.detailLabel setContentCompressionResistancePriority:110 forAxis:UILayoutConstraintAxisHorizontal];
[self layoutIfNeeded];
// 气泡
self.badge = [[TLBadge alloc] init];
[self.contentView addSubview:self.badge];
[self.badge mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.avatarView.mas_right).mas_offset(-1.5);
make.centerY.mas_equalTo(self.avatarView.mas_top).mas_equalTo(1.5);
}];
}
@end
@@ -0,0 +1,13 @@
//
// TLConversationNoNetCell.h
// TLChat
//
// Created by 李伯坤 on 2017/7/17.
// Copyright © 2017年 李伯坤. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface TLConversationNoNetCell : UITableViewCell <ZZFlexibleLayoutViewProtocol>
@end
@@ -0,0 +1,67 @@
//
// TLConversationNoNetCell.m
// TLChat
//
// Created by 李伯坤 on 2017/7/17.
// Copyright © 2017年 李伯坤. All rights reserved.
//
#import "TLConversationNoNetCell.h"
@interface TLConversationNoNetCell ()
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIImageView *iconView;
@end
@implementation TLConversationNoNetCell
+ (CGFloat)viewHeightByDataModel:(id)dataModel
{
return 45.0f;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self setSelectionStyle:UITableViewCellSelectionStyleNone];
[self.contentView setBackgroundColor:RGBAColor(255, 223, 224, 1)];
[self p_initViews];
}
return self;
}
- (void)layoutSubviews
{
[super layoutSubviews];
self.addSeparator(ZZSeparatorPositionBottom);
}
#pragma mark - # Private Methods
- (void)p_initViews
{
self.iconView = self.addImageView(1001)
.image(TLImage(@"conv_exclamation_mark"))
.masonry(^(MASConstraintMaker *make) {
make.size.mas_equalTo(40);
make.left.mas_equalTo(10);
make.centerY.mas_equalTo(0);
})
.view;
self.titleLabel = self.contentView.addLabel(1002)
.text(LOCSTR(@"当前网络不可用,请检查你的网络设置"))
.font([UIFont systemFontOfSize:14]).textColor([UIColor grayColor])
.masonry(^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.iconView.mas_right).mas_offset(10);
make.right.mas_lessThanOrEqualTo(-15);
make.centerY.mas_equalTo(0);
})
.view;
}
@end