Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
anfriis committed Nov 9, 2016
1 parent f6d9053 commit edd38fc
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 33 deletions.
Binary file added Default-568h@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 14 additions & 8 deletions GrowingTextViewHandler.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
9A8A4EE21DC4A0B000A6D5B5 /* GrowingTextViewHandler.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9A8A4ED91DC4A0B000A6D5B5 /* GrowingTextViewHandler.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9A8A4EE61DC4A0BB00A6D5B5 /* GrowingTextViewHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69CEFFEB1A9D9FB1003B4786 /* GrowingTextViewHandler.swift */; };
9A8A4EE71DC4A24500A6D5B5 /* GrowingTextViewHandler.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A8A4ED91DC4A0B000A6D5B5 /* GrowingTextViewHandler.framework */; };
9A9324641DD35A5B00CB1B99 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9A9324631DD35A5B00CB1B99 /* Default-568h@2x.png */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -69,6 +70,7 @@
9A8A4ED91DC4A0B000A6D5B5 /* GrowingTextViewHandler.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GrowingTextViewHandler.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9A8A4EDB1DC4A0B000A6D5B5 /* GrowingTextViewHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GrowingTextViewHandler.h; sourceTree = "<group>"; };
9A8A4EDC1DC4A0B000A6D5B5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9A9324631DD35A5B00CB1B99 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../Default-568h@2x.png"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -126,6 +128,7 @@
69CEFFCE1A9D9F03003B4786 /* Main.storyboard */,
69CEFFD11A9D9F03003B4786 /* Images.xcassets */,
69CEFFD31A9D9F03003B4786 /* LaunchScreen.xib */,
9A9324631DD35A5B00CB1B99 /* Default-568h@2x.png */,
69CEFFC81A9D9F03003B4786 /* Supporting Files */,
4EF6FE671D586229003863CC /* FormTableViewCell.swift */,
4EF6FE651D586146003863CC /* FormViewController.swift */,
Expand Down Expand Up @@ -295,6 +298,7 @@
buildActionMask = 2147483647;
files = (
69CEFFD01A9D9F03003B4786 /* Main.storyboard in Resources */,
9A9324641DD35A5B00CB1B99 /* Default-568h@2x.png in Resources */,
69CEFFD51A9D9F03003B4786 /* LaunchScreen.xib in Resources */,
69CEFFD21A9D9F03003B4786 /* Images.xcassets in Resources */,
);
Expand Down Expand Up @@ -417,7 +421,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -456,7 +460,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -470,12 +474,13 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = GrowingTextViewHandler/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.hsusmita.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 3.0.1;
};
name = Debug;
};
Expand All @@ -485,10 +490,11 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = GrowingTextViewHandler/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.hsusmita.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 3.0.1;
};
name = Release;
};
Expand Down Expand Up @@ -546,13 +552,13 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = GrowingTextViewHandler/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.GrowingTextViewHandler;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 3.0.1;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -576,12 +582,12 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = GrowingTextViewHandler/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.GrowingTextViewHandler;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 3.0.1;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down
34 changes: 19 additions & 15 deletions GrowingTextViewHandler/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="owB-Xf-cbh">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2555" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="owB-Xf-cbh">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="ViewController" customModule="GrowingTextViewHandler" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="vXZ-lx-hvc" customClass="ViewController" customModule="GrowingTextViewHandler_Demo" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
Expand All @@ -18,8 +21,8 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="q2N-J0-Gt2">
<frame key="frameInset" minX="100" minY="131" width="400" height="30"/>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="q2N-J0-Gt2">
<rect key="frame" x="100" y="164.5" width="175" height="30"/>
<color key="backgroundColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="3a3-GU-7qL"/>
Expand All @@ -30,8 +33,8 @@
<outlet property="delegate" destination="vXZ-lx-hvc" id="rI6-YI-qWf"/>
</connections>
</textView>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="bW7-U6-WNd">
<frame key="frameInset" minX="234" minY="79" width="132" height="30"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="bW7-U6-WNd">
<rect key="frame" x="121.5" y="79" width="132" height="30"/>
<state key="normal" title="TableView Example"/>
<connections>
<segue destination="9Tt-QS-DYI" kind="show" id="iNQ-Be-kT4"/>
Expand Down Expand Up @@ -68,7 +71,7 @@
<!--Form View Controller-->
<scene sceneID="mv7-0g-QYk">
<objects>
<viewController automaticallyAdjustsScrollViewInsets="NO" id="9Tt-QS-DYI" customClass="FormViewController" customModule="GrowingTextViewHandler" customModuleProvider="target" sceneMemberID="viewController">
<viewController automaticallyAdjustsScrollViewInsets="NO" id="9Tt-QS-DYI" customClass="FormViewController" customModule="GrowingTextViewHandler_Demo" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Gau-Ra-yMM"/>
<viewControllerLayoutGuide type="bottom" id="bXl-cO-cPl"/>
Expand All @@ -77,18 +80,19 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="singleLineEtched" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="BDi-64-MBC">
<frame key="frameInset" minY="64" width="600" height="536"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="BDi-64-MBC">
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="FormTableViewCellIdentifier" id="TGc-us-FUl" customClass="FormTableViewCell" customModule="GrowingTextViewHandler" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="600" height="44"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="FormTableViewCellIdentifier" id="TGc-us-FUl" customClass="FormTableViewCell" customModule="GrowingTextViewHandler_Demo" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="TGc-us-FUl" id="AgD-cy-1Vb">
<frame key="frameInset" width="600" height="43"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="sIY-p6-tJe">
<rect key="frame" x="5" y="5" width="365" height="50"/>
<color key="backgroundColor" red="0.76862745099999996" green="0.76862745099999996" blue="0.78039215689999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="mFB-Y8-03g"/>
Expand Down
20 changes: 10 additions & 10 deletions GrowingTextViewHandler/Source/GrowingTextViewHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ open class GrowingTextViewHandler: NSObject {
}
}

fileprivate var textViewHeightConstraint: NSLayoutConstraint?
private var textViewHeightConstraint: NSLayoutConstraint?

/**
The minumum height of the textView
*/
fileprivate var initialHeight: CGFloat = 0.0
private var initialHeight: CGFloat = 0.0

/**
The maximum height of the textView upto which it should grow and start scrolling
*/
fileprivate var maximumHeight: CGFloat = 0.0
private var maximumHeight: CGFloat = 0.0

/**
This denotes the line height of single line of characters. This value depends on the font size.
*/
fileprivate var caretHeight: CGFloat {
private var caretHeight: CGFloat {
if let selectedTextRange = growingTextView.selectedTextRange {
return growingTextView.caretRect(for: selectedTextRange.end).size.height
} else {
Expand All @@ -47,7 +47,7 @@ open class GrowingTextViewHandler: NSObject {
/**
This gives the total height of the textView based on the text present in it
*/
fileprivate var currentHeight: CGFloat {
private var currentHeight: CGFloat {
guard let textViewFont = growingTextView.font else {
return 0.0
}
Expand All @@ -61,7 +61,7 @@ open class GrowingTextViewHandler: NSObject {
/**
This gives the number of lines based on the text present in it
*/
fileprivate var currentNumberOfLines: Int {
private var currentNumberOfLines: Int {
let totalHeight = currentHeight + growingTextView.textContainerInset.top + growingTextView.textContainerInset.bottom
return Int(totalHeight/caretHeight) - 1
}
Expand Down Expand Up @@ -128,7 +128,7 @@ open class GrowingTextViewHandler: NSObject {
This method initialzes the variables intialHeight and maximum height and performs initial resize
*/

fileprivate func updateInitialHeightAndResize() {
private func updateInitialHeightAndResize() {
initialHeight = estimatedInitialHeight()
maximumHeight = estimatedMaximumHeight()
resizeTextView(false)
Expand All @@ -141,7 +141,7 @@ open class GrowingTextViewHandler: NSObject {
and returns the maximum of two.
*/

fileprivate func estimatedInitialHeight() -> CGFloat {
private func estimatedInitialHeight() -> CGFloat {
let totalHeight = caretHeight * CGFloat(minimumNumberOfLines) + growingTextView.textContainerInset.top
+ growingTextView.textContainerInset.bottom
return fmax(totalHeight, growingTextView.frame.height)
Expand All @@ -153,7 +153,7 @@ open class GrowingTextViewHandler: NSObject {
maximumNumberOfLines and caretHeight are the factors which determine the maximum height of the textView
*/

fileprivate func estimatedMaximumHeight() -> CGFloat {
private func estimatedMaximumHeight() -> CGFloat {
let totalHeight = caretHeight * CGFloat(maximumNumberOfLines) + growingTextView.textContainerInset.top
+ growingTextView.textContainerInset.bottom
return totalHeight
Expand All @@ -167,7 +167,7 @@ open class GrowingTextViewHandler: NSObject {
- animated: If set as true, the height change will be animated
*/

fileprivate func updateVerticalAlignmentWithHeight(_ height: CGFloat, animated: Bool) {
private func updateVerticalAlignmentWithHeight(_ height: CGFloat, animated: Bool) {
guard let heightConstraint = textViewHeightConstraint else {
return
}
Expand Down

0 comments on commit edd38fc

Please sign in to comment.