Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Fixing the text input not being interactive since iOS 11 (slackhq#624)
Browse files Browse the repository at this point in the history
* Fixed Xcode warnings + deprecating -shouldProcessTextForAutoCompletion:

* Making SLKTextInputbar a UIView subclass instead, with its own hairline layout.
This fixes slackhq#604 rendering SLKTVC useless in iOS 11 since UIToolBar's view hierarchy has drastically changed since, conflicting with the internal outlets of SLKTextInputbar

* Changelog
  • Loading branch information
Ignacio Romero Zurbuchen authored and Jakub Petrík committed Sep 25, 2017
1 parent 3032307 commit d670f73
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 25 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## Version 1.9.6

##### Hot Fixes & Enhancements:
- Fixed the text input not being interactive on iOS. Making `SLKTextInputbar` a UIView subclass instead of `UIToolbar`.

##### Deprecation:
- Deprecated `-shouldProcessTextForAutoCompletion:` in favor of `-shouldProcessTextForAutoCompletion`


## [Version 1.9.5](https://github.com/slackhq/SlackTextViewController/releases/tag/v1.9.5)

##### Features:
Expand Down
4 changes: 2 additions & 2 deletions Examples/Messenger-Shared/MessageViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,9 @@ - (BOOL)canShowTypingIndicator
#endif
}

- (BOOL)shouldProcessTextForAutoCompletion:(NSString *)text
- (BOOL)shouldProcessTextForAutoCompletion
{
return [super shouldProcessTextForAutoCompletion:text];
return [super shouldProcessTextForAutoCompletion];
}

- (BOOL)shouldDisableTypingSuggestionForAutoCompletion
Expand Down
14 changes: 13 additions & 1 deletion Examples/Messenger.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Slack Technologies, Inc.";
TargetAttributes = {
4F3EDB48199ED00F004C15D6 = {
Expand Down Expand Up @@ -743,14 +743,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -788,14 +794,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down
8 changes: 7 additions & 1 deletion Examples/Messenger.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 28 additions & 7 deletions Examples/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Source/SLKTextInputbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef NS_ENUM(NSUInteger, SLKCounterPosition) {
NS_ASSUME_NONNULL_BEGIN

/** @name A custom tool bar encapsulating messaging controls. */
@interface SLKTextInputbar : UIToolbar
@interface SLKTextInputbar : UIView

/** The centered text input view.
The maximum number of lines is configured by default, to best fit each devices dimensions.
Expand Down
36 changes: 31 additions & 5 deletions Source/SLKTextInputbar.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

@interface SLKTextInputbar ()

@property (nonatomic, strong) UIView *hairlineView;

@property (nonatomic, strong) NSLayoutConstraint *textViewBottomMarginC;
@property (nonatomic, strong) NSLayoutConstraint *leftMarginWC;
@property (nonatomic, strong) NSLayoutConstraint *rightButtonWC;
Expand Down Expand Up @@ -75,11 +77,15 @@ - (void)slk_commonInit
self.autoHideRightButton = YES;
self.contentInset = UIEdgeInsetsMake(5.0, 8.0, 54.0, 8.0);

[self addSubview:self.bottomButtonsStackView];
[self addSubview:self.editorContentView];
[self addSubview:self.leftButton];
[self addSubview:self.rightButton];
[self addSubview:self.textView];
[self addSubview:self.charCountLabel];
[self addSubview:self.bottomButtonsStackView];

[self addSubview:self.contentView];
[self addSubview:self.hairlineView];

[self slk_setupViewConstraints];
[self slk_updateConstraintConstants];

Expand Down Expand Up @@ -137,6 +143,27 @@ - (SLKTextView *)textView
return _textView;
}

- (UIView *)hairlineView
{
if (!_hairlineView) {
_hairlineView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, [UIScreen mainScreen].bounds.size.width, 0.5)];
_hairlineView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleBottomMargin;
_hairlineView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3];
}
return _hairlineView;
}

- (UIView *)contentView
{
if (!_contentView) {
_contentView = [UIView new];
_contentView.translatesAutoresizingMaskIntoConstraints = NO;
_contentView.backgroundColor = [UIColor clearColor];
_contentView.clipsToBounds = YES;
}
return _contentView;
}

- (SLKInputAccessoryView *)inputAccessoryView
{
if (!_inputAccessoryView) {
Expand Down Expand Up @@ -284,6 +311,7 @@ - (NSUInteger)slk_defaultNumberOfLines
- (void)setBackgroundColor:(UIColor *)color
{
self.barTintColor = color;
self.editorContentView.backgroundColor = color;
}

- (void)setAutoHideRightButton:(BOOL)hide
Expand Down Expand Up @@ -478,11 +506,9 @@ - (void)slk_setupViewConstraints
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[textView(0@999)]-(0)-|" options:0 metrics:metrics views:views]];
[[self.bottomButtonsStackView.leftAnchor constraintEqualToAnchor:self.textView.leftAnchor] setActive: YES];
[[self.bottomButtonsStackView.bottomAnchor constraintEqualToAnchor:self.bottomAnchor] setActive:YES];

self.textViewBottomMarginC = [self slk_constraintForAttribute:NSLayoutAttributeBottom firstItem:self secondItem:self.textView];

self.textViewBottomMarginC = [self slk_constraintForAttribute:NSLayoutAttributeBottom firstItem:self secondItem:self.textView];
self.leftMarginWC = [[self slk_constraintsForAttribute:NSLayoutAttributeLeading] firstObject];

self.rightButtonWC = [self slk_constraintForAttribute:NSLayoutAttributeWidth firstItem:self.rightButton secondItem:nil];
self.rightMarginWC = [[self slk_constraintsForAttribute:NSLayoutAttributeTrailing] firstObject];
}
Expand Down
1 change: 0 additions & 1 deletion Source/SLKTextViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ NS_CLASS_AVAILABLE_IOS(7_0) @interface SLKTextViewController : UIViewController
@return YES if the controller is allowed to process the text for auto-completion.
*/
- (BOOL)shouldProcessTextForAutoCompletion;
- (BOOL)shouldProcessTextForAutoCompletion:(NSString *)text DEPRECATED_MSG_ATTRIBUTE("Use -shouldProcessTextForAutoCompletion instead.");

/**
During text autocompletion, by default, auto-correction and spell checking are disabled.
Expand Down
9 changes: 2 additions & 7 deletions Source/SLKTextViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ - (void)setTextInputbarHidden:(BOOL)hidden animated:(BOOL)animated

__weak typeof(self) weakSelf = self;

void (^animations)() = ^void(){
void (^animations)(void) = ^void(){

weakSelf.textInputbarHC.constant = hidden ? 0.0 : weakSelf.textInputbar.appropriateHeight;

Expand Down Expand Up @@ -1354,7 +1354,7 @@ - (void)slk_willShowOrHideKeyboard:(NSNotification *)notification
CGRect beginFrame = [notification.userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGRect endFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];

void (^animations)() = ^void() {
void (^animations)(void) = ^void() {
// Scrolls to bottom only if the keyboard is about to show.
if (self.shouldScrollToBottomAfterKeyboardShows && self.keyboardStatus == SLKKeyboardStatusWillShow) {
if (self.isInverted) {
Expand Down Expand Up @@ -1583,11 +1583,6 @@ - (void)registerPrefixesForAutoCompletion:(NSArray <NSString *> *)prefixes
_registeredPrefixes = [NSSet setWithSet:set];
}

- (BOOL)shouldProcessTextForAutoCompletion:(NSString *)text
{
return [self shouldProcessTextForAutoCompletion];
}

- (BOOL)shouldProcessTextForAutoCompletion
{
if (!_registeredPrefixes || _registeredPrefixes.count == 0) {
Expand Down

0 comments on commit d670f73

Please sign in to comment.