@@ -25,7 +25,7 @@ struct CopilotIntroItem: View {
2525 image
2626 . resizable ( )
2727 . renderingMode ( . template)
28- . foregroundColor ( Color ( red : 0.0353 , green : 0.4118 , blue: 0.8549 ) )
28+ . foregroundColor ( . blue)
2929 . scaledToFit ( )
3030 . frame ( width: 28 , height: 28 )
3131 VStack ( alignment: . leading, spacing: 5 ) {
@@ -39,6 +39,66 @@ struct CopilotIntroItem: View {
3939 }
4040}
4141
42+ struct CopilotIntroContent : View {
43+ let hideIntro : Binding < Bool >
44+ let continueAction : ( ) -> Void
45+
46+ var body : some View {
47+ VStack {
48+ let appImage = if let nsImage = NSImage ( named: " AppIcon " ) {
49+ Image ( nsImage: nsImage)
50+ } else {
51+ Image ( systemName: " app " )
52+ }
53+ appImage
54+ . resizable ( )
55+ . scaledToFit ( )
56+ . frame ( width: 64 , height: 64 )
57+ . padding ( . bottom, 24 )
58+ Text ( " Welcome to Copilot for Xcode! " )
59+ . font ( . title. bold ( ) )
60+ . padding ( . bottom, 38 )
61+
62+ VStack ( alignment: . leading, spacing: 20 ) {
63+ CopilotIntroItem (
64+ imageName: " CopilotLogo " ,
65+ heading: " In-line Code Suggestions " ,
66+ text: " Copilot's code suggestions and text completion now available in Xcode. Press Tab ⇥ to accept a suggestion. "
67+ )
68+
69+ CopilotIntroItem (
70+ systemImage: " option " ,
71+ heading: " Full Suggestion " ,
72+ text: " Press Option ⌥ key to display the full suggestion. Only the first line of suggestions are shown inline. "
73+ )
74+
75+ CopilotIntroItem (
76+ imageName: " GitHubMark " ,
77+ heading: " GitHub Context " ,
78+ text: " Copilot utilizes project context to deliver smarter code suggestions relevant to your unique codebase. "
79+ )
80+ }
81+ . padding ( . bottom, 64 )
82+
83+ VStack ( spacing: 8 ) {
84+ Button ( action: continueAction) {
85+ Text ( " Continue " )
86+ . padding ( . horizontal, 80 )
87+ . padding ( . vertical, 6 )
88+ }
89+ . buttonStyle ( . borderedProminent)
90+
91+ Toggle ( " Don't show again " , isOn: hideIntro)
92+ . toggleStyle ( . checkbox)
93+ }
94+ }
95+ . padding ( . horizontal, 56 )
96+ . padding ( . top, 48 )
97+ . padding ( . bottom, 16 )
98+ . frame ( width: 560 )
99+ }
100+ }
101+
42102public struct CopilotIntroSheet < Content: View > : View {
43103 let content : Content
44104 let appVersion = Bundle . main. infoDictionary ? [ " CFBundleShortVersionString " ] as? String ?? " "
@@ -48,58 +108,13 @@ public struct CopilotIntroSheet<Content: View>: View {
48108
49109 public var body : some View {
50110 content. sheet ( isPresented: $isPresented) {
51- VStack {
52- Image ( nsImage: NSImage ( named: " AppIcon " ) ?? NSImage ( ) )
53- . resizable ( )
54- . scaledToFit ( )
55- . frame ( width: 64 , height: 64 )
56- . padding ( . bottom, 24 )
57- Text ( " Welcome to Copilot for Xcode! " )
58- . font ( . title)
59- . padding ( . bottom, 45 )
60-
61- VStack ( alignment: . leading, spacing: 25 ) {
62- CopilotIntroItem (
63- imageName: " CopilotLogo " ,
64- heading: " In-line Code Suggestions " ,
65- text: " Copilot's code suggestions and text completion now available in Xcode. Just press Tab ⇥ to accept a suggestion. "
66- )
67-
68- CopilotIntroItem (
69- systemImage: " option " ,
70- heading: " Full Suggestion " ,
71- text: " Press Option ⌥ key to display the full suggestion. Only the first line of suggestions are shown inline. "
72- )
73-
74- CopilotIntroItem (
75- imageName: " GitHubMark " ,
76- heading: " GitHub Context " ,
77- text: " Copilot utilizes GitHub and project context to deliver smarter completions and personalized code suggestions relevant to your unique codebase. "
78- )
79- }
80-
81- Spacer ( )
82-
83- VStack ( spacing: 8 ) {
84- Button ( action: { isPresented = false } ) {
85- Text ( " Continue " )
86- . padding ( . horizontal, 80 )
87- . padding ( . vertical, 6 )
88- }
89- . buttonStyle ( . borderedProminent)
90-
91- Toggle ( " Don't show again " , isOn: $hideIntro)
92- . toggleStyle ( . checkbox)
93- }
111+ CopilotIntroContent ( hideIntro: $hideIntro) {
112+ isPresented = false
94113 }
95- . padding ( EdgeInsets ( top: 50 , leading: 50 , bottom: 16 , trailing: 50 ) )
96- . frame ( width: 560 , height: 528 )
97114 }
98115 . task {
99- let neverShown = introLastShownVersion. isEmpty
100- isPresented = neverShown || !hideIntro
101- if isPresented {
102- hideIntro = neverShown ? true : hideIntro // default to hidden on first time
116+ if hideIntro == false {
117+ isPresented = true
103118 introLastShownVersion = appVersion
104119 }
105120 }
@@ -111,3 +126,10 @@ public extension View {
111126 CopilotIntroSheet ( content: self )
112127 }
113128}
129+
130+
131+ // MARK: - Preview
132+ @available ( macOS 14 . 0 , * )
133+ #Preview( traits: . sizeThatFitsLayout) {
134+ CopilotIntroContent ( hideIntro: . constant( false ) ) { }
135+ }
0 commit comments