Swipe-That_pic/Swipe That Pic/Views/IgnoredPictures.swift

54 lines
1.3 KiB
Swift
Raw Normal View History

2024-07-26 13:16:48 +00:00
//
// ContentView.swift
// Swipe That Pic
//
// Created by Amine Bou on 26/07/2024.
//
import SwiftUI
import SwiftData
import Photos
struct IgnoredPictures: View {
@Environment(\.modelContext) private var modelContext
@Query private var items: [Item]
var body: some View {
NavigationSplitView {
ScrollView {
LazyVGrid(columns: [GridItem(.adaptive(minimum: 200)), GridItem(.adaptive(minimum: 200))], alignment: .leading) {
ForEach(items) { item in
PhotoThumbnailFromStringView(localIdentifier: item.localIdentfier)
}
}
.toolbar {
ToolbarItem {
Button(action: clearItems) {
Label("Clear", systemImage: "bubbles.and.sparkles.fill")
}
}
}
}
} detail : {
Text("Ignored pictures")
}
}
private func clearItems() {
withAnimation {
do {
try modelContext.delete(model: Item.self)
} catch {
print("did not work")
}
}
}
}
#Preview {
ContentView()
.modelContainer(for: Item.self, inMemory: true)
}