From f7e25515874dd58b7f4e37909fa7b814af8a72d7 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Tue, 21 Nov 2023 17:11:28 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=97=20WIP:=20Adjust=20extension=20mana?= =?UTF-8?q?ger=20view?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Homebrew/BrewTapFormulae.swift | 1 + .../UI/PhpExtensionManagerView.swift | 22 ++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/phpmon/Domain/Integrations/Homebrew/BrewTapFormulae.swift b/phpmon/Domain/Integrations/Homebrew/BrewTapFormulae.swift index 6b9ad72..c05516a 100644 --- a/phpmon/Domain/Integrations/Homebrew/BrewTapFormulae.swift +++ b/phpmon/Domain/Integrations/Homebrew/BrewTapFormulae.swift @@ -11,6 +11,7 @@ import Foundation class BrewTapFormulae { public static func from(tap: String) -> [String: Set] { let directory = "\(Paths.tapPath)/\(tap)/Formula" + let files = try? FileSystem.getShallowContentsOfDirectory(directory) var availableExtensions = [String: Set]() diff --git a/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView.swift b/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView.swift index 6fac457..b2bcda8 100644 --- a/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView.swift +++ b/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView.swift @@ -17,24 +17,26 @@ struct BrewPhpExtension { struct PhpExtensionManagerView: View { init() { - let available = BrewTapFormulae - .from(tap: "shivammathur/homebrew-extensions")["8.2"]!.sorted() + let formulae = BrewTapFormulae.from(tap: "shivammathur/homebrew-extensions") - print(available) + if formulae.keys.contains(self.phpVersion) { + let extensions = formulae[self.phpVersion]! + .sorted() + .map({ name in + return BrewPhpExtension(name: name, isInstalled: false) + }) - let extensions = available.map({ name in - return BrewPhpExtension(name: name, isInstalled: false) - }) - - self.extensions = extensions + self.extensions = extensions + } } @State var searchText: String = "" - @State var extensions: [BrewPhpExtension] + @State var extensions: [BrewPhpExtension] = [] + @State var phpVersion: String = "" var body: some View { VStack { - header.padding(20) + // header.padding(20) List(Array(extensions.enumerated()), id: \.1.name) { (index, pExtension) in listContent(for: pExtension)