mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-10 21:10:08 +02:00
👌 Allow per-row customization
This commit is contained in:
@@ -13,6 +13,9 @@ class ValetProxyScanner: ProxyScanner {
|
|||||||
return try! FileManager
|
return try! FileManager
|
||||||
.default
|
.default
|
||||||
.contentsOfDirectory(atPath: directoryPath)
|
.contentsOfDirectory(atPath: directoryPath)
|
||||||
|
.filter {
|
||||||
|
return !$0.starts(with: ".")
|
||||||
|
}
|
||||||
.compactMap {
|
.compactMap {
|
||||||
return NginxConfigurationFile.from(filePath: "\(directoryPath)/\($0)")
|
return NginxConfigurationFile.from(filePath: "\(directoryPath)/\($0)")
|
||||||
}
|
}
|
||||||
|
@@ -216,6 +216,8 @@ class Valet {
|
|||||||
sites.insert(site, at: 0)
|
sites.insert(site, at: 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.info("\(sites.count) sites & \(proxies.count) proxies have been scanned.")
|
||||||
|
|
||||||
isBusy = false
|
isBusy = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,8 +12,9 @@ import SwiftUI
|
|||||||
struct ServicesView: View {
|
struct ServicesView: View {
|
||||||
@ObservedObject var manager: ServicesManager
|
@ObservedObject var manager: ServicesManager
|
||||||
@State var servicesToDisplay: [String]
|
@State var servicesToDisplay: [String]
|
||||||
|
@State var perRow: Int = 3
|
||||||
|
|
||||||
static func asMenuItem() -> NSMenuItem {
|
static func asMenuItem(perRow: Int = 3) -> NSMenuItem {
|
||||||
let item = NSMenuItem()
|
let item = NSMenuItem()
|
||||||
var services = [
|
var services = [
|
||||||
PhpEnv.phpInstall.formula,
|
PhpEnv.phpInstall.formula,
|
||||||
@@ -28,12 +29,13 @@ struct ServicesView: View {
|
|||||||
let view = NSHostingView(
|
let view = NSHostingView(
|
||||||
rootView: Self(
|
rootView: Self(
|
||||||
manager: ServicesManager.shared,
|
manager: ServicesManager.shared,
|
||||||
servicesToDisplay: services
|
servicesToDisplay: services,
|
||||||
|
perRow: perRow
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
view.autoresizingMask = [.width, .height]
|
view.autoresizingMask = [.width, .height]
|
||||||
let height = CGFloat(45 * services.chunked(by: 3).count)
|
let height = CGFloat(45 * services.chunked(by: perRow).count)
|
||||||
view.setFrameSize(CGSize(width: view.frame.width, height: height))
|
view.setFrameSize(CGSize(width: view.frame.width, height: height))
|
||||||
item.view = view
|
item.view = view
|
||||||
return item
|
return item
|
||||||
@@ -41,14 +43,21 @@ struct ServicesView: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading, spacing: 10) {
|
VStack(alignment: .leading, spacing: 10) {
|
||||||
ForEach(servicesToDisplay.chunked(by: 3), id: \.self) { chunk in
|
ForEach(servicesToDisplay.chunked(by: self.perRow), id: \.self) { chunk in
|
||||||
HStack {
|
HStack {
|
||||||
ForEach(chunk, id: \.self) { service in
|
ForEach(0...self.perRow - 1, id: \.self) { index in
|
||||||
VStack(alignment: .center, spacing: 3) {
|
if chunk.indices.contains(index) {
|
||||||
SectionHeaderView(text: service.uppercased())
|
// A service exists to fill the cell
|
||||||
CheckmarkView(serviceName: service)
|
let service = chunk[index]
|
||||||
.environmentObject(manager)
|
VStack(alignment: .center, spacing: 3) {
|
||||||
}.frame(minWidth: 0, maxWidth: .infinity)
|
SectionHeaderView(text: service.uppercased())
|
||||||
|
CheckmarkView(serviceName: service)
|
||||||
|
.environmentObject(manager)
|
||||||
|
}.frame(minWidth: 0, maxWidth: .infinity)
|
||||||
|
} else {
|
||||||
|
// Empty cell
|
||||||
|
VStack { Text("") }.frame(minWidth: 0, maxWidth: .infinity)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,7 +141,8 @@ struct ServicesView_Previews: PreviewProvider {
|
|||||||
"mysql": false
|
"mysql": false
|
||||||
]),
|
]),
|
||||||
servicesToDisplay: ["php", "nginx", "dnsmasq",
|
servicesToDisplay: ["php", "nginx", "dnsmasq",
|
||||||
"mysql", "redis", "mailhog"]
|
"mysql", "redis", "php@7.4"],
|
||||||
|
perRow: 4
|
||||||
)
|
)
|
||||||
.frame(width: 330.0)
|
.frame(width: 330.0)
|
||||||
.previewDisplayName("Dark Mode")
|
.previewDisplayName("Dark Mode")
|
||||||
|
Reference in New Issue
Block a user