Skip to main content

remove an unnecessary VStack

ID
0b26311
date
2023-06-09 21:20:37+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
cd74515
message
remove an unnecessary VStack
changed files
2 files, 40 additions, 46 deletions

Changed files

BlinkReviewer/BlinkReviewer.xcodeproj/project.pbxproj (29124) → BlinkReviewer/BlinkReviewer.xcodeproj/project.pbxproj (28688)

diff --git a/BlinkReviewer/BlinkReviewer.xcodeproj/project.pbxproj b/BlinkReviewer/BlinkReviewer.xcodeproj/project.pbxproj
index 339bed3..7d7b55e 100644
--- a/BlinkReviewer/BlinkReviewer.xcodeproj/project.pbxproj
+++ b/BlinkReviewer/BlinkReviewer.xcodeproj/project.pbxproj
@@ -9,7 +9,6 @@
 /* Begin PBXBuildFile section */
 		940331732A336B5100200C5D /* DeferredRendering.swift in Sources */ = {isa = PBXBuildFile; fileRef = 940331722A336B5100200C5D /* DeferredRendering.swift */; };
 		94C5FFF22A33ADD4004ADDF5 /* PHFetchResultCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C5FFF12A33ADD4004ADDF5 /* PHFetchResultCollection.swift */; };
-		94C5FFF42A33B09B004ADDF5 /* SwiftUIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C5FFF32A33B09B004ADDF5 /* SwiftUIView.swift */; };
 		94C5FFF62A33B698004ADDF5 /* PHAssetHStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C5FFF52A33B698004ADDF5 /* PHAssetHStack.swift */; };
 		94D2C8B92A320E6F00BEE15B /* ReviewState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94D2C8B82A320E6F00BEE15B /* ReviewState.swift */; };
 		94D2C8BD2A32796500BEE15B /* AlbumHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94D2C8BC2A32796500BEE15B /* AlbumHelpers.swift */; };
@@ -50,7 +49,6 @@
 /* Begin PBXFileReference section */
 		940331722A336B5100200C5D /* DeferredRendering.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeferredRendering.swift; sourceTree = "<group>"; };
 		94C5FFF12A33ADD4004ADDF5 /* PHFetchResultCollection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PHFetchResultCollection.swift; sourceTree = "<group>"; };
-		94C5FFF32A33B09B004ADDF5 /* SwiftUIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIView.swift; sourceTree = "<group>"; };
 		94C5FFF52A33B698004ADDF5 /* PHAssetHStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PHAssetHStack.swift; sourceTree = "<group>"; };
 		94D2C8B82A320E6F00BEE15B /* ReviewState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewState.swift; sourceTree = "<group>"; };
 		94D2C8BC2A32796500BEE15B /* AlbumHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumHelpers.swift; sourceTree = "<group>"; };
@@ -187,7 +185,6 @@
 				94D751212A31BD8E005859E7 /* PhotoReviewer.swift */,
 				94D7512F2A31DC4A005859E7 /* ThumbnailList.swift */,
 				94D2C8C02A32FCE300BEE15B /* PHAssetImage.swift */,
-				94C5FFF32A33B09B004ADDF5 /* SwiftUIView.swift */,
 				94F7E39D2A331A9E00763DB9 /* Statistics.swift */,
 			);
 			path = Views;
@@ -348,7 +345,6 @@
 				94D2C8B92A320E6F00BEE15B /* ReviewState.swift in Sources */,
 				94F7E39E2A331A9E00763DB9 /* Statistics.swift in Sources */,
 				94D2C8C12A32FCE300BEE15B /* PHAssetImage.swift in Sources */,
-				94C5FFF42A33B09B004ADDF5 /* SwiftUIView.swift in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

BlinkReviewer/BlinkReviewer/Views/ThumbnailList.swift (3271) → BlinkReviewer/BlinkReviewer/Views/ThumbnailList.swift (3016)

diff --git a/BlinkReviewer/BlinkReviewer/Views/ThumbnailList.swift b/BlinkReviewer/BlinkReviewer/Views/ThumbnailList.swift
index 0f4d9bd..ca7830f 100644
--- a/BlinkReviewer/BlinkReviewer/Views/ThumbnailList.swift
+++ b/BlinkReviewer/BlinkReviewer/Views/ThumbnailList.swift
@@ -19,52 +19,50 @@ struct ThumbnailList: View {
     }
     
     var body: some View {
-        VStack {
-            ScrollViewReader { proxy in
-                ScrollView(.horizontal) {
-                    LazyHStack(spacing: 5) {
-                        // TODO: placeholder images for start/end
-                        
-                        // Implementation note: we use the localIdentifier rather than the
-                        // array index as the id here, because the app gets way slower if
-                        // you use the array index -- it tries to regenerate a bunch of
-                        // the thumbnails every time you change position.
-                        
-                        // wassup with reversing???? lazy loading innit
-                        ForEach(Array(zip(assets.indices, assets)), id: \.1.localIdentifier) { index, asset in
-                            //                Text("asset \(index)")
-                            ThumbnailImage(
-                                thumbnail: PHAssetImage(asset, size: CGSize(width: 70, height: 70), deliveryMode: .opportunistic),
-                                state: photosLibrary.state(for: asset),
-                                isFavorite: asset.isFavorite,
-                                isSelected: photosLibrary.assets2.count - 1 - index == selectedAssetIndex
-                            ).onTapGesture {
-                                selectedAssetIndex = photosLibrary.assets2.count - 1 - index
-                            }
+        ScrollViewReader { proxy in
+            ScrollView(.horizontal) {
+                LazyHStack(spacing: 5) {
+                    // TODO: placeholder images for start/end
+                    
+                    // Implementation note: we use the localIdentifier rather than the
+                    // array index as the id here, because the app gets way slower if
+                    // you use the array index -- it tries to regenerate a bunch of
+                    // the thumbnails every time you change position.
+                    
+                    // wassup with reversing???? lazy loading innit
+                    ForEach(Array(zip(assets.indices, assets)), id: \.1.localIdentifier) { index, asset in
+                        //                Text("asset \(index)")
+                        ThumbnailImage(
+                            thumbnail: PHAssetImage(asset, size: CGSize(width: 70, height: 70), deliveryMode: .opportunistic),
+                            state: photosLibrary.state(for: asset),
+                            isFavorite: asset.isFavorite,
+                            isSelected: photosLibrary.assets2.count - 1 - index == selectedAssetIndex
+                        ).onTapGesture {
+                            selectedAssetIndex = photosLibrary.assets2.count - 1 - index
                         }
-                        
-                        // Note: these two uses of RTL direction are a way to get the LazyHStack
-                        // to start on the right-hand side (i.e. the newest image) without loading
-                        // everything else in the view.
-                        //
-                        // I suspect this may get easier with the new scrollPosition API, coming
-                        // in the 2023 OS releases.  TODO: Investigate this new API when available.
-                        //
-                        // See https://developer.apple.com/documentation/swiftui/view/scrollposition(initialanchor:)
-                            .flipsForRightToLeftLayoutDirection(true)
-                            .environment(\.layoutDirection, .rightToLeft)
-                        }.padding()
-                }
-                    .frame(height: 90)
+                    }
+                    
+                    // Note: these two uses of RTL direction are a way to get the LazyHStack
+                    // to start on the right-hand side (i.e. the newest image) without loading
+                    // everything else in the view.
+                    //
+                    // I suspect this may get easier with the new scrollPosition API, coming
+                    // in the 2023 OS releases.  TODO: Investigate this new API when available.
+                    //
+                    // See https://developer.apple.com/documentation/swiftui/view/scrollposition(initialanchor:)
                     .flipsForRightToLeftLayoutDirection(true)
                     .environment(\.layoutDirection, .rightToLeft)
-                    .onChange(of: selectedAssetIndex, perform: { newIndex in
-                        // fires on change + initial run
-                        withAnimation {
-                            proxy.scrollTo(assets[photosLibrary.assets2.count - 1 - selectedAssetIndex].localIdentifier, anchor: .center)
-                        }
-                    })
+                }.padding()
             }
+            .frame(height: 90)
+            .flipsForRightToLeftLayoutDirection(true)
+            .environment(\.layoutDirection, .rightToLeft)
+            .onChange(of: selectedAssetIndex, perform: { newIndex in
+                // fires on change + initial run
+                withAnimation {
+                    proxy.scrollTo(assets[photosLibrary.assets2.count - 1 - selectedAssetIndex].localIdentifier, anchor: .center)
+                }
+            })
         }
     }
 }