@@ -62,14 +62,14 @@ struct ChatPanelMessages: View {
6262 @ObservedObject var chat : ChatProvider
6363 @AppStorage ( \. disableLazyVStack) var disableLazyVStack
6464 @State var height : Double = 0
65-
65+
6666 struct HeightPreferenceKey : PreferenceKey {
6767 static var defaultValue : Double = 0
6868 static func reduce( value: inout Double , nextValue: ( ) -> Double ) {
6969 value = nextValue ( ) + value
7070 }
7171 }
72-
72+
7373 struct UpdateHeightModifier : ViewModifier {
7474 func body( content: Content ) -> some View {
7575 content
@@ -81,7 +81,7 @@ struct ChatPanelMessages: View {
8181 }
8282 }
8383 }
84-
84+
8585 var body : some View {
8686 List {
8787 Group {
@@ -169,13 +169,18 @@ private struct UserMessage: View {
169169 let text : String
170170 let chat : ChatProvider
171171 @Environment ( \. colorScheme) var colorScheme
172+ @AppStorage ( \. chatFontSize) var chatFontSize
173+ @AppStorage ( \. chatCodeFontSize) var chatCodeFontSize
172174
173175 var body : some View {
174176 Markdown ( text)
175177 . textSelection ( . enabled)
176- . markdownTheme ( . custom)
178+ . markdownTheme ( . custom( fontSize : chatFontSize ) )
177179 . markdownCodeSyntaxHighlighter (
178- ChatCodeSyntaxHighlighter ( brightMode: colorScheme != . dark)
180+ ChatCodeSyntaxHighlighter (
181+ brightMode: colorScheme != . dark,
182+ fontSize: chatCodeFontSize
183+ )
179184 )
180185 . frame ( alignment: . leading)
181186 . padding ( )
@@ -197,13 +202,13 @@ private struct UserMessage: View {
197202 NSPasteboard . general. clearContents ( )
198203 NSPasteboard . general. setString ( text, forType: . string)
199204 }
200-
205+
201206 Button ( " Send Again " ) {
202207 chat. resendMessage ( id: id)
203208 }
204-
209+
205210 Divider ( )
206-
211+
207212 Button ( " Delete " ) {
208213 chat. deleteMessage ( id: id)
209214 }
@@ -216,6 +221,8 @@ private struct BotMessage: View {
216221 let text : String
217222 let chat : ChatProvider
218223 @Environment ( \. colorScheme) var colorScheme
224+ @AppStorage ( \. chatFontSize) var chatFontSize
225+ @AppStorage ( \. chatCodeFontSize) var chatCodeFontSize
219226
220227 var body : some View {
221228 HStack ( alignment: . bottom, spacing: 2 ) {
@@ -227,9 +234,12 @@ private struct BotMessage: View {
227234
228235 Markdown ( text)
229236 . textSelection ( . enabled)
230- . markdownTheme ( . custom)
237+ . markdownTheme ( . custom( fontSize : chatFontSize ) )
231238 . markdownCodeSyntaxHighlighter (
232- ChatCodeSyntaxHighlighter ( brightMode: colorScheme != . dark)
239+ ChatCodeSyntaxHighlighter (
240+ brightMode: colorScheme != . dark,
241+ fontSize: chatCodeFontSize
242+ )
233243 )
234244 . frame ( alignment: . trailing)
235245 . padding ( )
@@ -249,9 +259,9 @@ private struct BotMessage: View {
249259 NSPasteboard . general. clearContents ( )
250260 NSPasteboard . general. setString ( text, forType: . string)
251261 }
252-
262+
253263 Divider ( )
254-
264+
255265 Button ( " Delete " ) {
256266 chat. deleteMessage ( id: id)
257267 }
@@ -499,17 +509,19 @@ struct ChatPanel_EmptyChat_Preview: PreviewProvider {
499509
500510struct ChatCodeSyntaxHighlighter : CodeSyntaxHighlighter {
501511 let brightMode : Bool
512+ let fontSize : Double
502513
503- init ( brightMode: Bool ) {
514+ init ( brightMode: Bool , fontSize : Double ) {
504515 self . brightMode = brightMode
516+ self . fontSize = fontSize
505517 }
506518
507519 func highlightCode( _ content: String , language: String ? ) -> Text {
508520 let content = highlightedCodeBlock (
509521 code: content,
510522 language: language ?? " " ,
511523 brightMode: brightMode,
512- fontSize: 12
524+ fontSize: fontSize
513525 )
514526 return Text ( AttributedString ( content) )
515527 }
0 commit comments