Skip to content

Commit 9ffda58

Browse files
Added support for custom padding in MessageTextView
1 parent 46e0537 commit 9ffda58

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
44
# Upcoming
55

66
### ✅ Added
7-
- Padding support to message bubble modifier
7+
- Customizing padding for message bubble modifier
8+
- Customizing padding for message text view
89

910
### 🐞 Fixed
1011
- Fixed a bug with canceled backswipe

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageView.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,23 @@ public struct MessageTextView<Factory: ViewFactory>: View {
114114
var factory: Factory
115115
var message: ChatMessage
116116
var isFirst: Bool
117+
var horizontalPadding: CGFloat
118+
var verticalPadding: CGFloat
117119
@Binding var scrolledId: String?
118120

119-
public init(factory: Factory, message: ChatMessage, isFirst: Bool, scrolledId: Binding<String?>) {
121+
public init(
122+
factory: Factory,
123+
message: ChatMessage,
124+
isFirst: Bool,
125+
horizontalPadding: CGFloat = 16,
126+
verticalPadding: CGFloat = 8,
127+
scrolledId: Binding<String?>
128+
) {
120129
self.factory = factory
121130
self.message = message
122131
self.isFirst = isFirst
132+
self.horizontalPadding = horizontalPadding
133+
self.verticalPadding = verticalPadding
123134
_scrolledId = scrolledId
124135
}
125136

@@ -138,7 +149,8 @@ public struct MessageTextView<Factory: ViewFactory>: View {
138149
}
139150

140151
Text(message.text)
141-
.standardPadding()
152+
.padding(.horizontal, horizontalPadding)
153+
.padding(.vertical, verticalPadding)
142154
.fixedSize(horizontal: false, vertical: true)
143155
.foregroundColor(textColor(for: message))
144156
.font(fonts.body)

0 commit comments

Comments
 (0)