完善景区排队设置页与全局按钮配置迁移。
重构排队设置与变更日志交互,补充 Overlay 与资源,并将多页面主操作按钮统一到 UIButton Configuration,同步更新相关单元测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -317,7 +317,7 @@ final class TaskAddViewController: BaseViewController {
|
||||
let uploadTaskId = UUID().uuidString.replacingOccurrences(of: "-", with: "")
|
||||
viewModel.addUploadPlaceholder(
|
||||
fileName: TaskMediaLoader.suggestedFileName(
|
||||
from: result.itemProvider,
|
||||
from: result.itemProvider.suggestedName,
|
||||
fallback: "upload_\(uploadTaskId).\(isImage ? "jpg" : "mp4")"
|
||||
),
|
||||
fileType: isImage ? 2 : 1,
|
||||
@ -472,8 +472,8 @@ enum TaskMediaLoader {
|
||||
}
|
||||
|
||||
/// 优先使用系统相册提供的原文件名。
|
||||
static func suggestedFileName(from provider: NSItemProvider, fallback: String) -> String {
|
||||
guard let suggestedName = provider.suggestedName?.trimmingCharacters(in: .whitespacesAndNewlines),
|
||||
static func suggestedFileName(from suggestedFileName: String?, fallback: String) -> String {
|
||||
guard let suggestedName = suggestedFileName?.trimmingCharacters(in: .whitespacesAndNewlines),
|
||||
!suggestedName.isEmpty else {
|
||||
return fallback
|
||||
}
|
||||
@ -493,7 +493,8 @@ enum TaskMediaLoader {
|
||||
}
|
||||
|
||||
private static func loadImage(from provider: NSItemProvider) async throws -> Payload {
|
||||
try await withCheckedThrowingContinuation { continuation in
|
||||
let suggestedName = provider.suggestedName
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
let identifier = provider.registeredTypeIdentifiers.first {
|
||||
UTType($0)?.conforms(to: .image) == true
|
||||
} ?? UTType.image.identifier
|
||||
@ -508,7 +509,7 @@ enum TaskMediaLoader {
|
||||
}
|
||||
let ext = url.pathExtension.isEmpty ? "jpg" : url.pathExtension
|
||||
let fallback = "image_\(UUID().uuidString).\(ext)"
|
||||
let fileName = suggestedFileName(from: provider, fallback: fallback)
|
||||
let fileName = suggestedFileName(from: suggestedName, fallback: fallback)
|
||||
let previewData = UIImage(data: data).flatMap(makePreviewData(from:))
|
||||
continuation.resume(returning: Payload(data: data, fileName: fileName, previewData: previewData))
|
||||
}
|
||||
@ -517,6 +518,7 @@ enum TaskMediaLoader {
|
||||
|
||||
private static func loadVideo(from provider: NSItemProvider) async throws -> Payload {
|
||||
let typeIdentifier = UTType.movie.identifier
|
||||
let suggestedName = provider.suggestedName
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
provider.loadFileRepresentation(forTypeIdentifier: typeIdentifier) { url, error in
|
||||
if let error {
|
||||
@ -529,7 +531,7 @@ enum TaskMediaLoader {
|
||||
}
|
||||
let ext = url.pathExtension.isEmpty ? "mp4" : url.pathExtension
|
||||
let fallback = "video_\(UUID().uuidString).\(ext)"
|
||||
let fileName = suggestedFileName(from: provider, fallback: fallback)
|
||||
let fileName = suggestedFileName(from: suggestedName, fallback: fallback)
|
||||
continuation.resume(returning: Payload(
|
||||
data: data,
|
||||
fileName: fileName,
|
||||
|
||||
Reference in New Issue
Block a user