Skip to content
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

Add customization for chat screen's textview placeholder and font #428

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
5 changes: 5 additions & 0 deletions ChatSDKCore/Classes/Session/BConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ typedef enum {
@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;
Expand Down
2 changes: 2 additions & 0 deletions ChatSDKCore/Classes/Session/BConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ @implementation BConfiguration

@synthesize messageColorMe;
@synthesize messageColorReply;
@synthesize chatTextViewPlaceholder;
@synthesize chatTextViewFont;
@synthesize rootPath;
@synthesize appBadgeEnabled;
@synthesize defaultUserNamePrefix;
Expand Down
13 changes: 13 additions & 0 deletions ChatSDKUI/Classes/Components/Chat View/BTextInputView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -125,6 +129,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]];

Expand Down Expand Up @@ -270,6 +277,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];
}

Expand Down Expand Up @@ -305,6 +315,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]
Expand Down