From f9f389e1391f5615ef895ed895bd48525e77b866 Mon Sep 17 00:00:00 2001 From: Ricky <42879920+Rspoon3@users.noreply.github.com> Date: Tue, 1 Oct 2024 16:57:15 -0400 Subject: [PATCH] Fixed placeholder button on mac --- Shotbot.xcodeproj/project.pbxproj | 4 +- .../HomeFeature/HomeView/HomeView.swift | 76 ++++++++++++------- 2 files changed, 49 insertions(+), 31 deletions(-) diff --git a/Shotbot.xcodeproj/project.pbxproj b/Shotbot.xcodeproj/project.pbxproj index cf65efc..013b2c8 100644 --- a/Shotbot.xcodeproj/project.pbxproj +++ b/Shotbot.xcodeproj/project.pbxproj @@ -597,7 +597,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -661,7 +661,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; diff --git a/ShotbotCore/Sources/HomeFeature/HomeView/HomeView.swift b/ShotbotCore/Sources/HomeFeature/HomeView/HomeView.swift index 12d4caa..55f1f46 100644 --- a/ShotbotCore/Sources/HomeFeature/HomeView/HomeView.swift +++ b/ShotbotCore/Sources/HomeFeature/HomeView/HomeView.swift @@ -30,28 +30,7 @@ public struct HomeView: View { VStack(spacing: 0) { picker mainContent - - VStack(spacing: 16) { - if ProcessInfo.processInfo.isiOSAppOnMac { - PrimaryButton(title: "Select From Files") { - viewModel.attemptToImportFile() - } - Button("Select Photos") { - viewModel.selectPhotos() - } - .font(.headline) - } else { - PrimaryButton(title: "Select Photos") { - viewModel.selectPhotos() - } - Button("Select From Files") { - viewModel.attemptToImportFile() - } - .font(.headline) - } - } - .disabled(viewModel.isLoading) - .padding([.bottom, .horizontal]) + selectionButtons } #if os(iOS) .navigationTitle("Shotbot") @@ -220,11 +199,44 @@ public struct HomeView: View { } } - private var importFileButton: some View { - Button { - viewModel.isImportingFile = true - } label: { - Label("Select From Files", systemImage: "doc") + private var selectionButtons: some View { + VStack(spacing: 16) { + if ProcessInfo.processInfo.isiOSAppOnMac { + PrimaryButton(title: "Select From Files") { + viewModel.attemptToImportFile() + } + Button("Select Photos") { + viewModel.selectPhotos() + } + .font(.headline) + } else { + PrimaryButton(title: "Select Photos") { + viewModel.selectPhotos() + } + Button("Select From Files") { + viewModel.attemptToImportFile() + } + .font(.headline) + } + } + .disabled(viewModel.isLoading) + .padding([.bottom, .horizontal]) + } + + @ViewBuilder + private var placeholderContextButton: some View { + if ProcessInfo.processInfo.isiOSAppOnMac { + Button { + viewModel.selectPhotos() + } label: { + Label("Select Photos", systemImage: "photo") + } + } else { + Button { + viewModel.attemptToImportFile() + } label: { + Label("Select From Files", systemImage: "doc") + } } } @@ -232,7 +244,7 @@ public struct HomeView: View { Image(systemName: "photo") .resizable() .scaledToFit() - .contextMenu { importFileButton } + .contextMenu { placeholderContextButton } .frame(maxWidth: 200) .padding() .contentShape( @@ -245,7 +257,13 @@ public struct HomeView: View { .hoverEffect() .foregroundColor(.secondary) .frame(maxHeight: .infinity) - .onTapGesture { viewModel.selectPhotos() } + .onTapGesture { + if ProcessInfo.processInfo.isiOSAppOnMac { + viewModel.attemptToImportFile() + } else { + viewModel.selectPhotos() + } + } } private func tabView(shareableImages: [ShareableImage]) -> some View {