diff --git a/ios/WatchRunner Watch App/Views/AttachmentView.swift b/ios/WatchRunner Watch App/Views/AttachmentView.swift index 2f7f49c3..cbd50396 100644 --- a/ios/WatchRunner Watch App/Views/AttachmentView.swift +++ b/ios/WatchRunner Watch App/Views/AttachmentView.swift @@ -46,26 +46,34 @@ struct AttachmentView: View { } } else if mimeType.starts(with: "video") { if let serverUrl = appState.serverUrl, let videoUrl = getAttachmentUrl(for: attachment.id, serverUrl: serverUrl) { - let thumbnailUrl = videoUrl.appendingPathComponent("thumbnail") // Construct thumbnail URL NavigationLink(destination: VideoPlayerView(videoUrl: videoUrl)) { - AsyncImage(url: thumbnailUrl) { phase in - if let image = phase.image { + if imageLoader.isLoading { + ProgressView() + } else if let image = imageLoader.image { + ZStack { image .resizable() .aspectRatio(contentMode: .fit) .frame(maxWidth: .infinity) .cornerRadius(8) - } else if phase.error != nil { - Image(systemName: "play.rectangle.fill") // Placeholder for video thumbnail + + Image(systemName: "play.circle.fill") .resizable() - .aspectRatio(contentMode: .fit) - .frame(maxWidth: .infinity) - .foregroundColor(.gray) - .cornerRadius(8) - } else { - ProgressView() - .cornerRadius(8) + .scaledToFit() + .frame(width: 36, height: 36) + .foregroundColor(.white) + .shadow(color: .black.opacity(0.6), radius: 4, x: 0, y: 2) } + } else if imageLoader.errorMessage != nil { + Image(systemName: "play.rectangle.fill") + .resizable() + .aspectRatio(contentMode: .fit) + .frame(maxWidth: .infinity) + .foregroundColor(.gray) + .cornerRadius(8) + } else { + ProgressView() + .cornerRadius(8) } } .buttonStyle(PlainButtonStyle()) @@ -90,6 +98,11 @@ struct AttachmentView: View { if attachment.mimeType?.starts(with: "image") == true { await imageLoader.loadImage(from: attachmentUrl, token: token) } + if attachment.mimeType?.starts(with: "video") == true { + let thumbnailUrl = attachmentUrl + .appending(queryItems: [URLQueryItem(name: "thumbnail", value: "true")]) // Construct thumbnail URL + await imageLoader.loadImage(from: thumbnailUrl, token: token) + } } } } diff --git a/ios/WatchRunner Watch App/Views/PostViews.swift b/ios/WatchRunner Watch App/Views/PostViews.swift index a4971ef7..726b40e3 100644 --- a/ios/WatchRunner Watch App/Views/PostViews.swift +++ b/ios/WatchRunner Watch App/Views/PostViews.swift @@ -82,27 +82,25 @@ struct PostDetailView: View { ScrollView { VStack(alignment: .leading, spacing: 8) { HStack { - if let serverUrl = appState.serverUrl, let pictureId = post.publisher.picture?.id { - if publisherImageLoader.isLoading { - ProgressView() - .frame(width: 32, height: 32) - } else if let image = publisherImageLoader.image { - image - .resizable() - .frame(width: 32, height: 32) - .clipShape(Circle()) - } else if let errorMessage = publisherImageLoader.errorMessage { - Text("Failed: \(errorMessage)") - .font(.caption) - .foregroundColor(.red) - .frame(width: 32, height: 32) - } else { - Image(systemName: "person.circle.fill") - .resizable() - .frame(width: 32, height: 32) - .clipShape(Circle()) - .foregroundColor(.gray) - } + if publisherImageLoader.isLoading { + ProgressView() + .frame(width: 32, height: 32) + } else if let image = publisherImageLoader.image { + image + .resizable() + .frame(width: 32, height: 32) + .clipShape(Circle()) + } else if let errorMessage = publisherImageLoader.errorMessage { + Text("Failed: \(errorMessage)") + .font(.caption) + .foregroundColor(.red) + .frame(width: 32, height: 32) + } else { + Image(systemName: "person.circle.fill") + .resizable() + .frame(width: 32, height: 32) + .clipShape(Circle()) + .foregroundColor(.gray) } Text("@\(post.publisher.name)") .font(.headline) @@ -138,7 +136,7 @@ struct PostDetailView: View { ForEach(post.tags) { tag in Text("#\(tag.name ?? tag.slug)") .font(.caption) - .padding(.horizontal, 6) + .padding(.horizontal, 8) .padding(.vertical, 3) .background(Capsule().fill(Color.accentColor.opacity(0.2))) .cornerRadius(5) @@ -147,6 +145,7 @@ struct PostDetailView: View { } } .padding() + .frame(width: .infinity) } .navigationTitle("Post") }