added preview for views
iOS CI / Build and Test SwiftUI App (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build Unsigned iOS IPA (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build macOS ZIP (push) Canceled after 0s

This commit is contained in:
wt committed 2026-09-04 01:45:09 +07:00
1 parent 1650145d4d
commit 1e2670903f
36 files changed
+744 -16

No files matched your search

@@ -326,3 +326,28 @@ enum MediaTimeFormatter {
return String(format: "%d:%02d", seconds / 60, seconds % 60)
}
}
#Preview("Голосовое") {
AudioMessagePlayer(
model: PreviewSupport.model,
message: PreviewSupport.voiceMessage(),
onFallbackTap: {}
)
.padding()
}
#Preview("Аудиофайл") {
AudioMessagePlayer(
model: PreviewSupport.model,
message: PreviewSupport.message(
body: "",
kind: .audio,
localFilename: "track.mp3",
mimeType: "audio/mpeg",
duration: 214,
byteCount: 8_550_000
),
onFallbackTap: {}
)
.padding()
}
@@ -90,3 +90,21 @@ struct AvatarView: View {
)
}
}
#Preview("Контакт") {
AvatarView(
conversation: PreviewSupport.conversation(displayName: "Алиса", isOnline: true)
)
}
#Preview("Группа") {
AvatarView(
conversation: PreviewSupport.conversation(
jid: "team@conference.example.org",
displayName: "Команда Luma",
kind: .group,
isGroupJoined: true,
occupantCount: 7
)
)
}
@@ -50,3 +50,27 @@ struct ReplyThreadBracket: Shape {
return path
}
}
#Preview("Кривая ответа") {
VStack(spacing: 24) {
ReplyThreadCurve(sourceDirection: .incoming)
.stroke(Color.blue, lineWidth: 2)
.frame(width: 90, height: 26)
ReplyThreadCurve(sourceDirection: .outgoing)
.stroke(Color.blue, lineWidth: 2)
.frame(width: 90, height: 26)
}
.padding()
}
#Preview("Скобка ветки") {
HStack(spacing: 40) {
ReplyThreadBracket(opensToTrailing: true)
.stroke(Color.blue, style: StrokeStyle(lineWidth: 3, lineCap: .round))
.frame(width: 38, height: 260)
ReplyThreadBracket(opensToTrailing: false)
.stroke(Color.blue, style: StrokeStyle(lineWidth: 3, lineCap: .round))
.frame(width: 38, height: 260)
}
.padding()
}
@@ -36,3 +36,8 @@ struct ConnectionBanner: View {
}
}
#Preview {
ConnectionBanner(model: PreviewSupport.model, text: "Чаты")
.padding()
}
@@ -58,3 +58,36 @@ struct ConversationRow: View {
.padding(.vertical, 2)
}
}
#Preview("Прямой чат") {
ConversationRow(
conversation: PreviewSupport.conversation(
displayName: "Алиса",
lastMessage: "Привет! Как дела?",
lastActivity: Date().addingTimeInterval(-120),
unreadCount: 2,
isOnline: true
),
imageData: nil,
isEncrypted: true
)
.padding()
}
#Preview("Групповой чат") {
ConversationRow(
conversation: PreviewSupport.conversation(
jid: "team@conference.example.org",
displayName: "Команда Luma",
lastMessage: "Иван: созвон в 15:00",
lastActivity: Date().addingTimeInterval(-3_600),
unreadCount: 5,
kind: .group,
isGroupJoined: true,
occupantCount: 7
),
imageData: nil,
isEncrypted: true
)
.padding()
}
@@ -90,3 +90,7 @@ struct EmojiPickerView: View {
}
}
}
#Preview {
EmojiPickerView { _ in }
}
@@ -71,3 +71,10 @@ struct InlineVideoPlayer: NSViewRepresentable {
}
}
#endif
#Preview {
InlineVideoPlayer(player: AVPlayer())
.frame(width: 260, height: 260)
.background(Color.black)
.clipShape(Circle())
}
@@ -61,3 +61,9 @@ struct LocationMessagePreview: View {
item.openInMaps()
}
}
#Preview {
LocationMessagePreview(
location: GeoLocation(latitude: 55.7558, longitude: 37.6173)!
)
}
+17 -6
View File
@@ -59,11 +59,12 @@ struct MediaViewer: View {
.ignoresSafeArea(edges: .bottom)
VStack(spacing: 0) {
Spacer()
HStack {
Text(item.title)
.font(.headline)
.foregroundStyle(.white)
.lineLimit(1)
// Text(item.title)
// .font(.headline)
// .foregroundStyle(.white)
// .lineLimit(1)
Spacer()
@@ -88,8 +89,6 @@ struct MediaViewer: View {
)
.ignoresSafeArea()
)
Spacer()
}
}
.offset(y: dragOffset)
@@ -398,3 +397,15 @@ private struct ZoomablePhotoView: View {
}
}
}
#Preview {
MediaViewer(
item: MediaViewerItem(
id: "preview",
url: URL(fileURLWithPath: "/tmp/preview-photo.jpg"),
kind: .photo,
title: "IMG_1234.jpg"
),
onClose: {}
)
}
@@ -816,3 +816,74 @@ extension View {
#endif
}
}
#Preview("Входящее") {
MessageBubble(
model: PreviewSupport.model,
message: PreviewSupport.message(),
isSelectionMode: false,
isSelected: false,
onAttachmentTap: {},
onEdit: {},
onReply: {},
onForward: {},
onRetry: {},
onToggleSelection: {},
onBeginSelection: {},
onRetract: {},
onDelete: {},
onReplyTap: { _ in },
onReact: { _ in },
onReactPicker: {}
)
.padding()
}
#Preview("Исходящее") {
MessageBubble(
model: PreviewSupport.model,
message: PreviewSupport.message(
senderJID: "me@example.org",
body: "Отлично! Созвонимся вечером?",
direction: .outgoing,
delivery: .delivered
),
isSelectionMode: false,
isSelected: false,
onAttachmentTap: {},
onEdit: {},
onReply: {},
onForward: {},
onRetry: {},
onToggleSelection: {},
onBeginSelection: {},
onRetract: {},
onDelete: {},
onReplyTap: { _ in },
onReact: { _ in },
onReactPicker: {}
)
.padding()
}
#Preview("Фото") {
MessageBubble(
model: PreviewSupport.model,
message: PreviewSupport.photoMessage(),
isSelectionMode: false,
isSelected: false,
onAttachmentTap: {},
onEdit: {},
onReply: {},
onForward: {},
onRetry: {},
onToggleSelection: {},
onBeginSelection: {},
onRetract: {},
onDelete: {},
onReplyTap: { _ in },
onReact: { _ in },
onReactPicker: {}
)
.padding()
}
@@ -131,3 +131,12 @@ struct PhotoAttachmentPreview: View {
}
}
}
#Preview {
PhotoAttachmentPreview(
model: PreviewSupport.model,
message: PreviewSupport.photoMessage(),
onFallbackTap: {}
)
.padding()
}
@@ -97,3 +97,9 @@ struct RTCVideoRendererView: NSViewRepresentable {
}
}
#endif
#Preview {
RTCVideoRendererView(track: nil)
.frame(width: 280, height: 320)
.background(Color.black)
}
@@ -345,3 +345,27 @@ private struct ReplyThreadMessageRow: View {
return "\(state) \(value)"
}
}
#Preview {
ReplyThreadOverlay(
model: PreviewSupport.model,
rootMessage: PreviewSupport.message(
body: "Кто пойдёт на конференцию?",
timestamp: Date().addingTimeInterval(-3_600)
),
replies: [
PreviewSupport.message(
id: "preview-reply-1",
body: "Я пойду!",
timestamp: Date().addingTimeInterval(-2_400)
),
PreviewSupport.message(
id: "preview-reply-2",
body: "Я тоже, но опоздаю на полчаса",
timestamp: Date().addingTimeInterval(-1_800)
),
],
selectedReplyID: "preview-reply-1",
onDismiss: {}
)
}
@@ -149,3 +149,12 @@ struct VideoAttachmentPreview: View {
}
}
}
#Preview {
VideoAttachmentPreview(
model: PreviewSupport.model,
message: PreviewSupport.videoMessage(),
onFallbackTap: {}
)
.padding()
}
@@ -50,7 +50,7 @@ struct VideoNotePreview: View {
VStack {
Spacer()
HStack {
Spacer()
// Spacer()
Text(durationText)
.font(.caption2.monospacedDigit().weight(.semibold))
.foregroundStyle(.white)
@@ -153,3 +153,12 @@ struct VideoNotePreview: View {
isPlaying.toggle()
}
}
#Preview {
VideoNotePreview(
model: PreviewSupport.model,
message: PreviewSupport.videoNoteMessage(),
onFallbackTap: {}
)
.padding()
}