Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ GhostTile.xcodeproj/
xcuserdata/
DerivedData/

# App bundle output
GhostTile.app/
GhostTile Dev.app/
# App bundle output (real dir from `just build`, or symlink from `just run`)
GhostTile.app
GhostTile Dev.app
dist/

# Generated during build (copied from docs/imgs/icon.svg)
Expand Down
4 changes: 2 additions & 2 deletions Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.0.8</string>
<string>2.0.9</string>
<key>CFBundleVersion</key>
<string>25</string>
<string>26</string>
<key>LSMinimumSystemVersion</key>
<string>15.0</string>
<key>LSUIElement</key>
Expand Down
34 changes: 34 additions & 0 deletions Sources/GhostTileApp/App/DebugBadge.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import AppKit

enum DebugBadge {
static func apply() {
#if DEBUG
let tile = NSApplication.shared.dockTile
let iconView = NSImageView(frame: NSRect(x: 0, y: 0, width: tile.size.width, height: tile.size.height))
iconView.image = NSApplication.shared.applicationIconImage

let badge = NSTextField(labelWithString: "βeta")
badge.font = NSFont.boldSystemFont(ofSize: 24)
badge.textColor = .white
badge.backgroundColor = .systemOrange
badge.isBezeled = false
badge.alignment = .center
badge.sizeToFit()
badge.frame = NSRect(
x: tile.size.width - badge.frame.width - 4,
y: 2,
width: badge.frame.width + 8,
height: badge.frame.height + 2
)
badge.wantsLayer = true
badge.layer?.cornerRadius = badge.frame.height / 2
badge.layer?.masksToBounds = true

let container = NSView(frame: iconView.frame)
container.addSubview(iconView)
container.addSubview(badge)
tile.contentView = container
tile.display()
#endif
}
}
5 changes: 5 additions & 0 deletions Sources/GhostTileApp/App/GhostTileApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {

func applicationDidFinishLaunching(_: Notification) {
intentListener.start()
DebugBadge.apply()
// Keep an already-installed CLI in sync with the app (user-owned ~/.local/bin, no prompt).
DispatchQueue.global(qos: .utility).async {
CLIInstaller.updateIfInstalledAndStale()
}
}

func applicationShouldTerminateAfterLastWindowClosed(_: NSApplication) -> Bool {
Expand Down
6 changes: 1 addition & 5 deletions Sources/GhostTileApp/MainWindow/MainWindowView+Layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ extension MainWindowView {
isLoading: appViewModel.loading.contains(app.id),
actions: appViewModel,
onPrimaryAction: {
if app.isRunning {
appViewModel.setDockVisibility(app, hidden: !app.isHiddenFromDock)
} else {
appViewModel.activateManagedApp(app)
}
appViewModel.perform(app.primaryAction, on: app)
}
)
}
Expand Down
29 changes: 12 additions & 17 deletions Sources/GhostTileApp/MainWindow/ManagedAppCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,6 @@ struct ManagedAppCard: View {
app.statusColor
}

private var primaryActionTitle: String {
if !app.isRunning {
return "Launch"
}

return app.isHiddenFromDock ? "Show" : "Hide"
}

private var primaryActionIcon: String {
if !app.isRunning {
return "play.fill"
}

return app.isHiddenFromDock ? "eye" : "eye.slash"
}

var body: some View {
VStack(alignment: .leading, spacing: 12) {
ZStack(alignment: .topLeading) {
Expand All @@ -98,6 +82,17 @@ struct ManagedAppCard: View {
.font(.system(size: 20, weight: .bold, design: .rounded))
.lineLimit(1)
.minimumScaleFactor(0.78)
if app.requiresReAdd {
Text("Re-add required")
.font(.system(size: 11, weight: .semibold))
.foregroundStyle(statusColor)
.lineLimit(1)
} else if let versionText = app.versionText {
Text("v\(versionText)")
.font(.system(size: 11, weight: .medium))
.foregroundStyle(.secondary)
.lineLimit(1)
}
}
}
}
Expand All @@ -117,7 +112,7 @@ struct ManagedAppCard: View {
Spacer()
} else {
Button(action: onPrimaryAction) {
Label(primaryActionTitle, systemImage: primaryActionIcon)
Label(app.primaryAction.title, systemImage: app.primaryAction.systemImage)
}
.buttonStyle(.borderedProminent)
.controlSize(.small)
Expand Down
61 changes: 29 additions & 32 deletions Sources/GhostTileApp/Overview/OverviewCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,11 @@ struct OverviewCard: View {
.onHover { hovering = $0 }
.animation(.easeOut(duration: 0.14), value: hovering)
.contextMenu {
if app.isRunning {
if app.isHiddenFromDock {
Button("Show in Dock", action: { actions.show(app) })
} else {
Button("Hide from Dock", action: { actions.hide(app) })
}
switch app.primaryAction {
case .reAdd, .showInDock, .hideFromDock:
Button(app.primaryAction.menuTitle) { actions.perform(app.primaryAction, on: app) }
case .launch:
EmptyView()
}
Button("Reveal in Finder", action: { actions.reveal(app) })
Divider()
Expand Down Expand Up @@ -153,35 +152,33 @@ struct OverviewCard: View {

private var actionButtons: some View {
HStack(spacing: 6) {
if app.isRunning {
Button {
app.isHiddenFromDock ? actions.show(app) : actions.hide(app)
} label: {
Image(systemName: app.isHiddenFromDock ? "eye" : "eye.slash")
.font(.system(size: 11, weight: .semibold))
}
.buttonStyle(.borderless)
.foregroundStyle(.secondary)
}
primaryActionButton

Button {
actions.reveal(app)
} label: {
Image(systemName: "folder")
.font(.system(size: 11, weight: .semibold))
}
.buttonStyle(.borderless)
.foregroundStyle(.secondary)

Button {
actions.remove(app)
} label: {
Image(systemName: "trash")
.font(.system(size: 11, weight: .semibold))
iconButton("folder") { actions.reveal(app) }
iconButton("trash") { actions.remove(app) }
}
}

/// Primary button shows only for actionable states; a not-running app (.launch) shows just reveal/remove.
@ViewBuilder
private var primaryActionButton: some View {
switch app.primaryAction {
case .reAdd, .showInDock, .hideFromDock:
iconButton(app.primaryAction.systemImage) {
actions.perform(app.primaryAction, on: app)
}
.buttonStyle(.borderless)
.foregroundStyle(.secondary)
case .launch:
EmptyView()
}
}

private func iconButton(_ systemImage: String, action: @escaping () -> Void) -> some View {
Button(action: action) {
Image(systemName: systemImage)
.font(.system(size: 11, weight: .semibold))
}
.buttonStyle(.borderless)
.foregroundStyle(.secondary)
}

private var statusText: String {
Expand Down
Loading
Loading