Stop passing the whole timeline item to the bubble background modifier.

This commit is contained in:
Stefan Ceriu
2024-12-13 14:57:45 +02:00
committed by Stefan Ceriu
parent 35e24656d7
commit 1b684d269e
5 changed files with 10 additions and 10 deletions

View File

@@ -21,7 +21,7 @@ struct AudioMediaEventsTimelineView: View {
isAudioFile: true)
.accessibilityLabel(L10n.commonAudio)
.frame(maxWidth: .infinity, alignment: .leading)
.bubbleBackground(timelineItem: timelineItem,
.bubbleBackground(isOutgoing: timelineItem.isOutgoing,
insets: .init(top: 8, leading: 12, bottom: 8, trailing: 12),
color: .compound.bgSubtleSecondary)
}

View File

@@ -20,7 +20,7 @@ struct FileMediaEventsTimelineView: View {
additionalWhitespaces: timelineItem.additionalWhitespaces())
.accessibilityLabel(L10n.commonFile)
.frame(maxWidth: .infinity, alignment: .leading)
.bubbleBackground(timelineItem: timelineItem,
.bubbleBackground(isOutgoing: timelineItem.isOutgoing,
insets: .init(top: 8, leading: 12, bottom: 8, trailing: 12),
color: .compound.bgSubtleSecondary)
}

View File

@@ -17,7 +17,7 @@ struct VoiceMessageMediaEventsTimelineView: View {
playerState: playerState)
.accessibilityLabel(L10n.commonVoiceMessage)
.frame(maxWidth: .infinity, alignment: .leading)
.bubbleBackground(timelineItem: timelineItem,
.bubbleBackground(isOutgoing: timelineItem.isOutgoing,
insets: .init(top: 8, leading: 12, bottom: 8, trailing: 12),
color: .compound.bgSubtleSecondary)
}

View File

@@ -8,10 +8,10 @@
import SwiftUI
extension View {
func bubbleBackground(timelineItem: EventBasedTimelineItemProtocol,
func bubbleBackground(isOutgoing: Bool,
insets: EdgeInsets,
color: Color? = nil) -> some View {
modifier(TimelineItemBubbleBackgroundModifier(timelineItem: timelineItem,
modifier(TimelineItemBubbleBackgroundModifier(isOutgoing: isOutgoing,
insets: insets,
color: color))
}
@@ -20,7 +20,7 @@ extension View {
private struct TimelineItemBubbleBackgroundModifier: ViewModifier {
@Environment(\.timelineGroupStyle) private var timelineGroupStyle
let timelineItem: EventBasedTimelineItemProtocol
let isOutgoing: Bool
let insets: EdgeInsets
var color: Color?
@@ -36,15 +36,15 @@ private struct TimelineItemBubbleBackgroundModifier: ViewModifier {
case .single:
return .allCorners
case .first:
if timelineItem.isOutgoing {
if isOutgoing {
return [.topLeft, .topRight, .bottomLeft]
} else {
return [.topLeft, .topRight, .bottomRight]
}
case .middle:
return timelineItem.isOutgoing ? [.topLeft, .bottomLeft] : [.topRight, .bottomRight]
return isOutgoing ? [.topLeft, .bottomLeft] : [.topRight, .bottomRight]
case .last:
if timelineItem.isOutgoing {
if isOutgoing {
return [.topLeft, .bottomLeft, .bottomRight]
} else {
return [.topRight, .bottomLeft, .bottomRight]

View File

@@ -163,7 +163,7 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
var messageBubble: some View {
contentWithReply
.timelineItemSendInfo(timelineItem: timelineItem, adjustedDeliveryStatus: adjustedDeliveryStatus, context: context)
.bubbleBackground(timelineItem: timelineItem,
.bubbleBackground(isOutgoing: timelineItem.isOutgoing,
insets: timelineItem.bubbleInsets,
color: timelineItem.bubbleBackgroundColor)
}