diff options
| author | Christian Cleberg <[email protected]> | 2026-04-01 23:54:01 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-01 23:54:01 -0500 |
| commit | fb103fbabd9865f711f5052f63816b35fc259585 (patch) | |
| tree | 3c6df1bb04c6d1e8e937e5bbc6f75725f5c6d926 /Hutch/Views/Lookup/UserProfileView.swift | |
| parent | 0bef9acc515cfcb4ac6e2530cd34cbdbc47c2c1d (diff) | |
| download | hutch-fb103fbabd9865f711f5052f63816b35fc259585.tar.gz hutch-fb103fbabd9865f711f5052f63816b35fc259585.tar.bz2 hutch-fb103fbabd9865f711f5052f63816b35fc259585.zip | |
feat: expand user profile in Look Up
Diffstat (limited to 'Hutch/Views/Lookup/UserProfileView.swift')
| -rw-r--r-- | Hutch/Views/Lookup/UserProfileView.swift | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/Hutch/Views/Lookup/UserProfileView.swift b/Hutch/Views/Lookup/UserProfileView.swift index 3fcbb2f..4c91244 100644 --- a/Hutch/Views/Lookup/UserProfileView.swift +++ b/Hutch/Views/Lookup/UserProfileView.swift @@ -3,7 +3,12 @@ import SwiftUI struct UserProfileView: View { let user: User - @Environment(AppState.self) private var appState + private static let iso8601Formatter: ISO8601DateFormatter = { + let formatter = ISO8601DateFormatter() + formatter.formatOptions = [.withInternetDateTime] + formatter.timeZone = TimeZone(secondsFromGMT: 0) + return formatter + }() var body: some View { List { @@ -42,11 +47,56 @@ struct UserProfileView: View { Section { LabeledContent("Username", value: user.username) LabeledContent("Canonical Name", value: user.canonicalName) + if let userType = user.userType { + LabeledContent("User Type", value: userType) + } + if let pronouns = user.pronouns { + LabeledContent("Pronouns", value: pronouns) + } + if let suspensionNotice = user.suspensionNotice { + LabeledContent("Suspension Notice", value: suspensionNotice) + } + } + + Section { LabeledContent("Email", value: user.email) + if let urlString = user.url, let url = URL(string: urlString) { + LabeledContent("URL") { + Link(urlString, destination: url) + } + } + if let location = user.location { + LabeledContent("Location", value: location) + } + } + + if let bio = user.bio { + Section("Bio") { + Text(bio) + } + } + + if user.created != nil || user.updated != nil { + Section { + if let created = user.created { + LabeledContent("Joined", value: formattedTimestamp(created)) + } + if let updated = user.updated { + LabeledContent("Updated", value: formattedTimestamp(updated)) + } + } } } .listStyle(.insetGrouped) .navigationTitle(user.canonicalName) .navigationBarTitleDisplayMode(.inline) } + + private func formattedTimestamp(_ value: String) -> String { + guard let date = Self.iso8601Formatter.date(from: value) else { + return value + } + + return date.formatted(date: .abbreviated, time: .shortened) + } } |
