90 lines
3.0 KiB
Swift
90 lines
3.0 KiB
Swift
//
|
|
// ScenicPromotionMaterialPreviewView.swift
|
|
// suixinkan
|
|
//
|
|
// Created by Codex on 2026/7/2.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
/// 设置页素材预览视图。
|
|
struct ScenicPromotionMaterialPreviewView: View {
|
|
let material: ScenicPromotionManagedMaterial
|
|
|
|
var body: some View {
|
|
ScrollView {
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
ZStack {
|
|
Image(material.assetName)
|
|
.resizable()
|
|
.scaledToFill()
|
|
.frame(height: 280)
|
|
.frame(maxWidth: .infinity)
|
|
.clipped()
|
|
|
|
if material.kind == .video {
|
|
Image(systemName: "play.fill")
|
|
.font(.system(size: 34, weight: .bold))
|
|
.foregroundStyle(.white)
|
|
.frame(width: 76, height: 76)
|
|
.background(.black.opacity(0.36), in: Circle())
|
|
.overlay(Circle().stroke(.white, lineWidth: 3))
|
|
}
|
|
}
|
|
.clipShape(RoundedRectangle(cornerRadius: 18))
|
|
|
|
VStack(alignment: .leading, spacing: 10) {
|
|
Text(material.title)
|
|
.font(.system(size: 22, weight: .bold))
|
|
.foregroundStyle(AppDesign.textPrimary)
|
|
Text(material.subtitle)
|
|
.font(.system(size: 14, weight: .medium))
|
|
.foregroundStyle(AppDesign.textSecondary)
|
|
|
|
Divider()
|
|
|
|
ScenicPromotionMaterialPreviewInfoRow(title: "素材类型", value: material.kind.shortTitle)
|
|
ScenicPromotionMaterialPreviewInfoRow(title: "上传时间", value: material.createdAt)
|
|
if let duration = material.duration {
|
|
ScenicPromotionMaterialPreviewInfoRow(title: "视频时长", value: duration)
|
|
}
|
|
}
|
|
.padding(16)
|
|
.background(.white, in: RoundedRectangle(cornerRadius: 16))
|
|
}
|
|
.padding(16)
|
|
}
|
|
.background(AppDesign.background.ignoresSafeArea())
|
|
.navigationTitle(material.kind == .video ? "视频预览" : "图片预览")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
}
|
|
}
|
|
|
|
/// 素材预览详情中的单行字段。
|
|
struct ScenicPromotionMaterialPreviewInfoRow: View {
|
|
let title: String
|
|
let value: String
|
|
|
|
var body: some View {
|
|
HStack {
|
|
Text(title)
|
|
.font(.system(size: 14, weight: .medium))
|
|
.foregroundStyle(AppDesign.textSecondary)
|
|
Spacer()
|
|
Text(value)
|
|
.font(.system(size: 14, weight: .bold))
|
|
.foregroundStyle(AppDesign.textPrimary)
|
|
}
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
#Preview("视频预览") {
|
|
NavigationStack {
|
|
ScenicPromotionMaterialPreviewView(
|
|
material: ScenicPromotionPreviewSupport.sampleManagedMaterial
|
|
)
|
|
}
|
|
}
|
|
#endif
|