Skip to content

Commit d9c626f

Browse files
authored
fixed color on send button (#105)
1 parent 4076b8a commit d9c626f

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

sdks/swift/Sources/DittoChatUI/Screens/ChatScreen/ChatInputView.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import DittoChatCore
1212
struct 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
5260
struct 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

sdks/swift/Sources/DittoChatUI/Screens/ChatScreen/ChatScreen.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff 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
}

sdks/swift/Sources/DittoChatUI/Screens/MessageEditView/MessageEditView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)