Open source CapCut alternative.
TypeScript
fix(ios): the export sheet names the preview for what it is
David Le5ed91b64fb1b
diff --git a/apps/ios/DonkeyKit/Sources/DonkeyKitModels/Projects.swift b/apps/ios/DonkeyKit/Sources/DonkeyKitModels/Projects.swiftindex d222caea..0c2cbd3f 100644--- a/apps/ios/DonkeyKit/Sources/DonkeyKitModels/Projects.swift+++ b/apps/ios/DonkeyKit/Sources/DonkeyKitModels/Projects.swift@@ -2,7 +2,10 @@ import Foundationnonisolated public enum ProjectExport: Equatable, Sendable {case none- case ready(renderedOn: String)+ /// Something is there to play. `isPreview` marks the composited proxy the+ /// editor renders for its own grid: it plays, but it is not the render an+ /// export produces, so anything that hands the file to the user says so.+ case ready(renderedOn: String, isPreview: Bool)}/// A cloud project as the phone shows it: name, duration, a cached thumbnail@@ -94,9 +97,15 @@ public final class ProjectsModel {private func project(for summary: RemoteProject, latest: RemoteExport?, thumbnail: URL?) -> Project {let export: ProjectExport =if let latest {- .ready(renderedOn: latest.modifiedAt.formatted(date: .abbreviated, time: .omitted))+ .ready(+ renderedOn: latest.modifiedAt.formatted(date: .abbreviated, time: .omitted),+ isPreview: false+ )} else if summary.hasPreview {- .ready(renderedOn: summary.updatedAt.formatted(date: .abbreviated, time: .omitted))+ .ready(+ renderedOn: summary.updatedAt.formatted(date: .abbreviated, time: .omitted),+ isPreview: true+ )} else {.none}diff --git a/apps/ios/DonkeyKit/Sources/DonkeyKitUI/ProjectsScreen.swift b/apps/ios/DonkeyKit/Sources/DonkeyKitUI/ProjectsScreen.swiftindex 5eeeb3c1..bb3fd5da 100644--- a/apps/ios/DonkeyKit/Sources/DonkeyKitUI/ProjectsScreen.swift+++ b/apps/ios/DonkeyKit/Sources/DonkeyKitUI/ProjectsScreen.swift@@ -55,7 +55,7 @@ struct ProjectCard: View {var body: some View {Group {switch project.export {- case .ready(let renderedOn):+ case .ready(let renderedOn, _):Button(action: onPlay) {MediaTile(ratio: 9 / 13) {if let thumbnail = project.thumbnail,@@ -279,10 +279,14 @@ struct ProjectPlayerView: View {}.buttonStyle(.borderedProminent).controlSize(.large)- Text("The video downloads to this device and lands in your photo library.")- .font(.caption)- .foregroundStyle(.secondary)- .multilineTextAlignment(.center)+ Text(+ playingPreview+ ? "This project has no export yet, so what saves is the preview the editor renders for itself. Export it in Donkey Cut for a full-quality file."+ : "The video downloads to this device and lands in your photo library."+ )+ .font(.caption)+ .foregroundStyle(.secondary)+ .multilineTextAlignment(.center)}.padding(20).navigationTitle("Export")@@ -326,7 +330,14 @@ struct ProjectPlayerView: View {}private var choices: [ExportChoice] {- ExportChoice.all(for: source)+ ExportChoice.all(for: source, isPreview: playingPreview)+ }++ /// Whether what is streaming is the editor's own composited proxy rather+ /// than a render someone exported.+ private var playingPreview: Bool {+ if case .ready(_, let isPreview) = project.export { return isPreview }+ return false}private var working: Bool {@@ -474,9 +485,20 @@ struct ExportChoice: Identifiable, Equatable, Sendable {preset: nil)+ /// What stands in for the original when the project has never been+ /// exported: the proxy, named as one.+ static let preview = ExportChoice(+ id: "original",+ label: "Preview · not an export",+ note: "what the editor's grid plays",+ shortSide: nil,+ preset: nil+ )+/// Original first, then every size smaller than the render — the same/// order the editor's dialog lists, largest to smallest.- static func all(for source: SourceVideo?) -> [ExportChoice] {+ static func all(for source: SourceVideo?, isPreview: Bool = false) -> [ExportChoice] {+ let full = isPreview ? preview : originallet steps = [ExportChoice(id: "hd",@@ -493,8 +515,8 @@ struct ExportChoice: Identifiable, Equatable, Sendable {preset: AVAssetExportPreset1280x720),]- guard let source else { return [original] }- return [original] + steps.filter { step in+ guard let source else { return [full] }+ return [full] + steps.filter { step inguard let side = step.shortSide else { return false }return source.shortSide > side}