diff --git a/phpmon/Domain/Integrations/Homebrew/BrewPhpFormula.swift b/phpmon/Domain/Integrations/Homebrew/BrewPhpFormula.swift index b0b4121..7930005 100644 --- a/phpmon/Domain/Integrations/Homebrew/BrewPhpFormula.swift +++ b/phpmon/Domain/Integrations/Homebrew/BrewPhpFormula.swift @@ -21,9 +21,7 @@ struct BrewPhpFormula: Equatable { /// The upgrade that is currently available, if it exists. let upgradeVersion: String? - #warning("The rebuild attribute should be checked, it can be used to check if a Tap update exists for a pre-release version.") - /// A rebuild version, if applicable. - // let rebuild: String? + // TODO: A rebuild attribute could be checked, to check if a Tap update exists for a pre-release version /// Whether this formula is a stable version of PHP. let prerelease: Bool diff --git a/phpmon/Domain/Integrations/Homebrew/BrewTapFormulae.swift b/phpmon/Domain/Integrations/Homebrew/BrewTapFormulae.swift index 1b62981..46cdd47 100644 --- a/phpmon/Domain/Integrations/Homebrew/BrewTapFormulae.swift +++ b/phpmon/Domain/Integrations/Homebrew/BrewTapFormulae.swift @@ -29,10 +29,11 @@ class BrewTapFormulae { let versionRange = Range(match.range(at: 2), in: file) { // Determine what the extension's name is let phpExtensionName = String(file[phpExtensionRange]) + // Determine what PHP version this is for let phpVersion = String(file[versionRange]) - // Create a new BrewPhpExtension object, which will determine whether this extension is installed or not + // Create a new BrewPhpExtension object (determines if installed) let phpExtension = BrewPhpExtension( path: "\(Paths.tapPath)/\(tap)/Formula/\(file)", name: phpExtensionName, diff --git a/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView.swift b/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView.swift index 20694bd..105c27e 100644 --- a/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView.swift +++ b/phpmon/Modules/PHP Extension Manager/UI/PhpExtensionManagerView.swift @@ -98,6 +98,44 @@ struct PhpExtensionManagerView: View { } } + private func dependency(named name: String) -> some View { + return Text(name) + .font(.system(size: 9)) + .padding(.horizontal, 5) + .padding(.vertical, 1) + .background(Color.appPrimary) + .foregroundColor(Color.white) + .clipShape(Capsule()) + .fixedSize(horizontal: true, vertical: true) + } + + private func extensionLabel(for ext: BrewPhpExtension) -> some View { + return Group { + if ext.isInstalled { + if let dependent = ext.firstDependent(in: self.manager.extensions) { + Text("You cannot uninstall this before uninstalling **\(dependent.name)**.") + .font(.system(size: 11)) + .foregroundStyle(.secondary) + } else { + Text("This extension is installed and can be managed by PHP Monitor.") + .font(.system(size: 11)) + .foregroundStyle(.secondary) + } + + } else { + if ext.hasAlternativeInstall { + Text("This extension is already installed via another source, and cannot be managed.") + .font(.system(size: 11)) + .foregroundStyle(.orange) + } else { + Text("This extension can be installed.") + .font(.system(size: 11)) + .foregroundStyle(.secondary) + } + } + } + } + private func listContent(for ext: BrewPhpExtension) -> some View { HStack(alignment: .center, spacing: 7.0) { VStack(alignment: .center, spacing: 0) { @@ -121,40 +159,12 @@ struct PhpExtensionManagerView: View { Text("Depends on:") .font(.system(size: 10)) ForEach(ext.extensionDependencies, id: \.self) { - Text($0) - .font(.system(size: 9)) - .padding(.horizontal, 5) - .padding(.vertical, 1) - .background(Color.appPrimary) - .foregroundColor(Color.white) - .clipShape(Capsule()) - .fixedSize(horizontal: true, vertical: true) + dependency(named: $0) } } } - if ext.isInstalled { - if let dependent = ext.firstDependent(in: self.manager.extensions) { - Text("You cannot uninstall this before uninstalling **\(dependent.name)**.") - .font(.system(size: 11)) - .foregroundStyle(.secondary) - } else { - Text("This extension is installed and can be managed by PHP Monitor.") - .font(.system(size: 11)) - .foregroundStyle(.secondary) - } - - } else { - if ext.hasAlternativeInstall { - Text("This extension is already installed via another source, and cannot be managed.") - .font(.system(size: 11)) - .foregroundStyle(.orange) - } else { - Text("This extension can be installed.") - .font(.system(size: 11)) - .foregroundStyle(.secondary) - } - } + extensionLabel(for: ext) } } }