chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
//
|
||||
// TLChatViewController.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/2/15.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLChatViewController.h"
|
||||
#import "TLChatViewController+Delegate.h"
|
||||
#import "TLChatDetailViewController.h"
|
||||
#import "TLChatGroupDetailViewController.h"
|
||||
#import "TLMoreKBHelper.h"
|
||||
#import "TLEmojiKBHelper.h"
|
||||
#import "TLUserHelper.h"
|
||||
#import "TLChatNotificationKey.h"
|
||||
#import "TLFriendHelper.h"
|
||||
|
||||
static TLChatViewController *chatVC;
|
||||
|
||||
@interface TLChatViewController()
|
||||
|
||||
@property (nonatomic, strong) TLMoreKBHelper *moreKBhelper;
|
||||
|
||||
@property (nonatomic, strong) TLEmojiKBHelper *emojiKBHelper;
|
||||
|
||||
@property (nonatomic, strong) UIBarButtonItem *rightBarButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLChatViewController
|
||||
|
||||
- (instancetype)initWithUserId:(NSString *)userId
|
||||
{
|
||||
if (self = [super init]) {
|
||||
TLUser *user = [[TLFriendHelper sharedFriendHelper] getFriendInfoByUserID:userId];
|
||||
self.partner = user;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithGroupId:(NSString *)groupId
|
||||
{
|
||||
if (self = [super init]) {
|
||||
TLGroup *group = [[TLFriendHelper sharedFriendHelper] getGroupInfoByGroupID:groupId];
|
||||
self.partner = group;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
[self.navigationItem setRightBarButtonItem:self.rightBarButton];
|
||||
|
||||
self.user = (id<TLChatUserProtocol>)[TLUserHelper sharedHelper].user;
|
||||
self.moreKBhelper = [[TLMoreKBHelper alloc] init];
|
||||
[self setChatMoreKeyboardData:self.moreKBhelper.chatMoreKeyboardData];
|
||||
self.emojiKBHelper = [TLEmojiKBHelper sharedKBHelper];
|
||||
TLWeakSelf(self);
|
||||
[self.emojiKBHelper emojiGroupDataByUserID:[TLUserHelper sharedHelper].userID complete:^(NSMutableArray *emojiGroups) {
|
||||
[weakself setChatEmojiKeyboardData:emojiGroups];
|
||||
}];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resetChatVC) name:NOTI_CHAT_VIEW_RESET object:nil];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
[MobClick beginLogPageView:@"ChatVC"];
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
{
|
||||
[super viewWillDisappear:animated];
|
||||
[MobClick endLogPageView:@"ChatVC"];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
#ifdef DEBUG_MEMERY
|
||||
NSLog(@"dealloc ChatVC");
|
||||
#endif
|
||||
}
|
||||
|
||||
#pragma mark - # Public Methods
|
||||
- (void)setPartner:(id<TLChatUserProtocol>)partner
|
||||
{
|
||||
[super setPartner:partner];
|
||||
if ([partner chat_userType] == TLChatUserTypeUser) {
|
||||
[self.rightBarButton setImage:[UIImage imageNamed:@"nav_chat_single"]];
|
||||
}
|
||||
else if ([partner chat_userType] == TLChatUserTypeGroup) {
|
||||
[self.rightBarButton setImage:[UIImage imageNamed:@"nav_chat_multi"]];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - # Event Response
|
||||
- (void)rightBarButtonDown:(UINavigationBar *)sender
|
||||
{
|
||||
if ([self.partner chat_userType] == TLChatUserTypeUser) {
|
||||
TLChatDetailViewController *chatDetailVC = [[TLChatDetailViewController alloc] initWithUserModel:(TLUser *)self.partner];
|
||||
PushVC(chatDetailVC);
|
||||
}
|
||||
else if ([self.partner chat_userType] == TLChatUserTypeGroup) {
|
||||
TLChatGroupDetailViewController *chatGroupDetailVC = [[TLChatGroupDetailViewController alloc] initWithGroupModel:(TLGroup *)self.partner];
|
||||
PushVC(chatGroupDetailVC);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - # Getter
|
||||
- (UIBarButtonItem *)rightBarButton
|
||||
{
|
||||
if (_rightBarButton == nil) {
|
||||
_rightBarButton = [[UIBarButtonItem alloc] initWithImage:nil style:UIBarButtonItemStylePlain target:self action:@selector(rightBarButtonDown:)];
|
||||
}
|
||||
return _rightBarButton;
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user