profile/refactor: break name section into its own function
This commit is contained in:
@@ -239,21 +239,8 @@ struct ProfileView: View {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
var TopSection: some View {
|
func NameSection(profile_data: Profile?) -> some View {
|
||||||
ZStack(alignment: .top) {
|
return Group {
|
||||||
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
|
|
||||||
|
|
||||||
HStack(alignment: .center) {
|
HStack(alignment: .center) {
|
||||||
ProfilePicView(pubkey: profile.pubkey, size: pfp_size, highlight: .custom(imageBorderColor(), 4.0), profiles: damus_state.profiles)
|
ProfilePicView(pubkey: profile.pubkey, size: pfp_size, highlight: .custom(imageBorderColor(), 4.0), profiles: damus_state.profiles)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
@@ -268,7 +255,7 @@ struct ProfileView: View {
|
|||||||
Group {
|
Group {
|
||||||
ActionSheetButton
|
ActionSheetButton
|
||||||
|
|
||||||
if let profile = data {
|
if let profile = profile_data {
|
||||||
if let lnurl = profile.lnurl, lnurl != "" {
|
if let lnurl = profile.lnurl, lnurl != "" {
|
||||||
LNButton(lnurl: lnurl, profile: profile)
|
LNButton(lnurl: lnurl, profile: profile)
|
||||||
}
|
}
|
||||||
@@ -279,6 +266,7 @@ struct ProfileView: View {
|
|||||||
if profile.pubkey != damus_state.pubkey {
|
if profile.pubkey != damus_state.pubkey {
|
||||||
FollowButtonView(
|
FollowButtonView(
|
||||||
target: profile.get_follow_target(),
|
target: profile.get_follow_target(),
|
||||||
|
follows_you: profile.follows(pubkey: damus_state.pubkey),
|
||||||
follow_state: damus_state.contacts.follow_state(profile.pubkey)
|
follow_state: damus_state.contacts.follow_state(profile.pubkey)
|
||||||
)
|
)
|
||||||
} else if damus_state.keypair.privkey != nil {
|
} 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(.bottom)
|
||||||
.padding(.top,-(pfp_size/2.0))
|
.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)
|
.font(.subheadline).textSelection(.enabled)
|
||||||
|
|
||||||
if let url = data?.website_url {
|
if let url = profile_data?.website_url {
|
||||||
WebsiteLink(url: url)
|
WebsiteLink(url: url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user