@@ -8,21 +8,23 @@ struct PromptToCodePanel: View {
88 let store : StoreOf < PromptToCode >
99
1010 var body : some View {
11- VStack ( spacing: 0 ) {
12- TopBar ( store: store)
13-
14- Content ( store: store)
15- . overlay ( alignment: . bottom) {
16- ActionBar ( store: store)
17- . padding ( . bottom, 8 )
18- }
11+ WithPerceptionTracking {
12+ VStack ( spacing: 0 ) {
13+ TopBar ( store: store)
14+
15+ Content ( store: store)
16+ . overlay ( alignment: . bottom) {
17+ ActionBar ( store: store)
18+ . padding ( . bottom, 8 )
19+ }
1920
20- Divider ( )
21+ Divider ( )
2122
22- Toolbar ( store: store)
23+ Toolbar ( store: store)
24+ }
25+ . background ( . ultraThickMaterial)
26+ . xcodeStyleFrame ( )
2327 }
24- . background ( . ultraThickMaterial)
25- . xcodeStyleFrame ( )
2628 }
2729}
2830
@@ -238,15 +240,17 @@ extension PromptToCodePanel {
238240 }
239241
240242 var body : some View {
241- ScrollView {
242- VStack ( spacing: 0 ) {
243- Spacer ( minLength: 60 )
244- ErrorMessage ( store: store)
245- DescriptionContent ( store: store, codeForegroundColor: codeForegroundColor)
243+ WithPerceptionTracking {
244+ ScrollView {
245+ VStack ( spacing: 0 ) {
246+ Spacer ( minLength: 60 )
247+ ErrorMessage ( store: store)
248+ DescriptionContent ( store: store, codeForegroundColor: codeForegroundColor)
249+ }
246250 }
251+ . background ( codeBackgroundColor)
252+ . scaleEffect ( x: 1 , y: - 1 , anchor: . center)
247253 }
248- . background ( codeBackgroundColor)
249- . scaleEffect ( x: 1 , y: - 1 , anchor: . center)
250254 }
251255
252256 struct ErrorMessage : View {
@@ -298,7 +302,7 @@ extension PromptToCodePanel {
298302 struct CodeContent : View {
299303 let store : StoreOf < PromptToCode >
300304 let codeForegroundColor : Color ?
301-
305+
302306 @AppStorage ( \. wrapCodeInPromptToCode) var wrapCode
303307
304308 var body : some View {
@@ -442,7 +446,7 @@ extension PromptToCodePanel {
442446 struct InputField : View {
443447 @Perception . Bindable var store : StoreOf < PromptToCode >
444448 var focusField : FocusState < PromptToCode . State . FocusField ? > . Binding
445-
449+
446450 var body : some View {
447451 WithPerceptionTracking {
448452 AutoresizingCustomTextEditor (
@@ -483,38 +487,36 @@ extension PromptToCodePanel {
483487
484488// MARK: - Previews
485489
486- struct PromptToCodePanel_Preview : PreviewProvider {
487- static var previews : some View {
488- PromptToCodePanel ( store: . init( initialState: . init(
489- code: """
490- ForEach(0..<viewModel.suggestion.count, id: \\ .self) { index in
491- Text(viewModel.suggestion[index])
492- .frame(maxWidth: .infinity, alignment: .leading)
493- .multilineTextAlignment(.leading)
494- }
495- """ ,
496- prompt: " " ,
497- language: . builtIn( . swift) ,
498- indentSize: 4 ,
499- usesTabsForIndentation: false ,
500- projectRootURL: URL ( fileURLWithPath: " path/to/file.txt " ) ,
501- documentURL: URL ( fileURLWithPath: " path/to/file.txt " ) ,
502- allCode: " " ,
503- allLines: [ String] ( ) ,
504- commandName: " Generate Code " ,
505- description: " Hello world " ,
506- isResponding: false ,
507- isAttachedToSelectionRange: true ,
508- selectionRange: . init(
509- start: . init( line: 8 , character: 0 ) ,
510- end: . init( line: 12 , character: 2 )
511- )
512- ) , reducer: { PromptToCode ( ) } ) )
513- . frame ( width: 450 , height: 400 )
514- }
490+ #Preview( " Default " ) {
491+ PromptToCodePanel ( store: . init( initialState: . init(
492+ code: """
493+ ForEach(0..<viewModel.suggestion.count, id: \\ .self) { index in
494+ Text(viewModel.suggestion[index])
495+ .frame(maxWidth: .infinity, alignment: .leading)
496+ .multilineTextAlignment(.leading)
497+ }
498+ """ ,
499+ prompt: " " ,
500+ language: . builtIn( . swift) ,
501+ indentSize: 4 ,
502+ usesTabsForIndentation: false ,
503+ projectRootURL: URL ( fileURLWithPath: " path/to/file.txt " ) ,
504+ documentURL: URL ( fileURLWithPath: " path/to/file.txt " ) ,
505+ allCode: " " ,
506+ allLines: [ String] ( ) ,
507+ commandName: " Generate Code " ,
508+ description: " Hello world " ,
509+ isResponding: false ,
510+ isAttachedToSelectionRange: true ,
511+ selectionRange: . init(
512+ start: . init( line: 8 , character: 0 ) ,
513+ end: . init( line: 12 , character: 2 )
514+ )
515+ ) , reducer: { PromptToCode ( ) } ) )
516+ . frame ( width: 450 , height: 400 )
515517}
516518
517- #Preview( " Prompt to Code Panel Super Long File Name" ) {
519+ #Preview( " Super Long File Name " ) {
518520 PromptToCodePanel ( store: . init( initialState: . init(
519521 code: """
520522 ForEach(0..<viewModel.suggestion.count, id: \\ .self) { index in
@@ -545,35 +547,33 @@ struct PromptToCodePanel_Preview: PreviewProvider {
545547 . frame ( width: 450 , height: 400 )
546548}
547549
548- struct PromptToCodePanel_Error_Detached_Preview : PreviewProvider {
549- static var previews : some View {
550- PromptToCodePanel ( store: . init( initialState: . init(
551- code: """
552- ForEach(0..<viewModel.suggestion.count, id: \\ .self) { index in
553- Text(viewModel.suggestion[index])
554- .frame(maxWidth: .infinity, alignment: .leading)
555- .multilineTextAlignment(.leading)
556- }
557- """ ,
558- prompt: " " ,
559- language: . builtIn( . swift) ,
560- indentSize: 4 ,
561- usesTabsForIndentation: false ,
562- projectRootURL: URL ( fileURLWithPath: " path/to/file.txt " ) ,
563- documentURL: URL ( fileURLWithPath: " path/to/file.txt " ) ,
564- allCode: " " ,
565- allLines: [ String] ( ) ,
566- commandName: " Generate Code " ,
567- description: " Hello world " ,
568- isResponding: false ,
569- isAttachedToSelectionRange: false ,
570- error: " Error " ,
571- selectionRange: . init(
572- start: . init( line: 8 , character: 0 ) ,
573- end: . init( line: 12 , character: 2 )
574- )
575- ) , reducer: { PromptToCode ( ) } ) )
576- . frame ( width: 450 , height: 400 )
577- }
550+ #Preview( " Error Detached " ) {
551+ PromptToCodePanel ( store: . init( initialState: . init(
552+ code: """
553+ ForEach(0..<viewModel.suggestion.count, id: \\ .self) { index in
554+ Text(viewModel.suggestion[index])
555+ .frame(maxWidth: .infinity, alignment: .leading)
556+ .multilineTextAlignment(.leading)
557+ }
558+ """ ,
559+ prompt: " " ,
560+ language: . builtIn( . swift) ,
561+ indentSize: 4 ,
562+ usesTabsForIndentation: false ,
563+ projectRootURL: URL ( fileURLWithPath: " path/to/file.txt " ) ,
564+ documentURL: URL ( fileURLWithPath: " path/to/file.txt " ) ,
565+ allCode: " " ,
566+ allLines: [ String] ( ) ,
567+ commandName: " Generate Code " ,
568+ description: " Hello world " ,
569+ isResponding: false ,
570+ isAttachedToSelectionRange: false ,
571+ error: " Error " ,
572+ selectionRange: . init(
573+ start: . init( line: 8 , character: 0 ) ,
574+ end: . init( line: 12 , character: 2 )
575+ )
576+ ) , reducer: { PromptToCode ( ) } ) )
577+ . frame ( width: 450 , height: 400 )
578578}
579579
0 commit comments