Skip to content

Commit

Permalink
feat: Add start and end dates to out-of-office view
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Sein <[email protected]>
  • Loading branch information
Ivansss committed Dec 2, 2024
1 parent 0e8fd30 commit 59d0aff
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
24 changes: 24 additions & 0 deletions NextcloudTalk/OutOfOfficeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import SwiftyAttributes
@IBOutlet weak var stackView: UIStackView!

@IBOutlet weak var title: UILabel!
@IBOutlet weak var dates: UILabel!
@IBOutlet weak var replacement: UILabel!
@IBOutlet weak var subtitle: UITextView!

Expand Down Expand Up @@ -81,6 +82,29 @@ import SwiftyAttributes

var menuActions = [dismissAction]

if let startDateTimestamp = absenceData.startDate, let endDateTimestamp = absenceData.endDate {
let startDate = Date(timeIntervalSince1970: TimeInterval(startDateTimestamp))
let endDate = Date(timeIntervalSince1970: TimeInterval(endDateTimestamp))

let isSameDay = Calendar.current.isDate(startDate, inSameDayAs: endDate)
if isSameDay {
title.text = String.localizedStringWithFormat(NSLocalizedString("%@ is out of office today", comment: "'%@' is the name of a user"), room.displayName)
dates.isHidden = true
} else {
let dateFormatter = DateFormatter()
dateFormatter.dateStyle = .medium
dateFormatter.timeStyle = .none
dateFormatter.locale = Locale.current

let startDateString = dateFormatter.string(from: startDate)
let endDateString = dateFormatter.string(from: endDate)

dates.text = "\(startDateString) - \(endDateString)"
}
} else {
dates.isHidden = true
}

if let replacementUserId = absenceData.replacementUserId, let replacementUserDisplayname = absenceData.replacementUserDisplayName {
let replacementString = NSLocalizedString("Replacement", comment: "Replacement in case of out of office").withFont(.preferredFont(forTextStyle: .body))
let separatorString = ": ".withFont(.preferredFont(forTextStyle: .body))
Expand Down
13 changes: 10 additions & 3 deletions NextcloudTalk/OutOfOfficeView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<connections>
<outlet property="backgroundView" destination="Xsl-mz-DBd" id="gvK-dc-O5I"/>
<outlet property="contentView" destination="iN0-l3-epB" id="gDR-On-leO"/>
<outlet property="dates" destination="0sH-vg-JfJ" id="nmq-2I-Q4r"/>
<outlet property="leftIndicator" destination="MdQ-4Z-aXZ" id="Op4-Ve-fJg"/>
<outlet property="replacement" destination="335-sd-Dif" id="2qP-rw-hYL"/>
<outlet property="stackView" destination="OHJ-nY-k0O" id="X43-BC-ZYX"/>
Expand Down Expand Up @@ -58,14 +59,20 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="1000" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0sH-vg-JfJ">
<rect key="frame" x="0.0" y="28.333333333333336" width="546" height="20.333333333333336"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="1000" text="Replacement is ..." textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="335-sd-Dif">
<rect key="frame" x="0.0" y="29.666666666666664" width="546" height="20.333333333333336"/>
<rect key="frame" x="0.0" y="56.666666666666679" width="546" height="20.333333333333336"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" editable="NO" textAlignment="natural" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fGe-4e-Cfj">
<rect key="frame" x="0.0" y="59" width="546" height="192"/>
<rect key="frame" x="0.0" y="85" width="546" height="166"/>
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
<color key="textColor" systemColor="labelColor"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
Expand Down Expand Up @@ -112,7 +119,7 @@
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemBlueColor">
<color red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>

0 comments on commit 59d0aff

Please sign in to comment.