mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-05-13 09:56:38 +08:00
better kb dismiss interaction
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1180</string>
|
||||
<string>1193</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSApplicationQueriesSchemes</key>
|
||||
|
||||
@@ -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? {
|
||||
|
||||
@@ -8,9 +8,19 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class SLKInputAccessoryView;
|
||||
|
||||
@protocol SLKInputAccessoryViewFrameDelegate <NSObject>
|
||||
|
||||
- (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
|
||||
@property (nonatomic, weak) id<SLKInputAccessoryViewFrameDelegate> frameDelegate;
|
||||
|
||||
@end
|
||||
|
||||
@@ -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<NSKeyValueChangeKey,id> *)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
|
||||
|
||||
@@ -25,6 +25,7 @@ NSString * const SLKKeyboardDidHideNotification = @"SLKKeyboardDidHideNoti
|
||||
CGFloat const SLKAutoCompletionViewDefaultHeight = 140.0;
|
||||
|
||||
@interface SLKTextViewController ()
|
||||
<SLKInputAccessoryViewFrameDelegate>
|
||||
{
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user