完善任务流程、键盘适配与页面交互
This commit is contained in:
@ -57,11 +57,7 @@ final class TaskAddViewModel {
|
||||
/// 更新自定义优先级小时文本。
|
||||
func updateCustomUrgentHourText(_ text: String) {
|
||||
let trimmed = text.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
guard let hour = Int(trimmed), hour > 0 else {
|
||||
urgentHour = 1
|
||||
notifyStateChange()
|
||||
return
|
||||
}
|
||||
guard let hour = Int(trimmed), hour > 0 else { return }
|
||||
urgentHour = hour
|
||||
notifyStateChange()
|
||||
}
|
||||
@ -117,13 +113,38 @@ final class TaskAddViewModel {
|
||||
notifyStateChange()
|
||||
}
|
||||
|
||||
/// 本地文件读取完成后同步真实文件名与预览图。
|
||||
func prepareUpload(uploadTaskId: String, fileName: String, localPreviewData: Data?) {
|
||||
selectedFiles = selectedFiles.map { item in
|
||||
guard item.uploadTaskId == uploadTaskId else { return item }
|
||||
var updated = item
|
||||
updated.uploadFileName = fileName
|
||||
updated.localPreviewData = localPreviewData
|
||||
return updated
|
||||
}
|
||||
notifyStateChange()
|
||||
}
|
||||
|
||||
/// 上传成功后更新文件 URL。
|
||||
func markUploadSucceeded(uploadTaskId: String, fileURL: String, coverURL: String? = nil, autoRemarkWhenSingle: Bool) {
|
||||
func markUploadSucceeded(
|
||||
uploadTaskId: String,
|
||||
fileURL: String,
|
||||
fileName: String? = nil,
|
||||
coverURL: String? = nil,
|
||||
localPreviewData: Data? = nil,
|
||||
autoRemarkWhenSingle: Bool
|
||||
) {
|
||||
selectedFiles = selectedFiles.map { item in
|
||||
guard item.uploadTaskId == uploadTaskId else { return item }
|
||||
var updated = item
|
||||
updated.uploadFileUrl = fileURL
|
||||
if let fileName, !fileName.isEmpty {
|
||||
updated.uploadFileName = fileName
|
||||
}
|
||||
updated.uploadCoverUrl = coverURL
|
||||
if let localPreviewData {
|
||||
updated.localPreviewData = localPreviewData
|
||||
}
|
||||
updated.isUploading = false
|
||||
updated.uploadProgress = 100
|
||||
return updated
|
||||
|
||||
Reference in New Issue
Block a user