1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-11-09 21:20:07 +01:00

🏗 WIP: Linked & parked sites UI (#58)

This commit is contained in:
2021-12-03 18:41:41 +01:00
parent d1fc9de4bd
commit 1e124a90f3
15 changed files with 386 additions and 9 deletions

View File

@@ -0,0 +1,25 @@
//
// SiteListCell.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 03/12/2021.
// Copyright © 2021 Nico Verbruggen. All rights reserved.
//
import Cocoa
import AppKit
class SiteListCell: NSTableCellView
{
@IBOutlet weak var labelSiteName: NSTextField!
@IBOutlet weak var labelPathName: NSTextField!
@IBOutlet weak var imageViewLock: NSImageView!
@IBOutlet weak var labelPhpVersion: NSTextField!
@IBOutlet weak var labelSiteType: NSTextField!
override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect)
}
}

View File

@@ -0,0 +1,70 @@
//
// SiteListVC.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 30/03/2021.
// Copyright © 2021 Nico Verbruggen. All rights reserved.
//
import Cocoa
import HotKey
import Carbon
class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
// MARK: - Display
public static func show(delegate: NSWindowDelegate? = nil) {
if (App.shared.siteListWindowController == nil) {
let vc = NSStoryboard(name: "Main", bundle: nil)
.instantiateController(withIdentifier: "siteList") as! SiteListVC
let window = NSWindow(contentViewController: vc)
window.title = "site_list.title".localized
window.delegate = delegate
window.styleMask = [.titled, .closable, .resizable]
App.shared.siteListWindowController = SiteListWC(window: window)
}
App.shared.siteListWindowController!.showWindow(self)
NSApp.activate(ignoringOtherApps: true)
}
// MARK: - Lifecycle
override func viewWillAppear() {
}
override func viewWillDisappear() {
}
// MARK: - Table View
func numberOfRows(in tableView: NSTableView) -> Int {
return Valet.shared.linkedSites.count
}
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
guard let userCell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "siteItem"), owner: self) as? SiteListCell else { return nil }
let item = Valet.shared.linkedSites[row]
userCell.labelSiteName.stringValue = "\(item.name).\(Valet.shared.config.tld)"
userCell.labelPathName.stringValue = item.absolutePath
userCell.labelSiteType.isHidden = true
userCell.labelPhpVersion.isHidden = true
return userCell
}
// MARK: - Deinitialization
deinit {
print("VC deallocated")
}
}

View File

@@ -0,0 +1,17 @@
//
// SiteListWC.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 03/12/2021.
// Copyright © 2021 Nico Verbruggen. All rights reserved.
//
import Cocoa
class SiteListWC: NSWindowController {
override func windowDidLoad() {
super.windowDidLoad()
}
}