mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
This commit is contained in:
@@ -44,6 +44,7 @@ struct TimelineItemPlainStylerView<Content: View>: View {
|
|||||||
.foregroundColor(.element.primaryContent)
|
.foregroundColor(.element.primaryContent)
|
||||||
.fontWeight(.semibold)
|
.fontWeight(.semibold)
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
|
Spacer()
|
||||||
Text(timelineItem.timestamp)
|
Text(timelineItem.timestamp)
|
||||||
.foregroundColor(Color.element.tertiaryContent)
|
.foregroundColor(Color.element.tertiaryContent)
|
||||||
.font(.element.caption2)
|
.font(.element.caption2)
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ struct EmoteRoomTimelineView_Previews: PreviewProvider {
|
|||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
body.preferredColorScheme(.light)
|
body.preferredColorScheme(.light)
|
||||||
body.preferredColorScheme(.dark)
|
body.preferredColorScheme(.dark)
|
||||||
|
body.preferredColorScheme(.light)
|
||||||
|
.timelineStyle(.plain)
|
||||||
|
body.preferredColorScheme(.dark)
|
||||||
|
.timelineStyle(.plain)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
@@ -52,6 +56,7 @@ struct EmoteRoomTimelineView_Previews: PreviewProvider {
|
|||||||
timestamp: "Later",
|
timestamp: "Later",
|
||||||
senderId: "Anne"))
|
senderId: "Anne"))
|
||||||
}
|
}
|
||||||
|
.environment(\.timelineWidth, 400)
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func itemWith(text: String, timestamp: String, senderId: String) -> EmoteRoomTimelineItem {
|
private static func itemWith(text: String, timestamp: String, senderId: String) -> EmoteRoomTimelineItem {
|
||||||
|
|||||||
@@ -18,19 +18,32 @@ import Foundation
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct FormattedBodyText: View {
|
struct FormattedBodyText: View {
|
||||||
|
@Environment(\.timelineStyle) private var timelineStyle
|
||||||
|
|
||||||
let attributedComponents: [AttributedStringBuilderComponent]
|
let attributedComponents: [AttributedStringBuilderComponent]
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading, spacing: 8.0) {
|
VStack(alignment: .leading, spacing: 8.0) {
|
||||||
ForEach(attributedComponents, id: \.self) { component in
|
ForEach(attributedComponents, id: \.self) { component in
|
||||||
if component.isBlockquote {
|
if component.isBlockquote {
|
||||||
Text(component.attributedString.mergingAttributes(blockquoteAttributes))
|
if timelineStyle == .plain {
|
||||||
|
HStack(spacing: 4.0) {
|
||||||
|
Rectangle()
|
||||||
|
.foregroundColor(Color.red)
|
||||||
|
.frame(width: 4.0)
|
||||||
|
Text(component.attributedString)
|
||||||
|
.foregroundColor(.element.primaryContent)
|
||||||
|
}
|
||||||
.fixedSize(horizontal: false, vertical: true)
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
.foregroundColor(.element.primaryContent)
|
} else {
|
||||||
.padding(EdgeInsets(top: 6, leading: 12, bottom: 6, trailing: 12))
|
Text(component.attributedString.mergingAttributes(blockquoteAttributes))
|
||||||
.clipped()
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
.background(Color.element.systemGray4)
|
.foregroundColor(.element.primaryContent)
|
||||||
.cornerRadius(13)
|
.padding(EdgeInsets(top: 6, leading: 12, bottom: 6, trailing: 12))
|
||||||
|
.clipped()
|
||||||
|
.background(Color.element.systemGray4)
|
||||||
|
.cornerRadius(13)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Text(component.attributedString)
|
Text(component.attributedString)
|
||||||
.fixedSize(horizontal: false, vertical: true)
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
@@ -58,6 +71,10 @@ struct FormattedBodyText_Previews: PreviewProvider {
|
|||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
body.preferredColorScheme(.light)
|
body.preferredColorScheme(.light)
|
||||||
body.preferredColorScheme(.dark)
|
body.preferredColorScheme(.dark)
|
||||||
|
body.preferredColorScheme(.light)
|
||||||
|
.timelineStyle(.plain)
|
||||||
|
body.preferredColorScheme(.dark)
|
||||||
|
.timelineStyle(.plain)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ struct ImageRoomTimelineView_Previews: PreviewProvider {
|
|||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
body.preferredColorScheme(.light)
|
body.preferredColorScheme(.light)
|
||||||
body.preferredColorScheme(.dark)
|
body.preferredColorScheme(.dark)
|
||||||
|
body.preferredColorScheme(.light)
|
||||||
|
.timelineStyle(.plain)
|
||||||
|
body.preferredColorScheme(.dark)
|
||||||
|
.timelineStyle(.plain)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
@@ -88,5 +92,6 @@ struct ImageRoomTimelineView_Previews: PreviewProvider {
|
|||||||
aspectRatio: 0.7,
|
aspectRatio: 0.7,
|
||||||
blurhash: "L%KUc%kqS$RP?Ks,WEf8OlrqaekW"))
|
blurhash: "L%KUc%kqS$RP?Ks,WEf8OlrqaekW"))
|
||||||
}
|
}
|
||||||
|
.environment(\.timelineWidth, 400)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ struct NoticeRoomTimelineView_Previews: PreviewProvider {
|
|||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
body.preferredColorScheme(.light)
|
body.preferredColorScheme(.light)
|
||||||
body.preferredColorScheme(.dark)
|
body.preferredColorScheme(.dark)
|
||||||
|
body.preferredColorScheme(.light)
|
||||||
|
.timelineStyle(.plain)
|
||||||
|
body.preferredColorScheme(.dark)
|
||||||
|
.timelineStyle(.plain)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
@@ -52,7 +56,7 @@ struct NoticeRoomTimelineView_Previews: PreviewProvider {
|
|||||||
timestamp: "Later",
|
timestamp: "Later",
|
||||||
senderId: "Anne"))
|
senderId: "Anne"))
|
||||||
}
|
}
|
||||||
.padding()
|
.environment(\.timelineWidth, 400)
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func itemWith(text: String, timestamp: String, senderId: String) -> NoticeRoomTimelineItem {
|
private static func itemWith(text: String, timestamp: String, senderId: String) -> NoticeRoomTimelineItem {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ struct RedactedRoomTimelineView_Previews: PreviewProvider {
|
|||||||
timestamp: "Later",
|
timestamp: "Later",
|
||||||
senderId: "Anne"))
|
senderId: "Anne"))
|
||||||
}
|
}
|
||||||
.padding()
|
.environment(\.timelineWidth, 400)
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func itemWith(text: String, timestamp: String, senderId: String) -> RedactedRoomTimelineItem {
|
private static func itemWith(text: String, timestamp: String, senderId: String) -> RedactedRoomTimelineItem {
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ struct TextRoomTimelineView_Previews: PreviewProvider {
|
|||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
body.preferredColorScheme(.light)
|
body.preferredColorScheme(.light)
|
||||||
body.preferredColorScheme(.dark)
|
body.preferredColorScheme(.dark)
|
||||||
|
body.preferredColorScheme(.light)
|
||||||
|
.timelineStyle(.plain)
|
||||||
|
body.preferredColorScheme(.dark)
|
||||||
|
.timelineStyle(.plain)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
@@ -55,15 +59,13 @@ struct TextRoomTimelineView_Previews: PreviewProvider {
|
|||||||
timestamp: "Now",
|
timestamp: "Now",
|
||||||
isOutgoing: false,
|
isOutgoing: false,
|
||||||
senderId: "Bob"))
|
senderId: "Bob"))
|
||||||
.timelineStyle(.plain)
|
|
||||||
|
|
||||||
TextRoomTimelineView(timelineItem: itemWith(text: "Some other text",
|
TextRoomTimelineView(timelineItem: itemWith(text: "Some other text",
|
||||||
timestamp: "Later",
|
timestamp: "Later",
|
||||||
isOutgoing: true,
|
isOutgoing: true,
|
||||||
senderId: "Anne"))
|
senderId: "Anne"))
|
||||||
.timelineStyle(.plain)
|
|
||||||
}
|
}
|
||||||
.padding(.horizontal, 8)
|
.environment(\.timelineWidth, 400)
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func itemWith(text: String, timestamp: String, isOutgoing: Bool, senderId: String) -> TextRoomTimelineItem {
|
private static func itemWith(text: String, timestamp: String, isOutgoing: Bool, senderId: String) -> TextRoomTimelineItem {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ struct TimelineItemList: View {
|
|||||||
.opacity(context.viewState.isBackPaginating ? 1.0 : 0.0)
|
.opacity(context.viewState.isBackPaginating ? 1.0 : 0.0)
|
||||||
.animation(.elementDefault, value: context.viewState.isBackPaginating)
|
.animation(.elementDefault, value: context.viewState.isBackPaginating)
|
||||||
|
|
||||||
LazyVStack(spacing: 0.0) {
|
LazyVStack(alignment: .leading, spacing: 0.0) {
|
||||||
ForEach(isRunningPreviews ? context.viewState.items : timelineItems) { item in
|
ForEach(isRunningPreviews ? context.viewState.items : timelineItems) { item in
|
||||||
item
|
item
|
||||||
.contextMenu {
|
.contextMenu {
|
||||||
|
|||||||
@@ -62,16 +62,14 @@ class MockRoomTimelineController: RoomTimelineControllerProtocol {
|
|||||||
inGroupState: .single,
|
inGroupState: .single,
|
||||||
isOutgoing: false,
|
isOutgoing: false,
|
||||||
senderId: "",
|
senderId: "",
|
||||||
senderDisplayName: "Helena",
|
senderDisplayName: "Helena"),
|
||||||
properties: RoomTimelineItemProperties()),
|
|
||||||
TextRoomTimelineItem(id: UUID().uuidString,
|
TextRoomTimelineItem(id: UUID().uuidString,
|
||||||
text: "And John's speech was amazing!",
|
text: "And John's speech was amazing!",
|
||||||
timestamp: "5 PM",
|
timestamp: "5 PM",
|
||||||
inGroupState: .beginning,
|
inGroupState: .beginning,
|
||||||
isOutgoing: true,
|
isOutgoing: true,
|
||||||
senderId: "",
|
senderId: "",
|
||||||
senderDisplayName: "Bob",
|
senderDisplayName: "Bob"),
|
||||||
properties: RoomTimelineItemProperties()),
|
|
||||||
TextRoomTimelineItem(id: UUID().uuidString,
|
TextRoomTimelineItem(id: UUID().uuidString,
|
||||||
text: "New home office set up!",
|
text: "New home office set up!",
|
||||||
timestamp: "5 PM",
|
timestamp: "5 PM",
|
||||||
@@ -82,7 +80,19 @@ class MockRoomTimelineController: RoomTimelineControllerProtocol {
|
|||||||
properties: RoomTimelineItemProperties(reactions: [
|
properties: RoomTimelineItemProperties(reactions: [
|
||||||
AggregatedReaction(key: "🙏", count: 1, isHighlighted: false),
|
AggregatedReaction(key: "🙏", count: 1, isHighlighted: false),
|
||||||
AggregatedReaction(key: "😁", count: 3, isHighlighted: false)
|
AggregatedReaction(key: "😁", count: 3, isHighlighted: false)
|
||||||
]))
|
])),
|
||||||
|
TextRoomTimelineItem(id: UUID().uuidString,
|
||||||
|
text: "",
|
||||||
|
attributedComponents: [
|
||||||
|
AttributedStringBuilderComponent(attributedString: "Hol' up", isBlockquote: false),
|
||||||
|
AttributedStringBuilderComponent(attributedString: "New home office set up!", isBlockquote: true),
|
||||||
|
AttributedStringBuilderComponent(attributedString: "That's amazing! Congrats 🥳", isBlockquote: false)
|
||||||
|
],
|
||||||
|
timestamp: "5 PM",
|
||||||
|
inGroupState: .single,
|
||||||
|
isOutgoing: false,
|
||||||
|
senderId: "",
|
||||||
|
senderDisplayName: "Helena")
|
||||||
]
|
]
|
||||||
|
|
||||||
func paginateBackwards(_ count: UInt) async -> Result<Void, RoomTimelineControllerError> {
|
func paginateBackwards(_ count: UInt) async -> Result<Void, RoomTimelineControllerError> {
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Fixed blockquote and item layout when using the plain timeline
|
||||||
Reference in New Issue
Block a user