damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit e3105a90c58bc0ea6d49565312aae796c17f7b3b
parent 38dc7b046ae2fabb8022a92a99d4608bff7e33dc
Author: Daniel D’Aquino <daniel@daquino.me>
Date:   Mon, 11 Nov 2024 19:09:49 -0800

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>

Diffstat:
Mdamus/Views/BannerImageView.swift | 11++++++++++-
Mdamus/Views/Profile/EditMetadataView.swift | 12+++++++++---
2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/damus/Views/BannerImageView.swift b/damus/Views/BannerImageView.swift @@ -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) + } } } } diff --git a/damus/Views/Profile/EditMetadataView.swift b/damus/Views/Profile/EditMetadataView.swift @@ -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"