diff options
Diffstat (limited to 'Hutch/Views/Settings')
| -rw-r--r-- | Hutch/Views/Settings/SettingsView.swift | 35 | ||||
| -rw-r--r-- | Hutch/Views/Settings/SettingsViewModel.swift | 4 |
2 files changed, 29 insertions, 10 deletions
diff --git a/Hutch/Views/Settings/SettingsView.swift b/Hutch/Views/Settings/SettingsView.swift index 5bbded8..9b7d41f 100644 --- a/Hutch/Views/Settings/SettingsView.swift +++ b/Hutch/Views/Settings/SettingsView.swift @@ -1,6 +1,10 @@ import PhotosUI import SwiftUI +private let settingsBioMarkdownOptions = AttributedString.MarkdownParsingOptions( + interpretedSyntax: .inlineOnlyPreservingWhitespace +) + struct SettingsView: View { @Environment(AppState.self) private var appState @Environment(\.colorScheme) private var colorScheme @@ -163,13 +167,7 @@ struct SettingsView: View { Text("Bio") .font(.caption) .foregroundStyle(.secondary) - RenderedMarkupContentView( - content: .markdown(bio), - readmePath: nil, - colorScheme: colorScheme, - ownerCanonicalName: "", - repositoryName: "" - ) + SettingsBioView(markdown: bio) } } @@ -424,6 +422,27 @@ struct SettingsView: View { } } +private struct SettingsBioView: View { + let markdown: String + + var body: some View { + Text(settingsBioAttributedString(markdown)) + .frame(maxWidth: .infinity, alignment: .leading) + .tint(.accentColor) + .textSelection(.enabled) + } +} + +func settingsBioAttributedString(_ markdown: String) -> AttributedString { + guard let attributed = try? AttributedString( + markdown: markdown, + options: settingsBioMarkdownOptions + ) else { + return AttributedString(markdown) + } + return attributed +} + // MARK: - Edit Profile Sheet private struct EditProfileSheet: View { @@ -695,7 +714,7 @@ private struct AboutView: View { Link(destination: URL(string: "https://man.sr.ht")!) { SwiftUI.Label("SourceHut Manuals", systemImage: "book") } - Link(destination: URL(string: "https://git.sr.ht/~ccleberg/Hutch")!) { + Link(destination: URL(string: "https://sr.ht/~ccleberg/Hutch")!) { SwiftUI.Label("Project Repository", systemImage: "folder") } } diff --git a/Hutch/Views/Settings/SettingsViewModel.swift b/Hutch/Views/Settings/SettingsViewModel.swift index 204afbf..1cc5426 100644 --- a/Hutch/Views/Settings/SettingsViewModel.swift +++ b/Hutch/Views/Settings/SettingsViewModel.swift @@ -24,7 +24,7 @@ private struct CreateSSHKeyResponse: Decodable, Sendable { } private struct DeleteSSHKeyResponse: Decodable, Sendable { - let deleteSSHKey: DeleteResult + let deleteSSHKey: DeleteResult? } private struct CreatePGPKeyResponse: Decodable, Sendable { @@ -32,7 +32,7 @@ private struct CreatePGPKeyResponse: Decodable, Sendable { } private struct DeletePGPKeyResponse: Decodable, Sendable { - let deletePGPKey: DeleteResult + let deletePGPKey: DeleteResult? } private struct DeleteResult: Decodable, Sendable { |
