Commit b0d3c4b2 authored by Quentin Muret's avatar Quentin Muret Committed by Adrien Béraud

When a message contains only emojis, it is displayed bigger and without background

Change-Id: I96d47b52b7967e6644c8751c85a5a97bbface9cb
parent 47c5c339
......@@ -37,6 +37,7 @@ extension UIColor {
static let ringMain = UIColor(red: 54, green: 125, blue: 156, alpha: 1.0)
static let ringSecondary = UIColor(red: 0, green: 76, blue: 96, alpha: 1.0)
static let ringMainLight = UIColor(red: 0, green: 76, blue: 96, alpha: 1.0)
static let ringMsgCellEmoji = UIColor(red: 0, green: 0, blue: 0, alpha: 0)
static let ringMsgCellSent = UIColor(red: 58, green: 192, blue: 210, alpha: 1.0)
static let ringMsgCellSentText = UIColor(red: 255, green: 255, blue: 255, alpha: 1.0)
static let ringMsgCellReceived = UIColor(red: 231, green: 235, blue: 235, alpha: 1.0)
......
......@@ -34,6 +34,7 @@ class MessageCell: UITableViewCell, NibReusable {
@IBOutlet weak var bubbleBottomConstraint: NSLayoutConstraint!
@IBOutlet weak var bubbleTopConstraint: NSLayoutConstraint!
@IBOutlet weak var messageLabelMarginConstraint: NSLayoutConstraint!
@IBOutlet weak var avatarBotomAlignConstraint: NSLayoutConstraint!
@IBOutlet weak var messageLabel: ActiveLabel!
@IBOutlet weak var sizeLabel: UILabel!
@IBOutlet weak var statusLabel: UILabel!
......@@ -56,6 +57,7 @@ class MessageCell: UITableViewCell, NibReusable {
var disposeBag = DisposeBag()
override func prepareForReuse() {
super.prepareForReuse()
self.stopProgressMonitor()
......@@ -158,9 +160,17 @@ class MessageCell: UITableViewCell, NibReusable {
let type = item.bubblePosition()
var bubbleColor: UIColor
if item.isTransfer {
bubbleColor = type == .received ? UIColor.ringMsgCellReceived : UIColor(hex: 0xcfebf5, alpha: 1.0)
if item.content.containsOnlyEmoji {
bubbleColor = UIColor.ringMsgCellEmoji
} else {
bubbleColor = type == .received ? UIColor.ringMsgCellReceived : UIColor(hex: 0xcfebf5, alpha: 1.0)
}
} else {
bubbleColor = type == .received ? UIColor.ringMsgCellReceived : UIColor.ringMsgCellSent
if item.content.containsOnlyEmoji {
bubbleColor = UIColor.ringMsgCellEmoji
} else {
bubbleColor = type == .received ? UIColor.ringMsgCellReceived : UIColor.ringMsgCellSent
}
}
if item.isTransfer {
......@@ -229,6 +239,11 @@ class MessageCell: UITableViewCell, NibReusable {
self.bubbleTopConstraint.constant = item.timeStringShown != nil ? 32 : 1
default: break
}
if item.content.containsOnlyEmoji {
self.messageLabel.font = UIFont.systemFont(ofSize: 40.0, weight: UIFont.Weight.medium)
} else {
self.messageLabel.font = UIFont.systemFont(ofSize: 16.0, weight: UIFont.Weight.medium)
}
}
/// swiftlint:disable function_body_length
......@@ -298,6 +313,12 @@ class MessageCell: UITableViewCell, NibReusable {
}
if item.bubblePosition() == .sent {
// When the message contains only emoji
if item.content.containsOnlyEmoji {
self.bubble.backgroundColor = UIColor.ringMsgCellEmoji
} else {
self.bubble.backgroundColor = UIColor.ringMsgCellSent
}
if item.isTransfer {
// outgoing transfer
} else {
......@@ -314,6 +335,14 @@ class MessageCell: UITableViewCell, NibReusable {
.disposed(by: self.disposeBag)
}
} else if item.bubblePosition() == .received {
// When the message contains only emoji
if item.content.containsOnlyEmoji {
self.bubble.backgroundColor = UIColor.ringMsgCellEmoji
self.avatarBotomAlignConstraint.constant = -14
} else {
self.bubble.backgroundColor = UIColor.ringMsgCellReceived
self.avatarBotomAlignConstraint.constant = -1
}
// received message avatar
Observable<(Data?, String)>.combineLatest(conversationViewModel.profileImageData.asObservable(),
conversationViewModel.userName.asObservable(),
......
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
......@@ -15,12 +15,12 @@
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" rowHeight="60" id="KGk-i7-Jjw" customClass="MessageCellReceived" customModule="Ring" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="510" height="47"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="510" height="46.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Nc6-du-YKs" userLabel="Avatar View">
<rect key="frame" x="16" y="4.5" width="32" height="32"/>
<rect key="frame" x="16" y="7.5" width="32" height="32"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="32" id="7ec-U6-IXo"/>
......@@ -36,7 +36,7 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XcL-CH-BiH" userLabel="Bottom Corner">
<rect key="frame" x="64" y="22" width="17" height="17"/>
<rect key="frame" x="64" y="24.5" width="17" height="17"/>
<color key="backgroundColor" red="1" green="0.5" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="17" id="ocR-DU-zKZ"/>
......@@ -44,10 +44,10 @@
</constraints>
</view>
<view clipsSubviews="YES" contentMode="scaleToFill" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="kZJ-Ay-LTR" customClass="MessageBubble" customModule="Ring" customModuleProvider="target">
<rect key="frame" x="64" y="8" width="198.5" height="30.5"/>
<rect key="frame" x="64" y="8" width="198.5" height="33.5"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label Label Label Label" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lyR-7c-S2k" customClass="ActiveLabel" customModule="ActiveLabel">
<rect key="frame" x="14" y="7" width="170.5" height="16.5"/>
<rect key="frame" x="14" y="7" width="170.5" height="19.5"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<nil key="highlightedColor"/>
</label>
......@@ -68,21 +68,21 @@
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="zuX-zz-1Qq" userLabel="Left Divider">
<rect key="frame" x="36" y="19" width="126.5" height="1"/>
<rect key="frame" x="36" y="19" width="126" height="1"/>
<color key="backgroundColor" red="0.94117647058823528" green="0.94117647058823528" blue="0.94117647058823528" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="OBa-HX-Vts"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="eza-Ni-w3g" userLabel="Right Divider">
<rect key="frame" x="348.5" y="19" width="125.5" height="1"/>
<rect key="frame" x="348" y="19" width="126" height="1"/>
<color key="backgroundColor" red="0.94117647058823528" green="0.94117647058823528" blue="0.94117647058823528" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="7z5-Mi-Abp"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="11/14/2016 12:34PM" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mhg-uK-iD9" userLabel="Message Time">
<rect key="frame" x="178.5" y="9" width="154" height="21"/>
<rect key="frame" x="178" y="9" width="154" height="21"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
......@@ -113,6 +113,7 @@
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="avatarBotomAlignConstraint" destination="yjZ-dX-bdF" id="Dzm-02-Mra"/>
<outlet property="avatarView" destination="Nc6-du-YKs" id="mSn-gc-VNs"/>
<outlet property="bottomCorner" destination="XcL-CH-BiH" id="4gw-IC-EAM"/>
<outlet property="bubble" destination="kZJ-Ay-LTR" id="hdG-fG-L69"/>
......
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina6_5" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
......@@ -15,12 +14,12 @@
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" rowHeight="60" id="KGk-i7-Jjw" customClass="MessageCellSent" customModule="Ring" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="510" height="47"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="510" height="46.5"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="510" height="46.666666666666664"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hdz-AQ-xHI" userLabel="Bottom Corner">
<rect key="frame" x="477" y="22" width="17" height="17"/>
<rect key="frame" x="477" y="25.666666666666671" width="17" height="17"/>
<color key="backgroundColor" red="1" green="0.5" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="17" id="D0h-cW-9kB"/>
......@@ -34,7 +33,7 @@
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="EMh-bG-ilg" userLabel="Top Corner">
<rect key="frame" x="477" y="8" width="17" height="17"/>
<rect key="frame" x="477" y="8.3333333333333321" width="17" height="17"/>
<color key="backgroundColor" red="1" green="0.0" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="17" id="zaa-Rn-ziw"/>
......@@ -48,10 +47,10 @@
</userDefinedRuntimeAttributes>
</view>
<view clipsSubviews="YES" contentMode="scaleToFill" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="kZJ-Ay-LTR" customClass="MessageBubble" customModule="Ring" customModuleProvider="target">
<rect key="frame" x="286.5" y="8" width="207.5" height="31"/>
<rect key="frame" x="286.66666666666669" y="8.3333333333333321" width="207.33333333333331" height="34.333333333333343"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label Label Label Label" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lyR-7c-S2k" customClass="ActiveLabel" customModule="ActiveLabel">
<rect key="frame" x="14" y="7" width="179.5" height="17"/>
<rect key="frame" x="14" y="7.0000000000000018" width="179.33333333333334" height="20.333333333333336"/>
<fontDescription key="fontDescription" name=".AppleSystemUIFont" family=".AppleSystemUIFont" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
......@@ -73,30 +72,30 @@
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="h8N-aw-5lV" userLabel="Right Divider">
<rect key="frame" x="347.5" y="19" width="126.5" height="1"/>
<rect key="frame" x="348" y="19.333333333333332" width="126" height="1"/>
<color key="backgroundColor" red="0.94117647058823528" green="0.94117647058823528" blue="0.94117647058823528" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="3h1-r8-Nis"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2U4-l3-KET" userLabel="Left Divider">
<rect key="frame" x="36" y="19" width="125.5" height="1"/>
<rect key="frame" x="36" y="19.333333333333332" width="126" height="1"/>
<color key="backgroundColor" red="0.94117647058823528" green="0.94117647058823528" blue="0.94117647058823528" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="gla-pJ-IsN"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="11/14/2016 12:34PM" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ogn-wv-fZy" userLabel="Message Time">
<rect key="frame" x="177.5" y="9" width="154" height="21"/>
<rect key="frame" x="178" y="9.3333333333333321" width="154" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" animating="YES" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="78h-fZ-7yf" userLabel="Sending Indicator">
<rect key="frame" x="258.5" y="16" width="20" height="20"/>
<rect key="frame" x="258.66666666666669" y="16.333333333333336" width="20" height="20"/>
</activityIndicatorView>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Failed" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="P5a-HI-uhr" userLabel="Failed Status Label">
<rect key="frame" x="236" y="16" width="42.5" height="19.5"/>
<rect key="frame" x="236.33333333333334" y="16.333333333333336" width="42.333333333333343" height="19.333333333333336"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.94117647058823528" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
......@@ -132,6 +131,7 @@
<outlet property="bubble" destination="kZJ-Ay-LTR" id="hdG-fG-L69"/>
<outlet property="bubbleBottomConstraint" destination="1QQ-bu-6Bl" id="woo-UQ-wXK"/>
<outlet property="bubbleTopConstraint" destination="jhd-A8-c1o" id="cll-eA-OC5"/>
<outlet property="buttonsHeightConstraint" destination="1Kj-UZ-gu7" id="5XS-t5-9Mb"/>
<outlet property="failedStatusLabel" destination="P5a-HI-uhr" id="6Sq-NU-j0d"/>
<outlet property="leftDivider" destination="2U4-l3-KET" id="y4j-CT-gez"/>
<outlet property="messageLabel" destination="lyR-7c-S2k" id="hd3-pz-Pwh"/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment