Fix min cell width

This commit is contained in:
kevinzhow
2015-05-01 17:08:42 +08:00
parent eef7bcda84
commit 78fc068a5f
7 changed files with 35 additions and 10 deletions
+1 -1
View File
@@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>3</string>
<string>5</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSLocationWhenInUseUsageDescription</key>
@@ -83,6 +83,11 @@ class ChatLeftAudioCell: UICollectionViewCell {
if let audioSamples = metaDataDict["audio_samples"] as? [CGFloat] {
sampleViewWidthConstraint.constant = CGFloat(audioSamples.count) * (YepConfig.audioSampleWidth() + YepConfig.audioSampleGap()) - YepConfig.audioSampleGap() // gap
if sampleViewWidthConstraint.constant < minSampleViewWidth {
sampleViewWidthConstraint.constant = minSampleViewWidth
}
sampleView.samples = audioSamples
if let audioDuration = metaDataDict["audio_duration"] as? Double {
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7528.3" systemVersion="14C1514" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7518.3"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</dependencies>
<objects>
@@ -91,7 +91,7 @@
</collectionViewCell>
</objects>
<resources>
<image name="icon_play" width="31" height="30"/>
<image name="icon_play" width="30" height="30"/>
<image name="left_tail_bubble" width="48" height="40"/>
</resources>
</document>
@@ -29,6 +29,7 @@ class ChatLeftTextCell: UICollectionViewCell {
avatarImageViewWidthConstraint.constant = YepConfig.chatCellAvatarSize()
textContentLabel.font = UIFont.chatTextFont()
textContentLabel.textAlignment = NSTextAlignment.Center
textContentLabelLeadingConstaint.constant = YepConfig.chatCellGapBetweenTextContentLabelAndAvatar()
textContentLabelTrailingConstraint.constant = YepConfig.chatTextGapBetweenWallAndContentLabel()
@@ -38,8 +39,12 @@ class ChatLeftTextCell: UICollectionViewCell {
func configureWithMessage(message: Message, textContentLabelWidth: CGFloat) {
textContentLabel.text = message.textContent
textContentLabelWidthConstraint.constant = textContentLabelWidth
if textContentLabelWidth < minTextLabelWidth {
textContentLabelWidthConstraint.constant = minTextLabelWidth
}else{
textContentLabelWidthConstraint.constant = textContentLabelWidth
}
if let sender = message.fromFriend {
AvatarCache.sharedInstance.roundAvatarOfUser(sender, withRadius: YepConfig.chatCellAvatarSize() * 0.5) { roundImage in
@@ -8,6 +8,8 @@
import UIKit
let minSampleViewWidth: CGFloat = 25.0
class ChatRightAudioCell: UICollectionViewCell {
var message: Message!
@@ -81,6 +83,11 @@ class ChatRightAudioCell: UICollectionViewCell {
if let audioSamples = metaDataDict["audio_samples"] as? [CGFloat] {
sampleViewWidthConstraint.constant = CGFloat(audioSamples.count) * (YepConfig.audioSampleWidth() + YepConfig.audioSampleGap()) - YepConfig.audioSampleGap() // gap
if sampleViewWidthConstraint.constant < minSampleViewWidth {
sampleViewWidthConstraint.constant = minSampleViewWidth
}
sampleView.samples = audioSamples
if let audioDuration = metaDataDict["audio_duration"] as? Double {
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7528.3" systemVersion="14C1514" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7518.3"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</dependencies>
<objects>
@@ -92,7 +92,7 @@
</collectionViewCell>
</objects>
<resources>
<image name="icon_play" width="31" height="30"/>
<image name="icon_play" width="30" height="30"/>
<image name="right_tail_bubble" width="48" height="40"/>
</resources>
</document>
@@ -8,6 +8,8 @@
import UIKit
let minTextLabelWidth: CGFloat = 20.0
class ChatRightTextCell: UICollectionViewCell {
@IBOutlet weak var avatarImageView: UIImageView!
@@ -29,6 +31,7 @@ class ChatRightTextCell: UICollectionViewCell {
avatarImageViewTrailingConstraint.constant = YepConfig.chatCellGapBetweenWallAndAvatar()
textContentLabel.font = UIFont.chatTextFont()
textContentLabel.textAlignment = NSTextAlignment.Center
textContentLabelTrailingConstraint.constant = YepConfig.chatCellGapBetweenTextContentLabelAndAvatar()
textContentLabelLeadingConstraint.constant = YepConfig.chatTextGapBetweenWallAndContentLabel()
@@ -41,7 +44,12 @@ class ChatRightTextCell: UICollectionViewCell {
func configureWithMessage(message: Message, textContentLabelWidth: CGFloat) {
textContentLabel.text = message.textContent
textContentLabelWidthConstraint.constant = textContentLabelWidth
if textContentLabelWidth < minTextLabelWidth {
textContentLabelWidthConstraint.constant = minTextLabelWidth
}else{
textContentLabelWidthConstraint.constant = textContentLabelWidth
}
if let sender = message.fromFriend {
AvatarCache.sharedInstance.roundAvatarOfUser(sender, withRadius: YepConfig.chatCellAvatarSize() * 0.5) { roundImage in