removing videos from selector

This commit is contained in:
leminlimez committed 2025-06-11 21:43:30 -04:00
1 parent ef444f7c5c
commit 5268d31581
2 files changed
+44 -1

No files matched your search

@@ -37,7 +37,11 @@ enum LoadState {
case unknown, loading, loaded(Movie), failed case unknown, loading, loaded(Movie), failed
} }
struct LoadInfo: Identifiable { struct LoadInfo: Identifiable, Equatable {
static func == (lhs: LoadInfo, rhs: LoadInfo) -> Bool {
lhs.id == rhs.id
}
var id = UUID() var id = UUID()
var loadState: LoadState var loadState: LoadState
} }
@@ -42,7 +42,13 @@ struct VideoView: View {
RoundedRectangle(cornerRadius: 24) RoundedRectangle(cornerRadius: 24)
.stroke(.gray, lineWidth: 4) .stroke(.gray, lineWidth: 4)
} }
.overlay(
// Delete Button
DeleteButton(video: vid, onDelete: removeVideo),
alignment: .topLeading
)
} }
.onDelete(perform: removeVideo)
// MARK: Select Photo Option // MARK: Select Photo Option
if selectedVideo == nil { if selectedVideo == nil {
@@ -99,4 +105,37 @@ struct VideoView: View {
} }
} }
} }
func removeVideo(at offsets: IndexSet) {
withAnimation {
pbManager.videos.remove(atOffsets: offsets)
}
}
}
struct DeleteButton: View {
@Environment(\.editMode) var editMode
let video: LoadInfo
@ObservedObject var pbManager = PosterBoardManager.shared
let onDelete: (IndexSet) -> ()
var body: some View {
VStack {
Button(action: {
if let index = pbManager.videos.firstIndex(of: video) {
self.onDelete(IndexSet(integer: index))
}
}) {
Image(systemName: "minus.circle")
.foregroundStyle(.black)
.font(.title2)
.background {
Circle()
.foregroundStyle(.white)
}
}
.offset(x: -8, y: -8)
}
}
} }