@@ -55,7 +55,7 @@ struct ChatPanelMessages: View {
5555 }
5656 }
5757 }
58-
58+
5959 var body : some View {
6060 ScrollView {
6161 vstack {
@@ -77,6 +77,7 @@ struct ChatPanelMessages: View {
7777 . buttonStyle ( . plain)
7878 . xcodeStyleFrame ( )
7979 . matchedGeometryEffect ( id: " input " , in: inputAreaNamespace)
80+ . scaleEffect ( x: - 1 , y: 1 , anchor: . center)
8081 }
8182
8283 if chat. history. isEmpty {
@@ -89,8 +90,9 @@ struct ChatPanelMessages: View {
8990 )
9091 . xcodeStyleFrame ( )
9192 . rotationEffect ( Angle ( degrees: 180 ) )
93+ . scaleEffect ( x: - 1 , y: 1 , anchor: . center)
9294 }
93-
95+
9496 ForEach ( chat. history. reversed ( ) , id: \. id) { message in
9597 let text = message. text. isEmpty && !message. isUser ? " ... " : message
9698 . text
@@ -112,31 +114,39 @@ struct ChatPanelMessages: View {
112114 )
113115 . xcodeStyleFrame ( )
114116 . rotationEffect ( Angle ( degrees: 180 ) )
115-
117+ . scaleEffect ( x : - 1 , y : 1 , anchor : . center )
116118 }
117119 }
118120 }
119121 . rotationEffect ( Angle ( degrees: 180 ) )
122+ . scaleEffect ( x: - 1 , y: 1 , anchor: . center)
120123 }
121124}
122125
123126struct ChatPanelInputArea : View {
124127 @ObservedObject var chat : ChatRoom
125128 var inputAreaNamespace : Namespace . ID
126129 @Binding var typedMessage : String
130+ @FocusState var isInputAreaFocused : Bool
127131
128132 var body : some View {
129133 HStack {
130134 // clear button
131135 Button ( action: {
132136 chat. clear ( )
133137 } ) {
134- Image ( systemName: " eraser.line.dashed.fill " )
135- . padding ( 8 )
136- . background (
137- . regularMaterial,
138- in: RoundedRectangle ( cornerRadius: 8 , style: . continuous)
139- )
138+ Group {
139+ if #available( macOS 13 . 0 , * ) {
140+ Image ( systemName: " eraser.line.dashed.fill " )
141+ } else {
142+ Image ( systemName: " trash.fill " )
143+ }
144+ }
145+ . padding ( 8 )
146+ . background (
147+ . regularMaterial,
148+ in: RoundedRectangle ( cornerRadius: 8 , style: . continuous)
149+ )
140150 }
141151 . buttonStyle ( . plain)
142152 . xcodeStyleFrame ( )
@@ -145,9 +155,13 @@ struct ChatPanelInputArea: View {
145155 if #available( macOS 13 . 0 , * ) {
146156 TextField ( " Type a message " , text: $typedMessage, axis: . vertical)
147157 } else {
148- TextField ( " Type a message " , text: $typedMessage)
158+ TextEditor ( text: $typedMessage)
159+ . frame ( height: 42 , alignment: . leading)
160+ . font ( . body)
161+ . background ( Color . clear)
149162 }
150163 }
164+ . focused ( $isInputAreaFocused)
151165 . lineLimit ( 3 )
152166 . multilineTextAlignment ( . leading)
153167 . textFieldStyle ( . plain)
@@ -179,6 +193,9 @@ struct ChatPanelInputArea: View {
179193 . buttonStyle ( . plain)
180194 . xcodeStyleFrame ( )
181195 }
196+ . onAppear {
197+ isInputAreaFocused = true
198+ }
182199 }
183200}
184201
@@ -246,7 +263,7 @@ struct ChatPanel_InputMultilineText_Preview: PreviewProvider {
246263 history: ChatPanel_Preview . history,
247264 isReceivingMessage: false
248265 ) ,
249- typedMessage: " Hello \n World "
266+ typedMessage: " Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce turpis dolor, malesuada quis fringilla sit amet, placerat at nunc. Suspendisse orci tortor, tempor nec blandit a, malesuada vel tellus. Nunc sed leo ligula. Ut at ligula eget turpis pharetra tristique. Integer luctus leo non elit rhoncus fermentum. "
250267 )
251268 . padding ( 8 )
252269 . background ( Color . contentBackground)
0 commit comments