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.

339 lines
9.5 KiB

2 years ago
//
// XHMessageTableViewController.h
// MessageDisplayExample
//
// Created by HUAJIE-1 on 14-4-24.
// Copyright (c) 2014年 嗨,我是曾宪华(@xhzengAIB),曾加入YY Inc.担任高级移动开发工程师,拍立秀App联合创始人,热衷于简洁、而富有理性的事物 QQ:543413507 主页:http://zengxianhua.com 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:(NSString*)voiceDuration fromSender:(NSString *)sender onDate:(NSDate *)date;
/**
*
*
* @param facePath
* @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:(id<XHMessageModel>)message;
@end
@protocol XHMessageTableViewControllerDataSource <NSObject>
@required
- (id <XHMessageModel>)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:(id<XHMessageModel>)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> dataSource;
/**
*
*/
@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;
#pragma mark - Message View Controller Default stup
/**
*
*/
@property (nonatomic, assign) BOOL allowsPanToDismissKeyboard; // 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 YES
/**
*
*/
@property (nonatomic, assign) XHMessageInputViewStyle inputViewStyle;
@property (nonatomic, strong) XHMessageTableViewCell *currentSelectedCell;//xTT 当前cell
#pragma mark - DataSource Change
/**
*
*
* @param addedMessage
*/
- (void)addMessage:(XHMessage *)addedMessage;
/**
*
*
* @param reomvedMessage
*/
- (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;
#pragma mark - Other Menu View Frame Helper Mehtod
/**
* Menu进行管理
*
* @param hide
*/
- (void)layoutOtherMenuViewHiden:(BOOL)hide;
@end