Sync previews when clip source changes
This commit is contained in:
@@ -603,6 +603,9 @@ private struct ClipPreviewView: View {
|
|||||||
.onChange(of: clip.id) { _ in
|
.onChange(of: clip.id) { _ in
|
||||||
loadClip()
|
loadClip()
|
||||||
}
|
}
|
||||||
|
.onChange(of: clip.sourcePath) { _ in
|
||||||
|
loadClip()
|
||||||
|
}
|
||||||
.onChange(of: clip.segmentStart) { _ in
|
.onChange(of: clip.segmentStart) { _ in
|
||||||
seekToSegmentStart()
|
seekToSegmentStart()
|
||||||
}
|
}
|
||||||
@@ -708,6 +711,7 @@ private struct ClipVariantPickerView: View {
|
|||||||
|
|
||||||
if let selectedVariant {
|
if let selectedVariant {
|
||||||
VariantPreviewView(variant: selectedVariant)
|
VariantPreviewView(variant: selectedVariant)
|
||||||
|
.id(selectedVariant.sourcePath)
|
||||||
.frame(height: 220)
|
.frame(height: 220)
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 8))
|
.clipShape(RoundedRectangle(cornerRadius: 8))
|
||||||
}
|
}
|
||||||
@@ -745,8 +749,19 @@ private struct ClipVariantPickerView: View {
|
|||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
.onAppear {
|
.onAppear {
|
||||||
selectedVariantID = selectedVariant?.id
|
selectedVariantID = currentVariantID()
|
||||||
}
|
}
|
||||||
|
.onChange(of: clip.id) { _ in
|
||||||
|
selectedVariantID = currentVariantID()
|
||||||
|
}
|
||||||
|
.onChange(of: clip.sourcePath) { _ in
|
||||||
|
selectedVariantID = currentVariantID()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func currentVariantID() -> UUID? {
|
||||||
|
clip.availableVariants.first(where: { $0.sourcePath == clip.sourcePath })?.id
|
||||||
|
?? clip.availableVariants.first?.id
|
||||||
}
|
}
|
||||||
|
|
||||||
private func format(_ value: Double) -> String {
|
private func format(_ value: Double) -> String {
|
||||||
@@ -770,6 +785,9 @@ private struct VariantPreviewView: View {
|
|||||||
.onChange(of: variant.id) { _ in
|
.onChange(of: variant.id) { _ in
|
||||||
loadVariant()
|
loadVariant()
|
||||||
}
|
}
|
||||||
|
.onChange(of: variant.sourcePath) { _ in
|
||||||
|
loadVariant()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func loadVariant() {
|
private func loadVariant() {
|
||||||
|
|||||||
Reference in New Issue
Block a user