├── CollectionThing.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── CollectionThing ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ └── LaunchScreen.storyboard ├── ContentView.swift ├── Info.plist ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json └── SceneDelegate.swift ├── CollectionThingMac ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ └── Main.storyboard ├── CollectionThingMac.entitlements ├── Info.plist └── Preview Content │ └── Preview Assets.xcassets │ └── Contents.json └── README.md /CollectionThing.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 83060F432381FE2000FDF0AD /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83060F422381FE2000FDF0AD /* AppDelegate.swift */; }; 11 | 83060F452381FE2000FDF0AD /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83060F442381FE2000FDF0AD /* SceneDelegate.swift */; }; 12 | 83060F472381FE2000FDF0AD /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83060F462381FE2000FDF0AD /* ContentView.swift */; }; 13 | 83060F492381FE2200FDF0AD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 83060F482381FE2200FDF0AD /* Assets.xcassets */; }; 14 | 83060F4C2381FE2200FDF0AD /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 83060F4B2381FE2200FDF0AD /* Preview Assets.xcassets */; }; 15 | 83060F4F2381FE2200FDF0AD /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 83060F4D2381FE2200FDF0AD /* LaunchScreen.storyboard */; }; 16 | 83A72CF02384CA9800C1AB7F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83A72CEF2384CA9800C1AB7F /* AppDelegate.swift */; }; 17 | 83A72CF42384CA9900C1AB7F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 83A72CF32384CA9900C1AB7F /* Assets.xcassets */; }; 18 | 83A72CF72384CA9900C1AB7F /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 83A72CF62384CA9900C1AB7F /* Preview Assets.xcassets */; }; 19 | 83A72CFA2384CA9900C1AB7F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 83A72CF82384CA9900C1AB7F /* Main.storyboard */; }; 20 | 83A72D002384CAC700C1AB7F /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83060F462381FE2000FDF0AD /* ContentView.swift */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | 83060F3F2381FE2000FDF0AD /* CollectionThing.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CollectionThing.app; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | 83060F422381FE2000FDF0AD /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 26 | 83060F442381FE2000FDF0AD /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 27 | 83060F462381FE2000FDF0AD /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 28 | 83060F482381FE2200FDF0AD /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 29 | 83060F4B2381FE2200FDF0AD /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 30 | 83060F4E2381FE2200FDF0AD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 31 | 83060F502381FE2200FDF0AD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | 83A72CED2384CA9800C1AB7F /* CollectionThingMac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CollectionThingMac.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | 83A72CEF2384CA9800C1AB7F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 34 | 83A72CF32384CA9900C1AB7F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 35 | 83A72CF62384CA9900C1AB7F /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 36 | 83A72CF92384CA9900C1AB7F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 37 | 83A72CFB2384CA9900C1AB7F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | 83A72CFC2384CA9900C1AB7F /* CollectionThingMac.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = CollectionThingMac.entitlements; sourceTree = ""; }; 39 | 83BEA7DE2384A0BE00AB1818 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 40 | /* End PBXFileReference section */ 41 | 42 | /* Begin PBXFrameworksBuildPhase section */ 43 | 83060F3C2381FE2000FDF0AD /* Frameworks */ = { 44 | isa = PBXFrameworksBuildPhase; 45 | buildActionMask = 2147483647; 46 | files = ( 47 | ); 48 | runOnlyForDeploymentPostprocessing = 0; 49 | }; 50 | 83A72CEA2384CA9800C1AB7F /* Frameworks */ = { 51 | isa = PBXFrameworksBuildPhase; 52 | buildActionMask = 2147483647; 53 | files = ( 54 | ); 55 | runOnlyForDeploymentPostprocessing = 0; 56 | }; 57 | /* End PBXFrameworksBuildPhase section */ 58 | 59 | /* Begin PBXGroup section */ 60 | 83060F362381FE2000FDF0AD = { 61 | isa = PBXGroup; 62 | children = ( 63 | 83BEA7DE2384A0BE00AB1818 /* README.md */, 64 | 83060F412381FE2000FDF0AD /* CollectionThing */, 65 | 83A72CEE2384CA9800C1AB7F /* CollectionThingMac */, 66 | 83060F402381FE2000FDF0AD /* Products */, 67 | ); 68 | sourceTree = ""; 69 | }; 70 | 83060F402381FE2000FDF0AD /* Products */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | 83060F3F2381FE2000FDF0AD /* CollectionThing.app */, 74 | 83A72CED2384CA9800C1AB7F /* CollectionThingMac.app */, 75 | ); 76 | name = Products; 77 | sourceTree = ""; 78 | }; 79 | 83060F412381FE2000FDF0AD /* CollectionThing */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 83060F422381FE2000FDF0AD /* AppDelegate.swift */, 83 | 83060F442381FE2000FDF0AD /* SceneDelegate.swift */, 84 | 83060F462381FE2000FDF0AD /* ContentView.swift */, 85 | 83060F482381FE2200FDF0AD /* Assets.xcassets */, 86 | 83060F4D2381FE2200FDF0AD /* LaunchScreen.storyboard */, 87 | 83060F502381FE2200FDF0AD /* Info.plist */, 88 | 83060F4A2381FE2200FDF0AD /* Preview Content */, 89 | ); 90 | path = CollectionThing; 91 | sourceTree = ""; 92 | }; 93 | 83060F4A2381FE2200FDF0AD /* Preview Content */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 83060F4B2381FE2200FDF0AD /* Preview Assets.xcassets */, 97 | ); 98 | path = "Preview Content"; 99 | sourceTree = ""; 100 | }; 101 | 83A72CEE2384CA9800C1AB7F /* CollectionThingMac */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 83A72CEF2384CA9800C1AB7F /* AppDelegate.swift */, 105 | 83A72CF32384CA9900C1AB7F /* Assets.xcassets */, 106 | 83A72CF82384CA9900C1AB7F /* Main.storyboard */, 107 | 83A72CFB2384CA9900C1AB7F /* Info.plist */, 108 | 83A72CFC2384CA9900C1AB7F /* CollectionThingMac.entitlements */, 109 | 83A72CF52384CA9900C1AB7F /* Preview Content */, 110 | ); 111 | path = CollectionThingMac; 112 | sourceTree = ""; 113 | }; 114 | 83A72CF52384CA9900C1AB7F /* Preview Content */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | 83A72CF62384CA9900C1AB7F /* Preview Assets.xcassets */, 118 | ); 119 | path = "Preview Content"; 120 | sourceTree = ""; 121 | }; 122 | /* End PBXGroup section */ 123 | 124 | /* Begin PBXNativeTarget section */ 125 | 83060F3E2381FE2000FDF0AD /* CollectionThing */ = { 126 | isa = PBXNativeTarget; 127 | buildConfigurationList = 83060F532381FE2200FDF0AD /* Build configuration list for PBXNativeTarget "CollectionThing" */; 128 | buildPhases = ( 129 | 83060F3B2381FE2000FDF0AD /* Sources */, 130 | 83060F3C2381FE2000FDF0AD /* Frameworks */, 131 | 83060F3D2381FE2000FDF0AD /* Resources */, 132 | ); 133 | buildRules = ( 134 | ); 135 | dependencies = ( 136 | ); 137 | name = CollectionThing; 138 | productName = CollectionThing; 139 | productReference = 83060F3F2381FE2000FDF0AD /* CollectionThing.app */; 140 | productType = "com.apple.product-type.application"; 141 | }; 142 | 83A72CEC2384CA9800C1AB7F /* CollectionThingMac */ = { 143 | isa = PBXNativeTarget; 144 | buildConfigurationList = 83A72CFF2384CA9900C1AB7F /* Build configuration list for PBXNativeTarget "CollectionThingMac" */; 145 | buildPhases = ( 146 | 83A72CE92384CA9800C1AB7F /* Sources */, 147 | 83A72CEA2384CA9800C1AB7F /* Frameworks */, 148 | 83A72CEB2384CA9800C1AB7F /* Resources */, 149 | ); 150 | buildRules = ( 151 | ); 152 | dependencies = ( 153 | ); 154 | name = CollectionThingMac; 155 | productName = CollectionThingMac; 156 | productReference = 83A72CED2384CA9800C1AB7F /* CollectionThingMac.app */; 157 | productType = "com.apple.product-type.application"; 158 | }; 159 | /* End PBXNativeTarget section */ 160 | 161 | /* Begin PBXProject section */ 162 | 83060F372381FE2000FDF0AD /* Project object */ = { 163 | isa = PBXProject; 164 | attributes = { 165 | LastSwiftUpdateCheck = 1130; 166 | LastUpgradeCheck = 1130; 167 | ORGANIZATIONNAME = "Christopher Liscio"; 168 | TargetAttributes = { 169 | 83060F3E2381FE2000FDF0AD = { 170 | CreatedOnToolsVersion = 11.3; 171 | }; 172 | 83A72CEC2384CA9800C1AB7F = { 173 | CreatedOnToolsVersion = 11.3; 174 | }; 175 | }; 176 | }; 177 | buildConfigurationList = 83060F3A2381FE2000FDF0AD /* Build configuration list for PBXProject "CollectionThing" */; 178 | compatibilityVersion = "Xcode 9.3"; 179 | developmentRegion = en; 180 | hasScannedForEncodings = 0; 181 | knownRegions = ( 182 | en, 183 | Base, 184 | ); 185 | mainGroup = 83060F362381FE2000FDF0AD; 186 | productRefGroup = 83060F402381FE2000FDF0AD /* Products */; 187 | projectDirPath = ""; 188 | projectRoot = ""; 189 | targets = ( 190 | 83060F3E2381FE2000FDF0AD /* CollectionThing */, 191 | 83A72CEC2384CA9800C1AB7F /* CollectionThingMac */, 192 | ); 193 | }; 194 | /* End PBXProject section */ 195 | 196 | /* Begin PBXResourcesBuildPhase section */ 197 | 83060F3D2381FE2000FDF0AD /* Resources */ = { 198 | isa = PBXResourcesBuildPhase; 199 | buildActionMask = 2147483647; 200 | files = ( 201 | 83060F4F2381FE2200FDF0AD /* LaunchScreen.storyboard in Resources */, 202 | 83060F4C2381FE2200FDF0AD /* Preview Assets.xcassets in Resources */, 203 | 83060F492381FE2200FDF0AD /* Assets.xcassets in Resources */, 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | 83A72CEB2384CA9800C1AB7F /* Resources */ = { 208 | isa = PBXResourcesBuildPhase; 209 | buildActionMask = 2147483647; 210 | files = ( 211 | 83A72CFA2384CA9900C1AB7F /* Main.storyboard in Resources */, 212 | 83A72CF72384CA9900C1AB7F /* Preview Assets.xcassets in Resources */, 213 | 83A72CF42384CA9900C1AB7F /* Assets.xcassets in Resources */, 214 | ); 215 | runOnlyForDeploymentPostprocessing = 0; 216 | }; 217 | /* End PBXResourcesBuildPhase section */ 218 | 219 | /* Begin PBXSourcesBuildPhase section */ 220 | 83060F3B2381FE2000FDF0AD /* Sources */ = { 221 | isa = PBXSourcesBuildPhase; 222 | buildActionMask = 2147483647; 223 | files = ( 224 | 83060F432381FE2000FDF0AD /* AppDelegate.swift in Sources */, 225 | 83060F452381FE2000FDF0AD /* SceneDelegate.swift in Sources */, 226 | 83060F472381FE2000FDF0AD /* ContentView.swift in Sources */, 227 | ); 228 | runOnlyForDeploymentPostprocessing = 0; 229 | }; 230 | 83A72CE92384CA9800C1AB7F /* Sources */ = { 231 | isa = PBXSourcesBuildPhase; 232 | buildActionMask = 2147483647; 233 | files = ( 234 | 83A72D002384CAC700C1AB7F /* ContentView.swift in Sources */, 235 | 83A72CF02384CA9800C1AB7F /* AppDelegate.swift in Sources */, 236 | ); 237 | runOnlyForDeploymentPostprocessing = 0; 238 | }; 239 | /* End PBXSourcesBuildPhase section */ 240 | 241 | /* Begin PBXVariantGroup section */ 242 | 83060F4D2381FE2200FDF0AD /* LaunchScreen.storyboard */ = { 243 | isa = PBXVariantGroup; 244 | children = ( 245 | 83060F4E2381FE2200FDF0AD /* Base */, 246 | ); 247 | name = LaunchScreen.storyboard; 248 | sourceTree = ""; 249 | }; 250 | 83A72CF82384CA9900C1AB7F /* Main.storyboard */ = { 251 | isa = PBXVariantGroup; 252 | children = ( 253 | 83A72CF92384CA9900C1AB7F /* Base */, 254 | ); 255 | name = Main.storyboard; 256 | sourceTree = ""; 257 | }; 258 | /* End PBXVariantGroup section */ 259 | 260 | /* Begin XCBuildConfiguration section */ 261 | 83060F512381FE2200FDF0AD /* Debug */ = { 262 | isa = XCBuildConfiguration; 263 | buildSettings = { 264 | ALWAYS_SEARCH_USER_PATHS = NO; 265 | CLANG_ANALYZER_NONNULL = YES; 266 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 267 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 268 | CLANG_CXX_LIBRARY = "libc++"; 269 | CLANG_ENABLE_MODULES = YES; 270 | CLANG_ENABLE_OBJC_ARC = YES; 271 | CLANG_ENABLE_OBJC_WEAK = YES; 272 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 273 | CLANG_WARN_BOOL_CONVERSION = YES; 274 | CLANG_WARN_COMMA = YES; 275 | CLANG_WARN_CONSTANT_CONVERSION = YES; 276 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 277 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 278 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 279 | CLANG_WARN_EMPTY_BODY = YES; 280 | CLANG_WARN_ENUM_CONVERSION = YES; 281 | CLANG_WARN_INFINITE_RECURSION = YES; 282 | CLANG_WARN_INT_CONVERSION = YES; 283 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 284 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 285 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 286 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 287 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 288 | CLANG_WARN_STRICT_PROTOTYPES = YES; 289 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 290 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 291 | CLANG_WARN_UNREACHABLE_CODE = YES; 292 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 293 | COPY_PHASE_STRIP = NO; 294 | DEBUG_INFORMATION_FORMAT = dwarf; 295 | ENABLE_STRICT_OBJC_MSGSEND = YES; 296 | ENABLE_TESTABILITY = YES; 297 | GCC_C_LANGUAGE_STANDARD = gnu11; 298 | GCC_DYNAMIC_NO_PIC = NO; 299 | GCC_NO_COMMON_BLOCKS = YES; 300 | GCC_OPTIMIZATION_LEVEL = 0; 301 | GCC_PREPROCESSOR_DEFINITIONS = ( 302 | "DEBUG=1", 303 | "$(inherited)", 304 | ); 305 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 306 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 307 | GCC_WARN_UNDECLARED_SELECTOR = YES; 308 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 309 | GCC_WARN_UNUSED_FUNCTION = YES; 310 | GCC_WARN_UNUSED_VARIABLE = YES; 311 | IPHONEOS_DEPLOYMENT_TARGET = 13.2; 312 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 313 | MTL_FAST_MATH = YES; 314 | ONLY_ACTIVE_ARCH = YES; 315 | SDKROOT = iphoneos; 316 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 317 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 318 | }; 319 | name = Debug; 320 | }; 321 | 83060F522381FE2200FDF0AD /* Release */ = { 322 | isa = XCBuildConfiguration; 323 | buildSettings = { 324 | ALWAYS_SEARCH_USER_PATHS = NO; 325 | CLANG_ANALYZER_NONNULL = YES; 326 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 327 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 328 | CLANG_CXX_LIBRARY = "libc++"; 329 | CLANG_ENABLE_MODULES = YES; 330 | CLANG_ENABLE_OBJC_ARC = YES; 331 | CLANG_ENABLE_OBJC_WEAK = YES; 332 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 333 | CLANG_WARN_BOOL_CONVERSION = YES; 334 | CLANG_WARN_COMMA = YES; 335 | CLANG_WARN_CONSTANT_CONVERSION = YES; 336 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 337 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 338 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 339 | CLANG_WARN_EMPTY_BODY = YES; 340 | CLANG_WARN_ENUM_CONVERSION = YES; 341 | CLANG_WARN_INFINITE_RECURSION = YES; 342 | CLANG_WARN_INT_CONVERSION = YES; 343 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 344 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 345 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 346 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 347 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 348 | CLANG_WARN_STRICT_PROTOTYPES = YES; 349 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 350 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 351 | CLANG_WARN_UNREACHABLE_CODE = YES; 352 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 353 | COPY_PHASE_STRIP = NO; 354 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 355 | ENABLE_NS_ASSERTIONS = NO; 356 | ENABLE_STRICT_OBJC_MSGSEND = YES; 357 | GCC_C_LANGUAGE_STANDARD = gnu11; 358 | GCC_NO_COMMON_BLOCKS = YES; 359 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 360 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 361 | GCC_WARN_UNDECLARED_SELECTOR = YES; 362 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 363 | GCC_WARN_UNUSED_FUNCTION = YES; 364 | GCC_WARN_UNUSED_VARIABLE = YES; 365 | IPHONEOS_DEPLOYMENT_TARGET = 13.2; 366 | MTL_ENABLE_DEBUG_INFO = NO; 367 | MTL_FAST_MATH = YES; 368 | SDKROOT = iphoneos; 369 | SWIFT_COMPILATION_MODE = wholemodule; 370 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 371 | VALIDATE_PRODUCT = YES; 372 | }; 373 | name = Release; 374 | }; 375 | 83060F542381FE2200FDF0AD /* Debug */ = { 376 | isa = XCBuildConfiguration; 377 | buildSettings = { 378 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 379 | CODE_SIGN_IDENTITY = "Apple Development"; 380 | CODE_SIGN_STYLE = Automatic; 381 | DEVELOPMENT_ASSET_PATHS = "\"CollectionThing/Preview Content\""; 382 | DEVELOPMENT_TEAM = ""; 383 | ENABLE_PREVIEWS = YES; 384 | INFOPLIST_FILE = CollectionThing/Info.plist; 385 | LD_RUNPATH_SEARCH_PATHS = ( 386 | "$(inherited)", 387 | "@executable_path/Frameworks", 388 | ); 389 | PRODUCT_BUNDLE_IDENTIFIER = org.liscio.CollectionThing; 390 | PRODUCT_NAME = "$(TARGET_NAME)"; 391 | PROVISIONING_PROFILE_SPECIFIER = ""; 392 | SWIFT_VERSION = 5.0; 393 | TARGETED_DEVICE_FAMILY = "1,2"; 394 | }; 395 | name = Debug; 396 | }; 397 | 83060F552381FE2200FDF0AD /* Release */ = { 398 | isa = XCBuildConfiguration; 399 | buildSettings = { 400 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 401 | CODE_SIGN_IDENTITY = "Apple Development"; 402 | CODE_SIGN_STYLE = Automatic; 403 | DEVELOPMENT_ASSET_PATHS = "\"CollectionThing/Preview Content\""; 404 | DEVELOPMENT_TEAM = ""; 405 | ENABLE_PREVIEWS = YES; 406 | INFOPLIST_FILE = CollectionThing/Info.plist; 407 | LD_RUNPATH_SEARCH_PATHS = ( 408 | "$(inherited)", 409 | "@executable_path/Frameworks", 410 | ); 411 | PRODUCT_BUNDLE_IDENTIFIER = org.liscio.CollectionThing; 412 | PRODUCT_NAME = "$(TARGET_NAME)"; 413 | PROVISIONING_PROFILE_SPECIFIER = ""; 414 | SWIFT_VERSION = 5.0; 415 | TARGETED_DEVICE_FAMILY = "1,2"; 416 | }; 417 | name = Release; 418 | }; 419 | 83A72CFD2384CA9900C1AB7F /* Debug */ = { 420 | isa = XCBuildConfiguration; 421 | buildSettings = { 422 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 423 | CODE_SIGN_ENTITLEMENTS = CollectionThingMac/CollectionThingMac.entitlements; 424 | CODE_SIGN_IDENTITY = "Apple Development"; 425 | CODE_SIGN_STYLE = Automatic; 426 | COMBINE_HIDPI_IMAGES = YES; 427 | DEVELOPMENT_ASSET_PATHS = "\"CollectionThingMac/Preview Content\""; 428 | DEVELOPMENT_TEAM = ""; 429 | ENABLE_HARDENED_RUNTIME = YES; 430 | ENABLE_PREVIEWS = YES; 431 | INFOPLIST_FILE = CollectionThingMac/Info.plist; 432 | LD_RUNPATH_SEARCH_PATHS = ( 433 | "$(inherited)", 434 | "@executable_path/../Frameworks", 435 | ); 436 | MACOSX_DEPLOYMENT_TARGET = 10.15; 437 | PRODUCT_BUNDLE_IDENTIFIER = com.supermegaultragroovy.CollectionThingMac; 438 | PRODUCT_NAME = "$(TARGET_NAME)"; 439 | PROVISIONING_PROFILE_SPECIFIER = ""; 440 | SDKROOT = macosx; 441 | SWIFT_VERSION = 5.0; 442 | }; 443 | name = Debug; 444 | }; 445 | 83A72CFE2384CA9900C1AB7F /* Release */ = { 446 | isa = XCBuildConfiguration; 447 | buildSettings = { 448 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 449 | CODE_SIGN_ENTITLEMENTS = CollectionThingMac/CollectionThingMac.entitlements; 450 | CODE_SIGN_IDENTITY = "Apple Development"; 451 | CODE_SIGN_STYLE = Automatic; 452 | COMBINE_HIDPI_IMAGES = YES; 453 | DEVELOPMENT_ASSET_PATHS = "\"CollectionThingMac/Preview Content\""; 454 | DEVELOPMENT_TEAM = ""; 455 | ENABLE_HARDENED_RUNTIME = YES; 456 | ENABLE_PREVIEWS = YES; 457 | INFOPLIST_FILE = CollectionThingMac/Info.plist; 458 | LD_RUNPATH_SEARCH_PATHS = ( 459 | "$(inherited)", 460 | "@executable_path/../Frameworks", 461 | ); 462 | MACOSX_DEPLOYMENT_TARGET = 10.15; 463 | PRODUCT_BUNDLE_IDENTIFIER = com.supermegaultragroovy.CollectionThingMac; 464 | PRODUCT_NAME = "$(TARGET_NAME)"; 465 | PROVISIONING_PROFILE_SPECIFIER = ""; 466 | SDKROOT = macosx; 467 | SWIFT_VERSION = 5.0; 468 | }; 469 | name = Release; 470 | }; 471 | /* End XCBuildConfiguration section */ 472 | 473 | /* Begin XCConfigurationList section */ 474 | 83060F3A2381FE2000FDF0AD /* Build configuration list for PBXProject "CollectionThing" */ = { 475 | isa = XCConfigurationList; 476 | buildConfigurations = ( 477 | 83060F512381FE2200FDF0AD /* Debug */, 478 | 83060F522381FE2200FDF0AD /* Release */, 479 | ); 480 | defaultConfigurationIsVisible = 0; 481 | defaultConfigurationName = Release; 482 | }; 483 | 83060F532381FE2200FDF0AD /* Build configuration list for PBXNativeTarget "CollectionThing" */ = { 484 | isa = XCConfigurationList; 485 | buildConfigurations = ( 486 | 83060F542381FE2200FDF0AD /* Debug */, 487 | 83060F552381FE2200FDF0AD /* Release */, 488 | ); 489 | defaultConfigurationIsVisible = 0; 490 | defaultConfigurationName = Release; 491 | }; 492 | 83A72CFF2384CA9900C1AB7F /* Build configuration list for PBXNativeTarget "CollectionThingMac" */ = { 493 | isa = XCConfigurationList; 494 | buildConfigurations = ( 495 | 83A72CFD2384CA9900C1AB7F /* Debug */, 496 | 83A72CFE2384CA9900C1AB7F /* Release */, 497 | ); 498 | defaultConfigurationIsVisible = 0; 499 | defaultConfigurationName = Release; 500 | }; 501 | /* End XCConfigurationList section */ 502 | }; 503 | rootObject = 83060F372381FE2000FDF0AD /* Project object */; 504 | } 505 | -------------------------------------------------------------------------------- /CollectionThing.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CollectionThing.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CollectionThing/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CollectionThing 4 | // 5 | // Created by Christopher Liscio on 2019-11-17. 6 | // Copyright © 2019 Christopher Liscio. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /CollectionThing/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /CollectionThing/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CollectionThing/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /CollectionThing/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // CollectionThing 4 | // 5 | // Created by Christopher Liscio on 2019-11-17. 6 | // Copyright © 2019 Christopher Liscio. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | import Combine 11 | 12 | struct WrappedLayout { 13 | /// The items to be laid out 14 | let items: [Item] 15 | 16 | /// The (maximum) number of items to be placed in a row 17 | let columns: Int 18 | 19 | /// A model representing the row of items 20 | struct Row: Identifiable { 21 | let id: Int 22 | let frame: CGRect 23 | let items: ArraySlice 24 | 25 | func translatingY(_ y: CGFloat) -> Row { 26 | return Row(id: id, frame: frame.offsetBy(dx: 0, dy: y), items: items) 27 | } 28 | 29 | func width(_ width: CGFloat) -> Row { 30 | return Row(id: id, frame: CGRect(x: frame.origin.x, y: frame.origin.y, width: width, height: frame.size.height), items: items) 31 | } 32 | } 33 | 34 | let contentSize: CGSize 35 | let rows: [Row] 36 | let rowHeight: CGFloat 37 | 38 | init(items: [Item], columns: Int) { 39 | let rowHeight: CGFloat = 80 40 | 41 | func rangeForRow(_ index: Int) -> Range { 42 | return ((index * columns) ..< ((index + 1) * columns)).clamped(to: items.indices) 43 | } 44 | 45 | func frameForRow(_ index: Int) -> CGRect { 46 | return CGRect(x: 0, y: CGFloat(index) * rowHeight, width: 1, height: rowHeight) 47 | } 48 | 49 | let (quotient, remainder) = items.count.quotientAndRemainder(dividingBy: columns) 50 | let rowCount = (remainder > 0) ? quotient + 1 : quotient 51 | 52 | self.items = items 53 | self.rows = (0 ..< rowCount).map { Row(id: $0, frame: frameForRow($0), items: items[rangeForRow($0)]) } 54 | self.columns = columns 55 | self.contentSize = CGSize(width: 1, height: CGFloat(rowCount) * rowHeight) 56 | self.rowHeight = rowHeight 57 | } 58 | 59 | struct LayoutItem: Identifiable { 60 | var id: Item.ID { item.id } 61 | let item: Item 62 | let frame: CGRect 63 | } 64 | 65 | func rows(in rect: CGRect) -> [Row] { 66 | return rows.filter { $0.frame.intersects(rect) }.map { $0.width(rect.width) } 67 | } 68 | } 69 | 70 | struct Item: Identifiable { 71 | let id = UUID() 72 | let title: String 73 | } 74 | 75 | struct ItemView: View { 76 | let title: String 77 | init(item: Item) { 78 | title = item.title 79 | } 80 | 81 | var body: some View { 82 | Color(.purple) 83 | .overlay(Text(title) 84 | .font(.system(.headline)) 85 | .foregroundColor(.white) 86 | .frame(maxWidth: .infinity, maxHeight: .infinity), alignment: .center) 87 | } 88 | } 89 | 90 | final class Store: ObservableObject { 91 | @Published var value: WrappedLayout 92 | init() { 93 | self.value = WrappedLayout(items: (0 ..< 50000).map { Item(title: "\($0)") }, columns: 8) 94 | } 95 | } 96 | 97 | struct ContentView: View { 98 | 99 | @ObservedObject var store: Store 100 | init() { 101 | self.store = Store() 102 | } 103 | 104 | @State var fixedBounds: CGRect = .zero 105 | @State var lastQueryRect: CGRect = .zero 106 | @State var visibleRowBounds: CGRect = .zero 107 | @State var visibleRows: [WrappedLayout.Row] = [] 108 | 109 | var body: some View { 110 | VStack { 111 | ScrollView { 112 | ZStack(alignment: .top) { 113 | MovingView() 114 | .frame(height: 0) 115 | 116 | Color.clear 117 | .frame( 118 | width: self.store.value.contentSize.width, 119 | height: self.store.value.contentSize.height 120 | ) 121 | .hidden() 122 | 123 | VStack(spacing: 0) { 124 | ForEach(self.visibleRows) { row in 125 | HStack(spacing: 0) { 126 | ForEach(row.items) { item in 127 | ItemView(item: item) 128 | } 129 | } 130 | } 131 | } 132 | .frame( 133 | width: self.fixedBounds.width, 134 | height: self.visibleRowBounds.height, 135 | alignment: .topLeading 136 | ) 137 | .position( 138 | x: self.fixedBounds.midX, 139 | y: self.visibleRowBounds.midY 140 | ) 141 | } 142 | } 143 | .background(FixedView().edgesIgnoringSafeArea(.all)) 144 | .onPreferenceChange(ViewFrames.self) { values in 145 | let fixedBounds = values[.fixedView] ?? .zero 146 | let movingBounds = values[.movingView] ?? .zero 147 | let boundsDirty = fixedBounds != self.fixedBounds 148 | if boundsDirty { 149 | self.fixedBounds = values[.fixedView] ?? .zero 150 | } 151 | 152 | #if os(iOS) 153 | let visibleRect = CGRect( 154 | x: movingBounds.origin.x, 155 | y: (fixedBounds.origin.y - movingBounds.origin.y), 156 | width: fixedBounds.width, 157 | height: fixedBounds.height) 158 | #else 159 | let visibleRect = CGRect( 160 | x: movingBounds.origin.x, 161 | y: movingBounds.origin.y - fixedBounds.height, 162 | width: fixedBounds.width, 163 | height: fixedBounds.height) 164 | #endif 165 | 166 | let queryRect = visibleRect.insetBy(dx: 0, dy: -(visibleRect.height / 8)) 167 | 168 | if boundsDirty || self.lastQueryRect.isEmpty || self.lastQueryRect.intersection(queryRect).height < (visibleRect.height * 1.2) { 169 | self.lastQueryRect = queryRect 170 | 171 | let rows = self.store.value.rows(in: queryRect) 172 | let bounds = (rows.first?.frame ?? .zero).union(rows.last?.frame ?? .zero) 173 | 174 | if rows.map({ $0.id }) != self.visibleRows.map({ $0.id }) { 175 | self.visibleRows = rows 176 | self.visibleRowBounds = bounds 177 | } 178 | } 179 | } 180 | } 181 | } 182 | 183 | struct MovingView: View { 184 | var body: some View { 185 | GeometryReader { proxy in 186 | Color.clear.hidden().preference(key: ViewFrames.self, value: [.movingView: proxy.frame(in: .global)]) 187 | }.frame(height: 0) 188 | } 189 | } 190 | 191 | struct FixedView: View { 192 | var body: some View { 193 | GeometryReader { proxy in 194 | Color.clear.hidden().preference(key: ViewFrames.self, value: [.fixedView: proxy.frame(in: .global)]) 195 | } 196 | } 197 | } 198 | 199 | struct ViewFrames: PreferenceKey { 200 | enum ViewType: Int { 201 | case movingView 202 | case fixedView 203 | } 204 | 205 | static var defaultValue: [ViewType:CGRect] = [:] 206 | 207 | static func reduce(value: inout [ViewType:CGRect], nextValue: () -> [ViewType:CGRect]) { 208 | value.merge(nextValue(), uniquingKeysWith: { old, new in new }) 209 | } 210 | 211 | typealias Value = [ViewType:CGRect] 212 | } 213 | } 214 | 215 | struct ContentView_Previews: PreviewProvider { 216 | static var previews: some View { 217 | ContentView() 218 | } 219 | } 220 | -------------------------------------------------------------------------------- /CollectionThing/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | 37 | 38 | 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UISupportedInterfaceOrientations~ipad 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationPortraitUpsideDown 56 | UIInterfaceOrientationLandscapeLeft 57 | UIInterfaceOrientationLandscapeRight 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /CollectionThing/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CollectionThing/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // CollectionThing 4 | // 5 | // Created by Christopher Liscio on 2019-11-17. 6 | // Copyright © 2019 Christopher Liscio. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SwiftUI 11 | 12 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 18 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 19 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 20 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 21 | 22 | // Create the SwiftUI view that provides the window contents. 23 | let contentView = ContentView() 24 | 25 | // Use a UIHostingController as window root view controller. 26 | if let windowScene = scene as? UIWindowScene { 27 | let window = UIWindow(windowScene: windowScene) 28 | window.rootViewController = UIHostingController(rootView: contentView) 29 | self.window = window 30 | window.makeKeyAndVisible() 31 | } 32 | } 33 | 34 | func sceneDidDisconnect(_ scene: UIScene) { 35 | // Called as the scene is being released by the system. 36 | // This occurs shortly after the scene enters the background, or when its session is discarded. 37 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 38 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 39 | } 40 | 41 | func sceneDidBecomeActive(_ scene: UIScene) { 42 | // Called when the scene has moved from an inactive state to an active state. 43 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 44 | } 45 | 46 | func sceneWillResignActive(_ scene: UIScene) { 47 | // Called when the scene will move from an active state to an inactive state. 48 | // This may occur due to temporary interruptions (ex. an incoming phone call). 49 | } 50 | 51 | func sceneWillEnterForeground(_ scene: UIScene) { 52 | // Called as the scene transitions from the background to the foreground. 53 | // Use this method to undo the changes made on entering the background. 54 | } 55 | 56 | func sceneDidEnterBackground(_ scene: UIScene) { 57 | // Called as the scene transitions from the foreground to the background. 58 | // Use this method to save data, release shared resources, and store enough scene-specific state information 59 | // to restore the scene back to its current state. 60 | } 61 | 62 | 63 | } 64 | 65 | -------------------------------------------------------------------------------- /CollectionThingMac/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CollectionThingMac 4 | // 5 | // Created by Christopher Liscio on 2019-11-19. 6 | // Copyright © 2019 Christopher Liscio. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import SwiftUI 11 | 12 | @NSApplicationMain 13 | class AppDelegate: NSObject, NSApplicationDelegate { 14 | 15 | var window: NSWindow! 16 | 17 | 18 | func applicationDidFinishLaunching(_ aNotification: Notification) { 19 | // Create the SwiftUI view that provides the window contents. 20 | let contentView = ContentView() 21 | 22 | // Create the window and set the content view. 23 | window = NSWindow( 24 | contentRect: NSRect(x: 0, y: 0, width: 480, height: 300), 25 | styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], 26 | backing: .buffered, defer: false) 27 | window.center() 28 | window.setFrameAutosaveName("Main Window") 29 | window.contentView = NSHostingView(rootView: contentView) 30 | window.makeKeyAndOrderFront(nil) 31 | } 32 | 33 | func applicationWillTerminate(_ aNotification: Notification) { 34 | // Insert code here to tear down your application 35 | } 36 | 37 | 38 | } 39 | 40 | -------------------------------------------------------------------------------- /CollectionThingMac/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /CollectionThingMac/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CollectionThingMac/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | Default 529 | 530 | 531 | 532 | 533 | 534 | 535 | Left to Right 536 | 537 | 538 | 539 | 540 | 541 | 542 | Right to Left 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | Default 554 | 555 | 556 | 557 | 558 | 559 | 560 | Left to Right 561 | 562 | 563 | 564 | 565 | 566 | 567 | Right to Left 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | -------------------------------------------------------------------------------- /CollectionThingMac/CollectionThingMac.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /CollectionThingMac/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | Copyright © 2019 Christopher Liscio. All rights reserved. 27 | NSMainStoryboardFile 28 | Main 29 | NSPrincipalClass 30 | NSApplication 31 | NSSupportsAutomaticTermination 32 | 33 | NSSupportsSuddenTermination 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /CollectionThingMac/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A CollectionView-y Thing For SwiftUI 2 | 3 | This is a sketch of an approach that lets you put a _ton_ of items into a SwiftUI `ScrollView` while maintaining decent performance. Even with *50,000* elements, the view appears almost immediately, and memory usage is not terrible. 4 | 5 | No weird uses of `DispatchQueue.async`, and (as far as I am concerned) it doesn't _really_ contain any gross hacks. Beauty is in the eye of the beholder, etc… 6 | 7 | ## How does it work? 8 | 9 | It's a lot like a `{UI,NS}CollectionView` in that you're responsible for maintaining the layout logic of views by yourself. But—as you can see—the `WrappedLayout` struct that I supplied isn't overly complicated. It just takes your model objects, and packages them up into rows. Those rows have `frame`s, and the layout itself has an overall `contentSize`. 10 | 11 | The `ContentView` calculates the current `visibleRect` using `PreferenceKey`s, and on changing preference values, the `layout` is queried for the rows that overlap the current `visibleRect` (plus a bit of "slop factor" to reduce flashing—play around for your own needs). 12 | 13 | A `@State` variable tracks the current set of `visibleRows`, and those are only updated when we start to get close to the edge of the rows we've already cached. 14 | 15 | When everything's laid out, the content of your `ScrollView` will look like this: 16 | 17 | ``` 18 | +++++++++++++++++++++++++ 19 | | Color(.clear) | 20 | | | 21 | | | 22 | +++++++++++++++++++++++++ 23 | | VStack(visibleRows) | 24 | | +++ 25 | | | | 26 | | | | visibleRect 27 | | | | 28 | | +++ 29 | | | 30 | +++++++++++++++++++++++++ 31 | | | 32 | | | 33 | | | 34 | +++++++++++++++++++++++++ 35 | ``` 36 | 37 | Effectively, the "magic" here is in the fact that a `VStack` contains _only_ as many rows as you'll need, and no more. It is positioned at the same spot where those visible rows would normally appear if you had a `VStack` containing _all_ of the rows in the layout. It looks an awful lot like the way `UICollectionView` works—only creating views that are visible, while defining a larger content area. 38 | 39 | As you scroll, the inner `VStack` is _only_ updated when the `visibleRows` change. So you'll experience the native scrolling speed until it is deemed that new rows need to get "faulted in" to the view. Even then, a reasonably new device should be able to retain smooth scrolling since `SwiftUI` can generate that new set of views very quickly. _Much faster_ than trying to calculate the viewport for the entire data set. 40 | 41 | When the `visibleRows` _do_ change, they are mostly the same—the amount of churn inside the inner `VStack` _should_ be minimal because the `Row`s themselves are `Identifiable`. 42 | 43 | ## Keys to Performance 44 | 45 | There are a few things that (I think) are important here: 46 | 47 | 1. The root-level `@ObservedObject` whose `value` does not change 48 | 2. The `@State` variables that _only_ get set _when necessary_ 49 | 3. `Row` values that are identifiable, used in concert with the inner `VStack` to try and keep churn to a minimum 50 | 51 | ## Known Issues 52 | 53 | The implementation is obviously incomplete, and there many details that you'll need to get sorted out. 54 | 55 | Stuff like: 56 | 57 | * Incorporating the `safeAreaInsets` into your layout (which are readable from the outer `GeometryProxy` on the `ScrollView`) 58 | * Dealing with rotation 59 | * Insertion/removal animations 60 | * Being smarter/faster about querying your `Row`s 61 | * Selection management 62 | 63 | Plenty of exercises for the reader. :) 64 | 65 | ## Credits/etc. 66 | 67 | Thanks to the folks at [swiftui-lab](https://swiftui-lab.com) for [their post](https://swiftui-lab.com/scrollview-pull-to-refresh/) that gave me a few nifty ideas that helped me narrow down my initial work on this. 68 | 69 | If you find this repo helpful, that's great! To repay me, you can go and check out [Capo](http://capoapp.com). Then, tell your friends to do the same. 70 | 71 | Also, pull requests are welcome if you find any opportunities for making this go _even faster_ without resorting to anything gross. 72 | --------------------------------------------------------------------------------