Commit af443d7c authored by Quentin Muret's avatar Quentin Muret Committed by Kateryna Kostiuk

emoji display: refactor leading and trailing margins

- set to 0 the leading and trailing margins for emoji messages.
Those messages are now aligned horizontally with others

Change-Id: Ica2934f432e5d80e6e5cb73e5d8da9869f3c8834
Reviewed-by: Kateryna Kostiuk<kateryna.kostiuk@savoirfairelinux.com>
parent f7cf9364
......@@ -22,4 +22,18 @@ import UIKit
import Reusable
class MessageCellReceived: MessageCell {
//Constraints
@IBOutlet weak var messageLabelTrailingConstraint: NSLayoutConstraint!
@IBOutlet weak var messageLabelLeadingConstraint: NSLayoutConstraint!
override func applyBubbleStyleToCell(_ items: [MessageViewModel]?, cellForRowAt indexPath: IndexPath) {
super.applyBubbleStyleToCell(items, cellForRowAt: indexPath)
if (self.messageLabel.text?.containsOnlyEmoji)! {
self.messageLabelTrailingConstraint.constant = 0
self.messageLabelLeadingConstraint.constant = 0
} else {
self.messageLabelTrailingConstraint.constant = 14
self.messageLabelLeadingConstraint.constant = 14
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" 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="14283.14"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
......@@ -121,7 +120,9 @@
<outlet property="bubbleTopConstraint" destination="jhd-A8-c1o" id="40k-2d-6rW"/>
<outlet property="leftDivider" destination="zuX-zz-1Qq" id="9Jc-cV-VTA"/>
<outlet property="messageLabel" destination="lyR-7c-S2k" id="hd3-pz-Pwh"/>
<outlet property="messageLabelLeadingConstraint" destination="8m5-sR-xnh" id="piI-w5-04J"/>
<outlet property="messageLabelMarginConstraint" destination="O3h-2G-pe5" id="bHE-Hw-I9b"/>
<outlet property="messageLabelTrailingConstraint" destination="uzV-kG-oGN" id="iIi-6G-TTU"/>
<outlet property="rightDivider" destination="eza-Ni-w3g" id="Jfy-s9-5t7"/>
<outlet property="timeLabel" destination="mhg-uK-iD9" id="x8D-vK-F6G"/>
<outlet property="topCorner" destination="WBd-CS-7Qv" id="GCm-Hv-5Ei"/>
......
......@@ -22,4 +22,18 @@ import UIKit
import Reusable
class MessageCellSent: MessageCell {
//Constraints
@IBOutlet weak var messageLabelTrailingConstraint: NSLayoutConstraint!
@IBOutlet weak var messageLabelLeadingConstraint: NSLayoutConstraint!
override func applyBubbleStyleToCell(_ items: [MessageViewModel]?, cellForRowAt indexPath: IndexPath) {
super.applyBubbleStyleToCell(items, cellForRowAt: indexPath)
if (self.messageLabel.text?.containsOnlyEmoji)! {
self.messageLabelTrailingConstraint.constant = 0
self.messageLabelLeadingConstraint.constant = 0
} else {
self.messageLabelTrailingConstraint.constant = 14
self.messageLabelLeadingConstraint.constant = 14
}
}
}
......@@ -72,21 +72,21 @@
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="h8N-aw-5lV" userLabel="Right Divider">
<rect key="frame" x="348" y="63.333333333333336" width="126" height="1.0000000000000071"/>
<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="63.333333333333336" width="126" height="1.0000000000000071"/>
<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="178" y="53.333333333333336" width="154" height="21.000000000000007"/>
<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"/>
......@@ -135,7 +135,9 @@
<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"/>
<outlet property="messageLabelLeadingConstraint" destination="8m5-sR-xnh" id="ShD-gb-tcN"/>
<outlet property="messageLabelMarginConstraint" destination="Fxg-Wa-Rb9" id="zuW-JC-pWN"/>
<outlet property="messageLabelTrailingConstraint" destination="uzV-kG-oGN" id="q3j-c6-l76"/>
<outlet property="rightDivider" destination="h8N-aw-5lV" id="9pc-93-BG6"/>
<outlet property="sendingIndicator" destination="78h-fZ-7yf" id="GrK-FT-q39"/>
<outlet property="timeLabel" destination="ogn-wv-fZy" id="7yt-vi-cSp"/>
......
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