add an auto reverses button

This commit is contained in:
leminlimez committed 2025-06-11 22:00:46 -04:00
1 parent b782d6c7a2
commit 1eab5e5476
2 files changed
+19 -1

No files matched your search

@@ -43,6 +43,7 @@ struct LoadInfo: Identifiable, Equatable {
} }
var id = UUID() var id = UUID()
var autoReverses: Bool = false
var loadState: LoadState var loadState: LoadState
} }
@@ -226,7 +227,7 @@ class PosterBoardManager: ObservableObject {
switch video.loadState { switch video.loadState {
case .loaded(let movie): case .loaded(let movie):
do { do {
let newVideo = try VideoHandler.createCaml(from: movie.url, autoReverses: false) let newVideo = try VideoHandler.createCaml(from: movie.url, autoReverses: video.autoReverses)
extList["com.apple.WallpaperKit.CollectionsPoster"]?.append(newVideo) extList["com.apple.WallpaperKit.CollectionsPoster"]?.append(newVideo)
} catch { } catch {
print(error.localizedDescription) print(error.localizedDescription)
@@ -47,6 +47,23 @@ struct VideoView: View {
DeleteButton(video: vid, onDelete: removeVideo), DeleteButton(video: vid, onDelete: removeVideo),
alignment: .topLeading alignment: .topLeading
) )
.overlay(
// Loops Button
Button(action: {
if let index = pbManager.videos.firstIndex(of: vid) {
pbManager.videos[index].autoReverses = !vid.autoReverses
}
}) {
Image(systemName: "arrow.left.arrow.right.circle")
.font(.title)
.foregroundStyle(.black)
.background {
Circle()
.foregroundStyle(vid.autoReverses ? .blue : .white)
}
}.offset(x: 8, y: -8),
alignment: .topTrailing
)
} }
.onDelete(perform: removeVideo) .onDelete(perform: removeVideo)