From 32e8878a68307930119f1101c6655da1e0fe26d1 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Sat, 22 Jan 2022 22:08:45 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=97=20WIP:=20UI=20for=20switch=20to=20?= =?UTF-8?q?version=20options=20(#84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpmon/Domain/SiteList/SiteListCell.swift | 39 +++++++++++++++++------ 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/phpmon/Domain/SiteList/SiteListCell.swift b/phpmon/Domain/SiteList/SiteListCell.swift index d4eea96..9f026c1 100644 --- a/phpmon/Domain/SiteList/SiteListCell.swift +++ b/phpmon/Domain/SiteList/SiteListCell.swift @@ -67,14 +67,35 @@ class SiteListCell: NSTableCellView @IBAction func pressedPhpVersion(_ sender: Any) { guard let site = self.site else { return } - Alert.confirm( - onWindow: App.shared.siteListWindowController!.window!, - messageText: "alert.composer_php_requirement.title" - .localized("\(site.name!).\(Valet.shared.config.tld)", site.composerPhp), - informativeText: "alert.composer_php_requirement.info" - .localized(site.composerPhpSource), - secondButtonTitle: "", - onFirstButtonPressed: {} - ) + let alert = NSAlert.init() + alert.alertStyle = .informational + + alert.messageText = "alert.composer_php_requirement.title" + .localized("\(site.name!).\(Valet.shared.config.tld)", site.composerPhp) + alert.informativeText = "alert.composer_php_requirement.info" + .localized(site.composerPhpSource) + + alert.addButton(withTitle: "Close") + + var mapIndex: Int = NSApplication.ModalResponse.alertSecondButtonReturn.rawValue + var map: [Int: String] = [:] + + var versions: [String] = [] + // TODO: Based on the version constraint, insert the desired version to switch to + + versions.forEach { version in + alert.addButton(withTitle: "Switch to PHP \(version)") + map[mapIndex] = version + mapIndex += 1 + } + + alert.beginSheetModal(for: App.shared.siteListWindowController!.window!) { response in + if response.rawValue > NSApplication.ModalResponse.alertFirstButtonReturn.rawValue { + if map.keys.contains(response.rawValue) { + let version = map[response.rawValue]! + print("Pressed button to switch to \(version)") + } + } + } } }