Skip to content

Commit

Permalink
Better datetime formatting in resources UI
Browse files Browse the repository at this point in the history
  • Loading branch information
tmolitor-stud-tu committed Jan 29, 2023
1 parent b8212af commit e9a52da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Monal/Classes/AVCallUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ struct AVCallUI: View {
self.delegate = delegate
self.appDelegate = UIApplication.shared.delegate as! MonalAppDelegate
self.formatter = DateComponentsFormatter()
formatter.allowedUnits = [.hour, .minute, .second]
formatter.unitsStyle = .positional
formatter.zeroFormattingBehavior = .pad
self.formatter.allowedUnits = [.hour, .minute, .second]
self.formatter.unitsStyle = .positional
self.formatter.zeroFormattingBehavior = .pad
}

var body: some View {
Expand Down
13 changes: 9 additions & 4 deletions Monal/Classes/ContactResources.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ struct ContactResources: View {
resourceRowElement("Client Version:", Text(versionInfo.appVersion as String? ?? ""))
resourceRowElement("OS:", Text(versionInfo.platformOs as String? ?? ""))
if let lastInteraction = versionInfo.lastInteraction as Date? {
resourceRowElement("Last Interaction:", HStack {
Text(lastInteraction, style:.date)
Text(lastInteraction, style:.time)
})
if lastInteraction.timeIntervalSince1970 == 0 {
resourceRowElement("Last Interaction:", Text("Currently Online"))
} else {
if #available(iOS 15, *) {
resourceRowElement("Last Interaction:", Text(lastInteraction.formatted(date:.numeric, time:.standard)))
} else {
resourceRowElement("Last Interaction:", Text("\(String(describing:lastInteraction))"))
}
}
} else {
resourceRowElement("Last Interaction:", Text("unsupported"))
}
Expand Down

0 comments on commit e9a52da

Please sign in to comment.