feat: 优化自动修图设置与模板网格交互
同页切换修图方式并展开三列模板,复用模板卡片与对比预览,保留草稿和滚动位置,统一卡片与固定底栏样式并补充回归测试。
This commit is contained in:
+17
-25
@@ -2,15 +2,9 @@ import Foundation
|
||||
|
||||
/// 自动修图设置状态,负责加载真实精修模板、单选和配置校验,不直接创建修图任务。
|
||||
final class TravelAlbumAutoRetouchSettingViewModel {
|
||||
/// 设置页当前层级。
|
||||
enum Stage: Sendable, Equatable {
|
||||
case mode
|
||||
case templates
|
||||
}
|
||||
|
||||
let scenicId: Int
|
||||
let startsWithModeSelection: Bool
|
||||
private(set) var stage: Stage
|
||||
/// 是否在模板上方展示修图方式;创建页已选择 AI 时只展示模板。
|
||||
let allowsModeSelection: Bool
|
||||
private(set) var templates: [TravelAlbumAIRetouchTemplate] = []
|
||||
private(set) var selectedTemplateId: Int?
|
||||
private(set) var isEnabled: Bool
|
||||
@@ -23,15 +17,24 @@ final class TravelAlbumAutoRetouchSettingViewModel {
|
||||
init(
|
||||
scenicId: Int,
|
||||
configuration: TravelAlbumAutoRetouchConfiguration,
|
||||
startsWithModeSelection: Bool
|
||||
allowsModeSelection: Bool
|
||||
) {
|
||||
self.scenicId = scenicId
|
||||
self.startsWithModeSelection = startsWithModeSelection
|
||||
self.stage = startsWithModeSelection ? .mode : .templates
|
||||
self.isEnabled = configuration.enabled
|
||||
self.allowsModeSelection = allowsModeSelection
|
||||
self.isEnabled = configuration.enabled || !allowsModeSelection
|
||||
self.selectedTemplateId = configuration.refinedTemplateId
|
||||
}
|
||||
|
||||
/// 关闭自动修图不依赖模板加载;开启时必须选择有效模板。
|
||||
var canConfirm: Bool {
|
||||
!isEnabled || (!isLoading && pendingConfiguration != nil)
|
||||
}
|
||||
|
||||
/// 当前草稿模板名称,用于固定底部的选择摘要。
|
||||
var selectedTemplateName: String? {
|
||||
templates.first { $0.id == selectedTemplateId }?.name
|
||||
}
|
||||
|
||||
/// 当前可提交配置;启用状态必须已经选择服务端模板。
|
||||
var pendingConfiguration: TravelAlbumAutoRetouchConfiguration? {
|
||||
if !isEnabled { return .disabled }
|
||||
@@ -75,14 +78,10 @@ final class TravelAlbumAutoRetouchSettingViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
/// 选择一级修图方式。
|
||||
/// 切换修图方式,保留本次草稿模板以便再次开启;关闭配置提交时仍不携带模板。
|
||||
func selectMode(enabled: Bool) {
|
||||
guard allowsModeSelection else { return }
|
||||
isEnabled = enabled
|
||||
if enabled {
|
||||
stage = .templates
|
||||
} else {
|
||||
selectedTemplateId = nil
|
||||
}
|
||||
notify()
|
||||
}
|
||||
|
||||
@@ -94,12 +93,5 @@ final class TravelAlbumAutoRetouchSettingViewModel {
|
||||
notify()
|
||||
}
|
||||
|
||||
/// 从模板列表返回修图方式层级。
|
||||
func returnToModeSelection() {
|
||||
guard startsWithModeSelection else { return }
|
||||
stage = .mode
|
||||
notify()
|
||||
}
|
||||
|
||||
private func notify() { onStateChange?() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user