mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Add permalink detection and custom attributed string attributes (#536)
* Pass full attributed string to TimelineItems and let the UI level handle blockquote coalescing * Add permalink detection and attribute embedding within the attributed string
This commit is contained in:
@@ -21,7 +21,7 @@ enum RoomTimelineItemFixtures {
|
||||
static var `default`: [RoomTimelineItemProtocol] = [
|
||||
SeparatorRoomTimelineItem(text: "Yesterday"),
|
||||
TextRoomTimelineItem(id: UUID().uuidString,
|
||||
text: "That looks so good!",
|
||||
body: "That looks so good!",
|
||||
timestamp: "10:10 AM",
|
||||
groupState: .single,
|
||||
isOutgoing: false,
|
||||
@@ -29,7 +29,7 @@ enum RoomTimelineItemFixtures {
|
||||
sender: .init(id: "", displayName: "Jacob"),
|
||||
properties: RoomTimelineItemProperties(isEdited: true)),
|
||||
TextRoomTimelineItem(id: UUID().uuidString,
|
||||
text: "Let’s get lunch soon! New salad place opened up 🥗. When are y’all free? 🤗",
|
||||
body: "Let’s get lunch soon! New salad place opened up 🥗. When are y’all free? 🤗",
|
||||
timestamp: "10:11 AM",
|
||||
groupState: .beginning,
|
||||
isOutgoing: false,
|
||||
@@ -39,7 +39,7 @@ enum RoomTimelineItemFixtures {
|
||||
AggregatedReaction(key: "🙌", count: 1, isHighlighted: true)
|
||||
])),
|
||||
TextRoomTimelineItem(id: UUID().uuidString,
|
||||
text: "I can be around on Wednesday. How about some 🌮 instead? Like https://www.tortilla.co.uk/",
|
||||
body: "I can be around on Wednesday. How about some 🌮 instead? Like https://www.tortilla.co.uk/",
|
||||
timestamp: "10:11 AM",
|
||||
groupState: .end,
|
||||
isOutgoing: false,
|
||||
@@ -51,21 +51,21 @@ enum RoomTimelineItemFixtures {
|
||||
])),
|
||||
SeparatorRoomTimelineItem(text: "Today"),
|
||||
TextRoomTimelineItem(id: UUID().uuidString,
|
||||
text: "Wow, cool. Ok, lets go the usual place tomorrow?! Is that too soon? Here’s the menu, let me know what you want it’s on me!",
|
||||
body: "Wow, cool. Ok, lets go the usual place tomorrow?! Is that too soon? Here’s the menu, let me know what you want it’s on me!",
|
||||
timestamp: "5 PM",
|
||||
groupState: .single,
|
||||
isOutgoing: false,
|
||||
isEditable: false,
|
||||
sender: .init(id: "", displayName: "Helena")),
|
||||
TextRoomTimelineItem(id: UUID().uuidString,
|
||||
text: "And John's speech was amazing!",
|
||||
body: "And John's speech was amazing!",
|
||||
timestamp: "5 PM",
|
||||
groupState: .beginning,
|
||||
isOutgoing: true,
|
||||
isEditable: true,
|
||||
sender: .init(id: "", displayName: "Bob")),
|
||||
TextRoomTimelineItem(id: UUID().uuidString,
|
||||
text: "New home office set up!",
|
||||
body: "New home office set up!",
|
||||
timestamp: "5 PM",
|
||||
groupState: .end,
|
||||
isOutgoing: true,
|
||||
@@ -76,12 +76,8 @@ enum RoomTimelineItemFixtures {
|
||||
AggregatedReaction(key: "😁", count: 3, isHighlighted: false)
|
||||
])),
|
||||
TextRoomTimelineItem(id: UUID().uuidString,
|
||||
text: "",
|
||||
attributedComponents: [
|
||||
AttributedStringBuilderComponent(attributedString: "Hol' up", isBlockquote: false, isReply: false),
|
||||
AttributedStringBuilderComponent(attributedString: "New home office set up!", isBlockquote: true, isReply: false),
|
||||
AttributedStringBuilderComponent(attributedString: "That's amazing! Congrats 🥳", isBlockquote: false, isReply: false)
|
||||
],
|
||||
body: "",
|
||||
formattedBody: AttributedStringBuilder().fromHTML("Hol' up <blockquote>New home office set up!</blockquote>That's amazing! Congrats 🥳"),
|
||||
timestamp: "5 PM",
|
||||
groupState: .single,
|
||||
isOutgoing: false,
|
||||
@@ -202,7 +198,7 @@ enum RoomTimelineItemFixtures {
|
||||
private extension TextRoomTimelineItem {
|
||||
init(text: String, groupState: TimelineItemGroupState = .single, senderDisplayName: String) {
|
||||
self.init(id: UUID().uuidString,
|
||||
text: text,
|
||||
body: text,
|
||||
timestamp: "10:47 am",
|
||||
groupState: groupState,
|
||||
isOutgoing: senderDisplayName == "Alice",
|
||||
|
||||
Reference in New Issue
Block a user