├── .gitignore ├── CustomCollectionLayout.xcodeproj └── project.pbxproj ├── CustomCollectionLayout ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── button_style │ │ ├── Contents.json │ │ ├── custom_grid.imageset │ │ │ ├── Contents.json │ │ │ ├── custom_grid.png │ │ │ ├── custom_grid@2x.png │ │ │ └── custom_grid@3x.png │ │ ├── default_grid.imageset │ │ │ ├── Contents.json │ │ │ ├── default_grid.png │ │ │ ├── default_grid@2x.png │ │ │ └── default_grid@3x.png │ │ └── table.imageset │ │ │ ├── Contents.json │ │ │ ├── table.png │ │ │ ├── table@2x.png │ │ │ └── table@3x.png │ └── fruits │ │ ├── Contents.json │ │ ├── apple.imageset │ │ ├── Contents.json │ │ ├── apple.png │ │ ├── apple@2x.png │ │ └── apple@3x.png │ │ ├── banana.imageset │ │ ├── Contents.json │ │ ├── banana.png │ │ ├── banana@2x.png │ │ └── banana@3x.png │ │ ├── garnet.imageset │ │ ├── Contents.json │ │ ├── garnet.png │ │ ├── garnet@2x.png │ │ └── garnet@3x.png │ │ ├── grapes.imageset │ │ ├── Contents.json │ │ ├── grapes.png │ │ ├── grapes@2x.png │ │ └── grapes@3x.png │ │ ├── green_apple.imageset │ │ ├── Contents.json │ │ ├── green_apple.png │ │ ├── green_apple@2x.png │ │ └── green_apple@3x.png │ │ ├── green_pears.imageset │ │ ├── Contents.json │ │ ├── green_pears.png │ │ ├── green_pears@2x.png │ │ └── green_pears@3x.png │ │ ├── kiwi.imageset │ │ ├── Contents.json │ │ ├── kiwi.png │ │ ├── kiwi@2x.png │ │ └── kiwi@3x.png │ │ ├── mango.imageset │ │ ├── Contents.json │ │ ├── mango.png │ │ ├── mango@2x.png │ │ └── mango@3x.png │ │ ├── mango2.imageset │ │ ├── Contents.json │ │ ├── mango2.png │ │ ├── mango2@2x.png │ │ └── mango2@3x.png │ │ ├── orange.imageset │ │ ├── Contents.json │ │ ├── orange.png │ │ ├── orange@2x.png │ │ └── orange@3x.png │ │ ├── pears.imageset │ │ ├── Contents.json │ │ ├── pears.png │ │ ├── pears@2x.png │ │ └── pears@3x.png │ │ └── pineapple.imageset │ │ ├── Contents.json │ │ ├── pineapple.png │ │ ├── pineapple@2x.png │ │ └── pineapple@3x.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Collection FlowLayouts │ ├── CustomGriddedContentCollectionViewDelegate.swift │ ├── DefaultCollectionViewDelegate.swift │ ├── DefaultGriddedContentCollectionViewDelegate.swift │ └── TabledContentCollectionViewDelegate.swift ├── Entities │ ├── Fruit.swift │ └── FruitsProvider.swift ├── FruitCollectionCell │ ├── FruitCollectionViewCell.swift │ └── FruitCollectionViewCell.xib ├── FruitsViewController.swift ├── Info.plist └── TabledContentCollectionViewDelegate.swift ├── LICENSE.txt ├── README.md └── demo.gif /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/osx,swift,xcode 3 | 4 | ### OSX ### 5 | *.DS_Store 6 | .AppleDouble 7 | .LSOverride 8 | 9 | # Icon must end with two \r 10 | Icon 11 | 12 | # Thumbnails 13 | ._* 14 | 15 | # Files that might appear in the root of a volume 16 | .DocumentRevisions-V100 17 | .fseventsd 18 | .Spotlight-V100 19 | .TemporaryItems 20 | .Trashes 21 | .VolumeIcon.icns 22 | .com.apple.timemachine.donotpresent 23 | 24 | # Directories potentially created on remote AFP share 25 | .AppleDB 26 | .AppleDesktop 27 | Network Trash Folder 28 | Temporary Items 29 | .apdisk 30 | 31 | ### Swift ### 32 | # Xcode 33 | # 34 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 35 | 36 | ## Build generated 37 | build/ 38 | DerivedData/ 39 | 40 | ## Various settings 41 | *.pbxuser 42 | !default.pbxuser 43 | *.mode1v3 44 | !default.mode1v3 45 | *.mode2v3 46 | !default.mode2v3 47 | *.perspectivev3 48 | !default.perspectivev3 49 | xcuserdata/ 50 | 51 | ## Other 52 | *.moved-aside 53 | *.xccheckout 54 | *.xcscmblueprint 55 | 56 | ## Obj-C/Swift specific 57 | *.hmap 58 | *.ipa 59 | *.dSYM.zip 60 | *.dSYM 61 | 62 | ## Playgrounds 63 | timeline.xctimeline 64 | playground.xcworkspace 65 | 66 | # Swift Package Manager 67 | # 68 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 69 | # Packages/ 70 | # Package.pins 71 | .build/ 72 | 73 | # CocoaPods 74 | # 75 | # We recommend against adding the Pods directory to your .gitignore. However 76 | # you should judge for yourself, the pros and cons are mentioned at: 77 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 78 | # 79 | Pods/ 80 | 81 | # Carthage 82 | # 83 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 84 | # Carthage/Checkouts 85 | 86 | Carthage/Build 87 | 88 | # fastlane 89 | # 90 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 91 | # screenshots whenever they are needed. 92 | # For more information about the recommended setup visit: 93 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 94 | 95 | fastlane/report.xml 96 | fastlane/Preview.html 97 | fastlane/screenshots 98 | fastlane/test_output 99 | 100 | ### Xcode ### 101 | # Xcode 102 | # 103 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 104 | 105 | ## Build generated 106 | 107 | ## Various settings 108 | 109 | ## Other 110 | 111 | ### Xcode Patch ### 112 | *.xcodeproj/* 113 | !*.xcodeproj/project.pbxproj 114 | !*.xcodeproj/xcshareddata/ 115 | !*.xcworkspace/contents.xcworkspacedata 116 | /*.gcno 117 | 118 | # End of https://www.gitignore.io/api/osx,swift,xcode -------------------------------------------------------------------------------- /CustomCollectionLayout.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 830AA79A221484740097B6F1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 830AA799221484740097B6F1 /* AppDelegate.swift */; }; 11 | 830AA79F221484740097B6F1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 830AA79D221484740097B6F1 /* Main.storyboard */; }; 12 | 830AA7A1221484770097B6F1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 830AA7A0221484770097B6F1 /* Assets.xcassets */; }; 13 | 830AA7A4221484770097B6F1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 830AA7A2221484770097B6F1 /* LaunchScreen.storyboard */; }; 14 | 830AA7AC221485720097B6F1 /* FruitsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 830AA7AB221485720097B6F1 /* FruitsViewController.swift */; }; 15 | 830AA7AF221485CE0097B6F1 /* FruitCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 830AA7AD221485CE0097B6F1 /* FruitCollectionViewCell.swift */; }; 16 | 830AA7B0221485CE0097B6F1 /* FruitCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 830AA7AE221485CE0097B6F1 /* FruitCollectionViewCell.xib */; }; 17 | 830AA7B2221486180097B6F1 /* Fruit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 830AA7B1221486180097B6F1 /* Fruit.swift */; }; 18 | 830AA7DD221857EE0097B6F1 /* TabledContentCollectionViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 830AA7DA221857ED0097B6F1 /* TabledContentCollectionViewDelegate.swift */; }; 19 | 830AA7DE221857EE0097B6F1 /* CustomGriddedContentCollectionViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 830AA7DB221857EE0097B6F1 /* CustomGriddedContentCollectionViewDelegate.swift */; }; 20 | 830AA7DF221857EE0097B6F1 /* DefaultCollectionViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 830AA7DC221857EE0097B6F1 /* DefaultCollectionViewDelegate.swift */; }; 21 | 83C945D4221955C600C5401C /* FruitsProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83C945D3221955C600C5401C /* FruitsProvider.swift */; }; 22 | 83C945D62219B9A700C5401C /* DefaultGriddedContentCollectionViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83C945D52219B9A700C5401C /* DefaultGriddedContentCollectionViewDelegate.swift */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXFileReference section */ 26 | 830AA796221484740097B6F1 /* CustomCollectionLayout.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CustomCollectionLayout.app; sourceTree = BUILT_PRODUCTS_DIR; }; 27 | 830AA799221484740097B6F1 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 28 | 830AA79E221484740097B6F1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 29 | 830AA7A0221484770097B6F1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 30 | 830AA7A3221484770097B6F1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 31 | 830AA7A5221484770097B6F1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | 830AA7AB221485720097B6F1 /* FruitsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FruitsViewController.swift; sourceTree = ""; }; 33 | 830AA7AD221485CE0097B6F1 /* FruitCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FruitCollectionViewCell.swift; sourceTree = ""; }; 34 | 830AA7AE221485CE0097B6F1 /* FruitCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FruitCollectionViewCell.xib; sourceTree = ""; }; 35 | 830AA7B1221486180097B6F1 /* Fruit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Fruit.swift; sourceTree = ""; }; 36 | 830AA7DA221857ED0097B6F1 /* TabledContentCollectionViewDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TabledContentCollectionViewDelegate.swift; sourceTree = ""; }; 37 | 830AA7DB221857EE0097B6F1 /* CustomGriddedContentCollectionViewDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomGriddedContentCollectionViewDelegate.swift; sourceTree = ""; }; 38 | 830AA7DC221857EE0097B6F1 /* DefaultCollectionViewDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DefaultCollectionViewDelegate.swift; sourceTree = ""; }; 39 | 83C945D3221955C600C5401C /* FruitsProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FruitsProvider.swift; sourceTree = ""; }; 40 | 83C945D52219B9A700C5401C /* DefaultGriddedContentCollectionViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultGriddedContentCollectionViewDelegate.swift; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | 830AA793221484740097B6F1 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | ); 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | /* End PBXFrameworksBuildPhase section */ 52 | 53 | /* Begin PBXGroup section */ 54 | 830AA78D221484740097B6F1 = { 55 | isa = PBXGroup; 56 | children = ( 57 | 830AA798221484740097B6F1 /* CustomCollectionLayout */, 58 | 830AA797221484740097B6F1 /* Products */, 59 | ); 60 | sourceTree = ""; 61 | }; 62 | 830AA797221484740097B6F1 /* Products */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | 830AA796221484740097B6F1 /* CustomCollectionLayout.app */, 66 | ); 67 | name = Products; 68 | sourceTree = ""; 69 | }; 70 | 830AA798221484740097B6F1 /* CustomCollectionLayout */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | 830AA7D5221853A30097B6F1 /* Entities */, 74 | 830AA7B3221487D30097B6F1 /* FruitCollectionCell */, 75 | 830AA7D9221857ED0097B6F1 /* Collection FlowLayouts */, 76 | 830AA7AB221485720097B6F1 /* FruitsViewController.swift */, 77 | 830AA79D221484740097B6F1 /* Main.storyboard */, 78 | 830AA7B4221487ED0097B6F1 /* Supporting Files */, 79 | ); 80 | path = CustomCollectionLayout; 81 | sourceTree = ""; 82 | }; 83 | 830AA7B3221487D30097B6F1 /* FruitCollectionCell */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | 830AA7AD221485CE0097B6F1 /* FruitCollectionViewCell.swift */, 87 | 830AA7AE221485CE0097B6F1 /* FruitCollectionViewCell.xib */, 88 | ); 89 | path = FruitCollectionCell; 90 | sourceTree = ""; 91 | }; 92 | 830AA7B4221487ED0097B6F1 /* Supporting Files */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 830AA7A0221484770097B6F1 /* Assets.xcassets */, 96 | 830AA7A2221484770097B6F1 /* LaunchScreen.storyboard */, 97 | 830AA799221484740097B6F1 /* AppDelegate.swift */, 98 | 830AA7A5221484770097B6F1 /* Info.plist */, 99 | ); 100 | name = "Supporting Files"; 101 | sourceTree = ""; 102 | }; 103 | 830AA7D5221853A30097B6F1 /* Entities */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 830AA7B1221486180097B6F1 /* Fruit.swift */, 107 | 83C945D3221955C600C5401C /* FruitsProvider.swift */, 108 | ); 109 | path = Entities; 110 | sourceTree = ""; 111 | }; 112 | 830AA7D9221857ED0097B6F1 /* Collection FlowLayouts */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 830AA7DC221857EE0097B6F1 /* DefaultCollectionViewDelegate.swift */, 116 | 830AA7DA221857ED0097B6F1 /* TabledContentCollectionViewDelegate.swift */, 117 | 83C945D52219B9A700C5401C /* DefaultGriddedContentCollectionViewDelegate.swift */, 118 | 830AA7DB221857EE0097B6F1 /* CustomGriddedContentCollectionViewDelegate.swift */, 119 | ); 120 | path = "Collection FlowLayouts"; 121 | sourceTree = ""; 122 | }; 123 | /* End PBXGroup section */ 124 | 125 | /* Begin PBXNativeTarget section */ 126 | 830AA795221484740097B6F1 /* CustomCollectionLayout */ = { 127 | isa = PBXNativeTarget; 128 | buildConfigurationList = 830AA7A8221484770097B6F1 /* Build configuration list for PBXNativeTarget "CustomCollectionLayout" */; 129 | buildPhases = ( 130 | 830AA792221484740097B6F1 /* Sources */, 131 | 830AA793221484740097B6F1 /* Frameworks */, 132 | 830AA794221484740097B6F1 /* Resources */, 133 | ); 134 | buildRules = ( 135 | ); 136 | dependencies = ( 137 | ); 138 | name = CustomCollectionLayout; 139 | productName = CustomCollectionLayout; 140 | productReference = 830AA796221484740097B6F1 /* CustomCollectionLayout.app */; 141 | productType = "com.apple.product-type.application"; 142 | }; 143 | /* End PBXNativeTarget section */ 144 | 145 | /* Begin PBXProject section */ 146 | 830AA78E221484740097B6F1 /* Project object */ = { 147 | isa = PBXProject; 148 | attributes = { 149 | LastSwiftUpdateCheck = 1010; 150 | LastUpgradeCheck = 1010; 151 | ORGANIZATIONNAME = MaksymHusar; 152 | TargetAttributes = { 153 | 830AA795221484740097B6F1 = { 154 | CreatedOnToolsVersion = 10.1; 155 | }; 156 | }; 157 | }; 158 | buildConfigurationList = 830AA791221484740097B6F1 /* Build configuration list for PBXProject "CustomCollectionLayout" */; 159 | compatibilityVersion = "Xcode 9.3"; 160 | developmentRegion = en; 161 | hasScannedForEncodings = 0; 162 | knownRegions = ( 163 | en, 164 | Base, 165 | ); 166 | mainGroup = 830AA78D221484740097B6F1; 167 | productRefGroup = 830AA797221484740097B6F1 /* Products */; 168 | projectDirPath = ""; 169 | projectRoot = ""; 170 | targets = ( 171 | 830AA795221484740097B6F1 /* CustomCollectionLayout */, 172 | ); 173 | }; 174 | /* End PBXProject section */ 175 | 176 | /* Begin PBXResourcesBuildPhase section */ 177 | 830AA794221484740097B6F1 /* Resources */ = { 178 | isa = PBXResourcesBuildPhase; 179 | buildActionMask = 2147483647; 180 | files = ( 181 | 830AA7A4221484770097B6F1 /* LaunchScreen.storyboard in Resources */, 182 | 830AA7B0221485CE0097B6F1 /* FruitCollectionViewCell.xib in Resources */, 183 | 830AA7A1221484770097B6F1 /* Assets.xcassets in Resources */, 184 | 830AA79F221484740097B6F1 /* Main.storyboard in Resources */, 185 | ); 186 | runOnlyForDeploymentPostprocessing = 0; 187 | }; 188 | /* End PBXResourcesBuildPhase section */ 189 | 190 | /* Begin PBXSourcesBuildPhase section */ 191 | 830AA792221484740097B6F1 /* Sources */ = { 192 | isa = PBXSourcesBuildPhase; 193 | buildActionMask = 2147483647; 194 | files = ( 195 | 830AA7DD221857EE0097B6F1 /* TabledContentCollectionViewDelegate.swift in Sources */, 196 | 830AA7DF221857EE0097B6F1 /* DefaultCollectionViewDelegate.swift in Sources */, 197 | 830AA7DE221857EE0097B6F1 /* CustomGriddedContentCollectionViewDelegate.swift in Sources */, 198 | 830AA7B2221486180097B6F1 /* Fruit.swift in Sources */, 199 | 830AA7AF221485CE0097B6F1 /* FruitCollectionViewCell.swift in Sources */, 200 | 830AA7AC221485720097B6F1 /* FruitsViewController.swift in Sources */, 201 | 830AA79A221484740097B6F1 /* AppDelegate.swift in Sources */, 202 | 83C945D62219B9A700C5401C /* DefaultGriddedContentCollectionViewDelegate.swift in Sources */, 203 | 83C945D4221955C600C5401C /* FruitsProvider.swift in Sources */, 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | /* End PBXSourcesBuildPhase section */ 208 | 209 | /* Begin PBXVariantGroup section */ 210 | 830AA79D221484740097B6F1 /* Main.storyboard */ = { 211 | isa = PBXVariantGroup; 212 | children = ( 213 | 830AA79E221484740097B6F1 /* Base */, 214 | ); 215 | name = Main.storyboard; 216 | sourceTree = ""; 217 | }; 218 | 830AA7A2221484770097B6F1 /* LaunchScreen.storyboard */ = { 219 | isa = PBXVariantGroup; 220 | children = ( 221 | 830AA7A3221484770097B6F1 /* Base */, 222 | ); 223 | name = LaunchScreen.storyboard; 224 | sourceTree = ""; 225 | }; 226 | /* End PBXVariantGroup section */ 227 | 228 | /* Begin XCBuildConfiguration section */ 229 | 830AA7A6221484770097B6F1 /* Debug */ = { 230 | isa = XCBuildConfiguration; 231 | buildSettings = { 232 | ALWAYS_SEARCH_USER_PATHS = NO; 233 | CLANG_ANALYZER_NONNULL = YES; 234 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 235 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 236 | CLANG_CXX_LIBRARY = "libc++"; 237 | CLANG_ENABLE_MODULES = YES; 238 | CLANG_ENABLE_OBJC_ARC = YES; 239 | CLANG_ENABLE_OBJC_WEAK = YES; 240 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 241 | CLANG_WARN_BOOL_CONVERSION = YES; 242 | CLANG_WARN_COMMA = YES; 243 | CLANG_WARN_CONSTANT_CONVERSION = YES; 244 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 245 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 246 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 247 | CLANG_WARN_EMPTY_BODY = YES; 248 | CLANG_WARN_ENUM_CONVERSION = YES; 249 | CLANG_WARN_INFINITE_RECURSION = YES; 250 | CLANG_WARN_INT_CONVERSION = YES; 251 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 252 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 253 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 254 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 255 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 256 | CLANG_WARN_STRICT_PROTOTYPES = YES; 257 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 258 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 259 | CLANG_WARN_UNREACHABLE_CODE = YES; 260 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 261 | CODE_SIGN_IDENTITY = "iPhone Developer"; 262 | COPY_PHASE_STRIP = NO; 263 | DEBUG_INFORMATION_FORMAT = dwarf; 264 | ENABLE_STRICT_OBJC_MSGSEND = YES; 265 | ENABLE_TESTABILITY = YES; 266 | GCC_C_LANGUAGE_STANDARD = gnu11; 267 | GCC_DYNAMIC_NO_PIC = NO; 268 | GCC_NO_COMMON_BLOCKS = YES; 269 | GCC_OPTIMIZATION_LEVEL = 0; 270 | GCC_PREPROCESSOR_DEFINITIONS = ( 271 | "DEBUG=1", 272 | "$(inherited)", 273 | ); 274 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 275 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 276 | GCC_WARN_UNDECLARED_SELECTOR = YES; 277 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 278 | GCC_WARN_UNUSED_FUNCTION = YES; 279 | GCC_WARN_UNUSED_VARIABLE = YES; 280 | IPHONEOS_DEPLOYMENT_TARGET = 12.1; 281 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 282 | MTL_FAST_MATH = YES; 283 | ONLY_ACTIVE_ARCH = YES; 284 | SDKROOT = iphoneos; 285 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 286 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 287 | }; 288 | name = Debug; 289 | }; 290 | 830AA7A7221484770097B6F1 /* Release */ = { 291 | isa = XCBuildConfiguration; 292 | buildSettings = { 293 | ALWAYS_SEARCH_USER_PATHS = NO; 294 | CLANG_ANALYZER_NONNULL = YES; 295 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 296 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 297 | CLANG_CXX_LIBRARY = "libc++"; 298 | CLANG_ENABLE_MODULES = YES; 299 | CLANG_ENABLE_OBJC_ARC = YES; 300 | CLANG_ENABLE_OBJC_WEAK = YES; 301 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 302 | CLANG_WARN_BOOL_CONVERSION = YES; 303 | CLANG_WARN_COMMA = YES; 304 | CLANG_WARN_CONSTANT_CONVERSION = YES; 305 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 306 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 307 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 308 | CLANG_WARN_EMPTY_BODY = YES; 309 | CLANG_WARN_ENUM_CONVERSION = YES; 310 | CLANG_WARN_INFINITE_RECURSION = YES; 311 | CLANG_WARN_INT_CONVERSION = YES; 312 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 313 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 314 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 315 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 316 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 317 | CLANG_WARN_STRICT_PROTOTYPES = YES; 318 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 319 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 320 | CLANG_WARN_UNREACHABLE_CODE = YES; 321 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 322 | CODE_SIGN_IDENTITY = "iPhone Developer"; 323 | COPY_PHASE_STRIP = NO; 324 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 325 | ENABLE_NS_ASSERTIONS = NO; 326 | ENABLE_STRICT_OBJC_MSGSEND = YES; 327 | GCC_C_LANGUAGE_STANDARD = gnu11; 328 | GCC_NO_COMMON_BLOCKS = YES; 329 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 330 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 331 | GCC_WARN_UNDECLARED_SELECTOR = YES; 332 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 333 | GCC_WARN_UNUSED_FUNCTION = YES; 334 | GCC_WARN_UNUSED_VARIABLE = YES; 335 | IPHONEOS_DEPLOYMENT_TARGET = 12.1; 336 | MTL_ENABLE_DEBUG_INFO = NO; 337 | MTL_FAST_MATH = YES; 338 | SDKROOT = iphoneos; 339 | SWIFT_COMPILATION_MODE = wholemodule; 340 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 341 | VALIDATE_PRODUCT = YES; 342 | }; 343 | name = Release; 344 | }; 345 | 830AA7A9221484770097B6F1 /* Debug */ = { 346 | isa = XCBuildConfiguration; 347 | buildSettings = { 348 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 349 | CODE_SIGN_STYLE = Automatic; 350 | INFOPLIST_FILE = CustomCollectionLayout/Info.plist; 351 | LD_RUNPATH_SEARCH_PATHS = ( 352 | "$(inherited)", 353 | "@executable_path/Frameworks", 354 | ); 355 | PRODUCT_BUNDLE_IDENTIFIER = com.maksymhusar.CustomCollectionLayout; 356 | PRODUCT_NAME = "$(TARGET_NAME)"; 357 | SWIFT_VERSION = 4.2; 358 | TARGETED_DEVICE_FAMILY = "1,2"; 359 | }; 360 | name = Debug; 361 | }; 362 | 830AA7AA221484770097B6F1 /* Release */ = { 363 | isa = XCBuildConfiguration; 364 | buildSettings = { 365 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 366 | CODE_SIGN_STYLE = Automatic; 367 | INFOPLIST_FILE = CustomCollectionLayout/Info.plist; 368 | LD_RUNPATH_SEARCH_PATHS = ( 369 | "$(inherited)", 370 | "@executable_path/Frameworks", 371 | ); 372 | PRODUCT_BUNDLE_IDENTIFIER = com.maksymhusar.CustomCollectionLayout; 373 | PRODUCT_NAME = "$(TARGET_NAME)"; 374 | SWIFT_VERSION = 4.2; 375 | TARGETED_DEVICE_FAMILY = "1,2"; 376 | }; 377 | name = Release; 378 | }; 379 | /* End XCBuildConfiguration section */ 380 | 381 | /* Begin XCConfigurationList section */ 382 | 830AA791221484740097B6F1 /* Build configuration list for PBXProject "CustomCollectionLayout" */ = { 383 | isa = XCConfigurationList; 384 | buildConfigurations = ( 385 | 830AA7A6221484770097B6F1 /* Debug */, 386 | 830AA7A7221484770097B6F1 /* Release */, 387 | ); 388 | defaultConfigurationIsVisible = 0; 389 | defaultConfigurationName = Release; 390 | }; 391 | 830AA7A8221484770097B6F1 /* Build configuration list for PBXNativeTarget "CustomCollectionLayout" */ = { 392 | isa = XCConfigurationList; 393 | buildConfigurations = ( 394 | 830AA7A9221484770097B6F1 /* Debug */, 395 | 830AA7AA221484770097B6F1 /* Release */, 396 | ); 397 | defaultConfigurationIsVisible = 0; 398 | defaultConfigurationName = Release; 399 | }; 400 | /* End XCConfigurationList section */ 401 | }; 402 | rootObject = 830AA78E221484740097B6F1 /* Project object */; 403 | } 404 | -------------------------------------------------------------------------------- /CustomCollectionLayout/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CustomCollectionLayout 4 | // 5 | // Created by Maksym Husar on 2/13/19. 6 | // Copyright © 2019 MaksymHusar. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /CustomCollectionLayout/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 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/button_style/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/button_style/custom_grid.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "custom_grid.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "custom_grid@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "custom_grid@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | }, 23 | "properties" : { 24 | "template-rendering-intent" : "original" 25 | } 26 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/button_style/custom_grid.imageset/custom_grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/button_style/custom_grid.imageset/custom_grid.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/button_style/custom_grid.imageset/custom_grid@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/button_style/custom_grid.imageset/custom_grid@2x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/button_style/custom_grid.imageset/custom_grid@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/button_style/custom_grid.imageset/custom_grid@3x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/button_style/default_grid.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "default_grid.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "default_grid@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "default_grid@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | }, 23 | "properties" : { 24 | "template-rendering-intent" : "original" 25 | } 26 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/button_style/default_grid.imageset/default_grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/button_style/default_grid.imageset/default_grid.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/button_style/default_grid.imageset/default_grid@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/button_style/default_grid.imageset/default_grid@2x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/button_style/default_grid.imageset/default_grid@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/button_style/default_grid.imageset/default_grid@3x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/button_style/table.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "table.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "table@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "table@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | }, 23 | "properties" : { 24 | "template-rendering-intent" : "original" 25 | } 26 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/button_style/table.imageset/table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/button_style/table.imageset/table.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/button_style/table.imageset/table@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/button_style/table.imageset/table@2x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/button_style/table.imageset/table@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/button_style/table.imageset/table@3x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/apple.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "apple.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "apple@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "apple@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/apple.imageset/apple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/apple.imageset/apple.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/apple.imageset/apple@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/apple.imageset/apple@2x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/apple.imageset/apple@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/apple.imageset/apple@3x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/banana.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "banana.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "banana@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "banana@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/banana.imageset/banana.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/banana.imageset/banana.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/banana.imageset/banana@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/banana.imageset/banana@2x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/banana.imageset/banana@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/banana.imageset/banana@3x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/garnet.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "garnet.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "garnet@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "garnet@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/garnet.imageset/garnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/garnet.imageset/garnet.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/garnet.imageset/garnet@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/garnet.imageset/garnet@2x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/garnet.imageset/garnet@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/garnet.imageset/garnet@3x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/grapes.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "grapes.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "grapes@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "grapes@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/grapes.imageset/grapes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/grapes.imageset/grapes.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/grapes.imageset/grapes@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/grapes.imageset/grapes@2x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/grapes.imageset/grapes@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/grapes.imageset/grapes@3x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/green_apple.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "green_apple.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "green_apple@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "green_apple@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/green_apple.imageset/green_apple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/green_apple.imageset/green_apple.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/green_apple.imageset/green_apple@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/green_apple.imageset/green_apple@2x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/green_apple.imageset/green_apple@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/green_apple.imageset/green_apple@3x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/green_pears.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "green_pears.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "green_pears@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "green_pears@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/green_pears.imageset/green_pears.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/green_pears.imageset/green_pears.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/green_pears.imageset/green_pears@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/green_pears.imageset/green_pears@2x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/green_pears.imageset/green_pears@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/green_pears.imageset/green_pears@3x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/kiwi.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "kiwi.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "kiwi@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "kiwi@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/kiwi.imageset/kiwi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/kiwi.imageset/kiwi.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/kiwi.imageset/kiwi@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/kiwi.imageset/kiwi@2x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/kiwi.imageset/kiwi@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/kiwi.imageset/kiwi@3x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/mango.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "mango.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "mango@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "mango@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/mango.imageset/mango.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/mango.imageset/mango.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/mango.imageset/mango@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/mango.imageset/mango@2x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/mango.imageset/mango@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/mango.imageset/mango@3x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/mango2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "mango2.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "mango2@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "mango2@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/mango2.imageset/mango2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/mango2.imageset/mango2.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/mango2.imageset/mango2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/mango2.imageset/mango2@2x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/mango2.imageset/mango2@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/mango2.imageset/mango2@3x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/orange.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "orange.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "orange@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "orange@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/orange.imageset/orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/orange.imageset/orange.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/orange.imageset/orange@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/orange.imageset/orange@2x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/orange.imageset/orange@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/orange.imageset/orange@3x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/pears.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "pears.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "pears@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "pears@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/pears.imageset/pears.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/pears.imageset/pears.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/pears.imageset/pears@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/pears.imageset/pears@2x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/pears.imageset/pears@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/pears.imageset/pears@3x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/pineapple.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "pineapple.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "pineapple@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "pineapple@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/pineapple.imageset/pineapple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/pineapple.imageset/pineapple.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/pineapple.imageset/pineapple@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/pineapple.imageset/pineapple@2x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/Assets.xcassets/fruits/pineapple.imageset/pineapple@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/CustomCollectionLayout/Assets.xcassets/fruits/pineapple.imageset/pineapple@3x.png -------------------------------------------------------------------------------- /CustomCollectionLayout/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 | -------------------------------------------------------------------------------- /CustomCollectionLayout/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 | -------------------------------------------------------------------------------- /CustomCollectionLayout/Collection FlowLayouts/CustomGriddedContentCollectionViewDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomGriddedContentCollectionViewDelegate.swift 3 | // CustomCollectionLayout 4 | // 5 | // Created by Maksym Husar on 2/16/19. 6 | // Copyright © 2019 MaksymHusar. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CustomGriddedContentCollectionViewDelegate: DefaultCollectionViewDelegate { 12 | private let itemsPerRow: CGFloat = 3 13 | private let minimumItemSpacing: CGFloat = 8 14 | 15 | // MARK: - UICollectionViewDelegateFlowLayout 16 | func collectionView(_ collectionView: UICollectionView, 17 | layout collectionViewLayout: UICollectionViewLayout, 18 | sizeForItemAt indexPath: IndexPath) -> CGSize { 19 | let itemSize: CGSize 20 | if indexPath.item % 4 == 0 { 21 | let itemWidth = collectionView.bounds.width - (sectionInsets.left + sectionInsets.right) 22 | itemSize = CGSize(width: itemWidth, height: 112) 23 | } else { 24 | let paddingSpace = sectionInsets.left + sectionInsets.right + minimumItemSpacing * (itemsPerRow - 1) 25 | let availableWidth = collectionView.bounds.width - paddingSpace 26 | let widthPerItem = availableWidth / itemsPerRow 27 | itemSize = CGSize(width: widthPerItem, height: widthPerItem) 28 | } 29 | return itemSize 30 | } 31 | 32 | func collectionView(_ collectionView: UICollectionView, 33 | layout collectionViewLayout: UICollectionViewLayout, 34 | insetForSectionAt section: Int) -> UIEdgeInsets { 35 | return sectionInsets 36 | } 37 | 38 | func collectionView(_ collectionView: UICollectionView, 39 | layout collectionViewLayout: UICollectionViewLayout, 40 | minimumLineSpacingForSectionAt section: Int) -> CGFloat { 41 | return 20 42 | } 43 | 44 | func collectionView(_ collectionView: UICollectionView, 45 | layout collectionViewLayout: UICollectionViewLayout, 46 | minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { 47 | return minimumItemSpacing 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /CustomCollectionLayout/Collection FlowLayouts/DefaultCollectionViewDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DefaultCollectionViewDelegate.swift 3 | // CustomCollectionLayout 4 | // 5 | // Created by Maksym Husar on 2/16/19. 6 | // Copyright © 2019 MaksymHusar. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol CollectionViewSelectableItemDelegate: class, UICollectionViewDelegateFlowLayout { 12 | var didSelectItem: ((_ indexPath: IndexPath) -> Void)? { get set } 13 | } 14 | 15 | class DefaultCollectionViewDelegate: NSObject, CollectionViewSelectableItemDelegate { 16 | var didSelectItem: ((_ indexPath: IndexPath) -> Void)? 17 | let sectionInsets = UIEdgeInsets(top: 16.0, left: 16.0, bottom: 20.0, right: 16.0) 18 | 19 | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 20 | didSelectItem?(indexPath) 21 | } 22 | 23 | func collectionView(_ collectionView: UICollectionView, didHighlightItemAt indexPath: IndexPath) { 24 | let cell = collectionView.cellForItem(at: indexPath) 25 | cell?.backgroundColor = UIColor.clear 26 | } 27 | 28 | func collectionView(_ collectionView: UICollectionView, didUnhighlightItemAt indexPath: IndexPath) { 29 | let cell = collectionView.cellForItem(at: indexPath) 30 | cell?.backgroundColor = UIColor.white 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /CustomCollectionLayout/Collection FlowLayouts/DefaultGriddedContentCollectionViewDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DefaultGriddedContentCollectionViewDelegate.swift 3 | // CustomCollectionLayout 4 | // 5 | // Created by Maksym Husar on 2/17/19. 6 | // Copyright © 2019 MaksymHusar. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class DefaultGriddedContentCollectionViewDelegate: DefaultCollectionViewDelegate { 12 | private let itemsPerRow: CGFloat = 3 13 | private let minimumItemSpacing: CGFloat = 8 14 | 15 | // MARK: - UICollectionViewDelegateFlowLayout 16 | func collectionView(_ collectionView: UICollectionView, 17 | layout collectionViewLayout: UICollectionViewLayout, 18 | sizeForItemAt indexPath: IndexPath) -> CGSize { 19 | let paddingSpace = sectionInsets.left + sectionInsets.right + minimumItemSpacing * (itemsPerRow - 1) 20 | let availableWidth = collectionView.bounds.width - paddingSpace 21 | let widthPerItem = availableWidth / itemsPerRow 22 | return CGSize(width: widthPerItem, height: widthPerItem) 23 | } 24 | 25 | func collectionView(_ collectionView: UICollectionView, 26 | layout collectionViewLayout: UICollectionViewLayout, 27 | insetForSectionAt section: Int) -> UIEdgeInsets { 28 | return sectionInsets 29 | } 30 | 31 | func collectionView(_ collectionView: UICollectionView, 32 | layout collectionViewLayout: UICollectionViewLayout, 33 | minimumLineSpacingForSectionAt section: Int) -> CGFloat { 34 | return 20 35 | } 36 | 37 | func collectionView(_ collectionView: UICollectionView, 38 | layout collectionViewLayout: UICollectionViewLayout, 39 | minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { 40 | return minimumItemSpacing 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /CustomCollectionLayout/Collection FlowLayouts/TabledContentCollectionViewDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TabledContentCollectionViewDelegate.swift 3 | // CustomCollectionLayout 4 | // 5 | // Created by Maksym Husar on 2/16/19. 6 | // Copyright © 2019 MaksymHusar. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class TabledContentCollectionViewDelegate: DefaultCollectionViewDelegate { 12 | // MARK: - UICollectionViewDelegateFlowLayout 13 | func collectionView(_ collectionView: UICollectionView, 14 | layout collectionViewLayout: UICollectionViewLayout, 15 | sizeForItemAt indexPath: IndexPath) -> CGSize { 16 | let paddingSpace = sectionInsets.left + sectionInsets.right 17 | let widthPerItem = collectionView.bounds.width - paddingSpace 18 | return CGSize(width: widthPerItem, height: 112) 19 | } 20 | 21 | func collectionView(_ collectionView: UICollectionView, 22 | layout collectionViewLayout: UICollectionViewLayout, 23 | insetForSectionAt section: Int) -> UIEdgeInsets { 24 | return sectionInsets 25 | } 26 | 27 | func collectionView(_ collectionView: UICollectionView, 28 | layout collectionViewLayout: UICollectionViewLayout, 29 | minimumLineSpacingForSectionAt section: Int) -> CGFloat { 30 | return 10 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /CustomCollectionLayout/Entities/Fruit.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Fruit.swift 3 | // CustomCollectionLayout 4 | // 5 | // Created by Maksym Husar on 2/13/19. 6 | // Copyright © 2019 MaksymHusar. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit.UIImage 11 | 12 | struct Fruit { 13 | let name: String 14 | let icon: UIImage 15 | } 16 | -------------------------------------------------------------------------------- /CustomCollectionLayout/Entities/FruitsProvider.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FruitsProvider.swift 3 | // CustomCollectionLayout 4 | // 5 | // Created by Maksym Husar on 2/17/19. 6 | // Copyright © 2019 MaksymHusar. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct FruitsProvider { 12 | static func get() -> [Fruit] { 13 | return [ 14 | Fruit(name: "Red Apple", icon: #imageLiteral(resourceName: "apple")), 15 | Fruit(name: "Banana", icon: #imageLiteral(resourceName: "banana")), 16 | Fruit(name: "Garnet", icon: #imageLiteral(resourceName: "garnet")), 17 | Fruit(name: "Grapes", icon: #imageLiteral(resourceName: "grapes")), 18 | Fruit(name: "Green Apple", icon: #imageLiteral(resourceName: "green_apple")), 19 | Fruit(name: "Kiwi", icon: #imageLiteral(resourceName: "kiwi")), 20 | Fruit(name: "Green Pears", icon: #imageLiteral(resourceName: "green_pears")), 21 | Fruit(name: "Mango", icon: #imageLiteral(resourceName: "mango")), 22 | Fruit(name: "Orange", icon: #imageLiteral(resourceName: "orange")), 23 | Fruit(name: "Sliced Mango", icon: #imageLiteral(resourceName: "mango2")), 24 | Fruit(name: "Pears", icon: #imageLiteral(resourceName: "pears")), 25 | Fruit(name: "Pineapple", icon: #imageLiteral(resourceName: "pineapple")) 26 | ] 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /CustomCollectionLayout/FruitCollectionCell/FruitCollectionViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FruitCollectionViewCell.swift 3 | // CustomCollectionLayout 4 | // 5 | // Created by Maksym Husar on 2/13/19. 6 | // Copyright © 2019 MaksymHusar. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class FruitCollectionViewCell: UICollectionViewCell { 12 | static let reuseID = String(describing: FruitCollectionViewCell.self) 13 | static let nib = UINib(nibName: String(describing: FruitCollectionViewCell.self), bundle: nil) 14 | 15 | @IBOutlet private weak var stackView: UIStackView! 16 | 17 | @IBOutlet private weak var ibImageView: UIImageView! 18 | @IBOutlet private weak var ibLabel: UILabel! 19 | 20 | override func awakeFromNib() { 21 | super.awakeFromNib() 22 | backgroundColor = .white 23 | clipsToBounds = true 24 | layer.cornerRadius = 4 25 | ibLabel.font = UIFont.systemFont(ofSize: 18) 26 | } 27 | 28 | override func layoutSubviews() { 29 | super.layoutSubviews() 30 | updateContentStyle() 31 | } 32 | 33 | func update(title: String, image: UIImage) { 34 | ibImageView.image = image 35 | ibLabel.text = title 36 | } 37 | 38 | private func updateContentStyle() { 39 | let isHorizontalStyle = bounds.width > 2 * bounds.height 40 | let oldAxis = stackView.axis 41 | let newAxis: NSLayoutConstraint.Axis = isHorizontalStyle ? .horizontal : .vertical 42 | guard oldAxis != newAxis else { return } 43 | 44 | stackView.axis = newAxis 45 | stackView.spacing = isHorizontalStyle ? 16 : 4 46 | ibLabel.textAlignment = isHorizontalStyle ? .left : .center 47 | let fontTransform: CGAffineTransform = isHorizontalStyle ? .identity : CGAffineTransform(scaleX: 0.8, y: 0.8) 48 | 49 | UIView.animate(withDuration: 0.3) { 50 | self.ibLabel.transform = fontTransform 51 | self.layoutIfNeeded() 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /CustomCollectionLayout/FruitCollectionCell/FruitCollectionViewCell.xib: -------------------------------------------------------------------------------- 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 | 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 | -------------------------------------------------------------------------------- /CustomCollectionLayout/FruitsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FruitsViewController.swift 3 | // CustomCollectionLayout 4 | // 5 | // Created by Maksym Husar on 2/13/19. 6 | // Copyright © 2019 MaksymHusar. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class FruitsViewController: UICollectionViewController { 12 | private enum PresentationStyle: String, CaseIterable { 13 | case table 14 | case defaultGrid 15 | case customGrid 16 | 17 | var buttonImage: UIImage { 18 | switch self { 19 | case .table: return #imageLiteral(resourceName: "table") 20 | case .defaultGrid: return #imageLiteral(resourceName: "default_grid") 21 | case .customGrid: return #imageLiteral(resourceName: "custom_grid") 22 | } 23 | } 24 | } 25 | 26 | private var selectedStyle: PresentationStyle = .table { 27 | didSet { updatePresentationStyle() } 28 | } 29 | private var styleDelegates: [PresentationStyle: CollectionViewSelectableItemDelegate] = { 30 | let result: [PresentationStyle: CollectionViewSelectableItemDelegate] = [ 31 | .table: TabledContentCollectionViewDelegate(), 32 | .defaultGrid: DefaultGriddedContentCollectionViewDelegate(), 33 | .customGrid: CustomGriddedContentCollectionViewDelegate(), 34 | ] 35 | result.values.forEach { 36 | $0.didSelectItem = { _ in 37 | print("Item selected") 38 | } 39 | } 40 | return result 41 | }() 42 | 43 | private var datasource: [Fruit] = FruitsProvider.get() 44 | 45 | override func viewDidLoad() { 46 | super.viewDidLoad() 47 | self.collectionView.register(FruitCollectionViewCell.nib, 48 | forCellWithReuseIdentifier: FruitCollectionViewCell.reuseID) 49 | collectionView.contentInset = .zero 50 | updatePresentationStyle() 51 | 52 | navigationItem.rightBarButtonItem = UIBarButtonItem(image: selectedStyle.buttonImage, style: .plain, target: self, action: #selector(changeContentLayout)) 53 | } 54 | 55 | private func updatePresentationStyle() { 56 | collectionView.delegate = styleDelegates[selectedStyle] 57 | collectionView.performBatchUpdates({ 58 | collectionView.reloadData() 59 | }, completion: nil) 60 | 61 | navigationItem.rightBarButtonItem?.image = selectedStyle.buttonImage 62 | } 63 | 64 | @objc private func changeContentLayout() { 65 | let allCases = PresentationStyle.allCases 66 | guard let index = allCases.firstIndex(of: selectedStyle) else { return } 67 | let nextIndex = (index + 1) % allCases.count 68 | selectedStyle = allCases[nextIndex] 69 | 70 | } 71 | } 72 | 73 | // MARK: UICollectionViewDataSource & UICollectionViewDelegate 74 | extension FruitsViewController { 75 | override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 76 | return datasource.count 77 | } 78 | 79 | override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 80 | guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: FruitCollectionViewCell.reuseID, 81 | for: indexPath) as? FruitCollectionViewCell else { 82 | fatalError("Wrong cell") 83 | } 84 | let fruit = datasource[indexPath.item] 85 | cell.update(title: fruit.name, image: fruit.icon) 86 | return cell 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /CustomCollectionLayout/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 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /CustomCollectionLayout/TabledContentCollectionViewDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TabledContentCollectionViewDelegate.swift 3 | // CustomCollectionLayout 4 | // 5 | // Created by Maksym Husar on 2/16/19. 6 | // Copyright © 2019 MaksymHusar. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class TabledContentCollectionViewDelegate: DefaultCollectionViewDelegate { 12 | private var itemsPerRow: CGFloat = 3 13 | private var sectionInsets = UIEdgeInsets(top: 20.0, left: 12.0, bottom: 30.0, right: 4.0) 14 | 15 | // MARK: - UICollectionViewDelegateFlowLayout 16 | func collectionView(_ collectionView: UICollectionView, 17 | layout collectionViewLayout: UICollectionViewLayout, 18 | sizeForItemAt indexPath: IndexPath) -> CGSize { 19 | let paddingSpace = sectionInsets.left + sectionInsets.right 20 | let widthPerItem = collectionView.bounds.width - paddingSpace 21 | return CGSize(width: widthPerItem, height: widthPerItem * 0.5) 22 | } 23 | 24 | func collectionView(_ collectionView: UICollectionView, 25 | layout collectionViewLayout: UICollectionViewLayout, 26 | insetForSectionAt section: Int) -> UIEdgeInsets { 27 | return sectionInsets 28 | } 29 | 30 | func collectionView(_ collectionView: UICollectionView, 31 | layout collectionViewLayout: UICollectionViewLayout, 32 | minimumLineSpacingForSectionAt section: Int) -> CGFloat { 33 | return 10 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Husar Maksym 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](https://github.com/IndeemaSoftware/CustomCollectionLayout/blob/master/demo.gif) 2 | 3 | ## Introduction 4 | This is an example project for my article called "UICollectionView Tutorial: Changing presentation on the fly" 5 | 6 | In English: 7 | https://indeema.com/blog/uicollectionview-tutorial--changing-presentation-on-the-fly 8 | 9 | In Russian: 10 | https://habr.com/ru/post/445708/ 11 | 12 | ## Minimum requirements: 13 | - Swift 4.2 14 | 15 | ## Communication and Support 16 | Simply email us at support@indeema.com. 17 | 18 | You can also follow our news at @IndeemaSoftware or on our blog. 19 | 20 | ## License 21 | CustomCollectionLayout is available under the MIT license. See the LICENSE file for more info. 22 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndeemaSoftware/CustomCollectionLayout/3d76a153053b55a26efaef44c1ba38860f07c971/demo.gif --------------------------------------------------------------------------------