@@ -15,6 +15,8 @@ struct SimulationStatePanel: View {
1515 let onStep : ( ) -> Void
1616 let onSubmitInput : ( ) -> Void
1717 let onStop : ( ) -> Void
18+ /// Hochkant auf dem iPad: Steuerung links, Schritt/Variablen/Ausgabe rechts statt alles untereinander.
19+ var usesWideLayout : Bool = false
1820
1921 private var sortedVariables : [ ( String , VisuStructSimulationValue ) ] {
2022 engine . state . variables
@@ -26,7 +28,9 @@ struct SimulationStatePanel: View {
2628
2729 var body : some View {
2830 Group {
29- if isWaitingForInput {
31+ if usesWideLayout {
32+ wideStack
33+ } else if isWaitingForInput {
3034 ScrollView {
3135 panelStack ( flexibleCardsFillHeight : false )
3236 }
@@ -50,125 +54,169 @@ struct SimulationStatePanel: View {
5054 @ ViewBuilder
5155 private func panelStack ( flexibleCardsFillHeight : Bool ) -> some View {
5256 VStack ( alignment : . leading , spacing : 16 ) {
53- VStack ( alignment : . leading , spacing : 10 ) {
54- Label ( lang . tr ( " simulation_controls " ) , systemImage : " slider.horizontal.3 " )
55- . font ( . headline )
57+ controlsSection
58+ inputCard
59+ traceCard ( flexibleCardsFillHeight : flexibleCardsFillHeight )
60+ variablesCard ( flexibleCardsFillHeight : flexibleCardsFillHeight )
61+ outputCard ( flexibleCardsFillHeight : flexibleCardsFillHeight )
62+ . layoutPriority ( flexibleCardsFillHeight ? 1 : 0 )
63+ noticeText
64+ }
65+ }
5666
57- LazyVGrid ( columns : [ GridItem ( . flexible ( ) ) , GridItem ( . flexible ( ) ) ] , spacing : 10 ) {
58- SimulationControlButton ( title : lang . tr ( " simulation_play " ) , systemImage : " play.fill " , isDisabled : isPlaying || ! engine . canStep , action : onPlay )
59- SimulationControlButton ( title : lang . tr ( " simulation_pause " ) , systemImage : " pause.fill " , isDisabled : ! isPlaying , action : onPause )
60- SimulationControlButton ( title : lang . tr ( " simulation_step " ) , systemImage : " arrow.right.circle " , isDisabled : isPlaying || ! engine . canStep , action : onStep )
61- SimulationControlButton ( title : lang . tr ( " simulation_stop " ) , systemImage : " stop.fill " , isDisabled : false , action : onStop )
67+ private var wideStack : some View {
68+ HStack ( alignment : . top , spacing : 16 ) {
69+ ScrollView {
70+ VStack ( alignment : . leading , spacing : 16 ) {
71+ controlsSection
72+ inputCard
73+ noticeText
6274 }
75+ }
76+ . scrollBounceBehavior ( . basedOnSize )
77+ . frame ( maxWidth : . infinity , maxHeight : . infinity , alignment : . topLeading )
6378
64- VStack ( alignment : . leading , spacing : 6 ) {
65- Text ( lang . tr ( " simulation_highlight_label " ) )
66- . font ( . caption )
67- . foregroundStyle ( . secondary )
68- Picker ( lang . tr ( " simulation_highlight_label " ) , selection : $highlightModeRaw ) {
69- Text ( lang . tr ( " simulation_highlight_last " ) ) . tag ( SimulationHighlightMode . lastExecuted . rawValue )
70- Text ( lang . tr ( " simulation_highlight_next " ) ) . tag ( SimulationHighlightMode . nextToExecute . rawValue )
71- }
72- . pickerStyle ( . segmented )
79+ VStack ( alignment : . leading , spacing : 16 ) {
80+ traceCard ( flexibleCardsFillHeight : false )
81+ HStack ( alignment : . top , spacing : 16 ) {
82+ variablesCard ( flexibleCardsFillHeight : true )
83+ outputCard ( flexibleCardsFillHeight : true )
7384 }
85+ . frame ( maxHeight : . infinity )
7486 }
87+ . frame ( maxWidth : . infinity , maxHeight : . infinity , alignment : . topLeading )
88+ }
89+ }
7590
76- SimulationInputCard (
77- prompt : engine . state . inputRequest ? . prompt ,
78- variableName : engine . state . inputRequest ? . variableName ,
79- valueType : engine . state . inputRequest ? . valueType ,
80- inputError : engine . state . inputErrorNotice ? . localized ( in : lang ) ,
81- inputText : $inputText ,
82- onSubmit : onSubmitInput
83- )
91+ private var controlsSection : some View {
92+ VStack ( alignment : . leading , spacing : 10 ) {
93+ Label ( lang . tr ( " simulation_controls " ) , systemImage : " slider.horizontal.3 " )
94+ . font ( . headline )
8495
85- SimulationPlaceholderCard (
86- title : lang . tr ( " simulation_trace " ) ,
87- systemImage : " arrow.left.arrow.right " ,
88- minHeight : flexibleCardsFillHeight ? 130 : 88
89- ) {
90- if let trace = engine . state . lastTrace {
91- Text ( trace )
92- . font ( . body . monospaced ( ) )
93- . frame ( maxWidth : . infinity , alignment : . leading )
94- . fixedSize ( horizontal : false , vertical : true )
95- } else {
96- Text ( lang . tr ( " simulation_trace_placeholder " ) )
97- . font ( . body )
98- . foregroundStyle ( . secondary )
99- . fixedSize ( horizontal : false , vertical : true )
100- }
96+ LazyVGrid ( columns : [ GridItem ( . flexible ( ) ) , GridItem ( . flexible ( ) ) ] , spacing : 10 ) {
97+ SimulationControlButton ( title : lang . tr ( " simulation_play " ) , systemImage : " play.fill " , isDisabled : isPlaying || ! engine . canStep , action : onPlay )
98+ SimulationControlButton ( title : lang . tr ( " simulation_pause " ) , systemImage : " pause.fill " , isDisabled : ! isPlaying , action : onPause )
99+ SimulationControlButton ( title : lang . tr ( " simulation_step " ) , systemImage : " arrow.right.circle " , isDisabled : isPlaying || ! engine . canStep , action : onStep )
100+ SimulationControlButton ( title : lang . tr ( " simulation_stop " ) , systemImage : " stop.fill " , isDisabled : false , action : onStop )
101101 }
102102
103- SimulationPlaceholderCard (
104- title : lang . tr ( " simulation_variables " ) ,
105- systemImage : " curlybraces " ,
106- minHeight : flexibleCardsFillHeight ? 190 : 96 ,
107- contentFillsHeight : flexibleCardsFillHeight
108- ) {
109- if sortedVariables . isEmpty {
110- Text ( lang . tr ( " simulation_variables_placeholder " ) )
111- . font ( . body )
112- . foregroundStyle ( . secondary )
113- . fixedSize ( horizontal : false , vertical : true )
114- } else {
115- ScrollView {
116- VStack ( alignment : . leading , spacing : 8 ) {
117- ForEach ( sortedVariables , id : \. 0 ) { name , value in
118- HStack ( alignment : . firstTextBaseline ) {
119- Text ( name )
120- . font ( . body . monospaced ( ) . weight ( . semibold ) )
121- Spacer ( minLength : 12 )
122- Text ( value . description )
123- . font ( . body . monospaced ( ) )
124- . foregroundStyle ( . secondary )
125- }
126- }
127- }
128- . padding ( . trailing , 14 )
129- . frame ( maxWidth : . infinity , alignment : . leading )
130- }
131- . frame ( maxWidth : . infinity , maxHeight : . infinity , alignment : . topLeading )
103+ VStack ( alignment : . leading , spacing : 6 ) {
104+ Text ( lang . tr ( " simulation_highlight_label " ) )
105+ . font ( . caption )
106+ . foregroundStyle ( . secondary )
107+ Picker ( lang . tr ( " simulation_highlight_label " ) , selection : $highlightModeRaw ) {
108+ Text ( lang . tr ( " simulation_highlight_last " ) ) . tag ( SimulationHighlightMode . lastExecuted . rawValue )
109+ Text ( lang . tr ( " simulation_highlight_next " ) ) . tag ( SimulationHighlightMode . nextToExecute . rawValue )
132110 }
111+ . pickerStyle ( . segmented )
133112 }
113+ }
114+ }
134115
135- SimulationPlaceholderCard (
136- title : lang . tr ( " simulation_output " ) ,
137- systemImage : " terminal " ,
138- minHeight : flexibleCardsFillHeight ? 170 : 96 ,
139- contentFillsHeight : flexibleCardsFillHeight
140- ) {
141- if engine . state . outputLines . isEmpty {
142- Text ( lang . tr ( " simulation_output_placeholder " ) )
143- . font ( . body )
144- . foregroundStyle ( . secondary )
145- . fixedSize ( horizontal : false , vertical : true )
146- } else {
147- ScrollView {
148- VStack ( alignment : . leading , spacing : 6 ) {
149- ForEach ( Array ( engine . state . outputLines . enumerated ( ) ) , id : \. offset ) { _ , line in
150- Text ( line )
116+ private var inputCard : some View {
117+ SimulationInputCard (
118+ prompt : engine . state . inputRequest ? . prompt ,
119+ variableName : engine . state . inputRequest ? . variableName ,
120+ valueType : engine . state . inputRequest ? . valueType ,
121+ inputError : engine . state . inputErrorNotice ? . localized ( in : lang ) ,
122+ inputText : $inputText ,
123+ onSubmit : onSubmitInput
124+ )
125+ }
126+
127+ private func traceCard ( flexibleCardsFillHeight : Bool ) -> some View {
128+ SimulationPlaceholderCard (
129+ title : lang . tr ( " simulation_trace " ) ,
130+ systemImage : " arrow.left.arrow.right " ,
131+ minHeight : flexibleCardsFillHeight ? 130 : 88
132+ ) {
133+ if let trace = engine . state . lastTrace {
134+ Text ( trace )
135+ . font ( . body . monospaced ( ) )
136+ . frame ( maxWidth : . infinity , alignment : . leading )
137+ . fixedSize ( horizontal : false , vertical : true )
138+ } else {
139+ Text ( lang . tr ( " simulation_trace_placeholder " ) )
140+ . font ( . body )
141+ . foregroundStyle ( . secondary )
142+ . fixedSize ( horizontal : false , vertical : true )
143+ }
144+ }
145+ }
146+
147+ private func variablesCard ( flexibleCardsFillHeight : Bool ) -> some View {
148+ SimulationPlaceholderCard (
149+ title : lang . tr ( " simulation_variables " ) ,
150+ systemImage : " curlybraces " ,
151+ minHeight : flexibleCardsFillHeight ? 190 : 96 ,
152+ contentFillsHeight : flexibleCardsFillHeight
153+ ) {
154+ if sortedVariables . isEmpty {
155+ Text ( lang . tr ( " simulation_variables_placeholder " ) )
156+ . font ( . body )
157+ . foregroundStyle ( . secondary )
158+ . fixedSize ( horizontal : false , vertical : true )
159+ } else {
160+ ScrollView {
161+ VStack ( alignment : . leading , spacing : 8 ) {
162+ ForEach ( sortedVariables , id : \. 0 ) { name , value in
163+ HStack ( alignment : . firstTextBaseline ) {
164+ Text ( name )
165+ . font ( . body . monospaced ( ) . weight ( . semibold ) )
166+ Spacer ( minLength : 12 )
167+ Text ( value . description )
151168 . font ( . body . monospaced ( ) )
152- . frame ( maxWidth : . infinity , alignment : . leading )
169+ . foregroundStyle ( . secondary )
153170 }
154171 }
155- . padding ( . trailing , 4 )
156- . frame ( maxWidth : . infinity , alignment : . leading )
157172 }
158- . frame ( maxWidth : . infinity , maxHeight : . infinity , alignment : . topLeading )
173+ . padding ( . trailing , 14 )
174+ . frame ( maxWidth : . infinity , alignment : . leading )
159175 }
176+ . frame ( maxWidth : . infinity , maxHeight : . infinity , alignment : . topLeading )
160177 }
161- . layoutPriority ( flexibleCardsFillHeight ? 1 : 0 )
178+ }
179+ }
162180
163- if let message = engine . state . notice ? . localized ( in : lang ) {
164- Text ( message )
165- . font ( . caption )
181+ private func outputCard ( flexibleCardsFillHeight : Bool ) -> some View {
182+ SimulationPlaceholderCard (
183+ title : lang . tr ( " simulation_output " ) ,
184+ systemImage : " terminal " ,
185+ minHeight : flexibleCardsFillHeight ? 170 : 96 ,
186+ contentFillsHeight : flexibleCardsFillHeight
187+ ) {
188+ if engine . state . outputLines . isEmpty {
189+ Text ( lang . tr ( " simulation_output_placeholder " ) )
190+ . font ( . body )
166191 . foregroundStyle ( . secondary )
167192 . fixedSize ( horizontal : false , vertical : true )
193+ } else {
194+ ScrollView {
195+ VStack ( alignment : . leading , spacing : 6 ) {
196+ ForEach ( Array ( engine . state . outputLines . enumerated ( ) ) , id : \. offset ) { _ , line in
197+ Text ( line )
198+ . font ( . body . monospaced ( ) )
199+ . frame ( maxWidth : . infinity , alignment : . leading )
200+ }
201+ }
202+ . padding ( . trailing , 4 )
203+ . frame ( maxWidth : . infinity , alignment : . leading )
204+ }
205+ . frame ( maxWidth : . infinity , maxHeight : . infinity , alignment : . topLeading )
168206 }
169207 }
170208 }
171209
210+ @ ViewBuilder
211+ private var noticeText : some View {
212+ if let message = engine . state . notice ? . localized ( in : lang ) {
213+ Text ( message )
214+ . font ( . caption )
215+ . foregroundStyle ( . secondary )
216+ . fixedSize ( horizontal : false , vertical : true )
217+ }
218+ }
219+
172220}
173221
174222private struct SimulationInputCard : View {
0 commit comments