feat(ui): rebuild the UX around two surfaces — a glance popover and a session window
The menu-bar popover was being used as a session manager: status, five text fields, thumbnails, three buttons, a history list and eight more flat rows in 320 pt. The redesign splits the product by job, from a UX pass whose mockups are kept under design/ux-rework/. - Popover: only the current session. Review details as one line plus a pencil that opens the window with the Lane field focused, at most three thumbnails, a Capture and a Send row, a New Session and Open Redline row, one status line when something happened, and a footer with the send channel, the retention policy and a ... menu for Settings / updates / quit. - Window: sidebar of sessions grouped Today / Yesterday / This week / by month with a Current tag and each session's state, the selected session's pages as cards (select, Delete or Remove Page, sent sessions read-only), and an inspector with editable review details, the PDF facts (file name, pages, channel, status) and the session facts (started, id, files). Past sessions show their details read-only. - Settings: three labelled groups (Capture, Sending, Sessions) replacing the headings-plus-grid layout. - Sessions list/search/grouping/state live on the model, so the window and the popover read the same truth (came-back-marked state comes from the return ledger). - Verification: 159 tests, the headless panel self-test, and an end-to-end run against the active app (scripts/run-e2e-ui.sh) which opens the real window, types into the Lane field with key events and clicks New Session, reporting what the launch mode could and could not deliver.
This commit is contained in:
+220
-334
@@ -2,79 +2,125 @@ import AppKit
|
||||
import SwiftUI
|
||||
import ShotdeckCore
|
||||
|
||||
/// The menu-bar panel. Hierarchy: what is being worked on first, the three core
|
||||
/// verbs second, recent sessions third, housekeeping last.
|
||||
/// The menu-bar popover: the current session, and the two things you do with it.
|
||||
///
|
||||
/// Everything else — history, review details, PDF facts — lives in the Redline
|
||||
/// window, which stays open and has room for it.
|
||||
struct MenuBarView: View {
|
||||
@Environment(AppModel.self) private var model
|
||||
/// Snapshot-only: opens the details editor on first render.
|
||||
private let startsWithDetailsOpen: Bool
|
||||
@State private var showsDetails = false
|
||||
|
||||
init(showsContextEditor: Bool = false) {
|
||||
self.startsWithDetailsOpen = showsContextEditor
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 10) {
|
||||
statusRow
|
||||
sessionBlock
|
||||
Divider()
|
||||
recentSessionsBlock
|
||||
Divider()
|
||||
secondaryActions
|
||||
if !model.allReturns.isEmpty {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
if model.screenRecordingGranted {
|
||||
sessionHeader
|
||||
thumbnailRow
|
||||
statusRow
|
||||
actionRows
|
||||
Divider()
|
||||
returnsBlock
|
||||
footer
|
||||
} else {
|
||||
permissionBlock
|
||||
Divider()
|
||||
footer
|
||||
}
|
||||
Divider()
|
||||
footer
|
||||
}
|
||||
.padding(10)
|
||||
.frame(width: 320, alignment: .leading)
|
||||
.frame(width: 340, alignment: .leading)
|
||||
.controlSize(.small)
|
||||
.onAppear { showsDetails = startsWithDetailsOpen }
|
||||
}
|
||||
|
||||
// MARK: - Status
|
||||
// MARK: - Header
|
||||
|
||||
@ViewBuilder
|
||||
private var statusRow: some View {
|
||||
if !model.screenRecordingGranted {
|
||||
HStack(alignment: .top, spacing: 6) {
|
||||
Image(systemName: "exclamationmark.triangle")
|
||||
.foregroundStyle(.yellow)
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text(
|
||||
ShotdeckError.screenRecordingNotGranted.errorDescription
|
||||
?? "Screen Recording is turned off."
|
||||
)
|
||||
.font(.caption)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
Button("Open Screen Recording settings") {
|
||||
model.openScreenRecordingSettings()
|
||||
private var sessionHeader: some View {
|
||||
HStack(alignment: .top, spacing: 8) {
|
||||
VStack(alignment: .leading, spacing: 1) {
|
||||
HStack(spacing: 5) {
|
||||
Text(laneTitle)
|
||||
.font(.system(size: 13, weight: .semibold))
|
||||
.lineLimit(1)
|
||||
if let version = versionTitle {
|
||||
Text(version)
|
||||
.font(.system(size: 13))
|
||||
.foregroundStyle(.secondary)
|
||||
.lineLimit(1)
|
||||
}
|
||||
}
|
||||
Text(detailLine)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
.help(detailLine)
|
||||
}
|
||||
} else if let status = model.statusLine {
|
||||
Text(status)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.primary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
} else {
|
||||
Text(defaultStatusText)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
Spacer(minLength: 4)
|
||||
if !model.session.isEmpty {
|
||||
Text("\(model.session.captures.count) page\(model.session.captures.count == 1 ? "" : "s")")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.monospacedDigit()
|
||||
.padding(.horizontal, 6)
|
||||
.padding(.vertical, 2)
|
||||
.background(.quaternary, in: Capsule())
|
||||
}
|
||||
Button {
|
||||
presentWindow(focusLane: true)
|
||||
} label: {
|
||||
Image(systemName: "square.and.pencil")
|
||||
.font(.system(size: 12, weight: .semibold))
|
||||
}
|
||||
.buttonStyle(.borderless)
|
||||
.help("Edit review details")
|
||||
.accessibilityLabel("Edit review details")
|
||||
}
|
||||
}
|
||||
|
||||
private var defaultStatusText: String {
|
||||
guard let region = model.region else {
|
||||
return "No area selected yet — press \(model.hotkeyDisplayString) to pick one."
|
||||
private var laneTitle: String {
|
||||
let lane = model.session.context.lane
|
||||
return lane.isEmpty ? "No lane" : lane
|
||||
}
|
||||
|
||||
private var versionTitle: String? {
|
||||
let version = model.session.context.deployedVersion
|
||||
return version.isEmpty ? nil : version
|
||||
}
|
||||
|
||||
private var detailLine: String {
|
||||
let context = model.session.context
|
||||
var parts: [String] = []
|
||||
if !context.commit.isEmpty { parts.append(context.commit) }
|
||||
if !context.reviewer.isEmpty { parts.append(context.reviewer) }
|
||||
let started = DubaiTime.checkTime(model.session.createdAt)
|
||||
if parts.isEmpty {
|
||||
return "No review details yet · started \(started)"
|
||||
}
|
||||
let w = Int(region.rect.width)
|
||||
let h = Int(region.rect.height)
|
||||
return "Capturing \(w) × \(h) on \(displayName(for: region))"
|
||||
return parts.joined(separator: " · ") + " · started \(started)"
|
||||
}
|
||||
|
||||
// MARK: - Body
|
||||
|
||||
@ViewBuilder
|
||||
private var thumbnailRow: some View {
|
||||
if model.session.isEmpty {
|
||||
VStack(spacing: 2) {
|
||||
Text("Nothing captured yet")
|
||||
.font(.callout)
|
||||
.foregroundStyle(.secondary)
|
||||
Text(emptyHint)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.tertiary)
|
||||
}
|
||||
.frame(maxWidth: .infinity, minHeight: 62)
|
||||
.background(.quaternary.opacity(0.4), in: RoundedRectangle(cornerRadius: 6, style: .continuous))
|
||||
} else {
|
||||
SessionStrip(limit: 3)
|
||||
}
|
||||
}
|
||||
|
||||
private var emptyHint: String {
|
||||
guard let region = model.region else {
|
||||
return "\(model.hotkeyDisplayString) picks an area, then captures it"
|
||||
}
|
||||
return "\(model.hotkeyDisplayString) captures \(Int(region.rect.width)) × \(Int(region.rect.height)) on \(displayName(for: region))"
|
||||
}
|
||||
|
||||
private func displayName(for region: CaptureRegion) -> String {
|
||||
@@ -88,322 +134,162 @@ struct MenuBarView: View {
|
||||
return "Display 1"
|
||||
}
|
||||
|
||||
// MARK: - Current session
|
||||
|
||||
private var sessionBlock: some View {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 6) {
|
||||
Text("Current session")
|
||||
.font(.caption.weight(.semibold))
|
||||
Spacer(minLength: 6)
|
||||
Text(captureCountText)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.monospacedDigit()
|
||||
}
|
||||
|
||||
HStack(alignment: .firstTextBaseline, spacing: 6) {
|
||||
Text(contextSummary)
|
||||
.font(.caption)
|
||||
.foregroundStyle(model.sessionContext.summaryLine.isEmpty ? .secondary : .primary)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
.help(contextSummary)
|
||||
Spacer(minLength: 4)
|
||||
// A bordered control, not a link: in a menu panel the row of text is
|
||||
// the value, and the thing you press has to look pressable.
|
||||
Button {
|
||||
showsDetails.toggle()
|
||||
} label: {
|
||||
HStack(spacing: 2) {
|
||||
Text(showsDetails ? "Hide" : "Details")
|
||||
Image(systemName: showsDetails ? "chevron.up" : "chevron.down")
|
||||
.font(.system(size: 9, weight: .semibold))
|
||||
}
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.accessibilityLabel(showsDetails ? "Hide details" : "Show details")
|
||||
}
|
||||
|
||||
if showsDetails {
|
||||
SessionContextEditor()
|
||||
}
|
||||
|
||||
SessionStrip()
|
||||
/// One line, only when there is something to say: the last action's result, or a
|
||||
/// PDF that came back with marks.
|
||||
@ViewBuilder
|
||||
private var statusRow: some View {
|
||||
if let status = model.statusLine, !status.isEmpty {
|
||||
Text(status)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.lineLimit(2)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
}
|
||||
|
||||
private var actionRows: some View {
|
||||
VStack(spacing: 6) {
|
||||
HStack(spacing: 6) {
|
||||
Button("Capture") {
|
||||
Button {
|
||||
Task { await model.captureNow() }
|
||||
} label: {
|
||||
HStack(spacing: 4) {
|
||||
Image(systemName: "viewfinder")
|
||||
Text(model.isCapturing ? "Capturing…" : "Capture")
|
||||
Text(model.hotkeyDisplayString)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.controlSize(.regular)
|
||||
.disabled(model.isCapturing)
|
||||
|
||||
Button(model.transport == .oneDrive ? "Send to OneDrive" : "Send…") {
|
||||
Button {
|
||||
guard let sender = model as? SendCapable else {
|
||||
model.setStatus("Send is not available in this build.")
|
||||
return
|
||||
}
|
||||
let anchor = NSApp.keyWindow?.contentView
|
||||
Task { await sender.send(anchor: anchor) }
|
||||
} label: {
|
||||
HStack(spacing: 4) {
|
||||
Image(systemName: "paperplane.fill")
|
||||
Text(sendTitle)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.controlSize(.regular)
|
||||
.disabled(model.session.isEmpty || model.isSending)
|
||||
}
|
||||
|
||||
Button("New session") {
|
||||
HStack(spacing: 6) {
|
||||
Button {
|
||||
Task { await model.startNewSession() }
|
||||
} label: {
|
||||
HStack(spacing: 4) {
|
||||
Image(systemName: "plus.square.on.square")
|
||||
Text("New Session")
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.controlSize(.regular)
|
||||
.disabled(!model.canStartNewSession)
|
||||
.help("Keeps these captures as a past session and starts a fresh one. Nothing is deleted.")
|
||||
.help("Keeps this session and starts a fresh one. Nothing is deleted.")
|
||||
|
||||
Button {
|
||||
presentWindow(focusLane: false)
|
||||
} label: {
|
||||
HStack(spacing: 4) {
|
||||
Image(systemName: "macwindow")
|
||||
Text("Open Redline")
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.controlSize(.regular)
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
|
||||
private var captureCountText: String {
|
||||
private var sendTitle: String {
|
||||
let count = model.session.captures.count
|
||||
if count == 0 { return "empty" }
|
||||
return "\(count) capture\(count == 1 ? "" : "s")"
|
||||
}
|
||||
|
||||
private var contextSummary: String {
|
||||
let summary = model.sessionContext.summaryLine
|
||||
return summary.isEmpty ? "No lane or build recorded — add details" : summary
|
||||
}
|
||||
|
||||
// MARK: - Recent sessions
|
||||
|
||||
private var recentSessionsBlock: some View {
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 6) {
|
||||
Text("Recent sessions")
|
||||
.font(.caption.weight(.semibold))
|
||||
if !model.pastSessions.isEmpty {
|
||||
Text("\(model.pastSessions.count)")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.monospacedDigit()
|
||||
}
|
||||
Spacer(minLength: 6)
|
||||
Button("Show all…") {
|
||||
if let presenter = model as? SubmissionsWindowPresenting {
|
||||
presenter.presentSubmissionsWindow()
|
||||
} else {
|
||||
model.setStatus("Past sessions are not available in this build.")
|
||||
}
|
||||
}
|
||||
.buttonStyle(.link)
|
||||
}
|
||||
|
||||
if model.pastSessions.isEmpty {
|
||||
Text("Nothing yet. “New session” keeps this one and starts a fresh one.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
} else {
|
||||
ForEach(model.pastSessions.prefix(4)) { session in
|
||||
RecentSessionRow(session: session)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Secondary actions
|
||||
|
||||
private var secondaryActions: some View {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
if let update = model.updateAvailable {
|
||||
Button {
|
||||
model.installUpdate()
|
||||
} label: {
|
||||
actionLabel("Update to \(update.version)")
|
||||
.foregroundStyle(Color.accentColor)
|
||||
}
|
||||
}
|
||||
|
||||
if let previous = model.previousVersion {
|
||||
Button {
|
||||
model.revertToPreviousVersion()
|
||||
} label: {
|
||||
actionLabel("Revert to \(previous)")
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
model.revealLastPDF()
|
||||
} label: {
|
||||
actionLabel("Reveal last PDF")
|
||||
}
|
||||
.disabled(!model.canRevealLastPDF)
|
||||
|
||||
Button {
|
||||
Task { await model.copyCommentedLinks() }
|
||||
} label: {
|
||||
actionLabel(
|
||||
"Copy commented links",
|
||||
trailing: model.commentedReturns.isEmpty ? nil : "\(model.commentedReturns.count)"
|
||||
)
|
||||
}
|
||||
.disabled(model.commentedReturns.isEmpty)
|
||||
|
||||
Button {
|
||||
Task { await model.rePickRegion() }
|
||||
} label: {
|
||||
actionLabel("Re-select area")
|
||||
}
|
||||
|
||||
Button {
|
||||
Task { await model.captureNow() }
|
||||
} label: {
|
||||
actionLabel("Capture now", trailing: model.hotkeyDisplayString)
|
||||
}
|
||||
.disabled(model.isCapturing)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
|
||||
private func actionLabel(_ title: String, trailing: String? = nil) -> some View {
|
||||
HStack(spacing: 8) {
|
||||
Text(title)
|
||||
Spacer(minLength: 8)
|
||||
if let trailing {
|
||||
Text(trailing)
|
||||
.foregroundStyle(.secondary)
|
||||
.monospacedDigit()
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.contentShape(Rectangle())
|
||||
.padding(.vertical, 3)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var returnsBlock: some View {
|
||||
if let provider = model as? ReturnsSectionProviding {
|
||||
provider.returnsSection()
|
||||
} else {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text("Came back from your device")
|
||||
.font(.caption.weight(.semibold))
|
||||
ForEach(newestReturns.prefix(6)) { doc in
|
||||
HStack(spacing: 8) {
|
||||
Text(doc.fileURL.lastPathComponent)
|
||||
.lineLimit(1)
|
||||
Spacer(minLength: 8)
|
||||
Text(doc.isCommented
|
||||
? "\(doc.annotatedPages.count) page\(doc.annotatedPages.count == 1 ? "" : "s") marked"
|
||||
: "not marked")
|
||||
.font(.caption)
|
||||
.foregroundStyle(doc.isCommented ? .primary : .secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var newestReturns: [ReturnedDocument] {
|
||||
model.allReturns.sorted { $0.detectedAt > $1.detectedAt }
|
||||
guard count > 0 else { return "Send…" }
|
||||
let pages = "\(count) page\(count == 1 ? "" : "s")"
|
||||
return model.transport == .oneDrive ? "Save \(pages)…" : "Send \(pages)…"
|
||||
}
|
||||
|
||||
// MARK: - Footer
|
||||
|
||||
private var footer: some View {
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
HStack(spacing: 6) {
|
||||
Button("Settings…") {
|
||||
if let presenter = model as? SettingsWindowPresenting {
|
||||
presenter.presentSettingsWindow()
|
||||
} else {
|
||||
model.setStatus("Settings is not available in this build.")
|
||||
}
|
||||
}
|
||||
.buttonStyle(.link)
|
||||
Button("Check for updates") {
|
||||
model.checkForUpdates()
|
||||
}
|
||||
.buttonStyle(.link)
|
||||
.disabled(model.isCheckingForUpdates)
|
||||
Spacer(minLength: 6)
|
||||
Button("Quit") {
|
||||
NSApp.terminate(nil)
|
||||
}
|
||||
.buttonStyle(.link)
|
||||
}
|
||||
Text("Redline \(model.appVersion) · \(model.retentionSummary)")
|
||||
HStack(spacing: 6) {
|
||||
Text("\(sendChannel) · \(model.retentionSummary)")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
Spacer(minLength: 4)
|
||||
Menu {
|
||||
Button("Settings…") {
|
||||
(model as? SettingsWindowPresenting)?.presentSettingsWindow()
|
||||
}
|
||||
.keyboardShortcut(",", modifiers: .command)
|
||||
Button(model.isCheckingForUpdates ? "Checking for Updates…" : "Check for Updates…") {
|
||||
model.checkForUpdates()
|
||||
}
|
||||
.disabled(model.isCheckingForUpdates)
|
||||
if let update = model.updateAvailable {
|
||||
Button("Update to \(update.version)") { model.installUpdate() }
|
||||
}
|
||||
if let previous = model.previousVersion {
|
||||
Button("Revert to \(previous)") { model.revertToPreviousVersion() }
|
||||
}
|
||||
Divider()
|
||||
Button("Quit Redline") { NSApp.terminate(nil) }
|
||||
.keyboardShortcut("q", modifiers: .command)
|
||||
} label: {
|
||||
Image(systemName: "ellipsis.circle")
|
||||
}
|
||||
.menuStyle(.borderlessButton)
|
||||
.menuIndicator(.hidden)
|
||||
.fixedSize()
|
||||
.help("More Redline actions")
|
||||
.accessibilityLabel("More")
|
||||
}
|
||||
.overlay(alignment: .topTrailing) {
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
|
||||
private var sendChannel: String {
|
||||
model.transport == .oneDrive ? "Saves to OneDrive" : "Sends via AirDrop"
|
||||
}
|
||||
|
||||
// MARK: - Not granted
|
||||
|
||||
private var permissionBlock: some View {
|
||||
HStack(alignment: .top, spacing: 6) {
|
||||
Image(systemName: "exclamationmark.triangle")
|
||||
.foregroundStyle(.yellow)
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Text(
|
||||
ShotdeckError.screenRecordingNotGranted.errorDescription
|
||||
?? "Screen Recording is turned off."
|
||||
)
|
||||
.font(.caption)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
if let message = model.updateStatusMessage {
|
||||
Text(message)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
Button("Open Screen Recording settings") {
|
||||
model.openScreenRecordingSettings()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One row of the panel's recent-sessions list: timestamp, readable session label,
|
||||
/// page count and sent state. Clicking reveals the sent PDF when there is one,
|
||||
/// otherwise that session's captures.
|
||||
private struct RecentSessionRow: View {
|
||||
@Environment(AppModel.self) private var model
|
||||
let session: CaptureSession
|
||||
@State private var hovering = false
|
||||
|
||||
var body: some View {
|
||||
Button {
|
||||
if model.sentPDFURL(for: session) != nil {
|
||||
model.revealSentPDF(session)
|
||||
} else {
|
||||
model.revealSessionCaptures(session)
|
||||
}
|
||||
} label: {
|
||||
HStack(spacing: 6) {
|
||||
Text(DubaiTime.shortStamp(session.createdAt))
|
||||
.font(.caption)
|
||||
.monospacedDigit()
|
||||
.foregroundStyle(.secondary)
|
||||
Text(SessionDisplay.label(for: session))
|
||||
.font(.caption)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
Spacer(minLength: 6)
|
||||
Text(session.pdfFileName == nil ? "Not sent" : "Sent")
|
||||
.font(.caption)
|
||||
.foregroundStyle(session.pdfFileName == nil ? .secondary : .primary)
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.vertical, 2)
|
||||
.contentShape(Rectangle())
|
||||
.background(hovering ? AnyShapeStyle(.quaternary) : AnyShapeStyle(.clear))
|
||||
private func presentWindow(focusLane: Bool) {
|
||||
guard let presenter = model as? SessionsWindowPresenting else {
|
||||
model.setStatus("The Redline window is not available in this build.")
|
||||
return
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.onHover { hovering = $0 }
|
||||
.help(helpText)
|
||||
}
|
||||
|
||||
private var helpText: String {
|
||||
let pages = "\(session.captures.count) page\(session.captures.count == 1 ? "" : "s")"
|
||||
let context = session.context.summaryLine
|
||||
let detail = context.isEmpty ? pages : "\(pages) · \(context)"
|
||||
if let name = session.pdfFileName {
|
||||
return "\(detail)\nSent as \(name)"
|
||||
}
|
||||
return "\(detail)\nNever sent — opens the captures"
|
||||
}
|
||||
}
|
||||
|
||||
/// Readable labels for sessions, shared by the panel and the Past sessions window.
|
||||
///
|
||||
/// The label is what the user typed plus the session's short id — never the
|
||||
/// upper-cased file-name slug, which is for filesystems, not people.
|
||||
enum SessionDisplay {
|
||||
static func label(for session: CaptureSession) -> String {
|
||||
let lane = session.context.lane
|
||||
return lane.isEmpty ? session.shortID : lane
|
||||
}
|
||||
|
||||
static func fullLabel(for session: CaptureSession) -> String {
|
||||
let lane = session.context.lane
|
||||
return lane.isEmpty ? session.shortID : "\(lane) · \(session.shortID)"
|
||||
presenter.presentSessionsWindow(focusLane: focusLane)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user