Files
suixinkan_ios_new/suixinkan/Features/TravelAlbum/Views/WiredTransfer/WiredTransferPhotoPreviewSheet.swift
汉秋 5e620623eb 对齐旅拍相册详情页 Android UI,并修复网格预览与布局问题。
重构相册详情为信息卡片、Tab 筛选、排序、批量删除与底部上传栏;修复网格重叠、禁用按钮蒙层,并支持点击预览大图。同步扩展素材列表 API 与 ViewModel 分页逻辑,并优化有线传图缩略图与传输性能。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 13:53:59 +08:00

59 lines
1.9 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// WiredTransferPhotoPreviewSheet.swift
// suixinkan
//
import SwiftUI
import Kingfisher
/// 线 file:// URL
struct WiredTransferPhotoPreviewSheet: View {
let imageSources: [String]
let startIndex: Int
let onDismiss: () -> Void
@State private var currentIndex: Int
init(imageSources: [String], startIndex: Int, onDismiss: @escaping () -> Void) {
self.imageSources = imageSources
self.startIndex = startIndex
self.onDismiss = onDismiss
let safeIndex = imageSources.isEmpty ? 0 : min(max(startIndex, 0), imageSources.count - 1)
_currentIndex = State(initialValue: safeIndex)
}
var body: some View {
NavigationStack {
TabView(selection: $currentIndex) {
ForEach(Array(imageSources.enumerated()), id: \.offset) { index, source in
previewImage(source)
.tag(index)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.black)
}
}
.tabViewStyle(.page(indexDisplayMode: imageSources.count > 1 ? .automatic : .never))
.background(Color.black.ignoresSafeArea())
.navigationTitle("图片预览")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("关闭", action: onDismiss)
}
}
}
}
@ViewBuilder
private func previewImage(_ source: String) -> some View {
if let url = URL(string: source), !source.isEmpty {
KFImage(url)
.resizable()
.scaledToFit()
} else {
Text("暂无法预览该照片")
.foregroundStyle(.white.opacity(0.8))
}
}
}