mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Added more timeline view SwiftUI previews.
This commit is contained in:
parent
d330950ed3
commit
6243973e36
@ -398,11 +398,12 @@
|
||||
18C5744727E1D84000D70937 /* Room */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
18DF7C5127E4753A00291672 /* Members */,
|
||||
18C5744927E1D84000D70937 /* Messages */,
|
||||
18C5744827E1D84000D70937 /* RoomProxyProtocol.swift */,
|
||||
18C5744A27E1D84000D70937 /* RoomProxy.swift */,
|
||||
18C5744B27E1D84000D70937 /* MockRoomProxy.swift */,
|
||||
18C5745527E1DCA800D70937 /* RoomMessageFactory.swift */,
|
||||
18DF7C5127E4753A00291672 /* Members */,
|
||||
18C5744927E1D84000D70937 /* Messages */,
|
||||
);
|
||||
path = Room;
|
||||
sourceTree = "<group>";
|
||||
@ -410,12 +411,11 @@
|
||||
18C5744927E1D84000D70937 /* Messages */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
18920C0D27F233FF00A717B5 /* EmoteRoomMessage.swift */,
|
||||
18C5745127E1D88600D70937 /* ImageRoomMessage.swift */,
|
||||
18920C0C27F233FF00A717B5 /* NoticeRoomMessage.swift */,
|
||||
18C5745527E1DCA800D70937 /* RoomMessageFactory.swift */,
|
||||
18C5744F27E1D87800D70937 /* RoomMessageProtocol.swift */,
|
||||
18C5745327E1D88E00D70937 /* TextRoomMessage.swift */,
|
||||
18C5745127E1D88600D70937 /* ImageRoomMessage.swift */,
|
||||
18920C0D27F233FF00A717B5 /* EmoteRoomMessage.swift */,
|
||||
18920C0C27F233FF00A717B5 /* NoticeRoomMessage.swift */,
|
||||
);
|
||||
path = Messages;
|
||||
sourceTree = "<group>";
|
||||
@ -437,8 +437,8 @@
|
||||
18DF7C3827E4670600291672 /* RoomTimelineViewFactory.swift */,
|
||||
18DF7C3527E4670600291672 /* RoomTimelineViewProvider.swift */,
|
||||
18DF7C3727E4670600291672 /* RoomTimelineItemProtocol.swift */,
|
||||
18DF7C4B27E4672C00291672 /* EventBasedTimelineItemProtocol.swift */,
|
||||
18DF7C4D27E4673E00291672 /* DecorationTimelineItemProtocol.swift */,
|
||||
18DF7C4B27E4672C00291672 /* EventBasedTimelineItemProtocol.swift */,
|
||||
18DF7C3927E4670600291672 /* Items */,
|
||||
);
|
||||
path = TimelineItems;
|
||||
|
@ -30,7 +30,13 @@ struct EmoteRoomTimelineView: View {
|
||||
|
||||
struct EmoteRoomTimelineView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VStack(spacing: 20.0) {
|
||||
body
|
||||
body.preferredColorScheme(.dark)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
static var body: some View {
|
||||
VStack(alignment: .leading, spacing: 20.0) {
|
||||
let timelineItem = EmoteRoomTimelineItem(id: UUID().uuidString,
|
||||
text: "Short loin ground round tongue hamburger, fatback salami shoulder. Beef turkey sausage kielbasa strip steak. Alcatra capicola pig tail pancetta chislic.",
|
||||
timestamp: "Now",
|
||||
@ -45,6 +51,5 @@ struct EmoteRoomTimelineView_Previews: PreviewProvider {
|
||||
senderId: "Anne")
|
||||
EmoteRoomTimelineView(timelineItem: timelineItem)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,13 @@ struct EventBasedTimelineView: View {
|
||||
|
||||
struct EventBasedTimelineView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VStack(spacing: 20.0) {
|
||||
body
|
||||
body.preferredColorScheme(.dark)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
static var body: some View {
|
||||
VStack(alignment: .leading, spacing: 20.0) {
|
||||
let timelineItem = TextRoomTimelineItem(id: UUID().uuidString,
|
||||
text: "Short loin ground round tongue hamburger, fatback salami shoulder. Beef turkey sausage kielbasa strip steak. Alcatra capicola pig tail pancetta chislic.",
|
||||
timestamp: "Now",
|
||||
@ -66,6 +72,5 @@ struct EventBasedTimelineView_Previews: PreviewProvider {
|
||||
senderId: "Anne")
|
||||
EventBasedTimelineView(timelineItem: timelineItem)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
@ -35,21 +35,43 @@ struct FormattedBodyText: View {
|
||||
|
||||
struct FormattedBodyText_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
let htmlString = """
|
||||
body
|
||||
body.preferredColorScheme(.dark)
|
||||
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
static var body: some View {
|
||||
let htmlStrings = [
|
||||
"""
|
||||
Text before blockquote
|
||||
<blockquote>
|
||||
<b>bold</b> <i>italic</i>
|
||||
</blockquote>
|
||||
Text after blockquote
|
||||
""",
|
||||
"""
|
||||
<blockquote>First blockquote with a <a href=\"https://www.matrix.org/\">link</a> in it</blockquote>
|
||||
<blockquote>Second blockquote with a <a href=\"https://www.matrix.org/\">link</a> in it</blockquote>
|
||||
<blockquote>Third blockquote with a <a href=\"https://www.matrix.org/\">link</a> in it</blockquote>
|
||||
""",
|
||||
"""
|
||||
<code>Hello world</code>
|
||||
<p>Text</p>
|
||||
<code><b>Hello</b> <i>world</i></code>
|
||||
<p>Text</p>
|
||||
<code>Hello world</code>
|
||||
"""]
|
||||
|
||||
let attributedStringBuilder = AttributedStringBuilder()
|
||||
let attributedString = attributedStringBuilder.fromHTML(htmlString)
|
||||
|
||||
if let components = attributedStringBuilder.blockquoteCoalescedComponentsFrom(attributedString) {
|
||||
VStack {
|
||||
FormattedBodyText(attributedComponents: components)
|
||||
.fixedSize()
|
||||
VStack(alignment: .leading, spacing: 24.0) {
|
||||
ForEach(htmlStrings, id: \.self) { htmlString in
|
||||
let attributedString = attributedStringBuilder.fromHTML(htmlString)
|
||||
|
||||
if let components = attributedStringBuilder.blockquoteCoalescedComponentsFrom(attributedString) {
|
||||
FormattedBodyText(attributedComponents: components)
|
||||
.fixedSize()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,13 @@ struct ImageRoomTimelineView: View {
|
||||
|
||||
struct ImageRoomTimelineView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VStack {
|
||||
body
|
||||
body.preferredColorScheme(.dark)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
static var body: some View {
|
||||
VStack(spacing: 20.0) {
|
||||
let timelineItem = ImageRoomTimelineItem(id: UUID().uuidString,
|
||||
text: "Some image",
|
||||
timestamp: "Now",
|
||||
|
@ -30,7 +30,13 @@ struct NoticeRoomTimelineView: View {
|
||||
|
||||
struct NoticeRoomTimelineView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VStack(spacing: 20.0) {
|
||||
body
|
||||
body.preferredColorScheme(.dark)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
static var body: some View {
|
||||
VStack(alignment: .leading, spacing: 20.0) {
|
||||
let timelineItem = NoticeRoomTimelineItem(id: UUID().uuidString,
|
||||
text: "Short loin ground round tongue hamburger, fatback salami shoulder. Beef turkey sausage kielbasa strip steak. Alcatra capicola pig tail pancetta chislic.",
|
||||
timestamp: "Now",
|
||||
|
@ -36,6 +36,12 @@ struct PlaceholderAvatarImage: View {
|
||||
|
||||
struct PlaceholderAvatarImage_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
body
|
||||
body.preferredColorScheme(.dark)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
static var body: some View {
|
||||
PlaceholderAvatarImage(firstCharacter: "X")
|
||||
.clipShape(Circle())
|
||||
.frame(width: 150, height: 100)
|
||||
|
@ -44,8 +44,13 @@ struct LabelledDivider: View {
|
||||
|
||||
struct SeparatorRoomTimelineView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
body
|
||||
body.preferredColorScheme(.dark)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
static var body: some View {
|
||||
let item = SeparatorRoomTimelineItem(id: UUID().uuidString, text: "This is a separator")
|
||||
|
||||
SeparatorRoomTimelineView(timelineItem: item)
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,13 @@ struct TextRoomTimelineView: View {
|
||||
|
||||
struct TextRoomTimelineView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VStack(spacing: 20.0) {
|
||||
body
|
||||
body.preferredColorScheme(.dark)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
static var body: some View {
|
||||
VStack(alignment: .leading, spacing: 20.0) {
|
||||
let timelineItem = TextRoomTimelineItem(id: UUID().uuidString,
|
||||
text: "Short loin ground round tongue hamburger, fatback salami shoulder. Beef turkey sausage kielbasa strip steak. Alcatra capicola pig tail pancetta chislic.",
|
||||
timestamp: "Now",
|
||||
@ -42,6 +48,5 @@ struct TextRoomTimelineView_Previews: PreviewProvider {
|
||||
senderId: "Anne")
|
||||
TextRoomTimelineView(timelineItem: timelineItem)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user