From 1dd6232891abf3a55237dc9ba5aafa1ea0ce6f31 Mon Sep 17 00:00:00 2001 From: Brandon Evans Date: Sat, 6 Feb 2021 18:28:05 -0700 Subject: [PATCH] Remove InfoPane from split view instead of hiding it When it was hidden the split view would still allow you to resize the remaining split, which resulted in weird behaviour. Instead, just remove the info pane split and the split view doesn't let you resize. Had to move where this global alert lives as a result because it might have to be presented even if the info pane isn't visible. I tried changing the alert so it wasn't on the main window, and was instead local to the buttons that triggered its presentation, and this worked for all but the case where the CancelInstallButton was used from the Xcode menu. So for now I left it close to where it already was. --- Xcodes/Frontend/MainWindow.swift | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Xcodes/Frontend/MainWindow.swift b/Xcodes/Frontend/MainWindow.swift index 890919a..d003227 100644 --- a/Xcodes/Frontend/MainWindow.swift +++ b/Xcodes/Frontend/MainWindow.swift @@ -24,19 +24,11 @@ struct MainWindow: View { primaryButton: .destructive(Text("Uninstall"), action: { self.appState.uninstall(id: xcode.id) }), secondaryButton: .cancel(Text("Cancel"))) } - InfoPane(selectedXcodeID: selectedXcodeID) - .frame(minWidth: 300, maxWidth: .infinity) - .frame(width: isShowingInfoPane ? nil : 0) - .isHidden(!isShowingInfoPane) - // This alert isn't intentionally placed here, - // just trying to put it in a unique part of the hierarchy - // since you can't have more than one in the same spot. - .alert(item: $appState.xcodeBeingConfirmedForInstallCancellation) { xcode in - Alert(title: Text("Are you sure you want to stop the installation of Xcode \(xcode.description)?"), - message: Text("Any progress will be discarded."), - primaryButton: .destructive(Text("Stop Installation"), action: { self.appState.cancelInstall(id: xcode.id) }), - secondaryButton: .cancel(Text("Cancel"))) - } + + if isShowingInfoPane { + InfoPane(selectedXcodeID: selectedXcodeID) + .frame(minWidth: 300, maxWidth: .infinity) + } } .mainToolbar( category: $category, @@ -51,6 +43,17 @@ struct MainWindow: View { .environmentObject(appState) } // This overlay is only here to work around the one-alert-per-view limitation + .overlay( + Color.clear + // This particular alert could be added specifically to InstallationStepView and CancelInstallButton _except_ for when CancelInstallButton is used in the Xcode CommandMenu, so it's here for now. + .alert(item: $appState.xcodeBeingConfirmedForInstallCancellation) { xcode in + Alert(title: Text("Are you sure you want to stop the installation of Xcode \(xcode.description)?"), + message: Text("Any progress will be discarded."), + primaryButton: .destructive(Text("Stop Installation"), action: { self.appState.cancelInstall(id: xcode.id) }), + secondaryButton: .cancel(Text("Cancel"))) + } + ) + // This overlay is only here to work around the one-alert-per-view limitation .overlay( Color.clear .alert(isPresented: $appState.isPreparingUserForActionRequiringHelper.isNotNil) {