@@ -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
0 commit comments