Skip to content
This repository was archived by the owner on Nov 7, 2026. It is now read-only.

Commit 9febfde

Browse files
committed
Merge branch 'editor-store' into simulation-controller
2 parents 0e77012 + dcc8adb commit 9febfde

24 files changed

Lines changed: 160 additions & 19 deletions

File tree

‎VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/Canvas/DiagramCanvasView.swift‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ struct DiagramCanvasView: View {
213213
Color.clear
214214
.frame(width: cw, height: ch)
215215
.contentShape(Rectangle())
216+
.accessibilityHidden(true)
216217
.onTapGesture {
217218
selectedPath = nil
218219
// iPhone: Einfügemarke durch Tap auf leeren Bereich löschen.
@@ -237,13 +238,16 @@ struct DiagramCanvasView: View {
237238

238239
canvasView(layout: layout, cw: cw, ch: ch)
239240
.allowsHitTesting(false)
241+
// Gezeichnete Fläche; VoiceOver liest stattdessen die Blöcke darüber.
242+
.accessibilityHidden(true)
240243

241244
if let firstRoot = layout.elements.first {
242245
rootInsertBeforeFirstStrip(
243246
firstRootFrame: firstRoot.frame,
244247
canvasWidth: cw,
245248
canvasHeight: ch
246249
)
250+
.accessibilityHidden(true)
247251
}
248252

249253
ForEach(flat, id: \.pathKey) { node in
@@ -354,13 +358,30 @@ struct DiagramCanvasView: View {
354358
.draggable(DiagramDragPayload(raw: ElementPalette.moveDragIdentifier(path: node.idPath))) {
355359
nodeDragPreview(for: node)
356360
}
361+
// VoiceOver: ein Element pro Block (statt der unbeschrifteten Drop-Streifen darin).
362+
.accessibilityElement(children: .ignore)
363+
.accessibilityLabel(accessibilityLabel(for: node))
364+
.accessibilityAddTraits(selectedPath == node.idPath ? [.isButton, .isSelected] : .isButton)
365+
.accessibilityAction {
366+
selectedPath = node.idPath
367+
}
357368
.accessibilityHint(
358369
isPlaceholderNode
359370
? lang.tr("a11y_placeholder_drop")
360371
: lang.tr("a11y_node_drop")
361372
)
362373
}
363374

375+
/// Vorgelesener Name eines Blocks: Elementart und Text, z. B. „Anweisung: int x = 5“.
376+
private func accessibilityLabel(for node: VisuStructLayout.Node) -> String {
377+
// Schlüssel wie in der Palette: element_anweisung, element_verzweigung, …
378+
let kind = lang.tr("element_\(node.element.type)")
379+
let text = node.element.textLines
380+
.joined(separator: " ")
381+
.trimmingCharacters(in: .whitespacesAndNewlines)
382+
return text.isEmpty ? kind : "\(kind): \(text)"
383+
}
384+
364385
private func copyElement(at path: [Int]) {
365386
guard let el = try? VisuStructDocumentEditing.element(at: path, in: document) else { return }
366387
elementClipboard = el

‎VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/ContentView.swift‎

Lines changed: 86 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,14 @@ struct ContentView: View {
5252
}
5353
// iPhone UX: Einfügemarke + Inspector einklappen beim Einfügen.
5454
@State private var insertTarget: DiagramInsertTarget? = nil
55-
@State private var hideInspectorOnPhone: Bool = false
55+
/// iPhone: Inspector startet eingeklappt, damit das Diagramm Platz hat.
56+
@State private var hideInspectorOnPhone: Bool = true
5657
// iPhone UX: Palette automatisch einklappen beim Text-Editieren.
57-
@State private var showPaletteOnPhone: Bool = true
58+
/// iPhone: Palette als Sheet über dem Editor (statt fest über der Navigationsleiste).
59+
@State private var showPaletteOnPhone: Bool = false
60+
/// iPhone: Diagrammtitel wird in einem kleinen Dialog bearbeitet statt in einem eigenen Feld über dem Diagramm.
61+
@State private var showPhoneTitleEditor: Bool = false
62+
@State private var phoneTitleDraft: String = ""
5863
// In-App Zwischenablage für Diagramm-Elemente (Copy/Cut/Paste).
5964
@State private var elementClipboard: VisuStructElement? = nil
6065
#if canImport(UIKit)
@@ -160,7 +165,7 @@ struct ContentView: View {
160165
.navigationSplitViewStyle(.balanced)
161166
} else {
162167
VStack(spacing: 0) {
163-
if !isPhone || showPaletteOnPhone {
168+
if !isPhone {
164169
paletteListPanel
165170
.frame(maxHeight: 300, alignment: .top)
166171
.background(Color(.secondarySystemGroupedBackground))
@@ -170,6 +175,14 @@ struct ContentView: View {
170175
mainEditorNavigationStack
171176
.frame(maxWidth: .infinity, maxHeight: .infinity)
172177
}
178+
.sheet(isPresented: phonePaletteSheetBinding) {
179+
paletteListPanel
180+
.environment(\.appLanguage, lang)
181+
.presentationDetents([.medium, .large])
182+
// Diagramm bleibt bedienbar, z. B. um eine Einfügestelle zu wählen.
183+
.presentationBackgroundInteraction(.enabled(upThrough: .medium))
184+
.presentationDragIndicator(.visible)
185+
}
173186
}
174187
}
175188
#if canImport(UIKit)
@@ -329,6 +342,11 @@ struct ContentView: View {
329342
refreshLineEditor()
330343
DiagramCommandCenter.shared.update(file: diagramFileActions, edit: diagramEditActions)
331344
}
345+
.onChange(of: insertTarget) { _, newTarget in
346+
// iPhone: Einfügestelle gewählt → Palette öffnen, damit gleich ein Element gewählt werden kann.
347+
guard isPhone, newTarget != nil else { return }
348+
showPaletteOnPhone = true
349+
}
332350
.onChange(of: focusedField) { _, newVal in
333351
// iPhone: Sobald Textbearbeitung startet, Palette einklappen für mehr Platz.
334352
guard isPhone else { return }
@@ -858,21 +876,25 @@ struct ContentView: View {
858876
let blockCorner: CGFloat = horizontalSizeClass == .regular ? 14 : 12
859877

860878
return VStack(alignment: .leading, spacing: 0) {
861-
VStack(alignment: .leading, spacing: 8) {
862-
Text(lang.tr("diagram_title_label"))
863-
.font(horizontalSizeClass == .regular ? .caption : .subheadline)
864-
.foregroundStyle(.secondary)
865-
TextField(lang.tr("diagram_title_placeholder"), text: captionBinding)
866-
.font(horizontalSizeClass == .regular ? .subheadline : .body)
867-
.textFieldStyle(.roundedBorder)
868-
.textInputAutocapitalization(.never)
869-
.autocorrectionDisabled(true)
870-
.focused($focusedField, equals: .caption)
879+
if isPhone {
880+
phoneCaptionRow
881+
} else {
882+
VStack(alignment: .leading, spacing: 8) {
883+
Text(lang.tr("diagram_title_label"))
884+
.font(horizontalSizeClass == .regular ? .caption : .subheadline)
885+
.foregroundStyle(.secondary)
886+
TextField(lang.tr("diagram_title_placeholder"), text: captionBinding)
887+
.font(horizontalSizeClass == .regular ? .subheadline : .body)
888+
.textFieldStyle(.roundedBorder)
889+
.textInputAutocapitalization(.never)
890+
.autocorrectionDisabled(true)
891+
.focused($focusedField, equals: .caption)
892+
}
893+
.frame(maxWidth: .infinity, alignment: .leading)
894+
.padding(.horizontal, 14)
895+
.padding(.top, 8)
896+
.padding(.bottom, 6)
871897
}
872-
.frame(maxWidth: .infinity, alignment: .leading)
873-
.padding(.horizontal, 14)
874-
.padding(.top, 8)
875-
.padding(.bottom, 6)
876898
// Innerer Trennstrich — Titel zählt zum Diagramm-„Blatt“, nicht als losgelöster Bereich oberhalb.
877899
Rectangle()
878900
.fill(Color.primary.opacity(0.1))
@@ -912,6 +934,47 @@ struct ContentView: View {
912934
}
913935
}
914936

937+
/// iPhone: Titel als eine kompakte Zeile; Tippen öffnet einen Dialog zum Bearbeiten.
938+
private var phoneCaptionRow: some View {
939+
Button {
940+
phoneTitleDraft = document.caption
941+
showPhoneTitleEditor = true
942+
} label: {
943+
HStack(spacing: 6) {
944+
Text(document.caption.isEmpty ? lang.tr("diagram_title_placeholder") : document.caption)
945+
.font(.subheadline.weight(.semibold))
946+
.foregroundStyle(document.caption.isEmpty ? .secondary : .primary)
947+
.lineLimit(1)
948+
Image(systemName: "pencil")
949+
.font(.caption)
950+
.foregroundStyle(.secondary)
951+
}
952+
.frame(maxWidth: .infinity, alignment: .leading)
953+
.contentShape(Rectangle())
954+
}
955+
.buttonStyle(.plain)
956+
.accessibilityLabel(lang.tr("diagram_title_label"))
957+
.padding(.horizontal, 14)
958+
.padding(.vertical, 8)
959+
.alert(lang.tr("diagram_title_label"), isPresented: $showPhoneTitleEditor) {
960+
TextField(lang.tr("diagram_title_placeholder"), text: $phoneTitleDraft)
961+
.textInputAutocapitalization(.never)
962+
.autocorrectionDisabled(true)
963+
Button(lang.tr("phone_title_done")) {
964+
if phoneTitleDraft != document.caption {
965+
captionBinding.wrappedValue = phoneTitleDraft
966+
}
967+
}
968+
}
969+
}
970+
971+
private var phonePaletteSheetBinding: Binding<Bool> {
972+
Binding(
973+
get: { isPhone && showPaletteOnPhone },
974+
set: { showPaletteOnPhone = $0 }
975+
)
976+
}
977+
915978
// MARK: - Bindings (Dokument, Caption)
916979

917980
private var documentBinding: Binding<VisuStructDocument> {
@@ -1245,7 +1308,11 @@ struct ContentView: View {
12451308
insertTargetActive: insertTarget != nil,
12461309
hideInspectorOnPhone: hideInspectorOnPhone,
12471310
onCancelInsert: { insertTarget = nil },
1248-
onShowInspector: { hideInspectorOnPhone = false }
1311+
onShowInspector: { hideInspectorOnPhone = false },
1312+
onHideInspector: {
1313+
focusedField = nil
1314+
hideInspectorOnPhone = true
1315+
}
12491316
) {
12501317
inspectorPanel
12511318
}
@@ -1508,6 +1575,7 @@ struct ContentView: View {
15081575
private func insertPaletteItem(_ item: ElementPalette.PaletteItem) {
15091576
if isPhone {
15101577
hideInspectorOnPhone = true
1578+
showPaletteOnPhone = false
15111579
}
15121580
let el = ElementPalette.element(for: item, lang: lang)
15131581
let doc = document

‎VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/Inspector/InspectorPanelViews.swift‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ struct InspectorPhoneChrome<Inspector: View>: View {
190190
let hideInspectorOnPhone: Bool
191191
let onCancelInsert: () -> Void
192192
let onShowInspector: () -> Void
193+
let onHideInspector: () -> Void
193194
@ViewBuilder let inspector: () -> Inspector
194195

195196
var body: some View {
@@ -211,7 +212,16 @@ struct InspectorPhoneChrome<Inspector: View>: View {
211212
}
212213
.buttonStyle(.bordered)
213214
} else {
214-
inspector()
215+
VStack(alignment: .trailing, spacing: 4) {
216+
Button {
217+
onHideInspector()
218+
} label: {
219+
Label(lang.tr("phone_hide_text_editor"), systemImage: "chevron.down")
220+
.font(.subheadline)
221+
}
222+
.buttonStyle(.borderless)
223+
inspector()
224+
}
215225
}
216226
}
217227
}

‎VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/ar.lproj/Localizable.strings‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@
194194
/* iPhone: tap-to-insert */
195195
"phone_insert_cancel" = "إلغاء الإدراج";
196196
"phone_show_text_editor" = "تحرير النص";
197+
"phone_hide_text_editor" = "طيّ";
198+
"phone_title_done" = "تم";
197199

198200
/* Alerts */
199201
"err_save_failed_fmt" = "تعذر الحفظ: %@";

‎VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/da.lproj/Localizable.strings‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,5 @@
140140
"sim_notice_division_by_zero" = "Division med nul.";
141141
"sim_notice_whole_number_expected" = "Indtast et heltal.";
142142
"sim_notice_number_expected" = "Indtast et tal.";
143+
"phone_hide_text_editor" = "Skjul";
144+
"phone_title_done" = "Færdig";

‎VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/de.lproj/Localizable.strings‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@
211211
/* iPhone: Einfügen per Tap */
212212
"phone_insert_cancel" = "Einfügen abbrechen";
213213
"phone_show_text_editor" = "Text bearbeiten";
214+
"phone_hide_text_editor" = "Einklappen";
215+
"phone_title_done" = "Fertig";
214216

215217
/* Meldungen */
216218
"err_save_failed_fmt" = "Speichern fehlgeschlagen: %@";

‎VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/el.lproj/Localizable.strings‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@
191191
/* iPhone: tap-to-insert */
192192
"phone_insert_cancel" = "Ακύρωση εισαγωγής";
193193
"phone_show_text_editor" = "Επεξεργασία κειμένου";
194+
"phone_hide_text_editor" = "Σύμπτυξη";
195+
"phone_title_done" = "Τέλος";
194196

195197
/* Alerts */
196198
"err_save_failed_fmt" = "Δεν ήταν δυνατή η αποθήκευση: %@";

‎VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/en.lproj/Localizable.strings‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@
211211
/* iPhone: tap-to-insert */
212212
"phone_insert_cancel" = "Cancel insert";
213213
"phone_show_text_editor" = "Edit text";
214+
"phone_hide_text_editor" = "Collapse";
215+
"phone_title_done" = "Done";
214216

215217
/* Alerts */
216218
"err_save_failed_fmt" = "Could not save: %@";

‎VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/es.lproj/Localizable.strings‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@
194194
/* iPhone: tap-to-insert */
195195
"phone_insert_cancel" = "Cancelar inserción";
196196
"phone_show_text_editor" = "Editar texto";
197+
"phone_hide_text_editor" = "Contraer";
198+
"phone_title_done" = "Listo";
197199

198200
/* Alerts */
199201
"err_save_failed_fmt" = "No se pudo guardar: %@";

‎VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/fr.lproj/Localizable.strings‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@
194194
/* iPhone: tap-to-insert */
195195
"phone_insert_cancel" = "Annuler l’insertion";
196196
"phone_show_text_editor" = "Modifier le texte";
197+
"phone_hide_text_editor" = "Réduire";
198+
"phone_title_done" = "OK";
197199

198200
/* Alerts */
199201
"err_save_failed_fmt" = "Impossible d’enregistrer : %@";

0 commit comments

Comments
 (0)