Skip to content

Extract shared CreationSheet wrapper for 4 duplicate sheet layouts #61

@2witstudios

Description

@2witstudios

Problem

Four creation sheets share an identical structural pattern with ~40 lines of boilerplate each:

  • AgentCreationSheet.swift
  • PromptCreationSheet.swift
  • SwarmCreationSheet.swift
  • ScheduleCreationSheet.swift

The header is character-for-character identical across all four (only the title string differs):

HStack {
    Text("New X").font(.system(size: 14, weight: .semibold))
    Spacer()
}
.padding(.horizontal, 20)
.padding(.vertical, 12)

The footer is structurally identical (Cancel + Create buttons with keyboard shortcuts, same padding), differing only in the Create action body and the .disabled() condition.

The body layout is identical: VStack(spacing: 0) { header; Divider; form; Divider; footer }

Suggested approach

Extract a generic CreationSheet<Content> wrapper:

struct CreationSheet<FormContent: View>: View {
    let title: String
    let isValid: Bool
    let onCreate: () -> Void
    @ViewBuilder let form: () -> FormContent
}

Estimated ~160 lines of boilerplate eliminated.

Files

  • apps/purepoint-macos/purepoint-macos/Views/Agents/AgentCreationSheet.swift
  • apps/purepoint-macos/purepoint-macos/Views/Agents/PromptCreationSheet.swift
  • apps/purepoint-macos/purepoint-macos/Views/Agents/SwarmCreationSheet.swift
  • apps/purepoint-macos/purepoint-macos/Views/Schedule/ScheduleCreationSheet.swift

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions