Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4683 from toggl-open-source/fix/timeline-descript…
Browse files Browse the repository at this point in the history
…ion-truncation

Truncate TE description on Timeline (mac)
  • Loading branch information
skel35 authored Nov 18, 2020
2 parents 6d16139 + 82e53ec commit 7948b8c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class ProjectTitleFactory: NSObject {

@objc
func title(withProject project: String,
task: String?,
client: String?,
task: String? = nil,
client: String? = nil,
projectColor: NSColor,
clientColor: NSColor? = nil) -> NSAttributedString {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ final class TimelineTimeEntryCell: TimelineBaseCell {
// MARK: OUTLET

@IBOutlet weak var titleLbl: NSTextField!
@IBOutlet weak var projectStackView: NSStackView!
@IBOutlet weak var dotColorBox: DotImageView!
@IBOutlet weak var projectLbl: ProjectTextField!
@IBOutlet weak var clientNameLbl: NSTextField!
@IBOutlet weak var billableImageView: NSImageView!
Expand Down Expand Up @@ -125,7 +123,7 @@ final class TimelineTimeEntryCell: TimelineBaseCell {

// Prepare controls need to check
var components: [NSView] = [titleLbl]
if !projectStackView.isHidden { components.append(projectStackView) }
if !projectLbl.isHidden { components.append(projectLbl) }
if !clientNameLbl.isHidden { components.append(clientNameLbl) }
components.append(iconStackView)

Expand Down Expand Up @@ -163,19 +161,12 @@ final class TimelineTimeEntryCell: TimelineBaseCell {

// Projects
if let project = item.projectLabel, !project.isEmpty {
projectStackView.isHidden = false
if let color = ConvertHexColor.hexCode(toNSColor: item.projectColor) {
dotColorBox.isHidden = false
dotColorBox.fill(with: color)
projectLbl.textColor = color
} else {
dotColorBox.isHidden = true
projectLbl.textColor = NSColor.labelColor
}
projectLbl.stringValue = project
projectLbl.isHidden = false
projectLbl.toolTip = project
projectLbl.attributedStringValue = projectTitle(from: item)

} else {
projectStackView.isHidden = true
projectLbl.isHidden = true
}

// Client
Expand Down Expand Up @@ -210,6 +201,18 @@ extension TimelineTimeEntryCell {
backgroundBox?.isHidden = isHidden
innerBackgroundBox.isHidden = isHidden
}

private func projectTitle(from timeEntry: TimeEntryViewItem) -> NSAttributedString {
let projectTitle = NSMutableAttributedString(
attributedString: ProjectTitleFactory().title(
withProject: timeEntry.projectLabel,
task: timeEntry.taskLabel,
projectColor: ConvertHexColor.hexCode(toNSColor: timeEntry.projectColor)
)
)
projectTitle.setAlignment(.left, range: NSRange(location: 0, length: projectTitle.length))
return projectTitle
}
}

// MARK: TimelineTimeEntryMenuDelegate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17506" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="16097.2"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17506"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -31,56 +31,35 @@
<customView horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="IJ4-qg-XP7" customClass="CornerBoxView" customModule="Toggl_Track" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="197" height="107"/>
<subviews>
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="4" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Dpe-7G-baj">
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="4" horizontalStackHuggingPriority="750" verticalStackHuggingPriority="249.99998474121094" horizontalClippingResistancePriority="250" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Dpe-7G-baj">
<rect key="frame" x="30" y="22" width="167" height="81"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xXs-or-rIk">
<textField horizontalHuggingPriority="750" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="xXs-or-rIk">
<rect key="frame" x="-2" y="66" width="77" height="15"/>
<textFieldCell key="cell" lineBreakMode="clipping" selectable="YES" title="Copy Review" id="x7F-x0-ynb">
<font key="font" metaFont="label" size="12"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" selectable="YES" title="Copy Review" id="x7F-x0-ynb">
<font key="font" metaFont="cellTitle"/>
<color key="textColor" name="black-text-color"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<stackView distribution="fill" orientation="horizontal" alignment="centerY" spacing="7" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Azu-a1-gfT">
<rect key="frame" x="0.0" y="47" width="100" height="15"/>
<subviews>
<imageView horizontalHuggingPriority="1000" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="IRd-GO-o1l" customClass="DotImageView" customModule="Toggl_Track" customModuleProvider="target">
<rect key="frame" x="0.0" y="4" width="8" height="8"/>
<constraints>
<constraint firstAttribute="height" constant="8" id="CyW-Lz-h7S"/>
<constraint firstAttribute="width" constant="8" id="H94-dd-E7G"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="time-entry-dot" id="aL9-XR-zzS"/>
</imageView>
<textField horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="euI-fo-hqA" customClass="ProjectTextField">
<rect key="frame" x="13" y="0.0" width="89" height="15"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" selectable="YES" sendsActionOnEndEditing="YES" alignment="left" title="NEW - TOGGL " placeholderString="+ Add project" id="liW-U4-bg3">
<font key="font" metaFont="label" size="12"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<visibilityPriorities>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ypi-B4-1IQ">
<textField horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="euI-fo-hqA" customClass="ProjectTextField">
<rect key="frame" x="-2" y="47" width="171" height="15"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" selectable="YES" sendsActionOnEndEditing="YES" alignment="left" title="NEW - TOGGL " placeholderString="+ Add project" id="liW-U4-bg3">
<font key="font" metaFont="cellTitle"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="750" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="Ypi-B4-1IQ">
<rect key="frame" x="-2" y="28" width="72" height="15"/>
<textFieldCell key="cell" lineBreakMode="clipping" selectable="YES" title="Client name" id="tNO-GK-NSh">
<font key="font" metaFont="label" size="12"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" selectable="YES" title="Client name" id="tNO-GK-NSh">
<font key="font" metaFont="cellTitle"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<stackView distribution="fill" orientation="horizontal" alignment="bottom" spacing="5" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" horizontalHuggingPriority="1000" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="PyM-uW-hFa">
<rect key="frame" x="0.0" y="0.0" width="147" height="24"/>
<rect key="frame" x="0.0" y="0.0" width="167" height="24"/>
<subviews>
<imageView translatesAutoresizingMaskIntoConstraints="NO" id="qtZ-fn-lLE">
<rect key="frame" x="0.0" y="0.0" width="17" height="17"/>
Expand All @@ -99,12 +78,12 @@
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" animates="YES" imageScaling="proportionallyDown" image="time-entry-billable" id="WjC-yn-K4V"/>
</imageView>
<customView horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="8dq-AH-3f2">
<rect key="frame" x="44" y="0.0" width="103" height="16"/>
<rect key="frame" x="44" y="0.0" width="123" height="16"/>
<subviews>
<textField horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="fa0-T9-1iU">
<rect key="frame" x="76" y="1" width="24" height="15"/>
<rect key="frame" x="96" y="1" width="24" height="15"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" alignment="right" title="12h" id="k25-lb-1QZ">
<font key="font" metaFont="label" size="12"/>
<font key="font" metaFont="cellTitle"/>
<color key="textColor" name="black-text-color"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
Expand Down Expand Up @@ -204,14 +183,12 @@
<outlet property="backgroundBox" destination="IJ4-qg-XP7" id="q8G-r5-CnQ"/>
<outlet property="billableImageView" destination="KGC-LT-pQG" id="6hB-b9-5ra"/>
<outlet property="clientNameLbl" destination="Ypi-B4-1IQ" id="CWd-5X-D9a"/>
<outlet property="dotColorBox" destination="IRd-GO-o1l" id="e83-2k-O8A"/>
<outlet property="durationLbl" destination="fa0-T9-1iU" id="dzs-lY-QOM"/>
<outlet property="foregroundBox" destination="CHS-wV-aVu" id="nAo-eo-eYl"/>
<outlet property="iconStackView" destination="PyM-uW-hFa" id="iwc-5a-pK9"/>
<outlet property="innerBackgroundBox" destination="ZlO-hY-zkZ" id="rfz-JL-MIh"/>
<outlet property="mainStackView" destination="Dpe-7G-baj" id="GwM-nb-8fY"/>
<outlet property="projectLbl" destination="euI-fo-hqA" id="tZs-ru-phr"/>
<outlet property="projectStackView" destination="Azu-a1-gfT" id="MiD-AE-fBP"/>
<outlet property="tagImageView" destination="qtZ-fn-lLE" id="36s-n9-HL8"/>
<outlet property="titleLbl" destination="xXs-or-rIk" id="dxH-Qt-9kv"/>
<outlet property="view" destination="Hz6-mo-xeY" id="KyO-gv-pek"/>
Expand All @@ -220,7 +197,6 @@
</objects>
<resources>
<image name="time-entry-billable" width="16" height="16"/>
<image name="time-entry-dot" width="8" height="8"/>
<image name="time-entry-tag" width="16" height="16"/>
<namedColor name="black-text-color">
<color red="0.17254901960784313" green="0.074509803921568626" blue="0.2196078431372549" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand Down

0 comments on commit 7948b8c

Please sign in to comment.