Merge branch 'feature/no_cell_animation_in_conversation_when_scroll' into develop

This commit is contained in:
nixzhu
2015-09-18 17:39:20 +08:00
3 changed files with 63 additions and 80 deletions
+22 -27
View File
@@ -62,27 +62,22 @@
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="o5R-dM-KPW">
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="o5R-dM-KPW">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="f8w-Kr-SFJ">
<size key="itemSize" width="50" height="50"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<collectionViewLayout key="collectionViewLayout" id="75A-E2-sxR" customClass="ConversationLayout" customModule="Yep" customModuleProvider="target"/>
<cells/>
<connections>
<outlet property="dataSource" destination="la3-6z-2aH" id="fMv-cD-ZTA"/>
<outlet property="delegate" destination="la3-6z-2aH" id="zOV-zM-2KH"/>
</connections>
</collectionView>
<view contentMode="scaleToFill" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Gu7-gn-2ia">
<rect key="frame" x="0.0" y="276" width="600" height="100"/>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Gu7-gn-2ia">
<rect key="frame" x="0.0" y="270" width="600" 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="Zew-F7-znc">
<rect key="frame" x="235" y="62" width="130" height="18"/>
<rect key="frame" x="235.5" y="62" width="129.5" height="18"/>
<animations/>
<fontDescription key="fontDescription" type="system" weight="light" pointSize="15"/>
<color key="textColor" red="1" green="0.0" blue="0.23529411764705882" alpha="1" colorSpace="calibratedRGB"/>
@@ -107,8 +102,8 @@
<constraint firstItem="Zew-F7-znc" firstAttribute="top" secondItem="4p2-ZI-7q3" secondAttribute="bottom" constant="10" id="b9o-gU-cOq"/>
</constraints>
</view>
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Q0w-sM-iIR" customClass="MessageToolbar" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="0.0" y="396" width="600" height="44"/>
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Q0w-sM-iIR" customClass="MessageToolbar" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="0.0" y="390" width="600" height="50"/>
<animations/>
<items/>
</toolbar>
@@ -116,7 +111,7 @@
<rect key="frame" x="0.0" y="440" width="600" height="300"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="avI-im-eEZ" userLabel="Choose Photo Button" customClass="MessageTypeButton" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="20" y="20" width="173" height="260"/>
<rect key="frame" x="20" y="20" width="173.5" height="260"/>
<animations/>
<state key="normal">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
@@ -126,8 +121,8 @@
<userDefinedRuntimeAttribute type="string" keyPath="title" value="Choose photo"/>
</userDefinedRuntimeAttributes>
</button>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HcA-7v-16m" userLabel="Take Photo Button" customClass="MessageTypeButton" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="213" y="20" width="174" height="260"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HcA-7v-16m" userLabel="Take Photo Button" customClass="MessageTypeButton" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="213.5" y="20" width="173" height="260"/>
<animations/>
<state key="normal">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
@@ -138,7 +133,7 @@
</userDefinedRuntimeAttributes>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Hg3-Ss-sqD" userLabel="Add Location Button" customClass="MessageTypeButton" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="407" y="20" width="173" height="260"/>
<rect key="frame" x="406.5" y="20" width="173.5" height="260"/>
<animations/>
<state key="normal">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
@@ -1024,8 +1019,8 @@
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="IrX-gK-Zkg">
<rect key="frame" x="0.0" y="100" width="600" height="44"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="IrX-gK-Zkg">
<rect key="frame" x="0.0" y="144" width="600" height="44"/>
<animations/>
<constraints>
<constraint firstAttribute="height" constant="44" id="ivj-KQ-byM"/>
@@ -1037,8 +1032,8 @@
<action selector="activeFrom" destination="GqQ-V0-aYk" eventType="touchUpInside" id="yIG-DH-kZc"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="flj-e3-cbm">
<rect key="frame" x="0.0" y="144" width="600" height="44"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="flj-e3-cbm">
<rect key="frame" x="0.0" y="188" width="600" height="44"/>
<animations/>
<constraints>
<constraint firstAttribute="height" constant="44" id="3Q2-xg-uQM"/>
@@ -1050,8 +1045,8 @@
<action selector="activeTo" destination="GqQ-V0-aYk" eventType="touchUpInside" id="90e-4a-0ZA"/>
</connections>
</button>
<pickerView contentMode="scaleToFill" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hap-y9-JVX">
<rect key="frame" x="0.0" y="438" width="600" height="162"/>
<pickerView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hap-y9-JVX">
<rect key="frame" x="0.0" y="389" width="600" height="162"/>
<animations/>
<connections>
<outlet property="dataSource" destination="GqQ-V0-aYk" id="ruH-BN-Hig"/>
@@ -1248,15 +1243,15 @@
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="We read every feedback" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pdt-Vd-sD9">
<rect key="frame" x="208" y="60" width="185" height="21"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="We read every feedback" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pdt-Vd-sD9">
<rect key="frame" x="208" y="104" width="185" height="20.5"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" misplaced="YES" keyboardDismissMode="onDrag" translatesAutoresizingMaskIntoConstraints="NO" id="fVo-Zl-gHQ">
<rect key="frame" x="0.0" y="121" width="600" height="214"/>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" keyboardDismissMode="onDrag" translatesAutoresizingMaskIntoConstraints="NO" id="fVo-Zl-gHQ">
<rect key="frame" x="0.0" y="164.5" width="600" height="121.5"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
@@ -1977,7 +1972,7 @@
<image name="yep_icon_solo" width="120" height="120"/>
</resources>
<inferredMetricsTieBreakers>
<segue reference="Pxr-1p-x84"/>
<segue reference="l4P-ds-ihU"/>
<segue reference="o3b-2D-AMq"/>
<segue reference="6No-Lc-7X4"/>
</inferredMetricsTieBreakers>
@@ -11,48 +11,46 @@ import QuartzCore
class ConversationLayout: UICollectionViewFlowLayout {
// var lastTimeContentSize: CGSize?
//
// var itemsDeleteIndexPaths = [NSIndexPath]()
//
// override func collectionViewContentSize() -> CGSize {
// var contentSize = super.collectionViewContentSize()
//
// if let lastTimeContentSize = lastTimeContentSize {
// if lastTimeContentSize.height > contentSize.height {
// contentSize.height = lastTimeContentSize.height
// }
// } else {
// lastTimeContentSize = contentSize
// }
//
// return contentSize
// }
//
// override func finalLayoutAttributesForDisappearingItemAtIndexPath(itemIndexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? {
// var attr = super.finalLayoutAttributesForDisappearingItemAtIndexPath(itemIndexPath)
//
// for (index, indexPath) in enumerate(itemsDeleteIndexPaths) {
// if indexPath == itemIndexPath {
//
// if let cell = collectionView?.cellForItemAtIndexPath(indexPath) as? ChatStateCell {
// var scale: CGFloat = 0.8
// var offsetScale: CGFloat = (1-scale)*0.5
//
// attr?.transform = CGAffineTransformMakeScale(scale, scale)
// attr?.alpha = 0
//
// println("Frame width \(cell.stateLabel.frame.width)")
//
// attr?.center = CGPointMake(attr!.center.x + attr!.size.width*offsetScale - cell.stateLabel.frame.width*offsetScale, attr!.center.y - cell.stateLabel.frame.height*scale*0.5)
// }
//
// itemsDeleteIndexPaths.removeAtIndex(index)
// }
// }
//
//
// return attr
// }
override func prepareLayout() {
super.prepareLayout()
minimumLineSpacing = YepConfig.ChatCell.lineSpacing
}
var insertIndexPathSet = Set<NSIndexPath>()
override func prepareForCollectionViewUpdates(updateItems: [AnyObject]!) {
super.prepareForCollectionViewUpdates(updateItems)
var insertIndexPathSet = Set<NSIndexPath>()
if let updateItems = updateItems as? [UICollectionViewUpdateItem] {
for updateItem in updateItems {
switch updateItem.updateAction {
case .Insert:
if let indexPath = updateItem.indexPathAfterUpdate {
insertIndexPathSet.insert(indexPath)
}
default:
break
}
}
}
self.insertIndexPathSet = insertIndexPathSet
}
override func initialLayoutAttributesForAppearingItemAtIndexPath(itemIndexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? {
let attributes = layoutAttributesForItemAtIndexPath(itemIndexPath)
if insertIndexPathSet.contains(itemIndexPath) {
attributes.frame.origin.y += 30
insertIndexPathSet.remove(itemIndexPath)
}
return attributes
}
}
@@ -216,16 +216,6 @@ class ConversationViewController: BaseViewController {
view.tintAdjustmentMode = .Normal
/*
let layout = ConversationLayout()
layout.minimumLineSpacing = YepConfig.ChatCell.lineSpacing
conversationCollectionView.setCollectionViewLayout(layout, animated: false)
*/
if let layout = conversationCollectionView.collectionViewLayout as? UICollectionViewFlowLayout {
layout.minimumLineSpacing = YepConfig.ChatCell.lineSpacing
}
if messages.count >= messagesBunchCount {
displayedMessagesRange = NSRange(location: Int(messages.count) - messagesBunchCount, length: messagesBunchCount)
} else {