get all the photo data
- ID
9cf55da- date
2023-06-08 06:42:18+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
3e6e144- message
get all the photo data- changed files
2 files, 37 additions, 7 deletions
Changed files
BlinkReviewer/BlinkReviewer.xcodeproj/project.pbxproj (22546) → BlinkReviewer/BlinkReviewer.xcodeproj/project.pbxproj (22748)
diff --git a/BlinkReviewer/BlinkReviewer.xcodeproj/project.pbxproj b/BlinkReviewer/BlinkReviewer.xcodeproj/project.pbxproj
index 9403922..37293c8 100644
--- a/BlinkReviewer/BlinkReviewer.xcodeproj/project.pbxproj
+++ b/BlinkReviewer/BlinkReviewer.xcodeproj/project.pbxproj
@@ -435,6 +435,7 @@
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
+ INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "This app needs full Photo Library permissions.";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
@@ -460,6 +461,7 @@
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
+ INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "This app needs full Photo Library permissions.";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
BlinkReviewer/BlinkReviewer/ContentView.swift (917) → BlinkReviewer/BlinkReviewer/ContentView.swift (1658)
diff --git a/BlinkReviewer/BlinkReviewer/ContentView.swift b/BlinkReviewer/BlinkReviewer/ContentView.swift
index 09b690c..ee99695 100644
--- a/BlinkReviewer/BlinkReviewer/ContentView.swift
+++ b/BlinkReviewer/BlinkReviewer/ContentView.swift
@@ -6,8 +6,36 @@
//
import SwiftUI
+import Photos
+
+struct AssetData: Codable, Identifiable {
+ var localIdentifier: String
+ var creationDate: String?
+ var isFavorite: Bool
+
+ var id: String {
+ localIdentifier
+ }
+}
struct ContentView: View {
+ var allPhotos: [AssetData] {
+ var photos: [AssetData] = []
+
+ PHAsset.fetchAssets(with: PHAssetMediaType.image, options: nil)
+ .enumerateObjects({ (asset, _, _) in
+ photos.append(
+ AssetData(
+ localIdentifier: asset.localIdentifier,
+ creationDate: asset.creationDate?.ISO8601Format(),
+ isFavorite: asset.isFavorite
+ )
+ )
+ })
+
+ return photos
+ }
+
var body: some View {
VStack {
Divider()
@@ -19,8 +47,8 @@ struct ContentView: View {
.padding()
LazyHStack(spacing: 10) {
- ForEach(0..<100, id: \.self) { index in
- ThumbnailItem(label: "\(index)")
+ ForEach(allPhotos) { photo in
+ ThumbnailItem(label: "\(photo.localIdentifier)")
}
}.padding()
}.frame(height: 100)
@@ -32,8 +60,8 @@ struct ContentView: View {
}
}
-struct ContentView_Previews: PreviewProvider {
- static var previews: some View {
- ContentView()
- }
-}
+//struct ContentView_Previews: PreviewProvider {
+// static var previews: some View {
+// ContentView()
+// }
+//}