Fix stretchy banner header in Edit profile
Put the views into ScrollView Fixed banner offset in Geometry reader Changelog-Fixed: Fixed stretchy banner header in Edit profile Signed-off-by: Swift Coder <scoder1747@gmail.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import SwiftUI
|
|||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
let BANNER_HEIGHT: CGFloat = 150.0;
|
let BANNER_HEIGHT: CGFloat = 150.0;
|
||||||
|
fileprivate let Scroll_height: CGFloat = 700.0
|
||||||
|
|
||||||
struct EditMetadataView: View {
|
struct EditMetadataView: View {
|
||||||
let damus_state: DamusState
|
let damus_state: DamusState
|
||||||
@@ -79,11 +80,14 @@ struct EditMetadataView: View {
|
|||||||
func topSection(topLevelGeo: GeometryProxy) -> some View {
|
func topSection(topLevelGeo: GeometryProxy) -> some View {
|
||||||
ZStack(alignment: .top) {
|
ZStack(alignment: .top) {
|
||||||
GeometryReader { geo in
|
GeometryReader { geo in
|
||||||
|
let offset = geo.frame(in: .global).minY
|
||||||
EditBannerImageView(damus_state: damus_state, viewModel: bannerUploadObserver, callback: uploadedBanner(image_url:), safeAreaInsets: topLevelGeo.safeAreaInsets, banner_image: URL(string: banner))
|
EditBannerImageView(damus_state: damus_state, viewModel: bannerUploadObserver, callback: uploadedBanner(image_url:), safeAreaInsets: topLevelGeo.safeAreaInsets, banner_image: URL(string: banner))
|
||||||
.aspectRatio(contentMode: .fill)
|
.aspectRatio(contentMode: .fill)
|
||||||
.frame(width: geo.size.width, height: BANNER_HEIGHT)
|
.frame(width: geo.size.width, height: offset > 0 ? BANNER_HEIGHT + offset : BANNER_HEIGHT)
|
||||||
.clipped()
|
.clipped()
|
||||||
}.frame(height: BANNER_HEIGHT)
|
.offset(y: offset > 0 ? -offset : 0) // Pin the top
|
||||||
|
}
|
||||||
|
.frame(height: BANNER_HEIGHT)
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
let pfp_size: CGFloat = 90.0
|
let pfp_size: CGFloat = 90.0
|
||||||
|
|
||||||
@@ -129,74 +133,78 @@ struct EditMetadataView: View {
|
|||||||
|
|
||||||
func content(topLevelGeo: GeometryProxy) -> some View {
|
func content(topLevelGeo: GeometryProxy) -> some View {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
self.topSection(topLevelGeo: topLevelGeo)
|
ScrollView(showsIndicators: false) {
|
||||||
Form {
|
self.topSection(topLevelGeo: topLevelGeo)
|
||||||
Section(NSLocalizedString("Your Name", comment: "Label for Your Name section of user profile form.")) {
|
|
||||||
let display_name_placeholder = "Satoshi Nakamoto"
|
|
||||||
TextField(display_name_placeholder, text: $display_name)
|
|
||||||
.autocorrectionDisabled(true)
|
|
||||||
.textInputAutocapitalization(.never)
|
|
||||||
}
|
|
||||||
|
|
||||||
Section(NSLocalizedString("Username", comment: "Label for Username section of user profile form.")) {
|
Form {
|
||||||
let username_placeholder = "satoshi"
|
Section(NSLocalizedString("Your Name", comment: "Label for Your Name section of user profile form.")) {
|
||||||
TextField(username_placeholder, text: $name)
|
let display_name_placeholder = "Satoshi Nakamoto"
|
||||||
.autocorrectionDisabled(true)
|
TextField(display_name_placeholder, text: $display_name)
|
||||||
.textInputAutocapitalization(.never)
|
.autocorrectionDisabled(true)
|
||||||
|
.textInputAutocapitalization(.never)
|
||||||
}
|
|
||||||
|
|
||||||
Section(NSLocalizedString("Website", comment: "Label for Website section of user profile form.")) {
|
|
||||||
TextField(NSLocalizedString("https://jb55.com", comment: "Placeholder example text for website URL for user profile."), text: $website)
|
|
||||||
.autocorrectionDisabled(true)
|
|
||||||
.textInputAutocapitalization(.never)
|
|
||||||
}
|
|
||||||
|
|
||||||
Section(NSLocalizedString("About Me", comment: "Label for About Me section of user profile form.")) {
|
|
||||||
let placeholder = NSLocalizedString("Absolute Boss", comment: "Placeholder text for About Me description.")
|
|
||||||
ZStack(alignment: .topLeading) {
|
|
||||||
TextEditor(text: $about)
|
|
||||||
.textInputAutocapitalization(.sentences)
|
|
||||||
.frame(minHeight: 45, alignment: .leading)
|
|
||||||
.multilineTextAlignment(.leading)
|
|
||||||
Text(about.isEmpty ? placeholder : about)
|
|
||||||
.padding(4)
|
|
||||||
.opacity(about.isEmpty ? 1 : 0)
|
|
||||||
.foregroundColor(Color(uiColor: .placeholderText))
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Section(NSLocalizedString("Username", comment: "Label for Username section of user profile form.")) {
|
||||||
Section(NSLocalizedString("Bitcoin Lightning Tips", comment: "Label for Bitcoin Lightning Tips section of user profile form.")) {
|
let username_placeholder = "satoshi"
|
||||||
TextField(NSLocalizedString("Lightning Address or LNURL", comment: "Placeholder text for entry of Lightning Address or LNURL."), text: $ln)
|
TextField(username_placeholder, text: $name)
|
||||||
.autocorrectionDisabled(true)
|
.autocorrectionDisabled(true)
|
||||||
.textInputAutocapitalization(.never)
|
.textInputAutocapitalization(.never)
|
||||||
.onReceive(Just(ln)) { newValue in
|
|
||||||
self.ln = newValue.trimmingCharacters(in: .whitespaces)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Section(content: {
|
|
||||||
TextField(NSLocalizedString("jb55@jb55.com", comment: "Placeholder example text for identifier used for Nostr addresses."), text: $nip05)
|
|
||||||
.autocorrectionDisabled(true)
|
|
||||||
.textInputAutocapitalization(.never)
|
|
||||||
.onReceive(Just(nip05)) { newValue in
|
|
||||||
self.nip05 = newValue.trimmingCharacters(in: .whitespaces)
|
|
||||||
}
|
|
||||||
}, header: {
|
|
||||||
Text("Nostr Address", comment: "Label for the Nostr Address section of user profile form.")
|
|
||||||
}, footer: {
|
|
||||||
switch validate_nostr_address(nip05: nip05_parts, nip05_str: nip05) {
|
|
||||||
case .empty:
|
|
||||||
// without this, the keyboard dismisses unnecessarily when the footer changes state
|
|
||||||
Text("")
|
|
||||||
case .valid:
|
|
||||||
Text("")
|
|
||||||
case .invalid:
|
|
||||||
Text("'\(nip05)' is an invalid Nostr address. It should look like an email address.", comment: "Description of why the Nostr address is invalid.")
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
Section(NSLocalizedString("Website", comment: "Label for Website section of user profile form.")) {
|
||||||
|
TextField(NSLocalizedString("https://jb55.com", comment: "Placeholder example text for website URL for user profile."), text: $website)
|
||||||
|
.autocorrectionDisabled(true)
|
||||||
|
.textInputAutocapitalization(.never)
|
||||||
|
}
|
||||||
|
|
||||||
|
Section(NSLocalizedString("About Me", comment: "Label for About Me section of user profile form.")) {
|
||||||
|
let placeholder = NSLocalizedString("Absolute Boss", comment: "Placeholder text for About Me description.")
|
||||||
|
ZStack(alignment: .topLeading) {
|
||||||
|
TextEditor(text: $about)
|
||||||
|
.textInputAutocapitalization(.sentences)
|
||||||
|
.frame(minHeight: 45, alignment: .leading)
|
||||||
|
.multilineTextAlignment(.leading)
|
||||||
|
Text(about.isEmpty ? placeholder : about)
|
||||||
|
.padding(4)
|
||||||
|
.opacity(about.isEmpty ? 1 : 0)
|
||||||
|
.foregroundColor(Color(uiColor: .placeholderText))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Section(NSLocalizedString("Bitcoin Lightning Tips", comment: "Label for Bitcoin Lightning Tips section of user profile form.")) {
|
||||||
|
TextField(NSLocalizedString("Lightning Address or LNURL", comment: "Placeholder text for entry of Lightning Address or LNURL."), text: $ln)
|
||||||
|
.autocorrectionDisabled(true)
|
||||||
|
.textInputAutocapitalization(.never)
|
||||||
|
.onReceive(Just(ln)) { newValue in
|
||||||
|
self.ln = newValue.trimmingCharacters(in: .whitespaces)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Section(content: {
|
||||||
|
TextField(NSLocalizedString("jb55@jb55.com", comment: "Placeholder example text for identifier used for Nostr addresses."), text: $nip05)
|
||||||
|
.autocorrectionDisabled(true)
|
||||||
|
.textInputAutocapitalization(.never)
|
||||||
|
.onReceive(Just(nip05)) { newValue in
|
||||||
|
self.nip05 = newValue.trimmingCharacters(in: .whitespaces)
|
||||||
|
}
|
||||||
|
}, header: {
|
||||||
|
Text("Nostr Address", comment: "Label for the Nostr Address section of user profile form.")
|
||||||
|
}, footer: {
|
||||||
|
switch validate_nostr_address(nip05: nip05_parts, nip05_str: nip05) {
|
||||||
|
case .empty:
|
||||||
|
// without this, the keyboard dismisses unnecessarily when the footer changes state
|
||||||
|
Text("")
|
||||||
|
case .valid:
|
||||||
|
Text("")
|
||||||
|
case .invalid:
|
||||||
|
Text("'\(nip05)' is an invalid Nostr address. It should look like an email address.", comment: "Description of why the Nostr address is invalid.")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
.frame(height: Scroll_height)
|
||||||
}
|
}
|
||||||
|
|
||||||
Button(action: {
|
Button(action: {
|
||||||
|
|||||||
Reference in New Issue
Block a user