mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 13:37:11 +00:00
Stop passing the whole timeline item to the bubble background modifier.
This commit is contained in:
parent
b11fbc6cce
commit
40d820d4f4
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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]
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user