From e3105a90c58bc0ea6d49565312aae796c17f7b3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Mon, 11 Nov 2024 19:09:49 -0800 Subject: [PATCH] Move edit banner button into safe area MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- damus/Views/BannerImageView.swift | 11 ++++++++++- damus/Views/Profile/EditMetadataView.swift | 12 +++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/damus/Views/BannerImageView.swift b/damus/Views/BannerImageView.swift index 8923d7bd..948db918 100644 --- 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 index cf930598..18654d86 100644 --- 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"