mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
🏗 WIP: UI for switch to version options (#84)
This commit is contained in:
@ -67,14 +67,35 @@ class SiteListCell: NSTableCellView
|
|||||||
@IBAction func pressedPhpVersion(_ sender: Any) {
|
@IBAction func pressedPhpVersion(_ sender: Any) {
|
||||||
guard let site = self.site else { return }
|
guard let site = self.site else { return }
|
||||||
|
|
||||||
Alert.confirm(
|
let alert = NSAlert.init()
|
||||||
onWindow: App.shared.siteListWindowController!.window!,
|
alert.alertStyle = .informational
|
||||||
messageText: "alert.composer_php_requirement.title"
|
|
||||||
.localized("\(site.name!).\(Valet.shared.config.tld)", site.composerPhp),
|
alert.messageText = "alert.composer_php_requirement.title"
|
||||||
informativeText: "alert.composer_php_requirement.info"
|
.localized("\(site.name!).\(Valet.shared.config.tld)", site.composerPhp)
|
||||||
.localized(site.composerPhpSource),
|
alert.informativeText = "alert.composer_php_requirement.info"
|
||||||
secondButtonTitle: "",
|
.localized(site.composerPhpSource)
|
||||||
onFirstButtonPressed: {}
|
|
||||||
)
|
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)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user