Merge branch 'develop' of https://github.com/CatchChat/Yep into develop

This commit is contained in:
kevinzhow
2016-01-14 14:45:49 +08:00
3 changed files with 33 additions and 16 deletions
+4
View File
@@ -47,6 +47,10 @@ extension String {
return nil
}
guard (self as NSString).length > index else {
return nil
}
let index = startIndex.advancedBy(index)
var wordString: String?
@@ -14,11 +14,11 @@
<viewControllerLayoutGuide type="bottom" id="UbN-sl-QUT"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="846-Dd-AxI">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="Eug-oZ-gjQ">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<collectionViewLayout key="collectionViewLayout" id="sS6-P1-xbg" customClass="ConversationLayout" customModule="Yep" customModuleProvider="target"/>
<cells/>
@@ -28,16 +28,16 @@
</connections>
</collectionView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="H35-sK-viT">
<rect key="frame" x="0.0" y="270" width="600" height="100"/>
<rect key="frame" x="0.0" y="337" width="375" height="100"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Swipe Up to Cancel" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="erl-b0-CMQ">
<rect key="frame" x="234" y="62" width="132.5" height="18"/>
<rect key="frame" x="121" y="62" width="132.5" height="18"/>
<fontDescription key="fontDescription" type="system" weight="light" pointSize="15"/>
<color key="textColor" red="1" green="0.0" blue="0.23529411759999999" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="swipe_up" translatesAutoresizingMaskIntoConstraints="NO" id="WVE-v0-1iA">
<rect key="frame" x="287" y="44" width="25" height="8"/>
<rect key="frame" x="174" y="44" width="25" height="8"/>
<constraints>
<constraint firstAttribute="height" constant="8" id="Q0N-bH-k2Y"/>
<constraint firstAttribute="width" constant="25" id="gpR-7R-3D5"/>
@@ -54,11 +54,11 @@
</constraints>
</view>
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9Uh-E6-Vss" customClass="MessageToolbar" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="0.0" y="390" width="600" height="50"/>
<rect key="frame" x="0.0" y="457" width="375" height="50"/>
<items/>
</toolbar>
<activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="fP4-ji-yWc">
<rect key="frame" x="290" y="140" width="20" height="20"/>
<rect key="frame" x="177" y="140" width="20" height="20"/>
</activityIndicatorView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@@ -73,10 +73,12 @@
<constraint firstItem="H35-sK-viT" firstAttribute="width" secondItem="9Uh-E6-Vss" secondAttribute="width" id="Thq-w4-dFj"/>
<constraint firstItem="9Uh-E6-Vss" firstAttribute="top" secondItem="H35-sK-viT" secondAttribute="bottom" constant="20" id="XB3-oz-ltH"/>
<constraint firstAttribute="trailing" secondItem="9Uh-E6-Vss" secondAttribute="trailing" id="sm6-8A-Lpk"/>
<constraint firstItem="9Uh-E6-Vss" firstAttribute="top" relation="greaterThanOrEqual" secondItem="3yg-SJ-CR8" secondAttribute="bottom" id="twv-t0-rmT"/>
<constraint firstAttribute="bottom" secondItem="9Uh-E6-Vss" secondAttribute="bottom" constant="160" id="xp5-FH-KYE"/>
<constraint firstAttribute="trailing" secondItem="Eug-oZ-gjQ" secondAttribute="trailing" id="zUR-03-3Fr"/>
</constraints>
</view>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina47"/>
<connections>
<outlet property="activityIndicator" destination="fP4-ji-yWc" id="0aI-A0-ptB"/>
<outlet property="conversationCollectionView" destination="Eug-oZ-gjQ" id="Cvy-ke-csl"/>
@@ -115,7 +117,7 @@
<viewControllerPlaceholder storyboardName="PickLocation" id="f8Q-Nw-run" sceneMemberID="viewController"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="axC-MU-2PW" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-549" y="2288"/>
<point key="canvasLocation" x="-629" y="2344"/>
</scene>
<!--MessageMediaViewController-->
<scene sceneID="mD6-JY-R4j">
@@ -131,7 +133,7 @@
<viewControllerPlaceholder storyboardName="NewFeed" id="9xD-Rm-9US" sceneMemberID="viewController"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="mtb-Uy-ezu" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-399.5" y="2288"/>
<point key="canvasLocation" x="-455.5" y="2344"/>
</scene>
<!--ProfileViewController-->
<scene sceneID="ZHm-QA-IAa">
+18 -7
View File
@@ -166,13 +166,14 @@ class MessageToolbar: UIToolbar {
button.tintAdjustmentMode = .Normal
button.addTarget(self, action: "toggleRecordVoice", forControlEvents: UIControlEvents.TouchUpInside)
return button
}()
}()
let normalCornerRadius: CGFloat = 6
lazy var messageTextView: UITextView = {
let textView = UITextView()
textView.textContainerInset = UIEdgeInsets(top: 8, left: 4, bottom: 8, right: 4)
//textView.textContainerInset = UIEdgeInsetsZero
textView.font = UIFont.systemFontOfSize(15)
textView.layer.borderWidth = 1
textView.layer.borderColor = UIColor.yepMessageToolbarSubviewBorderColor().CGColor
@@ -180,7 +181,7 @@ class MessageToolbar: UIToolbar {
textView.delegate = self
textView.scrollEnabled = false // top inset
return textView
}()
}()
lazy var voiceRecordButton: VoiceRecordButton = {
let button = VoiceRecordButton()
@@ -214,7 +215,7 @@ class MessageToolbar: UIToolbar {
}
return button
}()
}()
lazy var moreButton: UIButton = {
let button = UIButton()
@@ -223,7 +224,7 @@ class MessageToolbar: UIToolbar {
button.tintAdjustmentMode = .Normal
button.addTarget(self, action: "moreMessageTypes", forControlEvents: UIControlEvents.TouchUpInside)
return button
}()
}()
lazy var sendButton: UIButton = {
let button = UIButton()
@@ -233,7 +234,7 @@ class MessageToolbar: UIToolbar {
button.setTitleColor(UIColor.messageToolBarHighlightColor(), forState: .Normal)
button.addTarget(self, action: "trySendTextMessage", forControlEvents: UIControlEvents.TouchUpInside)
return button
}()
}()
// MARK: UI
@@ -281,6 +282,7 @@ class MessageToolbar: UIToolbar {
let textContainerInset = messageTextView.textContainerInset
let constant = ceil(messageTextView.font!.lineHeight + textContainerInset.top + textContainerInset.bottom)
messageTextViewHeightConstraint = NSLayoutConstraint(item: messageTextView, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1, constant: constant)
messageTextViewHeightConstraint.priority = UILayoutPriorityDefaultHigh
let constraintsH = NSLayoutConstraint.constraintsWithVisualFormat("H:|[micButton(48)][messageTextView][moreButton(==micButton)]|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: viewsDictionary)
@@ -363,10 +365,19 @@ class MessageToolbar: UIToolbar {
//println("oldHeight: \(messageTextViewHeightConstraint.constant), newHeight: \(newHeight)")
if newHeight != messageTextViewHeightConstraint.constant {
UIView.animateWithDuration(0.1, delay: 0.0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
UIView.animateWithDuration(0.1, delay: 0.0, options: .CurveEaseInOut, animations: {
self.messageTextViewHeightConstraint.constant = newHeight
self.layoutIfNeeded()
}, completion: { (finished) -> Void in
}, completion: { [weak self] finished in
// hack for scrollEnabled when input lots of text
if finished, let strongSelf = self {
//println("messageToolbar.frame: \(strongSelf.frame)")
let enabled = strongSelf.frame.origin.y < 100
strongSelf.messageTextView.scrollEnabled = enabled
}
})
}
}