Commit de43b158 authored by Ben Jackson's avatar Ben Jackson
Browse files

Update SlackTextViewController to latest

parent 7ec927a0
......@@ -8,7 +8,7 @@ target 'Gitter' do
pod 'ISO8601DateFormatter', '0.6'
pod 'CrittercismSDK', '~> 5.5.5'
pod 'SDWebImage', '~>3.7.6'
pod 'SlackTextViewController', '1.9.3'
pod 'SlackTextViewController', '1.9.6'
target 'GitterTests' do
inherit! :search_paths
......
......@@ -8,7 +8,7 @@ PODS:
- SDWebImage (3.7.6):
- SDWebImage/Core (= 3.7.6)
- SDWebImage/Core (3.7.6)
- SlackTextViewController (1.9.3)
- SlackTextViewController (1.9.6)
DEPENDENCIES:
- CrittercismSDK (~> 5.5.5)
......@@ -17,10 +17,10 @@ DEPENDENCIES:
- LibComponentLogging-qlog (~> 1.1.1)
- "NSData+Base64 (= 1.0.0)"
- SDWebImage (~> 3.7.6)
- SlackTextViewController (= 1.9.3)
- SlackTextViewController (= 1.9.6)
SPEC REPOS:
https://github.com/cocoapods/specs.git:
trunk:
- CrittercismSDK
- ISO8601DateFormatter
- LibComponentLogging-Core
......@@ -36,8 +36,8 @@ SPEC CHECKSUMS:
LibComponentLogging-qlog: 60ef1090df3d98c575c1c8185ab3f52e67ef977c
"NSData+Base64": 4e84902c4db907a15673474677e57763ef3903e4
SDWebImage: c325cf02c30337336b95beff20a13df489ec0ec9
SlackTextViewController: bd2a34c188d4f7dec93cf42388f38551263fac82
SlackTextViewController: b854e62c1c156336bc4fd409c6ca79b5773e8f9d
PODFILE CHECKSUM: 1b841d9b04bbe4747a3a78a5cb6bf75daf7845ab
PODFILE CHECKSUM: 3ea346ec0a5cf9b66823985e3704c0e0adf951f2
COCOAPODS: 1.5.3
COCOAPODS: 1.8.1
......@@ -8,7 +8,7 @@ PODS:
- SDWebImage (3.7.6):
- SDWebImage/Core (= 3.7.6)
- SDWebImage/Core (3.7.6)
- SlackTextViewController (1.9.3)
- SlackTextViewController (1.9.6)
DEPENDENCIES:
- CrittercismSDK (~> 5.5.5)
......@@ -17,10 +17,10 @@ DEPENDENCIES:
- LibComponentLogging-qlog (~> 1.1.1)
- "NSData+Base64 (= 1.0.0)"
- SDWebImage (~> 3.7.6)
- SlackTextViewController (= 1.9.3)
- SlackTextViewController (= 1.9.6)
SPEC REPOS:
https://github.com/cocoapods/specs.git:
trunk:
- CrittercismSDK
- ISO8601DateFormatter
- LibComponentLogging-Core
......@@ -36,8 +36,8 @@ SPEC CHECKSUMS:
LibComponentLogging-qlog: 60ef1090df3d98c575c1c8185ab3f52e67ef977c
"NSData+Base64": 4e84902c4db907a15673474677e57763ef3903e4
SDWebImage: c325cf02c30337336b95beff20a13df489ec0ec9
SlackTextViewController: bd2a34c188d4f7dec93cf42388f38551263fac82
SlackTextViewController: b854e62c1c156336bc4fd409c6ca79b5773e8f9d
PODFILE CHECKSUM: 1b841d9b04bbe4747a3a78a5cb6bf75daf7845ab
PODFILE CHECKSUM: 3ea346ec0a5cf9b66823985e3704c0e0adf951f2
COCOAPODS: 1.5.3
COCOAPODS: 1.8.1
This source diff could not be displayed because it is too large. You can view the blob instead.
File mode changed from 100755 to 100644
#SlackTextViewController
# SlackTextViewController
**IMPORTANT NOTICE: Please update to >= `1.9` to avoid any risk of app rejection.
More details in [#361](https://github.com/slackhq/SlackTextViewController/issues/361)**
[![License](https://img.shields.io/badge/license-apache%202.0-blue.svg?style=flat-square)](http://opensource.org/licenses/Apache2.0)
[![Pod Version](https://img.shields.io/cocoapods/v/SlackTextViewController.svg?style=flat-square)](http://cocoadocs.org/docsets/SlackTextViewController/1.9/)
[![Carthage compatible](https://img.shields.io/badge/carthage-compatible-F5B369.svg?style=flat-square)](https://github.com/Carthage/Carthage)
[![Build Status](https://img.shields.io/travis/slackhq/SlackTextViewController.svg?style=flat-square)](https://travis-ci.org/slackhq/SlackTextViewController)
[![License](http://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT)
[![Pod Version](https://img.shields.io/cocoapods/v/SlackTextViewController.svg)](http://cocoadocs.org/docsets/SlackTextViewController/1.9/)
[![Carthage compatible](https://img.shields.io/badge/carthage-compatible-F5B369.svg)](https://github.com/Carthage/Carthage)
[![BuddyBuild](https://dashboard.buddybuild.com/api/statusImage?appID=59f2234423c5f600018bb24b&branch=master&build=latest)](https://dashboard.buddybuild.com/apps/59f2234423c5f600018bb24b/build/latest?branch=master)
A drop-in UIViewController subclass with a growing text input view and other useful messaging features. Meant to be a replacement for UITableViewController & UICollectionViewController.
......@@ -17,7 +17,7 @@ This library is used in Slack's iOS app. It was built to fit our needs, but is f
## Feature List
### Core
- Works out of the box with [UITableView or UICollectionView or UIScrollView](https://github.com/slackhq/SlackTextViewController/tree/swift-example#subclassing)
- Works out of the box with [UITableView or UICollectionView or UIScrollView](https://github.com/slackhq/SlackTextViewController#subclassing)
- [Growing Text View](https://github.com/slackhq/SlackTextViewController#growing-text-view), with line count limit support
- Flexible UI built with Auto Layout
- Customizable: provides left and right button, and toolbar outlets
......@@ -42,7 +42,7 @@ This library is used in Slack's iOS app. It was built to fit our needs, but is f
### Compatibility
- Carthage & CocoaPods
- Swift: [A sample project is available in a different branch] (https://github.com/slackhq/SlackTextViewController/tree/swift-example)
- Objective-C & Swift
- iOS 7, 8 & 9
- iPhone & iPad
- [Storyboard](https://github.com/slackhq/SlackTextViewController#storyboard)
......@@ -70,9 +70,9 @@ There are two ways to do this:
- or compile the project located in `Builder/SlackTextViewController.xcodeproj` to create a `SlackTextViewController.framework` package. You could also [link the library into your project](https://developer.apple.com/library/ios/recipes/xcode_help-project_editor/Articles/AddingaLibrarytoaTarget.html#//apple_ref/doc/uid/TP40010155-CH17-SW1).
##How to use
## How to use
###Subclassing
### Subclassing
`SLKTextViewController` is meant to be subclassed, like you would normally do with UITableViewController or UICollectionViewController or UIScrollView. This pattern is a convenient way of extending UIViewController. SlackTextViewController manages a lot behind the scenes while still providing the ability to add custom behaviours. You may override methods, and decide to call super and perform additional logic, or not to call super and override default logic.
Start by creating a new subclass of `SLKTextViewController`.
......@@ -111,7 +111,7 @@ Protocols like `UITableViewDelegate` and `UITableViewDataSource` are already set
Calling `[super init]` will call `[super initWithTableViewStyle:UITableViewStylePlain]` by default.
###Storyboard
### Storyboard
When using SlackTextViewController with storyboards, instead of overriding the traditional `initWithCoder:` you will need to override any of the two custom methods below. This approach helps preserving the exact same features from the programatic approach, but also limits the edition of the nib of your `SLKTextViewController` subclass since it doesn't layout subviews from the nib (subviews are still initialized and layed out programatically).
......@@ -145,19 +145,18 @@ override class func collectionViewLayoutForCoder(decoder: NSCoder) -> UICollecti
}
```
###Sample Project
### Sample Project
Check out the sample project, everything is demo'd there.
There are 2 main examples (different targets) for testing the programatic and storyboard approaches. Most of the features are implemented for you to quickly start using them.
There are 2 main examples (different targets) for testing the programatic and storyboard approaches, and a Swift example. Most of the features are implemented for you to quickly start using them.
A CollectionView example, using Swift, is in progress on the `swift-example` branch. The idea with this project is to build a custom collection view layout allowing to display cells from the bottom (currently working but needs serious tweaks to make it perfect).
Feel free to contribute!
##Features
## Features
###Growing Text View
### Growing Text View
![Growing](Screenshots/screenshot_auto-expanding.png)
......@@ -171,7 +170,7 @@ By default, the number of lines is set to best fit each device dimensions:
On iPhone devices, in landscape orientation, the maximum number of lines is changed to fit the available space.
###Inverted Mode
### Inverted Mode
Some layouts may require to show from bottom to top and new subviews are inserted from the bottom. To enable this, you must use the `inverted` flag property (default is `YES`/`true`). This will actually invert the entire ScrollView object. Make sure to apply the same transformation to every subview. In the case of UITableView, the best place for adjusting the transformation is in its data source methods like:
##### Obj-C
......@@ -186,15 +185,14 @@ Some layouts may require to show from bottom to top and new subviews are inserte
```swift
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if let cell = tableView.dequeueReusableCellWithIdentifier(kAutoCompletionCellIdentifier) {
cell.textLabel!.text = self.searchResult[indexPath.row]
return cell
if let cell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) {
cell.transform = self.tableView.transform
}
}
```
###Autocompletion
### Autocompletion
We use autocompletion for many things: names, channels, emoji, and more.
......@@ -305,7 +303,7 @@ The autocompletion view will automatically be dismissed and the chosen string wi
You can always call `cancelAutoCompletion` to exit the autocompletion mode and refresh the UI.
###Edit Mode
### Edit Mode
![Edit Mode](Screenshots/screenshot_edit-mode.png)
......@@ -354,7 +352,7 @@ Notice that you must call `super` at some point, so the text input exits the edi
Use the `editing` property to know if the editing mode is on.
###Markdown Formatting
### Markdown Formatting
![Markdown Formatting](Screenshots/screenshot_markdown-formatting.png)
......@@ -421,7 +419,7 @@ In this other method implementation, we don't want to allow auto-completion for
```
###Typing Indicator
### Typing Indicator
![Typing Indicator](Screenshots/screenshot_typing-indicator.png)
......@@ -459,12 +457,12 @@ You can also dismiss it by calling:
self.typingIndicatorView?.dismissIndicator()
```
###Panning Gesture
### Panning Gesture
Dismissing the keyboard with a panning gesture is enabled by default with the `keyboardPanningEnabled` property. You can always disable it if you'd like. You can extend the `verticalPanGesture` behaviors with the `UIGestureRecognizerDelegate` methods.
###Hideable TextInputbar
### Hideable TextInputbar
Sometimes you may need to hide the text input bar.
Very similar to `UINavigationViewController`'s API, simply do:
......@@ -478,7 +476,7 @@ self.setTextInputbarHidden(true, animated: true)
```
###Shake Gesture
### Shake Gesture
![Shake Gesture](Screenshots/screenshot_shake-undo.png)
......@@ -489,7 +487,7 @@ You can optionally override `willRequestUndo`, to implement your UI to ask the u
If you don't override `willRequestUndo` and `undoShakingEnabled` is set to `YES`/`true`, a system alert will be shown.
###External Keyboard
### External Keyboard
There a few basic key commands enabled by default:
- cmd + z -> undo
......@@ -531,14 +529,14 @@ override var keyCommands: [UIKeyCommand]? {
There are also a set of useful flags for keyboard special detections such as `isExternalKeyboardDetected`, `isKeyboardUndocked`, `typingSuggestionEnabled` and `isTrackpadEnabled` (iOS 9 only)
###Dynamic Type
### Dynamic Type
Dynamic Type is enabled by default with the `dynamicTypeEnabled` property. You can always disable it if you'd like, but the text input bar would still adjust to best fit the font size of the text view.
![Dynamic-Type](Screenshots/screenshot_dynamic-type.png)
###Xcode Templates
### Xcode Templates
![Template](Screenshots/screenshot_template.png)
......
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
......@@ -34,10 +34,13 @@ NS_ASSUME_NONNULL_BEGIN
For iPhone 5 & 6 (>=568pts): 6 lines
For iPad (>=768pts): 8 lines
*/
@property (nonatomic, strong) SLKTextView *textView;
@property (nonatomic, readonly, strong) SLKTextView *textView;
/** Optional view to host outlets under the text view, adjusting its height based on its subviews. Non-visible by default. Subviews' layout should be configured using auto-layout as well. */
@property (nonatomic, readonly, strong) UIView *contentView;
/** The custom input accessory view, used as empty achor view to detect the keyboard frame. */
@property (nonatomic, strong) SLKInputAccessoryView *inputAccessoryView;
@property (nonatomic, readonly, strong) SLKInputAccessoryView *inputAccessoryView;
/** The left action button action. */
@property (nonatomic, strong) UIButton *leftButton;
......
......@@ -19,10 +19,12 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
@interface SLKTextInputbar ()
@property (nonatomic, strong) NSLayoutConstraint *textViewBottomMarginC;
@property (nonatomic, strong) NSLayoutConstraint *contentViewHC;
@property (nonatomic, strong) NSLayoutConstraint *leftButtonWC;
@property (nonatomic, strong) NSLayoutConstraint *leftButtonHC;
@property (nonatomic, strong) NSLayoutConstraint *leftMarginWC;
@property (nonatomic, strong) NSLayoutConstraint *bottomMarginWC;
@property (nonatomic, strong) NSLayoutConstraint *leftButtonBottomMarginC;
@property (nonatomic, strong) NSLayoutConstraint *rightButtonWC;
@property (nonatomic, strong) NSLayoutConstraint *rightMarginWC;
@property (nonatomic, strong) NSLayoutConstraint *rightButtonTopMarginC;
......@@ -41,6 +43,9 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
@end
@implementation SLKTextInputbar
@synthesize textView = _textView;
@synthesize contentView = _contentView;
@synthesize inputAccessoryView = _inputAccessoryView;
@synthesize hidden = _hidden;
#pragma mark - Initialization
......@@ -78,13 +83,18 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
self.autoHideRightButton = YES;
self.editorContentViewHeight = 38.0;
self.contentInset = UIEdgeInsetsMake(5.0, 8.0, 5.0, 8.0);
// Since iOS 11, it is required to call -layoutSubviews before adding custom subviews
// so private UIToolbar subviews don't interfere on the touch hierarchy
[self layoutSubviews];
[self addSubview:self.editorContentView];
[self addSubview:self.leftButton];
[self addSubview:self.rightButton];
[self addSubview:self.textView];
[self addSubview:self.charCountLabel];
[self addSubview:self.contentView];
[self slk_setupViewConstraints];
[self slk_updateConstraintConstants];
......@@ -133,9 +143,7 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
_textView.translatesAutoresizingMaskIntoConstraints = NO;
_textView.font = [UIFont systemFontOfSize:15.0];
_textView.maxNumberOfLines = [self slk_defaultNumberOfLines];
_textView.typingSuggestionEnabled = YES;
_textView.autocapitalizationType = UITextAutocapitalizationTypeSentences;
_textView.keyboardType = UIKeyboardTypeTwitter;
_textView.returnKeyType = UIReturnKeyDefault;
_textView.enablesReturnKeyAutomatically = YES;
......@@ -148,6 +156,17 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
return _textView;
}
- (UIView *)contentView
{
if (!_contentView) {
_contentView = [UIView new];
_contentView.translatesAutoresizingMaskIntoConstraints = NO;
_contentView.backgroundColor = [UIColor clearColor];
_contentView.clipsToBounds = YES;
}
return _contentView;
}
- (SLKInputAccessoryView *)inputAccessoryView
{
if (!_inputAccessoryView) {
......@@ -282,10 +301,11 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
- (CGFloat)minimumInputbarHeight
{
CGFloat minimumTextViewHeight = self.textView.intrinsicContentSize.height;
minimumTextViewHeight += self.contentInset.top + self.contentInset.bottom;
CGFloat minimumHeight = self.textView.intrinsicContentSize.height;
minimumHeight += self.contentInset.top;
minimumHeight += self.slk_bottomMargin;
return minimumTextViewHeight;
return minimumHeight;
}
- (CGFloat)appropriateHeight
......@@ -314,24 +334,42 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
return roundf(height);
}
- (BOOL)limitExceeded
{
NSString *text = [self.textView.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (self.maxCharCount > 0 && text.length > self.maxCharCount) {
return YES;
}
return NO;
}
- (CGFloat)slk_inputBarHeightForLines:(NSUInteger)numberOfLines
{
CGFloat height = self.textView.intrinsicContentSize.height;
height -= self.textView.font.lineHeight;
height += roundf(self.textView.font.lineHeight*numberOfLines);
height += self.contentInset.top + self.contentInset.bottom;
height += self.contentInset.top;
height += self.slk_bottomMargin;
return height;
}
- (BOOL)limitExceeded
- (CGFloat)slk_bottomMargin
{
NSString *text = [self.textView.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
CGFloat margin = self.contentInset.bottom;
margin += self.slk_contentViewHeight;
if (self.maxCharCount > 0 && text.length > self.maxCharCount) {
return YES;
return margin;
}
- (CGFloat)slk_contentViewHeight
{
if (!self.editing) {
return CGRectGetHeight(self.contentView.frame);
}
return NO;
return 0.0;
}
- (CGFloat)slk_appropriateRightButtonWidth
......@@ -375,6 +413,7 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
- (void)setBackgroundColor:(UIColor *)color
{
self.barTintColor = color;
self.editorContentView.backgroundColor = color;
}
......@@ -411,6 +450,7 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
// Add constant values and refresh layout
[self slk_updateConstraintConstants];
[super layoutIfNeeded];
}
......@@ -422,6 +462,11 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
_editing = editing;
_editorContentView.hidden = !editing;
self.contentViewHC.active = editing;
[super setNeedsLayout];
[super layoutIfNeeded];
}
- (void)setHidden:(BOOL)hidden
......@@ -430,6 +475,13 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
// The hidden render state is handled by the view controller.
_hidden = hidden;
if (!self.isEditing) {
self.contentViewHC.active = hidden;
[super setNeedsLayout];
[super layoutIfNeeded];
}
}
- (void)setCounterPosition:(SLKCounterPosition)counterPosition
......@@ -451,7 +503,7 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
};
NSDictionary *metrics = @{@"top" : @(self.contentInset.top),
@"bottom" : @(-self.contentInset.bottom/2.0)
@"bottom" : @(-self.slk_bottomMargin/2.0)
};
// Constraints are different depending of the counter's position type
......@@ -597,12 +649,12 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
NSDictionary *views = @{@"textView": self.textView,
@"leftButton": self.leftButton,
@"rightButton": self.rightButton,
@"contentView": self.editorContentView,
@"charCountLabel": self.charCountLabel
@"editorContentView": self.editorContentView,
@"charCountLabel": self.charCountLabel,
@"contentView": self.contentView,
};
NSDictionary *metrics = @{@"top" : @(self.contentInset.top),
@"bottom" : @(self.contentInset.bottom),
@"left" : @(self.contentInset.left),
@"right" : @(self.contentInset.right),
};
......@@ -611,19 +663,24 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(>=0)-[leftButton(0)]-(0@750)-|" options:0 metrics:metrics views:views]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(>=0)-[rightButton]-(<=0)-|" options:0 metrics:metrics views:views]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(left@250)-[charCountLabel(<=50@1000)]-(right@750)-|" options:0 metrics:metrics views:views]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[contentView(0)]-(<=top)-[textView(0@999)]-(bottom)-|" options:0 metrics:metrics views:views]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[editorContentView(0)]-(<=top)-[textView(0@999)]-(0)-|" options:0 metrics:metrics views:views]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[editorContentView]|" options:0 metrics:metrics views:views]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[contentView]|" options:0 metrics:metrics views:views]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[contentView(0)]|" options:0 metrics:metrics views:views]];
self.textViewBottomMarginC = [self slk_constraintForAttribute:NSLayoutAttributeBottom firstItem:self secondItem:self.textView];
self.editorContentViewHC = [self slk_constraintForAttribute:NSLayoutAttributeHeight firstItem:self.editorContentView secondItem:nil];
self.contentViewHC = [self slk_constraintForAttribute:NSLayoutAttributeHeight firstItem:self.contentView secondItem:nil];;
self.contentViewHC.active = NO; // Disabled by default, so the height is calculated with the height of its subviews
self.leftButtonWC = [self slk_constraintForAttribute:NSLayoutAttributeWidth firstItem:self.leftButton secondItem:nil];
self.leftButtonHC = [self slk_constraintForAttribute:NSLayoutAttributeHeight firstItem:self.leftButton secondItem:nil];
self.leftMarginWC = [self slk_constraintsForAttribute:NSLayoutAttributeLeading][0];
self.bottomMarginWC = [self slk_constraintForAttribute:NSLayoutAttributeBottom firstItem:self secondItem:self.leftButton];
self.leftButtonBottomMarginC = [self slk_constraintForAttribute:NSLayoutAttributeBottom firstItem:self secondItem:self.leftButton];
self.leftMarginWC = [[self slk_constraintsForAttribute:NSLayoutAttributeLeading] firstObject];
self.rightButtonWC = [self slk_constraintForAttribute:NSLayoutAttributeWidth firstItem:self.rightButton secondItem:nil];
self.rightMarginWC = [self slk_constraintsForAttribute:NSLayoutAttributeTrailing][0];
self.rightMarginWC = [[self slk_constraintsForAttribute:NSLayoutAttributeTrailing] firstObject];
self.rightButtonTopMarginC = [self slk_constraintForAttribute:NSLayoutAttributeTop firstItem:self.rightButton secondItem:self];
self.rightButtonBottomMarginC = [self slk_constraintForAttribute:NSLayoutAttributeBottom firstItem:self secondItem:self.rightButton];
......@@ -633,13 +690,16 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
{
CGFloat zero = 0.0;
self.textViewBottomMarginC.constant = self.slk_bottomMargin;
if (self.isEditing)
{
self.editorContentViewHC.constant = self.editorContentViewHeight;
self.leftButtonWC.constant = zero;
self.leftButtonHC.constant = zero;
self.leftMarginWC.constant = zero;
self.bottomMarginWC.constant = zero;
self.leftButtonBottomMarginC.constant = zero;
self.rightButtonWC.constant = zero;
self.rightMarginWC.constant = zero;
}
......@@ -650,7 +710,7 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
if (leftButtonSize.width > 0) {
self.leftButtonHC.constant = roundf(leftButtonSize.height);
self.bottomMarginWC.constant = roundf((self.intrinsicContentSize.height - leftButtonSize.height) / 2.0);
self.leftButtonBottomMarginC.constant = roundf((self.intrinsicContentSize.height - leftButtonSize.height) / 2.0) + self.slk_contentViewHeight / 2.0;
}
self.leftButtonWC.constant = roundf(leftButtonSize.width);
......@@ -659,10 +719,11 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
self.rightButtonWC.constant = [self slk_appropriateRightButtonWidth];
self.rightMarginWC.constant = [self slk_appropriateRightButtonMargin];
CGFloat rightVerMargin = (self.intrinsicContentSize.height - self.rightButton.intrinsicContentSize.height) / 2.0;
CGFloat rightVerMargin = (self.intrinsicContentSize.height - self.slk_contentViewHeight - self.rightButton.intrinsicContentSize.height) / 2.0;
CGFloat rightVerBottomMargin = rightVerMargin + self.slk_contentViewHeight;
self.rightButtonTopMarginC.constant = rightVerMargin;
self.rightButtonBottomMarginC.constant = rightVerMargin;
self.rightButtonBottomMarginC.constant = rightVerBottomMargin;
}
}
......@@ -739,28 +800,6 @@ NSString * const SLKTextInputbarDidMoveNotification = @"SLKTextInputbarDidMove
[self slk_unregisterFrom:self.layer forSelector:@selector(position)];
[self slk_unregisterFrom:self.leftButton.imageView forSelector:@selector(image)];
[self slk_unregisterFrom:self.rightButton.titleLabel forSelector:@selector(font)];
_leftButton = nil;
_rightButton = nil;
_inputAccessoryView = nil;
_textView.delegate = nil;
_textView = nil;
_editorContentView = nil;
_editorTitle = nil;
_editorLeftButton = nil;
_editorRightButton = nil;
_leftButtonWC = nil;
_leftButtonHC = nil;
_leftMarginWC = nil;
_bottomMarginWC = nil;
_rightButtonWC = nil;
_rightMarginWC = nil;
_rightButtonTopMarginC = nil;
_rightButtonBottomMarginC = nil;
_editorContentViewHC = nil;