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)
|
isAudioFile: true)
|
||||||
.accessibilityLabel(L10n.commonAudio)
|
.accessibilityLabel(L10n.commonAudio)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
.bubbleBackground(timelineItem: timelineItem,
|
.bubbleBackground(isOutgoing: timelineItem.isOutgoing,
|
||||||
insets: .init(top: 8, leading: 12, bottom: 8, trailing: 12),
|
insets: .init(top: 8, leading: 12, bottom: 8, trailing: 12),
|
||||||
color: .compound.bgSubtleSecondary)
|
color: .compound.bgSubtleSecondary)
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ struct FileMediaEventsTimelineView: View {
|
|||||||
additionalWhitespaces: timelineItem.additionalWhitespaces())
|
additionalWhitespaces: timelineItem.additionalWhitespaces())
|
||||||
.accessibilityLabel(L10n.commonFile)
|
.accessibilityLabel(L10n.commonFile)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
.bubbleBackground(timelineItem: timelineItem,
|
.bubbleBackground(isOutgoing: timelineItem.isOutgoing,
|
||||||
insets: .init(top: 8, leading: 12, bottom: 8, trailing: 12),
|
insets: .init(top: 8, leading: 12, bottom: 8, trailing: 12),
|
||||||
color: .compound.bgSubtleSecondary)
|
color: .compound.bgSubtleSecondary)
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ struct VoiceMessageMediaEventsTimelineView: View {
|
|||||||
playerState: playerState)
|
playerState: playerState)
|
||||||
.accessibilityLabel(L10n.commonVoiceMessage)
|
.accessibilityLabel(L10n.commonVoiceMessage)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
.bubbleBackground(timelineItem: timelineItem,
|
.bubbleBackground(isOutgoing: timelineItem.isOutgoing,
|
||||||
insets: .init(top: 8, leading: 12, bottom: 8, trailing: 12),
|
insets: .init(top: 8, leading: 12, bottom: 8, trailing: 12),
|
||||||
color: .compound.bgSubtleSecondary)
|
color: .compound.bgSubtleSecondary)
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
extension View {
|
extension View {
|
||||||
func bubbleBackground(timelineItem: EventBasedTimelineItemProtocol,
|
func bubbleBackground(isOutgoing: Bool,
|
||||||
insets: EdgeInsets,
|
insets: EdgeInsets,
|
||||||
color: Color? = nil) -> some View {
|
color: Color? = nil) -> some View {
|
||||||
modifier(TimelineItemBubbleBackgroundModifier(timelineItem: timelineItem,
|
modifier(TimelineItemBubbleBackgroundModifier(isOutgoing: isOutgoing,
|
||||||
insets: insets,
|
insets: insets,
|
||||||
color: color))
|
color: color))
|
||||||
}
|
}
|
||||||
@ -20,7 +20,7 @@ extension View {
|
|||||||
private struct TimelineItemBubbleBackgroundModifier: ViewModifier {
|
private struct TimelineItemBubbleBackgroundModifier: ViewModifier {
|
||||||
@Environment(\.timelineGroupStyle) private var timelineGroupStyle
|
@Environment(\.timelineGroupStyle) private var timelineGroupStyle
|
||||||
|
|
||||||
let timelineItem: EventBasedTimelineItemProtocol
|
let isOutgoing: Bool
|
||||||
let insets: EdgeInsets
|
let insets: EdgeInsets
|
||||||
var color: Color?
|
var color: Color?
|
||||||
|
|
||||||
@ -36,15 +36,15 @@ private struct TimelineItemBubbleBackgroundModifier: ViewModifier {
|
|||||||
case .single:
|
case .single:
|
||||||
return .allCorners
|
return .allCorners
|
||||||
case .first:
|
case .first:
|
||||||
if timelineItem.isOutgoing {
|
if isOutgoing {
|
||||||
return [.topLeft, .topRight, .bottomLeft]
|
return [.topLeft, .topRight, .bottomLeft]
|
||||||
} else {
|
} else {
|
||||||
return [.topLeft, .topRight, .bottomRight]
|
return [.topLeft, .topRight, .bottomRight]
|
||||||
}
|
}
|
||||||
case .middle:
|
case .middle:
|
||||||
return timelineItem.isOutgoing ? [.topLeft, .bottomLeft] : [.topRight, .bottomRight]
|
return isOutgoing ? [.topLeft, .bottomLeft] : [.topRight, .bottomRight]
|
||||||
case .last:
|
case .last:
|
||||||
if timelineItem.isOutgoing {
|
if isOutgoing {
|
||||||
return [.topLeft, .bottomLeft, .bottomRight]
|
return [.topLeft, .bottomLeft, .bottomRight]
|
||||||
} else {
|
} else {
|
||||||
return [.topRight, .bottomLeft, .bottomRight]
|
return [.topRight, .bottomLeft, .bottomRight]
|
||||||
|
@ -163,7 +163,7 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
|
|||||||
var messageBubble: some View {
|
var messageBubble: some View {
|
||||||
contentWithReply
|
contentWithReply
|
||||||
.timelineItemSendInfo(timelineItem: timelineItem, adjustedDeliveryStatus: adjustedDeliveryStatus, context: context)
|
.timelineItemSendInfo(timelineItem: timelineItem, adjustedDeliveryStatus: adjustedDeliveryStatus, context: context)
|
||||||
.bubbleBackground(timelineItem: timelineItem,
|
.bubbleBackground(isOutgoing: timelineItem.isOutgoing,
|
||||||
insets: timelineItem.bubbleInsets,
|
insets: timelineItem.bubbleInsets,
|
||||||
color: timelineItem.bubbleBackgroundColor)
|
color: timelineItem.bubbleBackgroundColor)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user