mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-09 04:46:35 +10:00
ChatLeftTextURLCell nib; configure
This commit is contained in:
@@ -269,7 +269,8 @@
|
||||
50D45FC31C44D2300044C95A /* OpenGraphService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50D45FC21C44D2300044C95A /* OpenGraphService.swift */; };
|
||||
50D4D0DB1AFA825B005AEB6F /* MediaControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50D4D0DA1AFA825B005AEB6F /* MediaControlView.swift */; };
|
||||
50DBDEF11C48C2240044E21B /* FeedURLInfoType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50DBDEF01C48C2240044E21B /* FeedURLInfoType.swift */; };
|
||||
50DBDEF91C4CBB040044E21B /* ChatLeftTextURLCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50DBDEF81C4CBB040044E21B /* ChatLeftTextURLCell.swift */; };
|
||||
50DBDEFD1C4CCB030044E21B /* ChatLeftTextURLCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50DBDEFB1C4CCB030044E21B /* ChatLeftTextURLCell.swift */; };
|
||||
50DBDEFE1C4CCB030044E21B /* ChatLeftTextURLCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50DBDEFC1C4CCB030044E21B /* ChatLeftTextURLCell.xib */; };
|
||||
50DEE02C1BE209FF00015741 /* DeletedFeedConversationCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50DEE02A1BE209FF00015741 /* DeletedFeedConversationCell.swift */; };
|
||||
50DEE02D1BE209FF00015741 /* DeletedFeedConversationCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50DEE02B1BE209FF00015741 /* DeletedFeedConversationCell.xib */; };
|
||||
50DEE0311BE339B000015741 /* LoadMoreTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50DEE02F1BE339B000015741 /* LoadMoreTableViewCell.swift */; };
|
||||
@@ -650,7 +651,8 @@
|
||||
50D45FC21C44D2300044C95A /* OpenGraphService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OpenGraphService.swift; path = Services/OpenGraphService.swift; sourceTree = "<group>"; };
|
||||
50D4D0DA1AFA825B005AEB6F /* MediaControlView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MediaControlView.swift; path = Views/Media/MediaControlView.swift; sourceTree = "<group>"; };
|
||||
50DBDEF01C48C2240044E21B /* FeedURLInfoType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FeedURLInfoType.swift; path = Protocols/FeedURLInfoType.swift; sourceTree = "<group>"; };
|
||||
50DBDEF81C4CBB040044E21B /* ChatLeftTextURLCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChatLeftTextURLCell.swift; path = Views/Cells/ChatLeftTextURL/ChatLeftTextURLCell.swift; sourceTree = "<group>"; };
|
||||
50DBDEFB1C4CCB030044E21B /* ChatLeftTextURLCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChatLeftTextURLCell.swift; path = Views/Cells/ChatLeftTextURL/ChatLeftTextURLCell.swift; sourceTree = "<group>"; };
|
||||
50DBDEFC1C4CCB030044E21B /* ChatLeftTextURLCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = ChatLeftTextURLCell.xib; path = Views/Cells/ChatLeftTextURL/ChatLeftTextURLCell.xib; sourceTree = "<group>"; };
|
||||
50DEE02A1BE209FF00015741 /* DeletedFeedConversationCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DeletedFeedConversationCell.swift; path = Views/Cells/DeletedFeedConversation/DeletedFeedConversationCell.swift; sourceTree = "<group>"; };
|
||||
50DEE02B1BE209FF00015741 /* DeletedFeedConversationCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = DeletedFeedConversationCell.xib; path = Views/Cells/DeletedFeedConversation/DeletedFeedConversationCell.xib; sourceTree = "<group>"; };
|
||||
50DEE02F1BE339B000015741 /* LoadMoreTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LoadMoreTableViewCell.swift; path = Views/Cells/LoadMore/LoadMoreTableViewCell.swift; sourceTree = "<group>"; };
|
||||
@@ -2101,7 +2103,8 @@
|
||||
50DBDEFA1C4CBB0F0044E21B /* ChatLeftTextURL */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
50DBDEF81C4CBB040044E21B /* ChatLeftTextURLCell.swift */,
|
||||
50DBDEFB1C4CCB030044E21B /* ChatLeftTextURLCell.swift */,
|
||||
50DBDEFC1C4CCB030044E21B /* ChatLeftTextURLCell.xib */,
|
||||
);
|
||||
name = ChatLeftTextURL;
|
||||
sourceTree = "<group>";
|
||||
@@ -2611,6 +2614,7 @@
|
||||
848806B41B7B4E2E000C5424 /* Show.storyboard in Resources */,
|
||||
0AD7EA771AC3EEB000617758 /* PushConfig.plist in Resources */,
|
||||
502B605B1BD1102B00D9C17E /* TitleCell.xib in Resources */,
|
||||
50DBDEFE1C4CCB030044E21B /* ChatLeftTextURLCell.xib in Resources */,
|
||||
5064F65A1B0B14420089FAD4 /* AddFriendMoreCell.xib in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -2878,7 +2882,7 @@
|
||||
502AE5351AB8649F005BD199 /* LoginByMobileViewController.swift in Sources */,
|
||||
506BB7F91AE5069500C1A2A0 /* RegisterPickSkillsSelectSkillsTransitionManager.swift in Sources */,
|
||||
50B8E6181B41340A00C17EA1 /* MessageLoadingProgressView.swift in Sources */,
|
||||
50DBDEF91C4CBB040044E21B /* ChatLeftTextURLCell.swift in Sources */,
|
||||
50DBDEFD1C4CCB030044E21B /* ChatLeftTextURLCell.swift in Sources */,
|
||||
505A48401B4E70CB00C3A301 /* RegisterSelectSkillsLayout.swift in Sources */,
|
||||
502AE52B1AB819AF005BD199 /* YepConfig.swift in Sources */,
|
||||
50B38FB71B69CD960064C132 /* Array+Yep.swift in Sources */,
|
||||
|
||||
@@ -114,7 +114,7 @@ class ChatLeftTextCell: ChatBaseCell {
|
||||
|
||||
if let strongSelf = self {
|
||||
|
||||
strongSelf.makeUI()
|
||||
//strongSelf.makeUI()
|
||||
|
||||
let topOffset: CGFloat
|
||||
if strongSelf.inGroup {
|
||||
|
||||
@@ -8,26 +8,147 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
class ChatLeftTextURLCell: ChatLeftTextCell {
|
||||
class ChatLeftTextURLCell: ChatBaseCell {
|
||||
|
||||
lazy var feedURLContainerView: FeedURLContainerView = {
|
||||
let view = FeedURLContainerView()
|
||||
view.compressionMode = false
|
||||
return view
|
||||
}()
|
||||
var tapUsernameAction: ((username: String) -> Void)?
|
||||
|
||||
@IBOutlet weak var bubbleTailImageView: UIImageView!
|
||||
|
||||
var bubbleBodyShapeLayer: CAShapeLayer!
|
||||
|
||||
@IBOutlet weak var textContainerView: UIView!
|
||||
@IBOutlet weak var textContentTextView: ChatTextView!
|
||||
|
||||
@IBOutlet weak var feedURLContainerView: FeedURLContainerView!
|
||||
|
||||
func makeUI() {
|
||||
|
||||
let halfAvatarSize = YepConfig.chatCellAvatarSize() / 2
|
||||
|
||||
var topOffset: CGFloat = 0
|
||||
|
||||
if inGroup {
|
||||
topOffset = YepConfig.ChatCell.marginTopForGroup
|
||||
} else {
|
||||
topOffset = 0
|
||||
}
|
||||
|
||||
avatarImageView.center = CGPoint(x: YepConfig.chatCellGapBetweenWallAndAvatar() + halfAvatarSize, y: halfAvatarSize + topOffset)
|
||||
|
||||
textContentTextView.tapMentionAction = { [weak self] username in
|
||||
self?.tapUsernameAction?(username: username)
|
||||
}
|
||||
}
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
|
||||
contentView.addSubview(feedURLContainerView)
|
||||
UIView.performWithoutAnimation { [weak self] in
|
||||
self?.makeUI()
|
||||
}
|
||||
|
||||
bubbleBodyShapeLayer = CAShapeLayer()
|
||||
bubbleBodyShapeLayer.backgroundColor = UIColor.leftBubbleTintColor().CGColor
|
||||
bubbleBodyShapeLayer.fillColor = UIColor.leftBubbleTintColor().CGColor
|
||||
|
||||
textContentTextView.textContainer.lineFragmentPadding = 0
|
||||
textContentTextView.font = UIFont.chatTextFont()
|
||||
textContentTextView.backgroundColor = UIColor.clearColor()
|
||||
textContentTextView.textColor = UIColor.blackColor()
|
||||
textContentTextView.tintColor = UIColor.blackColor()
|
||||
textContentTextView.linkTextAttributes = [
|
||||
NSForegroundColorAttributeName: UIColor.yepTintColor(),
|
||||
NSUnderlineStyleAttributeName: NSNumber(integer: NSUnderlineStyle.StyleSingle.rawValue),
|
||||
]
|
||||
|
||||
bubbleTailImageView.tintColor = UIColor.leftBubbleTintColor()
|
||||
|
||||
if let bubblePosition = layer.sublayers {
|
||||
contentView.layer.insertSublayer(bubbleBodyShapeLayer, atIndex: UInt32(bubblePosition.count))
|
||||
}
|
||||
}
|
||||
|
||||
override func configureWithMessage(message: Message, textContentLabelWidth: CGFloat, collectionView: UICollectionView, indexPath: NSIndexPath) {
|
||||
func configureWithMessage(message: Message, textContentLabelWidth: CGFloat, collectionView: UICollectionView, indexPath: NSIndexPath) {
|
||||
|
||||
super.configureWithMessage(message, textContentLabelWidth: textContentLabelWidth, collectionView: collectionView, indexPath: indexPath)
|
||||
self.user = message.fromFriend
|
||||
|
||||
let frame = CGRect(x: textContainerView.frame.origin.x, y: textContainerView.frame.origin.y + 10, width: 220, height: 100)
|
||||
feedURLContainerView.frame = frame
|
||||
textContentTextView.text = message.textContentToShow
|
||||
|
||||
if message.deletedByCreator {
|
||||
textContentTextView.textColor = UIColor.lightGrayColor()
|
||||
} else {
|
||||
textContentTextView.textColor = UIColor.blackColor()
|
||||
}
|
||||
|
||||
//textContentTextView.attributedText = NSAttributedString(string: message.textContent, attributes: textAttributes)
|
||||
|
||||
//textContentTextView.textAlignment = textContentLabelWidth < YepConfig.minMessageTextLabelWidth ? .Center : .Left
|
||||
|
||||
// 用 sizeThatFits 来对比,不需要 magicWidth 的时候就可以避免了
|
||||
var textContentLabelWidth = textContentLabelWidth
|
||||
let size = textContentTextView.sizeThatFits(CGSize(width: textContentLabelWidth, height: CGFloat.max))
|
||||
|
||||
// lineHeight 19.088, size.height 35.5 (1 line) 54.5 (2 lines)
|
||||
textContentTextView.textAlignment = ((size.height - textContentTextView.font!.lineHeight) < 20) ? .Center : .Left
|
||||
|
||||
if ceil(size.width) != textContentLabelWidth {
|
||||
//println("left ceil(size.width): \(ceil(size.width)), textContentLabelWidth: \(textContentLabelWidth)")
|
||||
//println(">>>\(message.textContent)<<<")
|
||||
|
||||
//textContentLabelWidth += YepConfig.ChatCell.magicWidth
|
||||
if abs(ceil(size.width) - textContentLabelWidth) >= YepConfig.ChatCell.magicWidth {
|
||||
textContentLabelWidth += YepConfig.ChatCell.magicWidth
|
||||
}
|
||||
}
|
||||
|
||||
textContentLabelWidth = max(textContentLabelWidth, YepConfig.ChatCell.minTextWidth)
|
||||
|
||||
UIView.performWithoutAnimation { [weak self] in
|
||||
|
||||
if let strongSelf = self {
|
||||
|
||||
//strongSelf.makeUI()
|
||||
|
||||
let topOffset: CGFloat
|
||||
if strongSelf.inGroup {
|
||||
topOffset = YepConfig.ChatCell.marginTopForGroup
|
||||
} else {
|
||||
topOffset = 0
|
||||
}
|
||||
|
||||
strongSelf.textContainerView.frame = CGRect(x: CGRectGetMaxX(strongSelf.avatarImageView.frame) + YepConfig.chatCellGapBetweenTextContentLabelAndAvatar(), y: 3 + topOffset, width: textContentLabelWidth, height: strongSelf.bounds.height - topOffset - 3 * 2 - 100 - 10)
|
||||
|
||||
strongSelf.textContentTextView.frame = strongSelf.textContainerView.bounds
|
||||
|
||||
let bubbleBodyFrame = CGRectInset(strongSelf.textContainerView.frame, -12, -3)
|
||||
|
||||
strongSelf.bubbleBodyShapeLayer.path = UIBezierPath(roundedRect: bubbleBodyFrame, byRoundingCorners: UIRectCorner.AllCorners, cornerRadii: CGSize(width: YepConfig.ChatCell.bubbleCornerRadius, height: YepConfig.ChatCell.bubbleCornerRadius)).CGPath
|
||||
|
||||
if strongSelf.inGroup {
|
||||
strongSelf.nameLabel.text = strongSelf.user?.chatCellCompositedName
|
||||
|
||||
let height = YepConfig.ChatCell.nameLabelHeightForGroup
|
||||
let x = strongSelf.textContainerView.frame.origin.x
|
||||
let y = strongSelf.textContainerView.frame.origin.y - height - 3
|
||||
let width = strongSelf.contentView.bounds.width - x - 10
|
||||
strongSelf.nameLabel.frame = CGRect(x: x, y: y, width: width, height: height)
|
||||
}
|
||||
|
||||
strongSelf.bubbleTailImageView.center = CGPoint(x: CGRectGetMinX(bubbleBodyFrame), y: CGRectGetMidY(strongSelf.avatarImageView.frame))
|
||||
|
||||
let feedURLContainerViewFrame = CGRect(x: strongSelf.textContainerView.frame.origin.x, y: CGRectGetMaxY(strongSelf.textContainerView.frame) + 10, width: 220, height: 100)
|
||||
strongSelf.feedURLContainerView.frame = feedURLContainerViewFrame
|
||||
|
||||
if let openGraphURLInfo = message.openGraphURLInfo {
|
||||
strongSelf.feedURLContainerView.configureWithFeedURLInfoType(openGraphURLInfo)
|
||||
strongSelf.feedURLContainerView.backgroundColor = UIColor.redColor()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let sender = message.fromFriend {
|
||||
let userAvatar = UserAvatar(userID: sender.userID, avatarStyle: nanoAvatarStyle)
|
||||
avatarImageView.navi_setAvatar(userAvatar, withFadeTransitionDuration: avatarFadeTransitionDuration)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
|
||||
</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" id="gTV-IL-0wX" customClass="ChatLeftTextURLCell" customModule="Yep" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="367" height="249"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="367" height="249"/>
|
||||
<subviews>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" id="N5w-gk-BB8" userLabel="Avatar Image View">
|
||||
<rect key="frame" x="15" y="0.0" width="40" height="40"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
</imageView>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="bubble_left_tail" id="Wg1-qw-vzw" userLabel="Bubble Tail Image View">
|
||||
<rect key="frame" x="57" y="13" width="13" height="14"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
</imageView>
|
||||
<view contentMode="scaleToFill" id="6TL-Ul-b1B">
|
||||
<rect key="frame" x="75" y="3" width="150" height="60"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<textView clipsSubviews="YES" contentMode="scaleToFill" bounces="NO" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" editable="NO" id="E4T-OA-5Jk" customClass="ChatTextView" customModule="Yep" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="150" height="60"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||
<dataDetectorType key="dataDetectorTypes" phoneNumber="YES" link="YES" address="YES" calendarEvent="YES"/>
|
||||
</textView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<view contentMode="scaleToFill" id="5bC-0n-JQd" customClass="FeedURLContainerView" customModule="Yep" customModuleProvider="target">
|
||||
<rect key="frame" x="75" y="76" width="220" height="100"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<size key="customSize" width="367" height="249"/>
|
||||
<connections>
|
||||
<outlet property="avatarImageView" destination="N5w-gk-BB8" id="JY0-mt-RZb"/>
|
||||
<outlet property="bubbleTailImageView" destination="Wg1-qw-vzw" id="CpO-pL-FId"/>
|
||||
<outlet property="feedURLContainerView" destination="5bC-0n-JQd" id="Vsh-zt-Ly0"/>
|
||||
<outlet property="textContainerView" destination="6TL-Ul-b1B" id="5mz-af-A7i"/>
|
||||
<outlet property="textContentTextView" destination="E4T-OA-5Jk" id="jre-lB-zTG"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="226.5" y="291.5"/>
|
||||
</collectionViewCell>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="bubble_left_tail" width="13" height="14"/>
|
||||
</resources>
|
||||
</document>
|
||||
Reference in New Issue
Block a user