profile/refactor: break name section into its own function
This commit is contained in:
@@ -239,21 +239,8 @@ struct ProfileView: View {
|
||||
return 0
|
||||
}
|
||||
|
||||
var TopSection: some View {
|
||||
ZStack(alignment: .top) {
|
||||
GeometryReader { geometry in
|
||||
BannerImageView(pubkey: profile.pubkey, profiles: damus_state.profiles)
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: geometry.size.width, height: self.getHeightForHeaderImage(geometry))
|
||||
.clipped()
|
||||
.offset(x: 0, y: self.getOffsetForHeaderImage(geometry))
|
||||
|
||||
}.frame(height: BANNER_HEIGHT)
|
||||
|
||||
VStack(alignment: .leading, spacing: 8.0) {
|
||||
let data = damus_state.profiles.lookup(id: profile.pubkey)
|
||||
let pfp_size: CGFloat = 90.0
|
||||
|
||||
func NameSection(profile_data: Profile?) -> some View {
|
||||
return Group {
|
||||
HStack(alignment: .center) {
|
||||
ProfilePicView(pubkey: profile.pubkey, size: pfp_size, highlight: .custom(imageBorderColor(), 4.0), profiles: damus_state.profiles)
|
||||
.onTapGesture {
|
||||
@@ -268,7 +255,7 @@ struct ProfileView: View {
|
||||
Group {
|
||||
ActionSheetButton
|
||||
|
||||
if let profile = data {
|
||||
if let profile = profile_data {
|
||||
if let lnurl = profile.lnurl, lnurl != "" {
|
||||
LNButton(lnurl: lnurl, profile: profile)
|
||||
}
|
||||
@@ -279,6 +266,7 @@ struct ProfileView: View {
|
||||
if profile.pubkey != damus_state.pubkey {
|
||||
FollowButtonView(
|
||||
target: profile.get_follow_target(),
|
||||
follows_you: profile.follows(pubkey: damus_state.pubkey),
|
||||
follow_state: damus_state.contacts.follow_state(profile.pubkey)
|
||||
)
|
||||
} else if damus_state.keypair.privkey != nil {
|
||||
@@ -292,14 +280,36 @@ struct ProfileView: View {
|
||||
|
||||
}
|
||||
|
||||
ProfileNameView(pubkey: profile.pubkey, profile: data, damus: damus_state)
|
||||
ProfileNameView(pubkey: profile.pubkey, profile: profile_data, damus: damus_state)
|
||||
//.padding(.bottom)
|
||||
.padding(.top,-(pfp_size/2.0))
|
||||
}
|
||||
}
|
||||
|
||||
Text(ProfileView.markdown.process(data?.about ?? ""))
|
||||
var pfp_size: CGFloat {
|
||||
return 90.0
|
||||
}
|
||||
|
||||
var TopSection: some View {
|
||||
ZStack(alignment: .top) {
|
||||
GeometryReader { geometry in
|
||||
BannerImageView(pubkey: profile.pubkey, profiles: damus_state.profiles)
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: geometry.size.width, height: self.getHeightForHeaderImage(geometry))
|
||||
.clipped()
|
||||
.offset(x: 0, y: self.getOffsetForHeaderImage(geometry))
|
||||
|
||||
}.frame(height: BANNER_HEIGHT)
|
||||
|
||||
VStack(alignment: .leading, spacing: 8.0) {
|
||||
let profile_data = damus_state.profiles.lookup(id: profile.pubkey)
|
||||
|
||||
NameSection(profile_data: profile_data)
|
||||
|
||||
Text(ProfileView.markdown.process(profile_data?.about ?? ""))
|
||||
.font(.subheadline).textSelection(.enabled)
|
||||
|
||||
if let url = data?.website_url {
|
||||
if let url = profile_data?.website_url {
|
||||
WebsiteLink(url: url)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user