@@ -167,6 +167,46 @@ struct CodeBlockSuggestionPanel: View {
167167 }
168168 }
169169
170+ struct Description : View {
171+ var descriptions : [ CodeSuggestion . Description ]
172+
173+ var body : some View {
174+ VStack ( spacing: 0 ) {
175+ ForEach ( 0 ..< descriptions. count, id: \. self) { index in
176+ Group {
177+ switch descriptions [ index] . kind {
178+ case . warning:
179+ HStack ( alignment: . firstTextBaseline, spacing: 4 ) {
180+ Text ( Image ( systemName: " exclamationmark.circle.fill " ) )
181+ Text ( descriptions [ index] . content)
182+ }
183+ . multilineTextAlignment ( . leading)
184+ . frame ( maxWidth: . infinity, alignment: . leading)
185+ . padding ( . vertical, 4 )
186+ . padding ( . horizontal, 4 )
187+ . background ( . orange. opacity ( 0.9 ) )
188+
189+ Divider ( ) . background ( Color . red)
190+ case . action:
191+ HStack ( alignment: . firstTextBaseline, spacing: 4 ) {
192+ Text ( Image ( systemName: " arrowshape.right.circle.fill " ) )
193+ Text ( descriptions [ index] . content)
194+ }
195+ . multilineTextAlignment ( . leading)
196+ . frame ( maxWidth: . infinity, alignment: . leading)
197+ . padding ( . vertical, 4 )
198+ . padding ( . horizontal, 4 )
199+ . background ( . cyan. opacity ( 0.9 ) )
200+
201+ Divider ( ) . background ( Color . blue)
202+ }
203+ }
204+ . foregroundColor ( . white)
205+ }
206+ }
207+ }
208+ }
209+
170210 var body : some View {
171211 WithPerceptionTracking {
172212 VStack ( spacing: 0 ) {
@@ -213,6 +253,10 @@ struct CodeBlockSuggestionPanel: View {
213253 }
214254 }
215255
256+ Description ( descriptions: suggestion. descriptions)
257+
258+ Divider ( )
259+
216260 if suggestionDisplayCompactMode {
217261 CompactToolBar ( suggestion: suggestion)
218262 } else {
@@ -317,6 +361,40 @@ struct CodeBlockSuggestionPanel: View {
317361 . padding ( )
318362}
319363
364+ #Preview( " Code Block Suggestion Panel With Descriptions " ) {
365+ CodeBlockSuggestionPanel ( suggestion: PresentingCodeSuggestion (
366+ code: """
367+ LazyVGrid(columns: [GridItem(.fixed(30)), GridItem(.flexible())]) {
368+ ForEach(0..<viewModel.suggestion.count, id: \\ .self) { index in // lkjaskldjalksjdlkasjdlkajslkdjas
369+ Text(viewModel.suggestion[index])
370+ .frame(maxWidth: .infinity, alignment: .leading)
371+ .multilineTextAlignment(.leading)
372+ }
373+ """ ,
374+ language: " swift " ,
375+ startLineIndex: 8 ,
376+ suggestionCount: 2 ,
377+ currentSuggestionIndex: 0 ,
378+ replacingRange: . outOfScope,
379+ replacingLines: [ ] ,
380+ descriptions: [
381+ . init( kind: . warning, content: " This is a warning message. \n warning " ) ,
382+ . init( kind: . action, content: " This is an action message. " ) ,
383+ ]
384+ ) , suggestionDisplayCompactMode: . init(
385+ wrappedValue: false ,
386+ " suggestionDisplayCompactMode " ,
387+ store: {
388+ let userDefault =
389+ UserDefaults ( suiteName: " CodeBlockSuggestionPanel_CompactToolBar_Preview " )
390+ userDefault? . set ( false , for: \. suggestionDisplayCompactMode)
391+ return userDefault!
392+ } ( )
393+ ) )
394+ . frame ( width: 450 , height: 400 )
395+ . padding ( )
396+ }
397+
320398#Preview( " Code Block Suggestion Panel Compact Mode " ) {
321399 CodeBlockSuggestionPanel ( suggestion: PresentingCodeSuggestion (
322400 code: """
@@ -332,7 +410,11 @@ struct CodeBlockSuggestionPanel: View {
332410 suggestionCount: 2 ,
333411 currentSuggestionIndex: 0 ,
334412 replacingRange: . outOfScope,
335- replacingLines: [ ]
413+ replacingLines: [ ] ,
414+ descriptions: [
415+ . init( kind: . warning, content: " This is a warning message. " ) ,
416+ . init( kind: . action, content: " This is an action message. " ) ,
417+ ]
336418 ) , suggestionDisplayCompactMode: . init(
337419 wrappedValue: true ,
338420 " suggestionDisplayCompactMode " ,
0 commit comments