From 59d0aff034b2cdd1bbee781a6e43e49d21fde768 Mon Sep 17 00:00:00 2001 From: Ivan Sein Date: Mon, 2 Dec 2024 12:01:18 +0100 Subject: [PATCH] feat: Add start and end dates to out-of-office view Signed-off-by: Ivan Sein --- NextcloudTalk/OutOfOfficeView.swift | 24 ++++++++++++++++++++++++ NextcloudTalk/OutOfOfficeView.xib | 13 ++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/NextcloudTalk/OutOfOfficeView.swift b/NextcloudTalk/OutOfOfficeView.swift index 0465ed0d1..a05478eff 100644 --- a/NextcloudTalk/OutOfOfficeView.swift +++ b/NextcloudTalk/OutOfOfficeView.swift @@ -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! @@ -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)) diff --git a/NextcloudTalk/OutOfOfficeView.xib b/NextcloudTalk/OutOfOfficeView.xib index 3bccf0def..87d9a773b 100644 --- a/NextcloudTalk/OutOfOfficeView.xib +++ b/NextcloudTalk/OutOfOfficeView.xib @@ -12,6 +12,7 @@ + @@ -58,14 +59,20 @@ + - + 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. @@ -112,7 +119,7 @@ - +