diff options
author | Vitaly Takmazov | 2021-03-20 12:47:37 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2021-03-20 12:47:37 +0300 |
commit | ae2b92c2876e3c0c8c8266187ad0eb4ae29fe5a8 (patch) | |
tree | 5cfd54aafeecf84d7bd846ab1302a0abd799d06b /Juick | |
parent | 4a892ab5db316d4e90d580d0192c55cd11e452c1 (diff) |
First part of the new chat view keyboard avoiding
Diffstat (limited to 'Juick')
-rw-r--r-- | Juick/Main.storyboard | 1 | ||||
-rw-r--r-- | Juick/ViewControllers/ChatViewController.h | 1 | ||||
-rw-r--r-- | Juick/ViewControllers/ChatViewController.m | 9 | ||||
-rw-r--r-- | Juick/Views/MessageInputView.xib | 18 |
4 files changed, 20 insertions, 9 deletions
diff --git a/Juick/Main.storyboard b/Juick/Main.storyboard index fae7c7e..fd673a0 100644 --- a/Juick/Main.storyboard +++ b/Juick/Main.storyboard @@ -105,6 +105,7 @@ <navigationItem key="navigationItem" id="8cn-fV-rqO"/> <connections> <outlet property="stack" destination="ypj-S8-a0N" id="Ywj-FB-Wqf"/> + <outlet property="stackBottomConstraint" destination="we7-9y-GcE" id="aE6-oF-PQc"/> <outlet property="tableView" destination="XSR-ku-71h" id="dDA-yH-aHj"/> </connections> </viewController> diff --git a/Juick/ViewControllers/ChatViewController.h b/Juick/ViewControllers/ChatViewController.h index f21eb10..f23ecc8 100644 --- a/Juick/ViewControllers/ChatViewController.h +++ b/Juick/ViewControllers/ChatViewController.h @@ -14,6 +14,7 @@ @property(nonatomic, strong) NSMutableArray *messages; @property(nonatomic, strong) NSString *uname; @property (weak, nonatomic) IBOutlet UIStackView *stack; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *stackBottomConstraint; @property (strong, nonatomic) IBOutlet UITableView *tableView; -(void) reloadChat; diff --git a/Juick/ViewControllers/ChatViewController.m b/Juick/ViewControllers/ChatViewController.m index 9493155..cfecc48 100644 --- a/Juick/ViewControllers/ChatViewController.m +++ b/Juick/ViewControllers/ChatViewController.m @@ -11,6 +11,8 @@ #import "MessageInputView.h" +#define kMessageInputInitialHeight 50 + @interface ChatViewController () @property (nonatomic, readwrite, retain) MessageInputView *accessoryView; @@ -37,6 +39,8 @@ [self addObserver:self forKeyPath:@"uname" options:0 context:nil]; #if TARGET_OS_MACCATALYST [self.stack addArrangedSubview:[self inputAccessoryView]]; +#else + self.stackBottomConstraint.constant = kMessageInputInitialHeight; #endif } @@ -102,11 +106,12 @@ if (userInfo) { CGRect beginFrame = [userInfo [UIKeyboardFrameBeginUserInfoKey] CGRectValue]; CGRect endFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; - CGFloat delta = endFrame.origin.y - beginFrame.origin.y; + CGFloat keyboardHeight = endFrame.origin.y - beginFrame.origin.y; CGFloat duration = [userInfo[UIKeyboardAnimationDurationUserInfoKey] floatValue]; UIViewAnimationCurve animationCurve = [userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue]; + [UIView animateWithDuration:duration delay:0 options:(animationCurve << 16) animations:^{ - self.tableView.contentOffset = CGPointMake(0, self.tableView.contentOffset.y - delta); + self.tableView.contentOffset = CGPointMake(0, self.tableView.contentOffset.y - keyboardHeight); } completion:nil]; } } diff --git a/Juick/Views/MessageInputView.xib b/Juick/Views/MessageInputView.xib index e13beca..76d72c9 100644 --- a/Juick/Views/MessageInputView.xib +++ b/Juick/Views/MessageInputView.xib @@ -1,11 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> <device id="retina4_7" orientation="portrait" appearance="light"/> <dependencies> <deployment identifier="iOS"/> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/> <capability name="Named colors" minToolsVersion="9.0"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/> + <capability name="System colors in document resources" minToolsVersion="11.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> <objects> @@ -20,14 +21,14 @@ <stackView opaque="NO" contentMode="scaleToFill" alignment="bottom" spacing="6" translatesAutoresizingMaskIntoConstraints="NO" id="OCM-7q-caQ"> <rect key="frame" x="8" y="8" width="296" height="39"/> <subviews> - <button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="999" horizontalCompressionResistancePriority="999" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="112-Yb-83a"> + <button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="999" horizontalCompressionResistancePriority="999" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="112-Yb-83a"> <rect key="frame" x="0.0" y="6" width="30" height="33"/> <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/> <state key="normal" title="@"/> </button> <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" textAlignment="natural" adjustsFontForContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tWq-jg-tXW"> <rect key="frame" x="36" y="0.0" width="214" height="39"/> - <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> + <color key="backgroundColor" systemColor="systemBackgroundColor"/> <constraints> <constraint firstAttribute="height" constant="39" id="Dhd-rY-QS9"/> </constraints> @@ -38,7 +39,7 @@ <outlet property="delegate" destination="2Ze-bx-tgN" id="Csx-Qg-lYh"/> </connections> </textView> - <button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="999" horizontalCompressionResistancePriority="999" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="iUb-5g-Btb"> + <button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="999" horizontalCompressionResistancePriority="999" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="iUb-5g-Btb"> <rect key="frame" x="256" y="6" width="40" height="33"/> <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/> <state key="normal" title="Send"/> @@ -49,16 +50,16 @@ </subviews> </stackView> </subviews> + <viewLayoutGuide key="safeArea" id="5tZ-ZX-uO1"/> <constraints> <constraint firstItem="5tZ-ZX-uO1" firstAttribute="trailing" secondItem="OCM-7q-caQ" secondAttribute="trailing" constant="16" id="70a-kb-HZp"/> <constraint firstItem="OCM-7q-caQ" firstAttribute="topMargin" secondItem="5tZ-ZX-uO1" secondAttribute="top" constant="8" id="Voz-db-iEt"/> <constraint firstItem="OCM-7q-caQ" firstAttribute="leadingMargin" secondItem="5tZ-ZX-uO1" secondAttribute="leading" constant="8" id="epV-Pa-CnX"/> <constraint firstItem="5tZ-ZX-uO1" firstAttribute="bottom" secondItem="OCM-7q-caQ" secondAttribute="bottom" constant="8" id="hsT-4s-U3s"/> </constraints> - <viewLayoutGuide key="safeArea" id="5tZ-ZX-uO1"/> </view> - <color key="tintColor" name="Title"/> <viewLayoutGuide key="safeArea" id="cMG-PD-wrX"/> + <color key="tintColor" name="Title"/> <blurEffect style="light"/> <connections> <outlet property="bottomConstraint" destination="hsT-4s-U3s" id="b1V-Gk-1At"/> @@ -77,5 +78,8 @@ <namedColor name="Title"> <color red="0.23529411764705882" green="0.46666666666666667" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> </namedColor> + <systemColor name="systemBackgroundColor"> + <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> + </systemColor> </resources> </document> |