You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

358 lines
9.9 KiB

//
// XHMessageTableViewController.h
// MessageDisplayExample
//
// Created by HUAJIE-1 on 14-4-24.
// Copyright (c) 2014年 曾宪华 开发团队(http://iyilunba.com ) 本人QQ:543413507 本人QQ群(142557668). All rights reserved.
//
#import <UIKit/UIKit.h>
// Model
#import "XHMessage.h"
// Views
#import "XHMessageTableView.h"
#import "XHMessageTableViewCell.h"
#import "XHMessageInputView.h"
#import "XHShareMenuView.h"
#import "XHEmotionManagerView.h"
#import "XHVoiceRecordHUD.h"
// Factory
#import "XHMessageBubbleFactory.h"
#import "XHMessageVideoConverPhotoFactory.h"
// Helper
#import "XHPhotographyHelper.h"
#import "XHLocationHelper.h"
#import "XHVoiceRecordHelper.h"
// Categorys
#import "UIScrollView+XHkeyboardControl.h"
#import "baseViewController.h"
@protocol XHMessageTableViewControllerDelegate <NSObject>
@optional
/**
*
*
* @param text
* @param sender
* @param date
*/
- (void)didSendText:(NSString *)text fromSender:(NSString *)sender onDate:(NSDate *)date;
/**
*
*
* @param photo
* @param sender
* @param date
*/
- (void)didSendPhoto:(UIImage *)photo fromSender:(NSString *)sender onDate:(NSDate *)date;
/**
*
*
* @param videoConverPhoto
* @param videoPath
* @param sender
* @param date
*/
- (void)didSendVideoConverPhoto:(UIImage *)videoConverPhoto videoPath:(NSString *)videoPath fromSender:(NSString *)sender onDate:(NSDate *)date;
/**
*
*
* @param voicePath
* @param voiceDuration
* @param sender
* @param date
*/
- (void)didSendVoice:(NSString *)voicePath voiceDuration:(NSNumber*)voiceDuration fromSender:(NSString *)sender onDate:(NSDate *)date;
/**
*
*
* @param emotionPath
* @param sender
* @param date
*/
- (void)didSendEmotion:(NSString *)emotionPath fromSender:(NSString *)sender onDate:(NSDate *)date;
/**
*
*
* @param geoLocationsPhoto
* @param geolocations
* @param location
* @param sender
* @param date
*/
- (void)didSendGeoLocationsPhoto:(UIImage *)geoLocationsPhoto geolocations:(NSString *)geolocations location:(CLLocation *)location fromSender:(NSString *)sender onDate:(NSDate *)date;
/**
* Label的回调方法
*
* @param indexPath IndexPath
*
* @return indexPath获取消息的Model的对象YES or NO来控制是否显示时间轴Label
*/
- (BOOL)shouldDisplayTimestampForRowAtIndexPath:(NSIndexPath *)indexPath;
/**
* Cell的样式或者字体
*
* @param cell Cell
* @param indexPath Cell所在位置IndexPath
*/
- (void)configureCell:(XHMessageTableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath;
/**
*
*
* @return YES or NO
*/
- (BOOL)shouldPreventScrollToBottomWhileUserScrolling;
/**
*
*
* @return BOOL值
*/
- (BOOL)shouldLoadMoreMessagesScrollToTop;
/**
*
*/
- (void)loadMoreMessagesScrollTotop;
/**
* TableViewCell高度的方法Cell样式DataSource中的方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath targetMessage:(id<XHMessageModel>)message;
*
* @param tableView TableView
* @param indexPath IndexPath
* @param message Model
*
* @return Cell高度
*/
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath targetMessage:(XHMessage *)message;
- (void)moreButtonClick:(void (^)())PickerMediaBlock;
@end
@protocol XHMessageTableViewControllerDataSource <NSObject>
@required
- (XHMessage *)messageForRowAtIndexPath:(NSIndexPath *)indexPath;
@optional
/**
* TableViewCell的方法Cell样式Delegate中的方法
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath targetMessage:(id<XHMessageModel>)message;
*
* @param tableView TableView
* @param indexPath IndexPath
* @param message Model
*
* @return UITableViewCell或者继承于UITableViewCell的实例化对象
*/
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath targetMessage:(XHMessage *)message;
@end
@interface XHMessageTableViewController : baseViewController <UITableViewDataSource, UITableViewDelegate, XHMessageTableViewControllerDelegate, XHMessageTableViewControllerDataSource, XHMessageInputViewDelegate, XHMessageTableViewCellDelegate, XHShareMenuViewDelegate, XHEmotionManagerViewDelegate, XHEmotionManagerViewDataSource>
@property (nonatomic, weak) id <XHMessageTableViewControllerDelegate> delegate;
@property (nonatomic, weak) id <XHMessageTableViewControllerDataSource> msgDataSource;
@property (nonatomic, assign, readonly) XHInputViewType textViewInputViewType;
@property (nonatomic, assign) UIActivityIndicatorViewStyle loadMoreActivityIndicatorViewStyle;
/**
*
*/
@property (nonatomic, strong) NSMutableArray *messages;
/**
*
*/
@property (nonatomic, strong) NSArray *shareMenuItems;
/**
* nil
*/
@property (nonatomic, copy) NSString *messageSender;
/**
* TableView
*/
@property (nonatomic, weak, readonly) XHMessageTableView *messageTableView;
/**
*
*/
@property (nonatomic, weak, readonly) XHMessageInputView *messageInputView;
/**
*
*/
@property (nonatomic, weak, readonly) XHShareMenuView *shareMenuView;
/**
* gif表情的控件
*/
@property (nonatomic, weak, readonly) XHEmotionManagerView *emotionManagerView;
/**
*
*/
@property (nonatomic, assign) BOOL loadingMoreMessage;
/**
*
*/
@property (nonatomic, strong) XHPhotographyHelper *photographyHelper;
/**
*
*/
@property (nonatomic, strong) XHVoiceRecordHelper *voiceRecordHelper;
/**
*
*/
@property (nonatomic, copy) NSNumber *lastShowTimetamp;
#pragma mark - Message View Controller Default stup
/**
*
*/
@property (nonatomic, assign) BOOL allowsPanToDismissKeyboard; // default is YES
/**
*
*/
@property (nonatomic, assign) BOOL allowsSendText; // default is YES
/**
*
*/
@property (nonatomic, assign) BOOL allowsSendVoice; // default is YES
/**
*
*/
@property (nonatomic, assign) BOOL allowsSendMultiMedia; // default is YES
/**
*
*/
@property (nonatomic, assign) BOOL allowsSendFace; // default is NO
/**
*
*/
@property (nonatomic, assign) XHMessageInputViewStyle inputViewStyle;
@property (nonatomic, strong) XHMessageTableViewCell *currentSelectedCell;//xTT 当前cell
/// 群聊单聊类型区分 111:单聊 222:群聊
@property (nonatomic ,assign) NSInteger chatType;
#pragma mark - DataSource Change
/**
*
*
* @param addedMessage
*/
- (void)addMessage:(XHMessage *)addedMessage;
/**
*
*
* @param indexPath
*/
- (void)removeMessageAtIndexPath:(NSIndexPath *)indexPath;
/**
* 仿
*
* @param oldMessages
*/
- (void)insertOldMessages:(NSArray *)oldMessages;
/**
* completion
*
* @param oldMessages
* @param completion insert
*/
- (void)insertOldMessages:(NSArray *)oldMessages completion:(void (^)())completion;
#pragma mark - Messages view controller
/**
*
*/
- (void)finishSendMessageWithBubbleMessageType:(XHBubbleMessageMediaType)mediaType;
/**
* ViewtableView的背景颜色
*
* @param color
*/
- (void)setBackgroundColor:(UIColor *)color;
/**
*
*
* @param backgroundImage
*/
- (void)setBackgroundImage:(UIImage *)backgroundImage;
/**
*
*
* @param animated YES Or NO
*/
- (void)scrollToBottomAnimated:(BOOL)animated;
/**
*
*
* @param indexPath
* @param position UITableViewScrollPosition
* @param animated YES or NO
*/
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath
atScrollPosition:(UITableViewScrollPosition)position
animated:(BOOL)animated;
/**
*
*/
- (void)cancelRecord;
#pragma mark - Other Menu View Frame Helper Mehtod
/**
* Menu进行管理
*
* @param hide
*/
- (void)layoutOtherMenuViewHiden:(BOOL)hide;
@end