@@ -57,9 +57,14 @@ struct ContentView: View {
5757 }
5858 // iPhone UX: Einfügemarke + Inspector einklappen beim Einfügen.
5959 @ State private var insertTarget : DiagramInsertTarget ? = nil
60- @ State private var hideInspectorOnPhone : Bool = false
60+ /// iPhone: Inspector startet eingeklappt, damit das Diagramm Platz hat.
61+ @ State private var hideInspectorOnPhone : Bool = true
6162 // iPhone UX: Palette automatisch einklappen beim Text-Editieren.
62- @ State private var showPaletteOnPhone : Bool = true
63+ /// iPhone: Palette als Sheet über dem Editor (statt fest über der Navigationsleiste).
64+ @ State private var showPaletteOnPhone : Bool = false
65+ /// iPhone: Diagrammtitel wird in einem kleinen Dialog bearbeitet statt in einem eigenen Feld über dem Diagramm.
66+ @ State private var showPhoneTitleEditor : Bool = false
67+ @ State private var phoneTitleDraft : String = " "
6368 // In-App Zwischenablage für Diagramm-Elemente (Copy/Cut/Paste).
6469 @ State private var elementClipboard : VisuStructElement ? = nil
6570 #if canImport( UIKit )
@@ -174,7 +179,7 @@ struct ContentView: View {
174179 . navigationSplitViewStyle ( . balanced )
175180 } else {
176181 VStack ( spacing : 0 ) {
177- if ! isPhone || showPaletteOnPhone {
182+ if ! isPhone {
178183 paletteListPanel
179184 . frame ( maxHeight : 300 , alignment : . top )
180185 . background ( Color ( . secondarySystemGroupedBackground ) )
@@ -184,6 +189,14 @@ struct ContentView: View {
184189 mainEditorNavigationStack
185190 . frame ( maxWidth : . infinity , maxHeight : . infinity )
186191 }
192+ . sheet ( isPresented : phonePaletteSheetBinding ) {
193+ paletteListPanel
194+ . environment ( \. appLanguage , lang )
195+ . presentationDetents ( [ . medium , . large ] )
196+ // Diagramm bleibt bedienbar, z. B. um eine Einfügestelle zu wählen.
197+ . presentationBackgroundInteraction ( . enabled ( upThrough : . medium ) )
198+ . presentationDragIndicator ( . visible )
199+ }
187200 }
188201 }
189202 #if canImport( UIKit )
@@ -343,6 +356,11 @@ struct ContentView: View {
343356 refreshLineEditor ( )
344357 DiagramCommandCenter . shared . update ( file : diagramFileActions , edit : diagramEditActions )
345358 }
359+ . onChange ( of : insertTarget ) { _ , newTarget in
360+ // iPhone: Einfügestelle gewählt → Palette öffnen, damit gleich ein Element gewählt werden kann.
361+ guard isPhone , newTarget != nil else { return }
362+ showPaletteOnPhone = true
363+ }
346364 . onChange ( of : focusedField ) { _ , newVal in
347365 // iPhone: Sobald Textbearbeitung startet, Palette einklappen für mehr Platz.
348366 guard isPhone else { return }
@@ -872,21 +890,25 @@ struct ContentView: View {
872890 let blockCorner : CGFloat = horizontalSizeClass == . regular ? 14 : 12
873891
874892 return VStack ( alignment : . leading , spacing : 0 ) {
875- VStack ( alignment : . leading , spacing : 8 ) {
876- Text ( lang . tr ( " diagram_title_label " ) )
877- . font ( horizontalSizeClass == . regular ? . caption : . subheadline )
878- . foregroundStyle ( . secondary )
879- TextField ( lang . tr ( " diagram_title_placeholder " ) , text : captionBinding )
880- . font ( horizontalSizeClass == . regular ? . subheadline : . body )
881- . textFieldStyle ( . roundedBorder )
882- . textInputAutocapitalization ( . never )
883- . autocorrectionDisabled ( true )
884- . focused ( $focusedField , equals : . caption )
893+ if isPhone {
894+ phoneCaptionRow
895+ } else {
896+ VStack ( alignment : . leading , spacing : 8 ) {
897+ Text ( lang . tr ( " diagram_title_label " ) )
898+ . font ( horizontalSizeClass == . regular ? . caption : . subheadline )
899+ . foregroundStyle ( . secondary )
900+ TextField ( lang . tr ( " diagram_title_placeholder " ) , text : captionBinding )
901+ . font ( horizontalSizeClass == . regular ? . subheadline : . body )
902+ . textFieldStyle ( . roundedBorder )
903+ . textInputAutocapitalization ( . never )
904+ . autocorrectionDisabled ( true )
905+ . focused ( $focusedField , equals : . caption )
906+ }
907+ . frame ( maxWidth : . infinity , alignment : . leading )
908+ . padding ( . horizontal , 14 )
909+ . padding ( . top , 8 )
910+ . padding ( . bottom , 6 )
885911 }
886- . frame ( maxWidth : . infinity , alignment : . leading )
887- . padding ( . horizontal , 14 )
888- . padding ( . top , 8 )
889- . padding ( . bottom , 6 )
890912 // Innerer Trennstrich — Titel zählt zum Diagramm-„Blatt“, nicht als losgelöster Bereich oberhalb.
891913 Rectangle ( )
892914 . fill ( Color . primary . opacity ( 0.1 ) )
@@ -926,6 +948,47 @@ struct ContentView: View {
926948 }
927949 }
928950
951+ /// iPhone: Titel als eine kompakte Zeile; Tippen öffnet einen Dialog zum Bearbeiten.
952+ private var phoneCaptionRow : some View {
953+ Button {
954+ phoneTitleDraft = document . caption
955+ showPhoneTitleEditor = true
956+ } label : {
957+ HStack ( spacing : 6 ) {
958+ Text ( document . caption . isEmpty ? lang . tr ( " diagram_title_placeholder " ) : document . caption )
959+ . font ( . subheadline . weight ( . semibold ) )
960+ . foregroundStyle ( document . caption . isEmpty ? . secondary : . primary )
961+ . lineLimit ( 1 )
962+ Image ( systemName : " pencil " )
963+ . font ( . caption )
964+ . foregroundStyle ( . secondary )
965+ }
966+ . frame ( maxWidth : . infinity , alignment : . leading )
967+ . contentShape ( Rectangle ( ) )
968+ }
969+ . buttonStyle ( . plain )
970+ . accessibilityLabel ( lang . tr ( " diagram_title_label " ) )
971+ . padding ( . horizontal , 14 )
972+ . padding ( . vertical , 8 )
973+ . alert ( lang . tr ( " diagram_title_label " ) , isPresented : $showPhoneTitleEditor ) {
974+ TextField ( lang . tr ( " diagram_title_placeholder " ) , text : $phoneTitleDraft )
975+ . textInputAutocapitalization ( . never )
976+ . autocorrectionDisabled ( true )
977+ Button ( lang . tr ( " phone_title_done " ) ) {
978+ if phoneTitleDraft != document . caption {
979+ captionBinding . wrappedValue = phoneTitleDraft
980+ }
981+ }
982+ }
983+ }
984+
985+ private var phonePaletteSheetBinding : Binding < Bool > {
986+ Binding (
987+ get : { isPhone && showPaletteOnPhone } ,
988+ set : { showPaletteOnPhone = $0 }
989+ )
990+ }
991+
929992 // MARK: - Bindings (Dokument, Caption)
930993
931994 private var documentBinding : Binding < VisuStructDocument > {
@@ -1350,7 +1413,11 @@ struct ContentView: View {
13501413 insertTargetActive : insertTarget != nil ,
13511414 hideInspectorOnPhone : hideInspectorOnPhone ,
13521415 onCancelInsert : { insertTarget = nil } ,
1353- onShowInspector : { hideInspectorOnPhone = false }
1416+ onShowInspector : { hideInspectorOnPhone = false } ,
1417+ onHideInspector : {
1418+ focusedField = nil
1419+ hideInspectorOnPhone = true
1420+ }
13541421 ) {
13551422 inspectorPanel
13561423 }
@@ -1613,6 +1680,7 @@ struct ContentView: View {
16131680 private func insertPaletteItem ( _ item : ElementPalette . PaletteItem ) {
16141681 if isPhone {
16151682 hideInspectorOnPhone = true
1683+ showPaletteOnPhone = false
16161684 }
16171685 let el = ElementPalette . element ( for : item , lang : lang )
16181686 let doc = document
0 commit comments