82 lines
3.4 KiB
Swift
82 lines
3.4 KiB
Swift
import HelderCore
|
|
import SwiftUI
|
|
|
|
/// The command exists but has not written `database/helder/schema.json` yet.
|
|
struct SchemaEmptyState: View {
|
|
let model: WorkspaceModel
|
|
let store: SchemaStore
|
|
|
|
var body: some View {
|
|
SchemaStateBlock(label: "[ no dump yet ]",
|
|
message: Text("— Helder draws the schema from ") + schemaMono(SchemaPaths.dumpFile)
|
|
+ Text(". Run the command to write it.")) {
|
|
HStack(spacing: 14) {
|
|
SchemaPrimaryButton(label: store.runLabel) { model.perform(.runSchemaDump) }
|
|
Text("$ " + SchemaPaths.commandLine).typeRole(Typography.path).foregroundStyle(Palette.text4).lineLimit(1)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// The project is a Laravel app without `HelderSchemaCommand.php`: the prompt that asks Claude to write it.
|
|
struct SchemaCommandMissing: View {
|
|
let model: WorkspaceModel
|
|
|
|
var body: some View {
|
|
SchemaStateBlock(label: "[ no command yet ]",
|
|
message: Text("— Helder draws the schema from ") + schemaMono(SchemaPaths.dumpFile)
|
|
+ Text(". The Artisan command ") + schemaMono(SchemaPaths.commandFile)
|
|
+ Text(" writes it, and this app does not have it yet.")) {
|
|
HStack(spacing: 14) {
|
|
SchemaPrimaryButton(label: "Generate command", icon: .sparkle) { model.perform(.generateSchemaCommand) }
|
|
SchemaOutlineButton(label: "Copy prompt", height: SchemaViewMetrics.primaryButton) { model.perform(.copySchemaPrompt) }
|
|
}
|
|
ScrollView {
|
|
Text(SchemaCommandPrompt.text)
|
|
.typeRole(Typography.console)
|
|
.foregroundStyle(Palette.textMuted)
|
|
.textSelection(.enabled)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.padding(12)
|
|
.background(PointerTextRegion())
|
|
}
|
|
.frame(maxHeight: SchemaViewMetrics.promptPreview)
|
|
.background(Palette.panel, in: RoundedRectangle(cornerRadius: Metrics.radiusSmall))
|
|
.overlay(RoundedRectangle(cornerRadius: Metrics.radiusSmall).strokeBorder(Palette.raised, lineWidth: Metrics.hairline))
|
|
}
|
|
}
|
|
}
|
|
|
|
/// A path inside the state copy: mono at the copy's size, in text-1.
|
|
private func schemaMono(_ text: String) -> Text {
|
|
Text(text).font(Typography.schemaBodyMono.font).foregroundColor(Palette.text1)
|
|
}
|
|
|
|
/// The centred block both states share: an amber label, Sans 15/1.6 copy, then the actions; at most 440 wide, 16 apart.
|
|
private struct SchemaStateBlock<Content: View>: View {
|
|
let label: String
|
|
let message: Text
|
|
@ViewBuilder let content: Content
|
|
|
|
init(label: String, message: Text, @ViewBuilder content: () -> Content) {
|
|
self.label = label
|
|
self.message = message
|
|
self.content = content()
|
|
}
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
Text(label).typeRole(Typography.gitLabel).foregroundStyle(Palette.amber)
|
|
message
|
|
.typeRole(Typography.schemaBody)
|
|
.foregroundStyle(Palette.text3)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
content
|
|
}
|
|
.frame(maxWidth: SchemaViewMetrics.emptyStateWidth, alignment: .leading)
|
|
.padding(24)
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
.background(Palette.editor)
|
|
}
|
|
}
|