Skip to content

Commit

Permalink
Fixed placeholder button on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
Rspoon3 committed Oct 1, 2024
1 parent ccd0acf commit f9f389e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 31 deletions.
4 changes: 2 additions & 2 deletions Shotbot.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
76 changes: 47 additions & 29 deletions ShotbotCore/Sources/HomeFeature/HomeView/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -220,19 +199,52 @@ 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")
}
}
}

private var placeholder: some View {
Image(systemName: "photo")
.resizable()
.scaledToFit()
.contextMenu { importFileButton }
.contextMenu { placeholderContextButton }
.frame(maxWidth: 200)
.padding()
.contentShape(
Expand All @@ -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 {
Expand Down

0 comments on commit f9f389e

Please sign in to comment.