mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-18 15:38:28 +02:00
Merge MatrixKit develop with commit hash: b85b736313bec0592bd1cabc68035d97f5331137
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
Copyright 2015 OpenMarket Ltd
|
||||
Copyright 2017 Vector Creations Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "MXKRoomInputToolbarViewWithSimpleTextView.h"
|
||||
|
||||
@implementation MXKRoomInputToolbarViewWithSimpleTextView
|
||||
|
||||
+ (UINib *)nib
|
||||
{
|
||||
return [UINib nibWithNibName:NSStringFromClass([MXKRoomInputToolbarViewWithSimpleTextView class])
|
||||
bundle:[NSBundle bundleForClass:[MXKRoomInputToolbarViewWithSimpleTextView class]]];
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
[super awakeFromNib];
|
||||
|
||||
// Add an accessory view to the text view in order to retrieve keyboard view.
|
||||
inputAccessoryView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
self.messageComposerTextView.inputAccessoryView = self.inputAccessoryView;
|
||||
}
|
||||
|
||||
-(void)customizeViewRendering
|
||||
{
|
||||
[super customizeViewRendering];
|
||||
|
||||
// Set default message composer background color
|
||||
self.messageComposerTextView.backgroundColor = [UIColor whiteColor];
|
||||
}
|
||||
|
||||
- (NSString*)textMessage
|
||||
{
|
||||
return _messageComposerTextView.text;
|
||||
}
|
||||
|
||||
- (void)setTextMessage:(NSString *)textMessage
|
||||
{
|
||||
_messageComposerTextView.text = textMessage;
|
||||
self.rightInputToolbarButton.enabled = textMessage.length;
|
||||
}
|
||||
|
||||
- (void)pasteText:(NSString *)text
|
||||
{
|
||||
self.textMessage = [_messageComposerTextView.text stringByReplacingCharactersInRange:_messageComposerTextView.selectedRange withString:text];
|
||||
}
|
||||
|
||||
- (BOOL)becomeFirstResponder
|
||||
{
|
||||
return [_messageComposerTextView becomeFirstResponder];
|
||||
}
|
||||
|
||||
- (void)dismissKeyboard
|
||||
{
|
||||
if (_messageComposerTextView)
|
||||
{
|
||||
[_messageComposerTextView resignFirstResponder];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UITextViewDelegate
|
||||
|
||||
- (void)textViewDidEndEditing:(UITextView *)textView
|
||||
{
|
||||
if ([self.delegate respondsToSelector:@selector(roomInputToolbarView:isTyping:)])
|
||||
{
|
||||
[self.delegate roomInputToolbarView:self isTyping:NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)textViewDidChange:(UITextView *)textView
|
||||
{
|
||||
NSString *msg = textView.text;
|
||||
|
||||
if (msg.length)
|
||||
{
|
||||
if ([self.delegate respondsToSelector:@selector(roomInputToolbarView:isTyping:)])
|
||||
{
|
||||
[self.delegate roomInputToolbarView:self isTyping:YES];
|
||||
}
|
||||
self.rightInputToolbarButton.enabled = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([self.delegate respondsToSelector:@selector(roomInputToolbarView:isTyping:)])
|
||||
{
|
||||
[self.delegate roomInputToolbarView:self isTyping:NO];
|
||||
}
|
||||
self.rightInputToolbarButton.enabled = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
|
||||
{
|
||||
if (!self.isEditable)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Hanlde here `Done` key pressed
|
||||
if([text isEqualToString:@"\n"])
|
||||
{
|
||||
[textView resignFirstResponder];
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user