diff --git a/ChatSDKCore/Classes/Defines/BCoreDefines.h b/ChatSDKCore/Classes/Defines/BCoreDefines.h index cb6e9479..0cac6e7e 100755 --- a/ChatSDKCore/Classes/Defines/BCoreDefines.h +++ b/ChatSDKCore/Classes/Defines/BCoreDefines.h @@ -16,8 +16,11 @@ #define bTypingTimeout 5.0 #define bLocationDefaultArea 1000 +#define bDefaultChatBgColor @"ffffff" + #define bDefaultMessageColorMe @"abcff4" #define bDefaultMessageColorReply @"d7d4d3" +#define bDefaultMessageColorTime @"aaaaaa" #define bDefaultProfileImage @"icn_100_anonymous.png" #define bDefaultPublicGroupImage @"icn_100_anonymous_group.png" diff --git a/ChatSDKCore/Classes/Session/BChatSDK.h b/ChatSDKCore/Classes/Session/BChatSDK.h index 096fe1d7..095b51b3 100755 --- a/ChatSDKCore/Classes/Session/BChatSDK.h +++ b/ChatSDKCore/Classes/Session/BChatSDK.h @@ -31,6 +31,7 @@ @property (nonatomic, readwrite) id interfaceAdapter; @property (nonatomic, readwrite) id storageAdapter; @property (nonatomic, readwrite) id networkAdapter; +@property (nonatomic, readwrite) BOOL keepAliveOnDidResignActive; +(BChatSDK *) shared; +(BConfiguration *) config; diff --git a/ChatSDKCore/Classes/Session/BChatSDK.m b/ChatSDKCore/Classes/Session/BChatSDK.m index ffe64809..e8b55aa5 100755 --- a/ChatSDKCore/Classes/Session/BChatSDK.m +++ b/ChatSDKCore/Classes/Session/BChatSDK.m @@ -18,6 +18,7 @@ @implementation BChatSDK @synthesize interfaceAdapter = _interfaceAdapter; @synthesize storageAdapter = _storageAdapter; @synthesize networkAdapter = _networkAdapter; +@synthesize keepAliveOnDidResignActive = _keepAliveOnDidResignActive; static BChatSDK * instance; @@ -77,7 +78,7 @@ +(void) initialize: (BConfiguration *) config app:(UIApplication *)application o } -(void) appDidResignActive { - if(self.networkAdapter) { + if(self.networkAdapter && self.keepAliveOnDidResignActive == NO) { [self.networkAdapter.core save]; [self.networkAdapter.core goOffline]; } diff --git a/ChatSDKCore/Classes/Session/BConfiguration.h b/ChatSDKCore/Classes/Session/BConfiguration.h index 6efc043c..ede53aef 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.h +++ b/ChatSDKCore/Classes/Session/BConfiguration.h @@ -31,11 +31,30 @@ typedef enum { // Should we ask the user to allow notifications when the app initially loads up? @property (nonatomic, readwrite) BOOL shouldAskForNotificationsPermission; + +/// Custom background color of BChatViewController's main view. +@property (nonatomic, readwrite) NSString * chatBgColor; + +/// Hide the section that shows "Today", "Yesterday", etc. +@property (nonatomic, readwrite) BOOL hideDayOfTheWeekSection; +/// Add a shadow to the message bubble using a default shadow configuration. +@property (nonatomic, readwrite) BOOL addShadowOnMessageBubble; +@property (nonatomic, readwrite) BOOL showReadStatus; +/// Format to be used for NSPredicate. +@property (nonatomic, readwrite) NSString * dateFilterFormat; +/// An NSDate filter used to filter thread messages to show only the messages that are greater than or equal +/// the set dateFilter. +@property (nonatomic, readwrite) NSDate * dateFilter; // Background color of messages: hex value like "FFFFFF" @property (nonatomic, readwrite) NSString * messageColorMe; @property (nonatomic, readwrite) NSString * messageColorReply; +/// Custom placeholder for chat screen's textview. +@property (nonatomic, readwrite) NSString * chatTextViewPlaceholder; +/// Custom font for chat screen's textview. +@property (nonatomic, readwrite) UIFont * chatTextViewFont; + // The Firebase root path. Data will be added to Firebase root/rootPath... // this allows you to run multiple chat instances on one Firebase database @property (nonatomic, readwrite) NSString * rootPath; @@ -55,6 +74,12 @@ typedef enum { // Should empty chats be shown in the threads view? @property (nonatomic, readwrite) BOOL showEmptyChats; +/// Show profile picture on every message cell. +@property (nonatomic, readwrite) BOOL showProfilePictureOnEveryCell; + +/// Value of profilePictureOnCellTapEnabled is enabled by default to follow previous implementation. +@property (nonatomic, readwrite) BOOL profilePictureOnCellTapEnabled; + // User profile image @property (nonatomic, readwrite) NSString * defaultAvatarURL; @@ -142,6 +167,8 @@ typedef enum { @property(nonatomic, readwrite) NSString * messageBubbleMaskLast; @property(nonatomic, readwrite) NSString * messageBubbleMaskSingle; +/// Hide the name label for each message bubble. +@property(nonatomic, readwrite) BOOL hideNameLabel; @property(nonatomic, readwrite) bNameLabelPosition nameLabelPosition; @property(nonatomic, readwrite) BOOL combineTimeWithNameLabel; @@ -167,6 +194,9 @@ typedef enum { @property (nonatomic, readwrite) UIFont * messageTimeFont; @property (nonatomic, readwrite) UIFont * messageNameFont; +/// Set the custom color of the time label. If not set, it will use the default color of time label. +@property (nonatomic, readwrite) NSString * messageTimeColor; + @property (nonatomic, readwrite) UIFont * threadTitleFont; @property (nonatomic, readwrite) UIFont * threadTimeFont; @property (nonatomic, readwrite) UIFont * threadSubtitleFont; @@ -247,6 +277,11 @@ typedef enum { // How much distance must be moved to update the server with our new location @property (nonatomic, readwrite) int nearbyUsersMinimumLocationChangeToUpdateServer; +/// Custom icon for the options/attachment button. +@property (nonatomic, readwrite) NSString * optionsButtonIcon; +/// Custom icon for the send message button. +@property (nonatomic, readwrite) NSString * sendButtonIcon; + // XMPP Auth type used which can be: // default, scramsha1, digestmd5, plain @property (nonatomic, readwrite) NSString * xmppAuthType; diff --git a/ChatSDKCore/Classes/Session/BConfiguration.m b/ChatSDKCore/Classes/Session/BConfiguration.m index 7ebc3e1b..8936c8c7 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.m +++ b/ChatSDKCore/Classes/Session/BConfiguration.m @@ -11,8 +11,17 @@ @implementation BConfiguration +@synthesize chatBgColor; +@synthesize hideDayOfTheWeekSection; +@synthesize addShadowOnMessageBubble; +@synthesize showReadStatus; +@synthesize dateFilterFormat; +@synthesize dateFilter; @synthesize messageColorMe; @synthesize messageColorReply; +@synthesize messageTimeColor; +@synthesize chatTextViewPlaceholder; +@synthesize chatTextViewFont; @synthesize rootPath; @synthesize appBadgeEnabled; @synthesize defaultUserNamePrefix; @@ -26,6 +35,8 @@ @implementation BConfiguration @synthesize defaultServer; @synthesize shouldOpenChatWhenPushNotificationClicked; @synthesize loginUsernamePlaceholder; +@synthesize showProfilePictureOnEveryCell; +@synthesize profilePictureOnCellTapEnabled; @synthesize defaultAvatarURL; @synthesize defaultBlankAvatar; @synthesize timeFormat; @@ -70,6 +81,7 @@ @implementation BConfiguration @synthesize messageBubbleMaskMiddle; @synthesize messageBubbleMaskLast; @synthesize messageBubbleMaskSingle; +@synthesize hideNameLabel; @synthesize nameLabelPosition; @synthesize combineTimeWithNameLabel; @@ -94,6 +106,8 @@ @implementation BConfiguration @synthesize publicChatRoomLifetimeMinutes; @synthesize nearbyUsersMinimumLocationChangeToUpdateServer; +@synthesize optionsButtonIcon; +@synthesize sendButtonIcon; @synthesize publicChatAutoSubscriptionEnabled; @synthesize remote; @synthesize remoteConfigEnabled; @@ -160,6 +174,8 @@ -(instancetype) init { shouldAskForNotificationsPermission = YES; + profilePictureOnCellTapEnabled = YES; + defaultBlankAvatar = [NSBundle imageNamed:bDefaultProfileImage bundle:bCoreBundleName]; defaultGroupChatAvatar = [NSBundle imageNamed:bDefaultPublicGroupImage bundle:bCoreBundleName]; diff --git a/ChatSDKUI/Classes/Components/Chat View/BChatViewController.m b/ChatSDKUI/Classes/Components/Chat View/BChatViewController.m index be455585..6cdbf33d 100755 --- a/ChatSDKUI/Classes/Components/Chat View/BChatViewController.m +++ b/ChatSDKUI/Classes/Components/Chat View/BChatViewController.m @@ -30,6 +30,11 @@ -(instancetype) initWithThread: (id) thread -(void) viewDidLoad { [super viewDidLoad]; + self.view.backgroundColor = [BCoreUtilities colorWithHexString:bDefaultChatBgColor]; + if(BChatSDK.config.chatBgColor) { + self.view.backgroundColor = [BCoreUtilities colorWithHexString:BChatSDK.config.chatBgColor]; + } + [_sendBarView setMaxLines:BChatSDK.config.textInputViewMaxLines]; [_sendBarView setMaxCharacters:BChatSDK.config.textInputViewMaxCharacters]; @@ -44,6 +49,12 @@ -(void) viewDidLoad { // Add the initial batch of messages NSArray * messages = [BChatSDK.db loadMessagesForThread:_thread newest:BChatSDK.config.messagesToLoadPerBatch]; messages = [messages sortedArrayUsingComparator:[BMessageSorter oldestFirst]]; + + if(BChatSDK.config.dateFilter && BChatSDK.config.dateFilterFormat) { + NSPredicate *dateFilterPredicate = [NSPredicate predicateWithFormat:BChatSDK.config.dateFilterFormat, BChatSDK.config.dateFilter]; + messages = (NSArray *)[messages filteredArrayUsingPredicate:dateFilterPredicate]; + } + [self setMessages:messages scrollToBottom:NO animate:NO force: YES]; } diff --git a/ChatSDKUI/Classes/Components/Chat View/BLazyReloadManager.m b/ChatSDKUI/Classes/Components/Chat View/BLazyReloadManager.m index dfab29fc..86d7c004 100755 --- a/ChatSDKUI/Classes/Components/Chat View/BLazyReloadManager.m +++ b/ChatSDKUI/Classes/Components/Chat View/BLazyReloadManager.m @@ -44,6 +44,11 @@ -(void) loadMessages: (UIScrollView *) scrollView { float height = scrollView.contentSize.height; float offsetY = scrollView.contentOffset.y; + if(BChatSDK.config.dateFilter && BChatSDK.config.dateFilterFormat) { + NSPredicate *dateFilterPredicate = [NSPredicate predicateWithFormat:BChatSDK.config.dateFilterFormat, BChatSDK.config.dateFilter]; + messages = (NSArray *)[messages filteredArrayUsingPredicate:dateFilterPredicate]; + } + [self.messageManager addMessages: messages]; [self.tableView reloadData]; diff --git a/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m b/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m index ea2a4a4c..827da72c 100755 --- a/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m +++ b/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m @@ -36,6 +36,10 @@ -(instancetype) initWithFrame:(CGRect)frame { // self.barTintColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.7]; self.backgroundColor = [UIColor whiteColor]; + if(BChatSDK.config.chatTextViewFont) { + _placeholderLabel.font = BChatSDK.config.chatTextViewFont; + } + // Decide how many lines the message should have minLines = bMinLines; maxLines = bMaxLines; @@ -60,13 +64,25 @@ -(instancetype) initWithFrame:(CGRect)frame { _sendButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [self addSubview: _sendButton]; - [_optionsButton setImage:[NSBundle uiImageNamed:@"icn_24_options.png"] forState:UIControlStateNormal]; - [_optionsButton setImage:[NSBundle uiImageNamed:@"icn_24_keyboard.png"] forState:UIControlStateSelected]; + if(BChatSDK.config.optionsButtonIcon) { + [_optionsButton setImage:[NSBundle uiImageNamed:BChatSDK.config.optionsButtonIcon] forState:UIControlStateNormal]; + [_optionsButton setImage:[NSBundle uiImageNamed:BChatSDK.config.optionsButtonIcon] forState:UIControlStateSelected]; + } else { + [_optionsButton setImage:[NSBundle uiImageNamed:@"icn_24_options.png"] forState:UIControlStateNormal]; + [_optionsButton setImage:[NSBundle uiImageNamed:@"icn_24_keyboard.png"] forState:UIControlStateSelected]; + } [_optionsButton addTarget:self action:@selector(optionsButtonPressed) forControlEvents:UIControlEventTouchUpInside]; - NSString * sendButtonTitle = [NSBundle t:bSend]; - [_sendButton setTitle:sendButtonTitle forState:UIControlStateNormal]; + if(BChatSDK.config.sendButtonIcon) { + [_sendButton setTitle:Nil forState:UIControlStateNormal]; + [_sendButton setImage:[UIImage imageNamed:BChatSDK.config.sendButtonIcon] forState:UIControlStateNormal]; + [_sendButton setImage:[UIImage imageNamed:BChatSDK.config.sendButtonIcon] forState:UIControlStateSelected]; + } else { + NSString * sendButtonTitle = [NSBundle t:bSend]; + [_sendButton setImage:Nil forState:UIControlStateNormal]; + [_sendButton setTitle:sendButtonTitle forState:UIControlStateNormal]; + } [_sendButton addTarget:self action:@selector(sendButtonPressed) forControlEvents:UIControlEventTouchUpInside]; [_sendButton addTarget:self action:@selector(sendButtonHeld) forControlEvents:UIControlEventTouchDown]; @@ -91,9 +107,15 @@ -(instancetype) initWithFrame:(CGRect)frame { // Constrain the elements _optionsButton.keepLeftInset.equal = bMargin +keepRequired; - - _optionsButton.keepBottomInset.equal = 8.0; - _optionsButton.keepHeight.equal = 24; + + /// If a custom options button icon has been set, then center align it. + if(BChatSDK.config.optionsButtonIcon) { + _optionsButton.keepBottomInset.equal = bMargin; + _optionsButton.keepTopInset.equal = bMargin; + } else { + _optionsButton.keepBottomInset.equal = 8.0; + _optionsButton.keepHeight.equal = 24; + } // If the user has no chat options available then remove the chat option button width _optionsButton.keepWidth.equal = BChatSDK.ui.chatOptions.count ? 24 : 0; @@ -125,6 +147,9 @@ -(instancetype) initWithFrame:(CGRect)frame { [_placeholderLabel setTextColor:_placeholderColor]; [_placeholderLabel setText:[NSBundle t:bWriteSomething]]; + if(BChatSDK.config.chatTextViewPlaceholder) { + [_placeholderLabel setText:BChatSDK.config.chatTextViewPlaceholder]; + } [self setFont:[UIFont systemFontOfSize:bFontSize]]; @@ -176,8 +201,14 @@ -(void) setMicButtonEnabled: (BOOL) enabled sendButtonEnabled: (BOOL) sendButton forState:UIControlStateNormal]; } else { - [_sendButton setTitle:[NSBundle t:bSend] forState:UIControlStateNormal]; - [_sendButton setImage:Nil forState:UIControlStateNormal]; + if(BChatSDK.config.sendButtonIcon) { + [_sendButton setTitle:Nil forState:UIControlStateNormal]; + [_sendButton setImage:[UIImage imageNamed:BChatSDK.config.sendButtonIcon] forState:UIControlStateNormal]; + [_sendButton setImage:[UIImage imageNamed:BChatSDK.config.sendButtonIcon] forState:UIControlStateSelected]; + } else { + [_sendButton setTitle:[NSBundle t:bSend] forState:UIControlStateNormal]; + [_sendButton setImage:Nil forState:UIControlStateNormal]; + } } } @@ -270,6 +301,9 @@ -(void) stopRecording { [[BAudioManager sharedManager] finishRecording]; [_sendBarDelegate.view hideAllToasts]; [_placeholderLabel setText:[NSBundle t:bWriteSomething]]; + if(BChatSDK.config.chatTextViewPlaceholder) { + [_placeholderLabel setText:BChatSDK.config.chatTextViewPlaceholder]; + } [self cancelRecordingToastTimer]; } @@ -305,6 +339,9 @@ -(void) cancelRecordingToastTimer { - (void)sendButtonCancelled { [_sendBarDelegate.view hideAllToasts]; [_placeholderLabel setText:[NSBundle t:bWriteSomething]]; + if(BChatSDK.config.chatTextViewPlaceholder) { + [_placeholderLabel setText:BChatSDK.config.chatTextViewPlaceholder]; + } CSToastStyle * style = [[CSToastStyle alloc] initWithDefaultStyle]; style.backgroundColor = [UIColor redColor]; [_sendBarDelegate.view makeToast:[NSBundle t:bCancelled] diff --git a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m index dfc8e250..f2a01a3c 100755 --- a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m +++ b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m @@ -28,12 +28,12 @@ -(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr // Make sure the selected color is white self.selectedBackgroundView = [[UIView alloc] init]; - + // Bubble view bubbleImageView = [[UIImageView alloc] init]; bubbleImageView.contentMode = UIViewContentModeScaleToFill; bubbleImageView.userInteractionEnabled = YES; - + [self.contentView addSubview:bubbleImageView]; _profilePicture = [[UIImageView alloc] init]; @@ -48,12 +48,16 @@ -(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr if(BChatSDK.config.messageTimeFont) { _timeLabel.font = BChatSDK.config.messageTimeFont; } - - _timeLabel.textColor = [UIColor lightGrayColor]; + + _timeLabel.textColor = [BCoreUtilities colorWithHexString:bDefaultMessageColorTime]; + if(BChatSDK.config.messageTimeColor) { + _timeLabel.textColor = [BCoreUtilities colorWithHexString:BChatSDK.config.messageTimeColor]; + } + _timeLabel.userInteractionEnabled = NO; [self.contentView addSubview:_timeLabel]; - + _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(bTimeLabelPadding, 0, 0, 0)]; _nameLabel.userInteractionEnabled = NO; @@ -62,24 +66,27 @@ -(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr _nameLabel.font = BChatSDK.config.messageNameFont; } [self.contentView addSubview:_nameLabel]; - + _readMessageImageView = [[UIImageView alloc] initWithFrame:CGRectMake(bTimeLabelPadding, 0, 0, 0)]; [self setReadStatus:bMessageReadStatusNone]; [self.contentView addSubview:_readMessageImageView]; - UITapGestureRecognizer * profileTouched = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showProfileView)]; - _profilePicture.userInteractionEnabled = YES; - [_profilePicture addGestureRecognizer:profileTouched]; + // Value of profilePictureOnCellTapEnabled is enabled by default to follow previous implementation. + if (BChatSDK.config.profilePictureOnCellTapEnabled) { + UITapGestureRecognizer * profileTouched = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showProfileView)]; + _profilePicture.userInteractionEnabled = YES; + [_profilePicture addGestureRecognizer:profileTouched]; + } _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; - + } return self; } -(void) setReadStatus: (bMessageReadStatus) status { NSString * imageName = Nil; - + switch (status) { case bMessageReadStatusNone: imageName = @"icn_message_received.png"; @@ -138,14 +145,18 @@ -(void) setMessage: (id) message withColorWeight: (float) colorWeig // Set the bubble to be the correct color bubbleImageView.image = [[BMessageCache sharedCache] bubbleForMessage:message withColorWeight:colorWeight]; - + // Hide profile pictures for 1-to-1 threads _profilePicture.hidden = self.profilePictureHidden; NSLog(@"Position: %i", position); // We only want to show the user picture if it is the latest message from the user - if (position & BChatSDK.config.showMessageAvatarAtPosition) { + // + // 11/05/2019 + // Or we can also show a profile picture beside each message cell by setting a value to + // BChatSDK.config.showProfilePictureOnEveryCell, depends on the project requirements. + if ((position & BChatSDK.config.showMessageAvatarAtPosition) || BChatSDK.config.showProfilePictureOnEveryCell) { if (message.userModel) { [_profilePicture loadAvatar:message.userModel]; @@ -173,7 +184,7 @@ -(void) setMessage: (id) message withColorWeight: (float) colorWeig if (message.flagged.intValue) { _timeLabel.text = [NSBundle t:bFlagged]; } - + _timeLabel.text = _message.date.messageTimeAt; // We use 10 here because if the messages are less than 10 minutes apart, then we // can just compare the minute figures. If they were hours apart they could have @@ -186,14 +197,22 @@ -(void) setMessage: (id) message withColorWeight: (float) colorWeig _nameLabel.text = _message.userModel.name; -// // // We only want to show the name label if the previous message was posted by someone else and if this is enabled in the thread // // Or if the message is mine... _nameLabel.hidden = ![BMessageCell showUserNameLabelForMessage:message atPosition:@(position)]; - // Hide the read receipt view if this is a public thread or if read receipts are disabled - _readMessageImageView.hidden = _message.thread.type.intValue & bThreadFilterPublic || !BChatSDK.readReceipt; + if(BChatSDK.config.hideNameLabel) { + _nameLabel.hidden = BChatSDK.config.hideNameLabel; + } + + if(BChatSDK.config.showReadStatus) { + // TODO: Find actual way to show the message status. This is temp solution only. + _readMessageImageView.hidden = NO; + } else { + // Hide the read receipt view if this is a public thread or if read receipts are disabled + _readMessageImageView.hidden = _message.thread.type.intValue & bThreadFilterPublic || !BChatSDK.readReceipt; + } _timeLabel.hidden = BChatSDK.config.combineTimeWithNameLabel; @@ -227,7 +246,7 @@ -(void) willDisplayCell { else { float ppDiameter = [BMessageCell profilePictureDiameter]; float ppPadding = self.profilePicturePadding; - + [_profilePicture setFrame:CGRectMake(ppPadding, (self.cellHeight - ppDiameter - self.nameHeight)/2.0, ppDiameter, @@ -564,7 +583,7 @@ +(UIEdgeInsets) bubbleMargin: (id) message { } Class cellType = [BChatSDK.ui cellTypeForMessageType:message.type]; - + SEL selector = @selector(messageBubbleMargin:); if ([cellType respondsToSelector:selector]) { return [[cellType performSelector:selector withObject:message] UIEdgeInsetsValue]; @@ -585,12 +604,12 @@ +(UIEdgeInsets) bubblePadding: (id) message { } Class cellType = [BChatSDK.ui cellTypeForMessageType:message.type]; - + SEL selector = @selector(messageBubblePadding:); if ([cellType respondsToSelector:selector]) { return [[cellType performSelector:selector withObject:message] UIEdgeInsetsValue]; } - + return [self messageBubblePadding:message].UIEdgeInsetsValue; } @@ -640,7 +659,7 @@ +(NSNumber *) messageContentHeight: (id) message maxWidth: (float) } +(NSNumber *) messageContentWidth: (id) message maxWidth: (float) maxWidth { - return @(bMaxMessageWidth); + return @(maxWidth); } +(NSValue *) messageBubblePadding: (id) message { diff --git a/ChatSDKUI/Classes/Components/Message Cells/BTextMessageCell.m b/ChatSDKUI/Classes/Components/Message Cells/BTextMessageCell.m index 60e32d65..72473665 100755 --- a/ChatSDKUI/Classes/Components/Message Cells/BTextMessageCell.m +++ b/ChatSDKUI/Classes/Components/Message Cells/BTextMessageCell.m @@ -44,6 +44,16 @@ -(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr // textView.contentInset = UIEdgeInsetsMake(-9.0, -5.0, 0.0, 0.0); + if(BChatSDK.config.addShadowOnMessageBubble) { + if(BChatSDK.config.addShadowOnMessageBubble == YES) { + self.bubbleImageView.layer.shadowColor = UIColor.blackColor.CGColor; + self.bubbleImageView.layer.shadowOffset = CGSizeMake(0, 1.0); + self.bubbleImageView.layer.shadowRadius = 1.0; + self.bubbleImageView.layer.shadowOpacity = 0.2; + self.bubbleImageView.layer.cornerRadius = 10.0; + } + } + [self.bubbleImageView addSubview:textView]; } diff --git a/ChatSDKUI/Classes/Components/SDK/ElmChatViewController.m b/ChatSDKUI/Classes/Components/SDK/ElmChatViewController.m index 78717148..6f3687ca 100755 --- a/ChatSDKUI/Classes/Components/SDK/ElmChatViewController.m +++ b/ChatSDKUI/Classes/Components/SDK/ElmChatViewController.m @@ -46,6 +46,10 @@ -(instancetype) initWithDelegate: (id) delegate_ _tapRecognizer.enabled = NO; [self.view addGestureRecognizer:_tapRecognizer]; + if (BChatSDK.config.chatBgColor) { + self.tableView.backgroundColor = [BCoreUtilities colorWithHexString:BChatSDK.config.chatBgColor]; + } + // When a user taps the title bar we want to know to show the options screen if (BChatSDK.config.userChatInfoEnabled) { UITapGestureRecognizer * titleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(navigationBarTapped)]; @@ -404,6 +408,14 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger return [_messageManager messageForIndexPath:path]; } +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { + if(BChatSDK.config.hideDayOfTheWeekSection) { + return 0.01; + } + + return UITableViewAutomaticDimension; +} + - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { return [_messageManager headerForSection:section]; }