damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 6ec533b0cdee2d78705489597a269a164130004d
parent 51a58360f97c18b003abb4e06434382ca585bc66
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 20 Jun 2023 15:30:48 +0200

view: Add AboutView

This will be used by different views for the user's about section

Diffstat:
Mdamus.xcodeproj/project.pbxproj | 4++++
Adamus/Views/Profile/AboutView.swift | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/damus.xcodeproj/project.pbxproj b/damus.xcodeproj/project.pbxproj @@ -196,6 +196,7 @@ 4CB883AE2976FA9300DC99E7 /* FormatTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CB883AD2976FA9300DC99E7 /* FormatTests.swift */; }; 4CB883B0297705DD00DC99E7 /* ZapButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CB883AF297705DD00DC99E7 /* ZapButton.swift */; }; 4CB883B6297730E400DC99E7 /* LNUrls.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CB883B5297730E400DC99E7 /* LNUrls.swift */; }; + 4CB8FC232A41ABA800763C51 /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CB8FC222A41ABA500763C51 /* AboutView.swift */; }; 4CB9D4A72992D02B00A9A7E4 /* ProfileNameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CB9D4A62992D02B00A9A7E4 /* ProfileNameView.swift */; }; 4CB9D4A92992D2F400A9A7E4 /* FollowsYou.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CB9D4A82992D2F400A9A7E4 /* FollowsYou.swift */; }; 4CBCA930297DB57F00EC6B2F /* WebsiteLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CBCA92F297DB57F00EC6B2F /* WebsiteLink.swift */; }; @@ -637,6 +638,7 @@ 4CB883AD2976FA9300DC99E7 /* FormatTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormatTests.swift; sourceTree = "<group>"; }; 4CB883AF297705DD00DC99E7 /* ZapButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZapButton.swift; sourceTree = "<group>"; }; 4CB883B5297730E400DC99E7 /* LNUrls.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LNUrls.swift; sourceTree = "<group>"; }; + 4CB8FC222A41ABA500763C51 /* AboutView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = "<group>"; }; 4CB9D4A62992D02B00A9A7E4 /* ProfileNameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileNameView.swift; sourceTree = "<group>"; }; 4CB9D4A82992D2F400A9A7E4 /* FollowsYou.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FollowsYou.swift; sourceTree = "<group>"; }; 4CBCA92F297DB57F00EC6B2F /* WebsiteLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebsiteLink.swift; sourceTree = "<group>"; }; @@ -1196,6 +1198,7 @@ 4CB9D4A52992D01900A9A7E4 /* Profile */ = { isa = PBXGroup; children = ( + 4CB8FC222A41ABA500763C51 /* AboutView.swift */, 4CEE2AF6280B2DEA00AB5EEF /* ProfileName.swift */, 4C285C892838B985008A31F1 /* ProfilePictureSelector.swift */, F79C7FAC29D5E9620000F946 /* EditProfilePictureControl.swift */, @@ -1883,6 +1886,7 @@ 4C363A8E28236FE4006E126D /* NoteContentView.swift in Sources */, 4C90BD1A283AA67F008EE7EF /* Bech32.swift in Sources */, E990020F2955F837003BBC5A /* EditMetadataView.swift in Sources */, + 4CB8FC232A41ABA800763C51 /* AboutView.swift in Sources */, 5C513FBA297F72980072348F /* CustomPicker.swift in Sources */, 4CACA9D5280C31E100D9BBE8 /* ReplyView.swift in Sources */, F7908E92298B0F0700AB113A /* RelayDetailView.swift in Sources */, diff --git a/damus/Views/Profile/AboutView.swift b/damus/Views/Profile/AboutView.swift @@ -0,0 +1,53 @@ +// +// AboutView.swift +// damus +// +// Created by William Casarin on 2023-06-18. +// + +import SwiftUI + +struct AboutView: View { + let state: DamusState + let about: String + let max_about_length = 280 + @State var show_full_about: Bool = false + @State private var about_string: AttributedString? = nil + + var body: some View { + Group { + if let about_string { + let truncated_about = show_full_about ? about_string : about_string.truncateOrNil(maxLength: max_about_length) + SelectableText(attributedString: truncated_about ?? about_string, size: .subheadline) + + if truncated_about != nil { + if show_full_about { + Button(NSLocalizedString("Show less", comment: "Button to show less of a long profile description.")) { + show_full_about = false + } + .font(.footnote) + } else { + Button(NSLocalizedString("Show more", comment: "Button to show more of a long profile description.")) { + show_full_about = true + } + .font(.footnote) + } + } + } else { + Text(verbatim: "") + .font(.subheadline) + } + } + .onAppear { + let blocks = parse_mentions(content: about, tags: []) + about_string = render_blocks(blocks: blocks, profiles: state.profiles).content.attributed + } + + } +} + +/* + #Preview { + AboutView() + } + */