Add new development assets and use in mocks/previews. (#3581)

This commit is contained in:
Doug
2024-12-03 17:14:05 +00:00
committed by GitHub
parent c566c64c78
commit 4966083b58
194 changed files with 501 additions and 492 deletions
@@ -66,7 +66,7 @@ struct ReadReceiptCell_Previews: PreviewProvider, TestablePreview {
ReadReceiptCell(readReceipt: .init(userID: "@test:matrix.org",
formattedTimestamp: "10:00"),
memberState: .init(displayName: "Test",
avatarURL: .mockMXCAvatar),
avatarURL: .mockMXCUserAvatar),
mediaProvider: MediaProviderMock(configuration: .init()))
.previewDisplayName("With Image")
ReadReceiptCell(readReceipt: .init(userID: "@test:matrix.org",
@@ -277,7 +277,7 @@ struct TimelineReplyView_Previews: PreviewProvider, TestablePreview {
eventContent: .message(.video(.init(filename: "video.mp4",
caption: "Some video",
videoInfo: .mockVideo,
thumbnailInfo: .mockThumbnail))))),
thumbnailInfo: .mockVideoThumbnail))))),
TimelineReplyView(placement: .timeline,
timelineItemReplyDetails: .loaded(sender: .init(id: "", displayName: "Alice"),
eventID: "123",
@@ -374,19 +374,27 @@ struct TimelineItemBubbledStylerView_Previews: PreviewProvider, TestablePreview
static var previews: some View {
mockTimeline
.previewDisplayName("Mock Timeline")
.previewLayout(.fixed(width: 390, height: 900))
.padding(.bottom, 20)
mockTimeline
.environment(\.layoutDirection, .rightToLeft)
.previewDisplayName("Mock Timeline RTL")
.previewLayout(.fixed(width: 390, height: 900))
.padding(.bottom, 20)
replies
.previewDisplayName("Replies")
threads
.previewDisplayName("Thread decorator")
.snapshotPreferences(delay: 1)
.previewLayout(.fixed(width: 390, height: 1700))
.padding(.bottom, 20)
encryptionAuthenticity
.previewDisplayName("Encryption Indicators")
pinned
.previewDisplayName("Pinned messages")
.snapshotPreferences(delay: 1)
.previewLayout(.fixed(width: 390, height: 1150))
.padding(.bottom, 20)
}
static var mockTimeline: some View {
@@ -74,61 +74,38 @@ struct ImageRoomTimelineView_Previews: PreviewProvider, TestablePreview {
static let viewModel = TimelineViewModel.mock
static var previews: some View {
body
.environmentObject(viewModel.context)
.environment(\.timelineContext, viewModel.context)
ScrollView {
VStack(spacing: 20.0) {
ImageRoomTimelineView(timelineItem: makeTimelineItem())
ImageRoomTimelineView(timelineItem: makeTimelineItem(isEdited: true))
// Blur hashed item?
ImageRoomTimelineView(timelineItem: makeTimelineItem(caption: "This is a great image 😎"))
ImageRoomTimelineView(timelineItem: makeTimelineItem(caption: "This is a great image with a really long multiline caption.",
isEdited: true))
}
}
.environmentObject(viewModel.context)
.environment(\.timelineContext, viewModel.context)
.previewLayout(.fixed(width: 390, height: 1200))
.padding(.bottom, 20)
}
static var body: some View {
VStack(spacing: 20.0) {
ImageRoomTimelineView(timelineItem: ImageRoomTimelineItem(id: .randomEvent,
timestamp: "Now",
isOutgoing: false,
isEditable: false,
canBeRepliedTo: true,
isThreaded: false,
sender: .init(id: "Bob"),
content: .init(filename: "image.jpg",
imageInfo: .mockImage,
thumbnailInfo: nil)))
ImageRoomTimelineView(timelineItem: ImageRoomTimelineItem(id: .randomEvent,
timestamp: "Now",
isOutgoing: false,
isEditable: false,
canBeRepliedTo: true,
isThreaded: false,
sender: .init(id: "Bob"),
content: .init(filename: "other.png",
imageInfo: .mockImage,
thumbnailInfo: nil)))
ImageRoomTimelineView(timelineItem: ImageRoomTimelineItem(id: .randomEvent,
timestamp: "Now",
isOutgoing: false,
isEditable: false,
canBeRepliedTo: true,
isThreaded: false,
sender: .init(id: "Bob"),
content: .init(filename: "Blurhashed.jpg",
imageInfo: .mockImage,
thumbnailInfo: nil,
blurhash: "L%KUc%kqS$RP?Ks,WEf8OlrqaekW",
contentType: .gif)))
ImageRoomTimelineView(timelineItem: ImageRoomTimelineItem(id: .randomEvent,
timestamp: "Now",
isOutgoing: false,
isEditable: false,
canBeRepliedTo: true,
isThreaded: false,
sender: .init(id: "Bob"),
content: .init(filename: "Blurhashed.jpg",
caption: "This is a great image 😎",
imageInfo: .mockImage,
thumbnailInfo: .mockThumbnail,
blurhash: "L%KUc%kqS$RP?Ks,WEf8OlrqaekW",
contentType: .gif)))
}
private static func makeTimelineItem(caption: String? = nil, isEdited: Bool = false) -> ImageRoomTimelineItem {
ImageRoomTimelineItem(id: .randomEvent,
timestamp: "Now",
isOutgoing: false,
isEditable: false,
canBeRepliedTo: true,
isThreaded: false,
sender: .init(id: "Bob"),
content: .init(filename: "image.jpg",
caption: caption,
imageInfo: .mockImage,
thumbnailInfo: .mockThumbnail,
blurhash: "L%KUc%kqS$RP?Ks,WEf8OlrqaekW",
contentType: .jpeg),
properties: .init(isEdited: isEdited))
}
}
@@ -41,12 +41,6 @@ struct StickerRoomTimelineView_Previews: PreviewProvider, TestablePreview {
static let viewModel = TimelineViewModel.mock
static var previews: some View {
body
.environmentObject(viewModel.context)
.environment(\.timelineContext, viewModel.context)
}
static var body: some View {
VStack(spacing: 20.0) {
StickerRoomTimelineView(timelineItem: StickerRoomTimelineItem(id: .randomEvent,
body: "Some image",
@@ -57,15 +51,6 @@ struct StickerRoomTimelineView_Previews: PreviewProvider, TestablePreview {
sender: .init(id: "Bob"),
imageInfo: .mockImage))
StickerRoomTimelineView(timelineItem: StickerRoomTimelineItem(id: .randomEvent,
body: "Some other image",
timestamp: "Now",
isOutgoing: false,
isEditable: false,
canBeRepliedTo: true,
sender: .init(id: "Bob"),
imageInfo: .mockImage))
StickerRoomTimelineView(timelineItem: StickerRoomTimelineItem(id: .randomEvent,
body: "Blurhashed image",
timestamp: "Now",
@@ -76,5 +61,7 @@ struct StickerRoomTimelineView_Previews: PreviewProvider, TestablePreview {
imageInfo: .mockImage,
blurhash: "L%KUc%kqS$RP?Ks,WEf8OlrqaekW"))
}
.environmentObject(viewModel.context)
.environment(\.timelineContext, viewModel.context)
}
}
@@ -5,7 +5,7 @@
// Please see LICENSE in the repository root for full details.
//
import Foundation
import Compound
import SwiftUI
struct VideoRoomTimelineView: View {
@@ -78,56 +78,37 @@ struct VideoRoomTimelineView_Previews: PreviewProvider, TestablePreview {
static let viewModel = TimelineViewModel.mock
static var previews: some View {
body.environmentObject(viewModel.context)
ScrollView {
VStack(spacing: 20.0) {
VideoRoomTimelineView(timelineItem: makeTimelineItem())
VideoRoomTimelineView(timelineItem: makeTimelineItem(isEdited: true))
// Blurhash item?
VideoRoomTimelineView(timelineItem: makeTimelineItem(caption: "This is a great image 😎"))
VideoRoomTimelineView(timelineItem: makeTimelineItem(caption: "This is a great image with a really long multiline caption",
isEdited: true))
}
}
.environmentObject(viewModel.context)
.environment(\.timelineContext, viewModel.context)
.previewLayout(.fixed(width: 390, height: 975))
.padding(.bottom, 20)
}
static var body: some View {
VStack(spacing: 20.0) {
VideoRoomTimelineView(timelineItem: VideoRoomTimelineItem(id: .randomEvent,
timestamp: "Now",
isOutgoing: false,
isEditable: false,
canBeRepliedTo: true,
isThreaded: false,
sender: .init(id: "Bob"),
content: .init(filename: "video.mp4",
videoInfo: .mockVideo,
thumbnailInfo: nil)))
VideoRoomTimelineView(timelineItem: VideoRoomTimelineItem(id: .randomEvent,
timestamp: "Now",
isOutgoing: false,
isEditable: false,
canBeRepliedTo: true,
isThreaded: false,
sender: .init(id: "Bob"),
content: .init(filename: "other.mp4",
videoInfo: .mockVideo,
thumbnailInfo: nil)))
VideoRoomTimelineView(timelineItem: VideoRoomTimelineItem(id: .randomEvent,
timestamp: "Now",
isOutgoing: false,
isEditable: false,
canBeRepliedTo: true,
isThreaded: false,
sender: .init(id: "Bob"),
content: .init(filename: "Blurhashed.mp4",
videoInfo: .mockVideo,
thumbnailInfo: nil,
blurhash: "L%KUc%kqS$RP?Ks,WEf8OlrqaekW")))
VideoRoomTimelineView(timelineItem: VideoRoomTimelineItem(id: .randomEvent,
timestamp: "Now",
isOutgoing: false,
isEditable: false,
canBeRepliedTo: true,
isThreaded: false,
sender: .init(id: "Bob"),
content: .init(filename: "video.mp4",
caption: "This is a caption",
videoInfo: .mockVideo,
thumbnailInfo: nil)))
}
private static func makeTimelineItem(caption: String? = nil, isEdited: Bool = false) -> VideoRoomTimelineItem {
VideoRoomTimelineItem(id: .randomEvent,
timestamp: "Now",
isOutgoing: false,
isEditable: false,
canBeRepliedTo: true,
isThreaded: false,
sender: .init(id: "Bob"),
content: .init(filename: "video.mp4",
caption: caption,
videoInfo: .mockVideo,
thumbnailInfo: .mockVideoThumbnail,
blurhash: "L%KUc%kqS$RP?Ks,WEf8OlrqaekW"),
properties: .init(isEdited: isEdited))
}
}