@@ -108,17 +108,20 @@ struct ReferenceList: View {
108108 chat. send ( . referenceClicked( reference) )
109109 } ) {
110110 HStack ( spacing: 8 ) {
111+ ReferenceIcon ( kind: reference. kind)
112+ . layoutPriority ( 2 )
111113 Text ( reference. title)
112114 . truncationMode ( . middle)
113115 . lineLimit ( 1 )
116+ . layoutPriority ( 1 )
114117 Text ( reference. subtitle)
115118 . lineLimit ( 1 )
116119 . truncationMode ( . middle)
117- . layoutPriority ( /*@START_MENU_TOKEN@*/0 /*@END_MENU_TOKEN@*/)
118120 . foregroundStyle ( . tertiary)
121+ . layoutPriority ( 0 )
119122 }
120- . padding ( . vertical, 6 )
121- . padding ( . horizontal, 8 )
123+ . padding ( . vertical, 4 )
124+ . padding ( . horizontal, 4 )
122125 . frame ( maxWidth: . infinity, alignment: . leading)
123126 . overlay {
124127 RoundedRectangle ( cornerRadius: 4 )
@@ -134,6 +137,83 @@ struct ReferenceList: View {
134137 }
135138}
136139
140+ struct ReferenceIcon : View {
141+ let kind : DisplayedChatMessage . Reference . Kind
142+
143+ var body : some View {
144+ RoundedRectangle ( cornerRadius: 4 )
145+ . fill ( {
146+ switch kind {
147+ case . class:
148+ Color . purple
149+ case . struct:
150+ Color . purple
151+ case . enum:
152+ Color . purple
153+ case . actor :
154+ Color . purple
155+ case . protocol:
156+ Color . purple
157+ case . extension:
158+ Color . indigo
159+ case . case:
160+ Color . green
161+ case . property:
162+ Color . teal
163+ case . typealias:
164+ Color . orange
165+ case . function:
166+ Color . teal
167+ case . method:
168+ Color . blue
169+ case . text:
170+ Color . gray
171+ case . webpage:
172+ Color . blue
173+ case . other:
174+ Color . gray
175+ }
176+ } ( ) )
177+ . frame ( width: 22 , height: 22 )
178+ . overlay ( alignment: . center) {
179+ Group {
180+ switch kind {
181+ case . class:
182+ Text ( " C " )
183+ case . struct:
184+ Text ( " S " )
185+ case . enum:
186+ Text ( " E " )
187+ case . actor :
188+ Text ( " A " )
189+ case . protocol:
190+ Text ( " Pr " )
191+ case . extension:
192+ Text ( " Ex " )
193+ case . case:
194+ Text ( " K " )
195+ case . property:
196+ Text ( " P " )
197+ case . typealias:
198+ Text ( " T " )
199+ case . function:
200+ Text ( " 𝑓 " )
201+ case . method:
202+ Text ( " M " )
203+ case . text:
204+ Text ( " Tx " )
205+ case . webpage:
206+ Text ( " Wb " )
207+ case . other:
208+ Text ( " Ot " )
209+ }
210+ }
211+ . font ( . system( size: 12 ) . monospaced ( ) )
212+ . foregroundColor ( . white)
213+ }
214+ }
215+ }
216+
137217#Preview( " Bot Message " ) {
138218 BotMessage (
139219 id: " 1 " ,
@@ -147,7 +227,8 @@ struct ReferenceList: View {
147227 title: " ReferenceList " ,
148228 subtitle: " /Core/Sources/ChatGPTChatTab/Views/BotMessage.swift:100 " ,
149229 uri: " https://google.com " ,
150- startLine: nil
230+ startLine: nil ,
231+ kind: . class
151232 ) , count: 20 ) ,
152233 chat: . init( initialState: . init( ) , reducer: Chat ( service: . init( ) ) )
153234 )
@@ -161,37 +242,43 @@ struct ReferenceList: View {
161242 title: " ReferenceList " ,
162243 subtitle: " /Core/Sources/ChatGPTChatTab/Views/BotMessage.swift:100 " ,
163244 uri: " https://google.com " ,
164- startLine: nil
245+ startLine: nil ,
246+ kind: . class
165247 ) ,
166248 . init(
167249 title: " BotMessage.swift:100-102 " ,
168250 subtitle: " /Core/Sources/ChatGPTChatTab/Views " ,
169251 uri: " https://google.com " ,
170- startLine: nil
252+ startLine: nil ,
253+ kind: . struct
171254 ) ,
172255 . init(
173256 title: " ReferenceList " ,
174257 subtitle: " /Core/Sources/ChatGPTChatTab/Views/BotMessage.swift:100 " ,
175258 uri: " https://google.com " ,
176- startLine: nil
259+ startLine: nil ,
260+ kind: . function
177261 ) ,
178262 . init(
179263 title: " ReferenceList " ,
180264 subtitle: " /Core/Sources/ChatGPTChatTab/Views/BotMessage.swift:100 " ,
181265 uri: " https://google.com " ,
182- startLine: nil
266+ startLine: nil ,
267+ kind: . case
183268 ) ,
184269 . init(
185270 title: " ReferenceList " ,
186271 subtitle: " /Core/Sources/ChatGPTChatTab/Views/BotMessage.swift:100 " ,
187272 uri: " https://google.com " ,
188- startLine: nil
273+ startLine: nil ,
274+ kind: . extension
189275 ) ,
190276 . init(
191277 title: " ReferenceList " ,
192278 subtitle: " /Core/Sources/ChatGPTChatTab/Views/BotMessage.swift:100 " ,
193279 uri: " https://google.com " ,
194- startLine: nil
280+ startLine: nil ,
281+ kind: . webpage
195282 ) ,
196283 ] , chat: . init( initialState: . init( ) , reducer: Chat ( service: . init( ) ) ) )
197284}
0 commit comments