Skip to content

Add customization for chat screen's background color #426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ChatSDKCore/Classes/Defines/BCoreDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#define bTypingTimeout 5.0
#define bLocationDefaultArea 1000

#define bDefaultChatBgColor @"ffffff"

#define bDefaultMessageColorMe @"abcff4"
#define bDefaultMessageColorReply @"d7d4d3"

Expand Down
4 changes: 4 additions & 0 deletions ChatSDKCore/Classes/Session/BConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ 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;


// Background color of messages: hex value like "FFFFFF"
@property (nonatomic, readwrite) NSString * messageColorMe;
Expand Down
1 change: 1 addition & 0 deletions ChatSDKCore/Classes/Session/BConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

@implementation BConfiguration

@synthesize chatBgColor;
@synthesize messageColorMe;
@synthesize messageColorReply;
@synthesize rootPath;
Expand Down
5 changes: 5 additions & 0 deletions ChatSDKUI/Classes/Components/Chat View/BChatViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ -(instancetype) initWithThread: (id<PThread>) 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];

Expand Down
4 changes: 4 additions & 0 deletions ChatSDKUI/Classes/Components/SDK/ElmChatViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ -(instancetype) initWithDelegate: (id<ElmChatViewDelegate>) 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)];
Expand Down