Simplify how we build bubbles for previewing purposes, make use of the new bubbleBackground modifier.

This commit is contained in:
Stefan Ceriu
2024-12-13 15:38:23 +02:00
committed by Stefan Ceriu
parent 681daf50ea
commit c97dcc18f2
7 changed files with 15 additions and 44 deletions
@@ -189,18 +189,18 @@ struct FormattedBodyText_Previews: PreviewProvider, TestablePreview {
ForEach(htmlStrings, id: \.self) { htmlString in
if let attributedString = attributedStringBuilder.fromHTML(htmlString) {
FormattedBodyText(attributedString: attributedString)
.previewBubble()
.bubbleBackground()
}
}
FormattedBodyText(attributedString: AttributedString("Some plain text wrapped in an AttributedString."))
.previewBubble()
.bubbleBackground()
FormattedBodyText(text: "Some plain text that's not an attributed component.")
.previewBubble()
.bubbleBackground()
FormattedBodyText(text: "Some plain text that's not an attributed component. This one is really long.")
.previewBubble()
.bubbleBackground()
FormattedBodyText(text: "❤️", boostEmojiSize: true)
.previewBubble()
.bubbleBackground()
}
.padding()
}
@@ -208,19 +208,3 @@ struct FormattedBodyText_Previews: PreviewProvider, TestablePreview {
.snapshotPreferences(delay: 0.25)
}
}
private struct PreviewBubbleModifier: ViewModifier {
func body(content: Content) -> some View {
content
.padding(8)
.background(Color.compound._bgBubbleOutgoing)
.cornerRadius(12)
.environmentObject(TimelineViewModel.mock.context)
}
}
private extension View {
func previewBubble() -> some View {
modifier(PreviewBubbleModifier())
}
}