Skip to content

Commit

Permalink
Create bottom Contraint to open keyboard ( update pod )- BS2
Browse files Browse the repository at this point in the history
  • Loading branch information
AcacioFernando committed Aug 10, 2021
1 parent 01eff74 commit a8a29eb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
Binary file added .DS_Store
Binary file not shown.
17 changes: 8 additions & 9 deletions src/BlipChat/Storyboard.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="32R-DJ-UGp">
<device id="retina4_0" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="32R-DJ-UGp">
<device id="retina4_0" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -19,10 +17,10 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" restorationIdentifier="baseView" preservesSuperviewLayoutMargins="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5xx-bq-PFL" userLabel="baseView">
<rect key="frame" x="0.0" y="20" width="320" height="548"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<subviews>
<progressView autoresizesSubviews="NO" opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="LaT-Zt-8KK">
<rect key="frame" x="0.0" y="0.0" width="320" height="2"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="4"/>
</progressView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
Expand All @@ -33,18 +31,19 @@
</constraints>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="zJv-WX-D0o"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="5xx-bq-PFL" firstAttribute="bottom" secondItem="zJv-WX-D0o" secondAttribute="bottom" id="MeK-IB-W7K"/>
<constraint firstItem="5xx-bq-PFL" firstAttribute="bottom" secondItem="zJv-WX-D0o" secondAttribute="bottom" id="MeK-IB-W7K" userLabel="Bottom Constraint"/>
<constraint firstItem="5xx-bq-PFL" firstAttribute="leading" secondItem="zJv-WX-D0o" secondAttribute="leading" id="QOM-Dn-4Nm"/>
<constraint firstItem="5xx-bq-PFL" firstAttribute="top" secondItem="zJv-WX-D0o" secondAttribute="top" id="ceK-LL-Ezu"/>
<constraint firstItem="5xx-bq-PFL" firstAttribute="trailing" secondItem="zJv-WX-D0o" secondAttribute="trailing" id="vFB-8B-ZXd"/>
</constraints>
<viewLayoutGuide key="safeArea" id="zJv-WX-D0o"/>
</view>
<navigationItem key="navigationItem" title="Title" id="JE0-4t-T4g"/>
<connections>
<outlet property="baseView" destination="5xx-bq-PFL" id="2rz-M5-x4l"/>
<outlet property="bottomConstraint" destination="MeK-IB-W7K" id="Ux5-n7-YIR"/>
<outlet property="progressView" destination="LaT-Zt-8KK" id="Bsd-be-hgs"/>
</connections>
</viewController>
Expand Down
37 changes: 21 additions & 16 deletions src/BlipChat/ThreadViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ internal class ThreadViewController: UIViewController, WKNavigationDelegate, UIS
var baseUrl : URL!
var html : String = ""

@IBOutlet weak var bottomConstraint: NSLayoutConstraint!
@IBOutlet var progressView: UIProgressView!
@IBOutlet var baseView: UIView!

Expand Down Expand Up @@ -91,25 +92,29 @@ internal class ThreadViewController: UIViewController, WKNavigationDelegate, UIS
}

/// Handle keyboard appearing on screen
@objc func keyboardWillShow(notification: NSNotification) {
if let keyboardSize = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
let statusBarHeight = UIApplication.shared.statusBarFrame.height
let navBarheight = self.navigationController?.navigationBar.bounds.size.height
let height = -keyboardSize.height + statusBarHeight + navBarheight!
self.view.frame.origin.y = height

// Notify about blipchat that keyboard is open
self.webView.evaluateJavaScript("setKeyboardOpen(true)", completionHandler: nil)
}

}

@objc func keyboardWillShow(notification: NSNotification) {
if let keyboardSize = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
let statusBarHeight = UIApplication.shared.statusBarFrame.height
let navBarheight = self.navigationController?.navigationBar.bounds.size.height
let height = -keyboardSize.height + statusBarHeight + navBarheight!
self.view.frame.origin.y = height

bottomConstraint.constant = -keyboardSize.height
updateViewConstraints()

// Notify about blipchat that keyboard is open
self.webView.evaluateJavaScript("setKeyboardOpen(true)", completionHandler: nil)
}
}

/// Handle keyboard hiding on screen
@objc func keyboardWillHide(notification: NSNotification) {
let statusBarHeight = UIApplication.shared.statusBarFrame.height
if let navBarheight = self.navigationController?.navigationBar.bounds.size.height {
self.view.frame.origin.y = statusBarHeight + navBarheight
}
let navBarheight = self.navigationController?.navigationBar.bounds.size.height
self.view.frame.origin.y = statusBarHeight + navBarheight!

bottomConstraint.constant = 0
updateViewConstraints()

// Notify about blipchat that keyboard is closed
self.webView.evaluateJavaScript("setKeyboardOpen(false)", completionHandler: nil)
Expand Down

0 comments on commit a8a29eb

Please sign in to comment.