Skip to content

Commit 6c4ae3d

Browse files
Add messageUseStyler builder
This allows the user to pass a function which automatically converts the message's String to the AttributedString displayed in each message bubble.
1 parent 116da1b commit 6c4ae3d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
- Can display a fullscreen menu on long press a message cell (automatically shows scroll for big messages)
4949
- Supports "reply to message" via message menu or through a closure. Remove and edit are **coming soon**
5050
- This library allows to send the following content in messages in any combination:
51-
- Text with/without markdown
51+
- Arbitrarily styled text with `AttributedString` or markdown
5252
- Photo/video
5353
- Audio recording
5454
**Coming soon:**
@@ -277,6 +277,7 @@ Please use `mediaPickerTheme` in a similar fashion to customize the built-in pho
277277
`avatarSize` - the default avatar is a circle, you can specify its diameter here
278278
`tapAvatarClosure` - closure to call on avatar tap
279279
`messageUseMarkdown` - use markdown (e.g. ** to make something bold) or not
280+
`messageUseStyler` - pass a function that converts the message's `String` to the styled `AttributedString`
280281
`showMessageTimeView` - show timestamp in a corner of the message
281282
`setMessageFont` - pass custom font to use for messages
282283

Sources/ExyteChat/ChatView/ChatView.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,12 @@ public extension ChatView {
600600
}
601601

602602
func messageUseMarkdown(_ messageUseMarkdown: Bool) -> ChatView {
603+
return messageUseStyler(String.markdownStyler)
604+
}
605+
606+
func messageUseStyler(_ styler: @escaping (String) -> AttributedString) -> ChatView {
603607
var view = self
604-
view.messageStyler = String.markdownStyler
608+
view.messageStyler = styler
605609
return view
606610
}
607611

0 commit comments

Comments
 (0)