ui: use AboutView in existing views
This commit is contained in:
@@ -33,8 +33,9 @@ struct UserView: View {
|
|||||||
let damus_state: DamusState
|
let damus_state: DamusState
|
||||||
let pubkey: String
|
let pubkey: String
|
||||||
|
|
||||||
|
@State var about_text: Text? = nil
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
|
||||||
VStack {
|
VStack {
|
||||||
HStack {
|
HStack {
|
||||||
ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
|
ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
|
||||||
@@ -42,10 +43,8 @@ struct UserView: View {
|
|||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
let profile = damus_state.profiles.lookup(id: pubkey)
|
let profile = damus_state.profiles.lookup(id: pubkey)
|
||||||
ProfileName(pubkey: pubkey, profile: profile, damus: damus_state, show_nip5_domain: false)
|
ProfileName(pubkey: pubkey, profile: profile, damus: damus_state, show_nip5_domain: false)
|
||||||
if let about = profile?.about {
|
if let about_text {
|
||||||
let blocks = parse_mentions(content: about, tags: [])
|
about_text
|
||||||
let about_string = render_blocks(blocks: blocks, profiles: damus_state.profiles).content.attributed
|
|
||||||
Text(about_string)
|
|
||||||
.lineLimit(3)
|
.lineLimit(3)
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,21 +51,7 @@ struct ParticipantsView: View {
|
|||||||
ForEach(originalReferences.pRefs) { participant in
|
ForEach(originalReferences.pRefs) { participant in
|
||||||
let pubkey = participant.id
|
let pubkey = participant.id
|
||||||
HStack {
|
HStack {
|
||||||
ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
|
UserView(damus_state: damus_state, pubkey: pubkey)
|
||||||
|
|
||||||
VStack(alignment: .leading) {
|
|
||||||
let profile = damus_state.profiles.lookup(id: pubkey)
|
|
||||||
ProfileName(pubkey: pubkey, profile: profile, damus: damus_state, show_nip5_domain: false)
|
|
||||||
if let about = profile?.about {
|
|
||||||
let blocks = parse_mentions(content: about, tags: [])
|
|
||||||
let about_string = render_blocks(blocks: blocks, profiles: damus_state.profiles).content.attributed
|
|
||||||
Text(about_string)
|
|
||||||
.lineLimit(3)
|
|
||||||
.font(.footnote)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer()
|
|
||||||
|
|
||||||
Image("check-circle.fill")
|
Image("check-circle.fill")
|
||||||
.font(.system(size: 30))
|
.font(.system(size: 30))
|
||||||
|
|||||||
@@ -93,7 +93,6 @@ struct ProfileView: View {
|
|||||||
let damus_state: DamusState
|
let damus_state: DamusState
|
||||||
let pfp_size: CGFloat = 90.0
|
let pfp_size: CGFloat = 90.0
|
||||||
let bannerHeight: CGFloat = 150.0
|
let bannerHeight: CGFloat = 150.0
|
||||||
let max_about_length = 280
|
|
||||||
|
|
||||||
static let markdown = Markdown()
|
static let markdown = Markdown()
|
||||||
|
|
||||||
@@ -104,7 +103,6 @@ struct ProfileView: View {
|
|||||||
@State var action_sheet_presented: Bool = false
|
@State var action_sheet_presented: Bool = false
|
||||||
@State var filter_state : FilterState = .posts
|
@State var filter_state : FilterState = .posts
|
||||||
@State var yOffset: CGFloat = 0
|
@State var yOffset: CGFloat = 0
|
||||||
@State var show_full_about: Bool = false
|
|
||||||
|
|
||||||
@StateObject var profile: ProfileModel
|
@StateObject var profile: ProfileModel
|
||||||
@StateObject var followers: FollowersModel
|
@StateObject var followers: FollowersModel
|
||||||
@@ -403,28 +401,7 @@ struct ProfileView: View {
|
|||||||
nameSection(profile_data: profile_data)
|
nameSection(profile_data: profile_data)
|
||||||
|
|
||||||
if let about = profile_data?.about {
|
if let about = profile_data?.about {
|
||||||
let blocks = parse_mentions(content: about, tags: [])
|
AboutView(state: damus_state, about: about)
|
||||||
let about_string = render_blocks(blocks: blocks, profiles: damus_state.profiles).content.attributed
|
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let url = profile_data?.website_url {
|
if let url = profile_data?.website_url {
|
||||||
|
|||||||
Reference in New Issue
Block a user