audio cells UI

This commit is contained in:
nixzhu
2015-04-02 14:02:50 +08:00
parent 99d1608d63
commit 63bf44cd67
7 changed files with 189 additions and 4 deletions
+13
View File
@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "icon_play.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode",
"template-rendering-intent" : "template"
}
}
Binary file not shown.
@@ -298,6 +298,9 @@ class ConversationViewController: UIViewController {
case MessageMediaType.Image.rawValue:
return messageImageHeight + 10 + 10
case MessageMediaType.Audio.rawValue:
return 50
default:
let rect = message.textContent.boundingRectWithSize(CGSize(width: messageTextLabelMaxWidth, height: CGFloat(FLT_MAX)), options: .UsesLineFragmentOrigin | .UsesFontLeading, attributes: messageTextAttributes, context: nil)
@@ -549,6 +552,17 @@ extension ConversationViewController: UICollectionViewDataSource, UICollectionVi
return cell
case MessageMediaType.Audio.rawValue:
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(chatLeftAudioCellIdentifier, forIndexPath: indexPath) as! ChatLeftAudioCell
AvatarCache.sharedInstance.roundAvatarOfUser(sender, withRadius: YepConfig.chatCellAvatarSize() * 0.5) { roundImage in
dispatch_async(dispatch_get_main_queue()) {
cell.avatarImageView.image = roundImage
}
}
return cell
default:
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(chatLeftTextCellIdentifier, forIndexPath: indexPath) as! ChatLeftTextCell
@@ -593,6 +607,16 @@ extension ConversationViewController: UICollectionViewDataSource, UICollectionVi
return cell
case MessageMediaType.Audio.rawValue:
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(chatRightAudioCellIdentifier, forIndexPath: indexPath) as! ChatRightAudioCell
AvatarCache.sharedInstance.roundAvatarOfUser(sender, withRadius: YepConfig.chatCellAvatarSize() * 0.5) { roundImage in
dispatch_async(dispatch_get_main_queue()) {
cell.avatarImageView.image = roundImage
}
}
return cell
default:
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(chatRightTextCellIdentifier, forIndexPath: indexPath) as! ChatRightTextCell
@@ -10,6 +10,8 @@ import UIKit
class ChatLeftAudioCell: UICollectionViewCell {
@IBOutlet weak var avatarImageView: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
@@ -2,17 +2,89 @@
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7528.3" systemVersion="14C1514" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7518.3"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="ChatLeftAudioCell" id="gTV-IL-0wX" customClass="ChatLeftAudioCell" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<rect key="frame" x="0.0" y="0.0" width="276" height="126"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<rect key="frame" x="0.0" y="0.0" width="276" height="126"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="1K0-wd-BOr" userLabel="Avatar Image View">
<rect key="frame" x="15" y="43" width="40" height="40"/>
<constraints>
<constraint firstAttribute="width" constant="40" id="d1f-94-FWk"/>
<constraint firstAttribute="width" secondItem="1K0-wd-BOr" secondAttribute="height" multiplier="1:1" id="rxl-T9-vR3"/>
</constraints>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Whb-i5-kn8" userLabel="Audio Container View">
<rect key="frame" x="69" y="5" width="150" height="116"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="left_bubble" translatesAutoresizingMaskIntoConstraints="NO" id="j0p-8V-Tjb" userLabel="Bubble Image View">
<rect key="frame" x="0.0" y="0.0" width="150" height="116"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JJr-x8-Ljw" userLabel="Play Button">
<rect key="frame" x="10" y="43" width="30" height="30"/>
<constraints>
<constraint firstAttribute="width" secondItem="JJr-x8-Ljw" secondAttribute="height" id="qcL-S0-MeP"/>
<constraint firstAttribute="width" constant="30" id="yBd-CJ-kw2"/>
</constraints>
<color key="tintColor" red="0.0" green="1" blue="0.50196081400000003" alpha="1" colorSpace="calibratedRGB"/>
<state key="normal" image="icon_play">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="mlz-An-Tuw" userLabel="Wave View">
<rect key="frame" x="45" y="0.0" width="85" height="116"/>
<color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2&quot;" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Nar-PJ-uc5" userLabel="Time Length Label">
<rect key="frame" x="45" y="0.0" width="85" height="116"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="j0p-8V-Tjb" firstAttribute="top" secondItem="Whb-i5-kn8" secondAttribute="top" id="2P1-sj-nDd"/>
<constraint firstItem="JJr-x8-Ljw" firstAttribute="leading" secondItem="Whb-i5-kn8" secondAttribute="leading" constant="10" id="8Wa-dF-0TV"/>
<constraint firstAttribute="bottom" secondItem="j0p-8V-Tjb" secondAttribute="bottom" id="J5p-D5-MJf"/>
<constraint firstAttribute="trailing" secondItem="mlz-An-Tuw" secondAttribute="trailing" constant="20" id="Lps-ic-PsY"/>
<constraint firstItem="Nar-PJ-uc5" firstAttribute="trailing" secondItem="mlz-An-Tuw" secondAttribute="trailing" id="PWf-JE-OeL"/>
<constraint firstItem="mlz-An-Tuw" firstAttribute="top" secondItem="Whb-i5-kn8" secondAttribute="top" id="RO3-HD-5VX"/>
<constraint firstAttribute="centerY" secondItem="JJr-x8-Ljw" secondAttribute="centerY" id="RhN-1T-q4N"/>
<constraint firstItem="j0p-8V-Tjb" firstAttribute="leading" secondItem="Whb-i5-kn8" secondAttribute="leading" id="TmR-CA-j6B"/>
<constraint firstItem="mlz-An-Tuw" firstAttribute="leading" secondItem="JJr-x8-Ljw" secondAttribute="trailing" constant="5" id="UwV-wg-0GN"/>
<constraint firstItem="Nar-PJ-uc5" firstAttribute="leading" secondItem="mlz-An-Tuw" secondAttribute="leading" id="YIF-on-6fg"/>
<constraint firstItem="Nar-PJ-uc5" firstAttribute="bottom" secondItem="mlz-An-Tuw" secondAttribute="bottom" id="qyd-GU-56h"/>
<constraint firstAttribute="trailing" secondItem="j0p-8V-Tjb" secondAttribute="trailing" id="r6r-TN-l5p"/>
<constraint firstAttribute="width" constant="150" id="sta-YS-9h3"/>
<constraint firstItem="Nar-PJ-uc5" firstAttribute="top" secondItem="mlz-An-Tuw" secondAttribute="top" id="vdR-5f-8fd"/>
<constraint firstAttribute="bottom" secondItem="mlz-An-Tuw" secondAttribute="bottom" id="zwN-D3-Jl5"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<constraints>
<constraint firstItem="Whb-i5-kn8" firstAttribute="leading" secondItem="1K0-wd-BOr" secondAttribute="trailing" constant="14" id="0XT-SX-UNS"/>
<constraint firstAttribute="centerY" secondItem="1K0-wd-BOr" secondAttribute="centerY" id="8np-sL-P6D"/>
<constraint firstAttribute="bottom" secondItem="Whb-i5-kn8" secondAttribute="bottom" constant="5" id="esK-jX-i13"/>
<constraint firstItem="1K0-wd-BOr" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="15" id="kHD-0i-acN"/>
<constraint firstItem="Whb-i5-kn8" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="5" id="sWd-sM-aGR"/>
</constraints>
<size key="customSize" width="276" height="126"/>
<connections>
<outlet property="avatarImageView" destination="1K0-wd-BOr" id="ldH-Pm-vDG"/>
</connections>
<point key="canvasLocation" x="360" y="358"/>
</collectionViewCell>
</objects>
<resources>
<image name="icon_play" width="31" height="30"/>
<image name="left_bubble" width="36" height="30"/>
</resources>
</document>
@@ -10,6 +10,8 @@ import UIKit
class ChatRightAudioCell: UICollectionViewCell {
@IBOutlet weak var avatarImageView: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
@@ -2,17 +2,89 @@
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7528.3" systemVersion="14C1514" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7518.3"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="ChatRightAudioCell" id="gTV-IL-0wX" customClass="ChatRightAudioCell" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<rect key="frame" x="0.0" y="3" width="316" height="105"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<rect key="frame" x="0.0" y="0.0" width="316" height="105"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="knU-A0-FO4" userLabel="Audio Container View">
<rect key="frame" x="101" y="5" width="150" height="95"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="right_bubble" translatesAutoresizingMaskIntoConstraints="NO" id="IUw-Mk-XlZ" userLabel="Bubble Image View">
<rect key="frame" x="0.0" y="0.0" width="150" height="95"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XTQ-XN-AqX" userLabel="Play Button">
<rect key="frame" x="10" y="33" width="30" height="30"/>
<constraints>
<constraint firstAttribute="width" secondItem="XTQ-XN-AqX" secondAttribute="height" id="0Xe-vj-6Vr"/>
<constraint firstAttribute="width" constant="30" id="ReT-Bg-ERe"/>
</constraints>
<color key="tintColor" red="0.0" green="1" blue="0.50196081400000003" alpha="1" colorSpace="calibratedRGB"/>
<state key="normal" image="icon_play">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ynj-aF-z4D" userLabel="Wave View">
<rect key="frame" x="45" y="0.0" width="85" height="95"/>
<color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2&quot;" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="alU-Q7-YxY" userLabel="Time Length Label">
<rect key="frame" x="45" y="0.0" width="85" height="95"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="XTQ-XN-AqX" firstAttribute="leading" secondItem="knU-A0-FO4" secondAttribute="leading" constant="10" id="2gQ-ob-cgb"/>
<constraint firstAttribute="trailing" secondItem="IUw-Mk-XlZ" secondAttribute="trailing" id="8dj-VI-b8r"/>
<constraint firstAttribute="centerY" secondItem="XTQ-XN-AqX" secondAttribute="centerY" id="9sZ-NN-OjE"/>
<constraint firstItem="alU-Q7-YxY" firstAttribute="leading" secondItem="ynj-aF-z4D" secondAttribute="leading" id="DWl-Kd-47z"/>
<constraint firstItem="alU-Q7-YxY" firstAttribute="bottom" secondItem="ynj-aF-z4D" secondAttribute="bottom" id="FfY-Nf-2Wq"/>
<constraint firstAttribute="trailing" secondItem="ynj-aF-z4D" secondAttribute="trailing" constant="20" id="HSM-71-9gP"/>
<constraint firstAttribute="width" constant="150" id="LBt-mx-R7u"/>
<constraint firstItem="IUw-Mk-XlZ" firstAttribute="leading" secondItem="knU-A0-FO4" secondAttribute="leading" id="LgR-iA-qgz"/>
<constraint firstItem="IUw-Mk-XlZ" firstAttribute="top" secondItem="knU-A0-FO4" secondAttribute="top" id="PED-I8-vTn"/>
<constraint firstItem="ynj-aF-z4D" firstAttribute="top" secondItem="knU-A0-FO4" secondAttribute="top" id="RIA-cc-ovU"/>
<constraint firstItem="alU-Q7-YxY" firstAttribute="trailing" secondItem="ynj-aF-z4D" secondAttribute="trailing" id="bWp-na-rZM"/>
<constraint firstAttribute="bottom" secondItem="IUw-Mk-XlZ" secondAttribute="bottom" id="fGm-iu-3L1"/>
<constraint firstItem="alU-Q7-YxY" firstAttribute="top" secondItem="ynj-aF-z4D" secondAttribute="top" id="fyp-2L-t3i"/>
<constraint firstAttribute="bottom" secondItem="ynj-aF-z4D" secondAttribute="bottom" id="mJb-Pl-UbX"/>
<constraint firstItem="ynj-aF-z4D" firstAttribute="leading" secondItem="XTQ-XN-AqX" secondAttribute="trailing" constant="5" id="uLL-Bt-Lsk"/>
</constraints>
</view>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="76j-Ht-EsY" userLabel="Avatar Image View">
<rect key="frame" x="261" y="34" width="40" height="40"/>
<constraints>
<constraint firstAttribute="width" secondItem="76j-Ht-EsY" secondAttribute="height" multiplier="1:1" id="hTd-vS-wy8"/>
<constraint firstAttribute="width" constant="40" id="tKU-Zf-UDc"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<constraints>
<constraint firstItem="knU-A0-FO4" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="5" id="8UY-FZ-lzu"/>
<constraint firstItem="76j-Ht-EsY" firstAttribute="leading" secondItem="knU-A0-FO4" secondAttribute="trailing" constant="10" id="Mcc-nk-9BG"/>
<constraint firstItem="knU-A0-FO4" firstAttribute="centerY" secondItem="76j-Ht-EsY" secondAttribute="centerY" constant="-1" id="S2w-AX-ROG"/>
<constraint firstAttribute="bottom" secondItem="knU-A0-FO4" secondAttribute="bottom" constant="5" id="a8r-IT-Jd1"/>
<constraint firstAttribute="trailing" secondItem="76j-Ht-EsY" secondAttribute="trailing" constant="15" id="utb-F3-DnW"/>
</constraints>
<size key="customSize" width="316" height="105"/>
<connections>
<outlet property="avatarImageView" destination="76j-Ht-EsY" id="uPV-sw-dlg"/>
</connections>
<point key="canvasLocation" x="434" y="419.5"/>
</collectionViewCell>
</objects>
<resources>
<image name="icon_play" width="31" height="30"/>
<image name="right_bubble" width="36" height="30"/>
</resources>
</document>