File tree Expand file tree Collapse file tree
sdks/swift/Sources/DittoChatUI/Screens Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import DittoChatCore
1212struct ChatInputView : View {
1313 @Binding var text : String
1414 var onSendButtonTappedCallback : ( ( ) -> Void ) ? = nil
15- var primaryColor : Color = . blue
15+ let dittoChat : DittoChat
1616
1717 var body : some View {
1818 HStack ( alignment: . bottom) {
@@ -31,7 +31,7 @@ struct ChatInputView: View {
3131 Image ( systemName: arrowUpKey)
3232 . padding ( . all, 5 )
3333 . foregroundColor ( Color . white)
34- . background ( primaryColor )
34+ . background ( backgroundColor )
3535 . clipShape ( Circle ( ) )
3636 }
3737 . padding ( 4 )
@@ -46,12 +46,20 @@ struct ChatInputView: View {
4646 Spacer ( minLength: 12 )
4747 }
4848 }
49+
50+ private var backgroundColor : Color {
51+ if let colorHex = dittoChat. primaryColor, let color = Color ( hex: colorHex) {
52+ return color
53+ }
54+ return Color . blue
55+ }
4956}
5057
5158#if DEBUG
59+ import DittoSwift
5260struct ChatInputView_Previews : PreviewProvider {
5361 static var previews : some View {
54- ChatInputView ( text: . constant( " Hello how are you this fine evening? " ) ) { /*for previews only*/ }
62+ ChatInputView ( text: . constant( " Hello how are you this fine evening? " ) , dittoChat : DittoChat ( config : ChatConfig ( ditto : Ditto ( ) ) ) )
5563 }
5664}
5765#endif
Original file line number Diff line number Diff line change @@ -92,9 +92,7 @@ public struct ChatScreen: View {
9292 ChatInputView (
9393 text: $viewModel. inputText,
9494 onSendButtonTappedCallback: viewModel. sendMessage,
95- primaryColor: Color (
96- hex: dittoChat. primaryColor ?? " "
97- ) ?? . blue
95+ dittoChat: dittoChat
9896 )
9997 . padding ( . leading, 0 )
10098 }
Original file line number Diff line number Diff line change @@ -111,7 +111,8 @@ struct MessageEditView: View {
111111
112112 ChatInputView (
113113 text: $viewModel. editText,
114- onSendButtonTappedCallback: viewModel. saveEdit
114+ onSendButtonTappedCallback: viewModel. saveEdit,
115+ dittoChat: dittoChat
115116 )
116117 }
117118 #if !os(tvOS)
You can’t perform that action at this time.
0 commit comments