Move edit banner button into safe area
In some conditions, it was found that the banner edit button was obscured behind a top nav bar. This commit fixes that by introspecting on the safe area margins and applying them to the button Closes: https://github.com/damus-io/damus/issues/2636 Changelog-Fixed: Fixed issue where banner edit button is unclickable Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
@@ -14,6 +14,7 @@ struct EditBannerImageView: View {
|
||||
@ObservedObject var viewModel: ImageUploadingObserver
|
||||
let callback: (URL?) -> Void
|
||||
let defaultImage = UIImage(named: "damoose") ?? UIImage()
|
||||
let safeAreaInsets: EdgeInsets
|
||||
|
||||
@State var banner_image: URL? = nil
|
||||
|
||||
@@ -31,7 +32,15 @@ struct EditBannerImageView: View {
|
||||
.onFailureImage(defaultImage)
|
||||
.kfClickable()
|
||||
|
||||
EditPictureControl(uploader: damus_state.settings.default_media_uploader, keypair: damus_state.keypair, pubkey: damus_state.pubkey, image_url: $banner_image, uploadObserver: viewModel, callback: callback)
|
||||
if #available(iOS 17.0, *) {
|
||||
EditPictureControl(uploader: damus_state.settings.default_media_uploader, keypair: damus_state.keypair, pubkey: damus_state.pubkey, image_url: $banner_image, uploadObserver: viewModel, callback: callback)
|
||||
.padding(10)
|
||||
.safeAreaPadding(self.safeAreaInsets)
|
||||
} else {
|
||||
EditPictureControl(uploader: damus_state.settings.default_media_uploader, keypair: damus_state.keypair, pubkey: damus_state.pubkey, image_url: $banner_image, uploadObserver: viewModel, callback: callback)
|
||||
.padding(10)
|
||||
.padding(.top, self.safeAreaInsets.top)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,10 +76,10 @@ struct EditMetadataView: View {
|
||||
return NIP05.parse(nip05)
|
||||
}
|
||||
|
||||
var TopSection: some View {
|
||||
func topSection(topLevelGeo: GeometryProxy) -> some View {
|
||||
ZStack(alignment: .top) {
|
||||
GeometryReader { geo in
|
||||
EditBannerImageView(damus_state: damus_state, viewModel: bannerUploadObserver, callback: uploadedBanner(image_url:), 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)
|
||||
.frame(width: geo.size.width, height: BANNER_HEIGHT)
|
||||
.clipped()
|
||||
@@ -122,8 +122,14 @@ struct EditMetadataView: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { proxy in
|
||||
self.content(topLevelGeo: proxy)
|
||||
}
|
||||
}
|
||||
|
||||
func content(topLevelGeo: GeometryProxy) -> some View {
|
||||
VStack(alignment: .leading) {
|
||||
TopSection
|
||||
self.topSection(topLevelGeo: topLevelGeo)
|
||||
Form {
|
||||
Section(NSLocalizedString("Your Name", comment: "Label for Your Name section of user profile form.")) {
|
||||
let display_name_placeholder = "Satoshi Nakamoto"
|
||||
|
||||
Reference in New Issue
Block a user