diff --git a/Classes/Issues/IssuesViewController.swift b/Classes/Issues/IssuesViewController.swift index b6a06b00..0f170380 100644 --- a/Classes/Issues/IssuesViewController.swift +++ b/Classes/Issues/IssuesViewController.swift @@ -87,10 +87,8 @@ IssueNeckLoadSectionControllerDelegate { collectionView?.keyboardDismissMode = .interactive - NotificationCenter.default.addObserver(self, selector: #selector(IssuesViewController.onKeyboardChange(notification:)), name: NSNotification.Name.UIKeyboardDidChangeFrame, object: nil) - // displayed once an add comment client is created (requires a gql subject id) - setTextInputbarHidden(true, animated: false) +// setTextInputbarHidden(true, animated: false) let rightItem = UIBarButtonItem( image: UIImage(named: "bullets-hollow"), @@ -102,10 +100,6 @@ IssueNeckLoadSectionControllerDelegate { navigationItem.rightBarButtonItem = rightItem } - func onKeyboardChange(notification: NSNotification) { - print(notification.userInfo) - } - override func viewWillLayoutSubviews() { super.viewWillLayoutSubviews() feed.viewWillLayoutSubviews(view: view) diff --git a/Freetime.xcodeproj/project.pbxproj b/Freetime.xcodeproj/project.pbxproj index b04a40fd..2a591e82 100644 --- a/Freetime.xcodeproj/project.pbxproj +++ b/Freetime.xcodeproj/project.pbxproj @@ -75,6 +75,9 @@ 292FCB211EDFCF870026635E /* IssueReactionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 292FCB201EDFCF870026635E /* IssueReactionCell.swift */; }; 292FCB2C1EE054900026635E /* API.swift in Sources */ = {isa = PBXBuildFile; fileRef = 292FCB2B1EE054900026635E /* API.swift */; }; 292FF8A71F2EA860009E63F7 /* Strings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29C167661ECA005500439D62 /* Strings.swift */; }; + 292FF8A81F2FC3E5009E63F7 /* authorizations.json in Resources */ = {isa = PBXBuildFile; fileRef = 296CD82C1F01476D001190B9 /* authorizations.json */; }; + 292FF8A91F2FC3E5009E63F7 /* _graphql.json in Resources */ = {isa = PBXBuildFile; fileRef = 296CD8241F014130001190B9 /* _graphql.json */; }; + 292FF8AA1F2FC3E5009E63F7 /* _notifications.json in Resources */ = {isa = PBXBuildFile; fileRef = 296CD8251F014130001190B9 /* _notifications.json */; }; 29316DB51ECC7DEB007CAE3F /* ButtonCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29316DB41ECC7DEB007CAE3F /* ButtonCell.swift */; }; 29316DBD1ECC8970007CAE3F /* GithubUserSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29316DBC1ECC8970007CAE3F /* GithubUserSession.swift */; }; 29316DBF1ECC95DB007CAE3F /* RootViewControllers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29316DBE1ECC95DB007CAE3F /* RootViewControllers.swift */; }; @@ -1289,11 +1292,14 @@ files = ( 29416BF91F1138B700D03E1A /* OauthLogin.storyboard in Resources */, 297AE8821EC0D5C200B44A1F /* LaunchScreen.storyboard in Resources */, + 292FF8A91F2FC3E5009E63F7 /* _graphql.json in Resources */, 98F0A0431F27BC4B0062A2CA /* emoji.json in Resources */, 297AE8811EC0D5C200B44A1F /* Assets.xcassets in Resources */, 29A195071EC7601000C3E289 /* Localizable.stringsdict in Resources */, + 292FF8AA1F2FC3E5009E63F7 /* _notifications.json in Resources */, 984D9CA91F212ADF00ECEA7F /* Settings.bundle in Resources */, 297AE8831EC0D5C200B44A1F /* Main.storyboard in Resources */, + 292FF8A81F2FC3E5009E63F7 /* authorizations.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Resources/Info.plist b/Resources/Info.plist index 62f33ec5..f5691bba 100644 --- a/Resources/Info.plist +++ b/Resources/Info.plist @@ -32,7 +32,7 @@ CFBundleVersion - 1180 + 1193 ITSAppUsesNonExemptEncryption LSApplicationQueriesSchemes diff --git a/Sample/Samples.swift b/Sample/Samples.swift index a3336966..55337feb 100644 --- a/Sample/Samples.swift +++ b/Sample/Samples.swift @@ -9,7 +9,7 @@ import Foundation func runningInSample() -> Bool { - return Bundle.main.object(forInfoDictionaryKey: "RUN_AS_SAMPLE") as? Bool ?? false + return true || Bundle.main.object(forInfoDictionaryKey: "RUN_AS_SAMPLE") as? Bool ?? false } func sampleUserSession() -> GithubUserSession? { diff --git a/SlackTextViewController/Source/SLKInputAccessoryView.h b/SlackTextViewController/Source/SLKInputAccessoryView.h index a7cb20e2..cb22d6d4 100755 --- a/SlackTextViewController/Source/SLKInputAccessoryView.h +++ b/SlackTextViewController/Source/SLKInputAccessoryView.h @@ -8,9 +8,19 @@ #import +@class SLKInputAccessoryView; + +@protocol SLKInputAccessoryViewFrameDelegate + +- (void)accessoryView:(SLKInputAccessoryView *)accessoryView didChangeFrame:(CGRect)frame; + +@end + @interface SLKInputAccessoryView : UIView /* The system keyboard view used as reference. */ @property (nonatomic, weak, readonly) UIView *_Nullable keyboardViewProxy; -@end \ No newline at end of file +@property (nonatomic, weak) id frameDelegate; + +@end diff --git a/SlackTextViewController/Source/SLKInputAccessoryView.m b/SlackTextViewController/Source/SLKInputAccessoryView.m index d4b08105..a538b513 100755 --- a/SlackTextViewController/Source/SLKInputAccessoryView.m +++ b/SlackTextViewController/Source/SLKInputAccessoryView.m @@ -10,19 +10,41 @@ #import "SLKUIConstants.h" -@implementation SLKInputAccessoryView +@implementation SLKInputAccessoryView { + __weak id _kb; +} -//#pragma mark - Super Overrides -// -//- (void)willMoveToSuperview:(UIView *)newSuperview -//{ -// if (!SLK_IS_IOS9_AND_HIGHER) { -// _keyboardViewProxy = newSuperview; -// } -//} +#pragma mark - Super Overrides -- (UIView *)keyboardViewProxy { +- (void)dealloc +{ + [_kb removeObserver:self forKeyPath:@"center"]; +} + +- (void)willMoveToSuperview:(UIView *)newSuperview +{ + [super willMoveToSuperview:newSuperview]; + + if (_kb != newSuperview) { + [_kb removeObserver:self forKeyPath:@"center"]; + } + + _kb = newSuperview; + [newSuperview addObserver:self forKeyPath:@"center" options:NSKeyValueObservingOptionNew context:nil]; +} + +- (UIView *)keyboardViewProxy +{ return self.superview; } +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context +{ + if ([keyPath isEqualToString:@"center"]) { + [self.frameDelegate accessoryView:self didChangeFrame:self.superview.frame]; + } else { + [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; + } +} + @end diff --git a/SlackTextViewController/Source/SLKTextViewController.m b/SlackTextViewController/Source/SLKTextViewController.m index 96b8ffa7..ea52b2d2 100755 --- a/SlackTextViewController/Source/SLKTextViewController.m +++ b/SlackTextViewController/Source/SLKTextViewController.m @@ -25,6 +25,7 @@ NSString * const SLKKeyboardDidHideNotification = @"SLKKeyboardDidHideNoti CGFloat const SLKAutoCompletionViewDefaultHeight = 140.0; @interface SLKTextViewController () + { CGPoint _scrollViewOffsetBeforeDragging; CGFloat _keyboardHeightBeforeDragging; @@ -293,7 +294,7 @@ CGFloat const SLKAutoCompletionViewDefaultHeight = 140.0; #endif CGRect rect = CGRectZero; - rect.size = CGSizeMake(CGRectGetWidth(self.view.frame), 0.5); + rect.size = CGSizeMake(CGRectGetWidth(self.view.frame), 1.0 / [UIScreen mainScreen].scale); _autoCompletionHairline = [[UIView alloc] initWithFrame:rect]; _autoCompletionHairline.autoresizingMask = UIViewAutoresizingFlexibleWidth; @@ -307,6 +308,7 @@ CGFloat const SLKAutoCompletionViewDefaultHeight = 140.0; { if (!_textInputbar) { _textInputbar = [[SLKTextInputbar alloc] initWithTextViewClass:self.textViewClass]; + _textInputbar.inputAccessoryView.frameDelegate = self; _textInputbar.translatesAutoresizingMaskIntoConstraints = NO; [_textInputbar.leftButton addTarget:self action:@selector(didPressLeftButton:) forControlEvents:UIControlEventTouchUpInside]; @@ -919,6 +921,8 @@ CGFloat const SLKAutoCompletionViewDefaultHeight = 140.0; } - (void)slk_handlePanGestureRecognizer:(UIPanGestureRecognizer *)gesture { + return; + UIView *kb = _textInputbar.inputAccessoryView.superview; if (kb == nil) { @@ -2442,4 +2446,12 @@ CGFloat const SLKAutoCompletionViewDefaultHeight = 140.0; [_typingIndicatorProxyView removeObserver:self forKeyPath:@"visible"]; } +#pragma mark - SLKInputAccessoryViewFrameDelegate + +- (void)accessoryView:(SLKInputAccessoryView *)accessoryView didChangeFrame:(CGRect)frame { + self.keyboardHC.constant = [self slk_appropriateKeyboardHeightFromRect:frame]; + self.scrollViewHC.constant = [self slk_appropriateScrollViewHeight]; + [self.view layoutIfNeeded]; +} + @end