├── .gitignore ├── ImageCarousel.xcodeproj └── project.pbxproj ├── ImageCarousel ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── image_carousel_1.imageset │ │ ├── Contents.json │ │ └── black-cassette-tape-on-top-of-red-and-yellow-surface-1626481.jpg │ ├── image_carousel_2.imageset │ │ ├── Contents.json │ │ └── man-in-bus-247929.jpg │ ├── image_carousel_3.imageset │ │ ├── Contents.json │ │ └── black-crt-tv-showing-gray-screen-704555.jpg │ └── person.imageset │ │ ├── Contents.json │ │ └── adolescent-adult-black-and-white-casual-270968 2.jpg ├── Base.lproj │ └── LaunchScreen.storyboard ├── ContentView.swift ├── ImageCarouselView.swift ├── Info.plist ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json └── SceneDelegate.swift ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ImageCarousel.xcodeproj/project.xcworkspace 2 | ImageCarousel.xcodeproj/xcuserdata 3 | -------------------------------------------------------------------------------- /ImageCarousel.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8F9A480123C56D3F00D2B40F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F9A480023C56D3F00D2B40F /* AppDelegate.swift */; }; 11 | 8F9A480323C56D3F00D2B40F /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F9A480223C56D3F00D2B40F /* SceneDelegate.swift */; }; 12 | 8F9A480523C56D3F00D2B40F /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F9A480423C56D3F00D2B40F /* ContentView.swift */; }; 13 | 8F9A480723C56D4000D2B40F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8F9A480623C56D4000D2B40F /* Assets.xcassets */; }; 14 | 8F9A480A23C56D4000D2B40F /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8F9A480923C56D4000D2B40F /* Preview Assets.xcassets */; }; 15 | 8F9A480D23C56D4000D2B40F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8F9A480B23C56D4000D2B40F /* LaunchScreen.storyboard */; }; 16 | 8F9A481523C576F000D2B40F /* ImageCarouselView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F9A481423C576F000D2B40F /* ImageCarouselView.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 8F9A47FD23C56D3F00D2B40F /* ImageCarousel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ImageCarousel.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 8F9A480023C56D3F00D2B40F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 22 | 8F9A480223C56D3F00D2B40F /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 23 | 8F9A480423C56D3F00D2B40F /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 24 | 8F9A480623C56D4000D2B40F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 25 | 8F9A480923C56D4000D2B40F /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 26 | 8F9A480C23C56D4000D2B40F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 27 | 8F9A480E23C56D4000D2B40F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 28 | 8F9A481423C576F000D2B40F /* ImageCarouselView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageCarouselView.swift; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 8F9A47FA23C56D3F00D2B40F /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 8F9A47F423C56D3F00D2B40F = { 43 | isa = PBXGroup; 44 | children = ( 45 | 8F9A47FF23C56D3F00D2B40F /* ImageCarousel */, 46 | 8F9A47FE23C56D3F00D2B40F /* Products */, 47 | ); 48 | sourceTree = ""; 49 | }; 50 | 8F9A47FE23C56D3F00D2B40F /* Products */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 8F9A47FD23C56D3F00D2B40F /* ImageCarousel.app */, 54 | ); 55 | name = Products; 56 | sourceTree = ""; 57 | }; 58 | 8F9A47FF23C56D3F00D2B40F /* ImageCarousel */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 8F9A480023C56D3F00D2B40F /* AppDelegate.swift */, 62 | 8F9A480223C56D3F00D2B40F /* SceneDelegate.swift */, 63 | 8F9A480423C56D3F00D2B40F /* ContentView.swift */, 64 | 8F9A481423C576F000D2B40F /* ImageCarouselView.swift */, 65 | 8F9A480623C56D4000D2B40F /* Assets.xcassets */, 66 | 8F9A480B23C56D4000D2B40F /* LaunchScreen.storyboard */, 67 | 8F9A480E23C56D4000D2B40F /* Info.plist */, 68 | 8F9A480823C56D4000D2B40F /* Preview Content */, 69 | ); 70 | path = ImageCarousel; 71 | sourceTree = ""; 72 | }; 73 | 8F9A480823C56D4000D2B40F /* Preview Content */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | 8F9A480923C56D4000D2B40F /* Preview Assets.xcassets */, 77 | ); 78 | path = "Preview Content"; 79 | sourceTree = ""; 80 | }; 81 | /* End PBXGroup section */ 82 | 83 | /* Begin PBXNativeTarget section */ 84 | 8F9A47FC23C56D3F00D2B40F /* ImageCarousel */ = { 85 | isa = PBXNativeTarget; 86 | buildConfigurationList = 8F9A481123C56D4000D2B40F /* Build configuration list for PBXNativeTarget "ImageCarousel" */; 87 | buildPhases = ( 88 | 8F9A47F923C56D3F00D2B40F /* Sources */, 89 | 8F9A47FA23C56D3F00D2B40F /* Frameworks */, 90 | 8F9A47FB23C56D3F00D2B40F /* Resources */, 91 | ); 92 | buildRules = ( 93 | ); 94 | dependencies = ( 95 | ); 96 | name = ImageCarousel; 97 | productName = ImageCarousel; 98 | productReference = 8F9A47FD23C56D3F00D2B40F /* ImageCarousel.app */; 99 | productType = "com.apple.product-type.application"; 100 | }; 101 | /* End PBXNativeTarget section */ 102 | 103 | /* Begin PBXProject section */ 104 | 8F9A47F523C56D3F00D2B40F /* Project object */ = { 105 | isa = PBXProject; 106 | attributes = { 107 | LastSwiftUpdateCheck = 1130; 108 | LastUpgradeCheck = 1130; 109 | ORGANIZATIONNAME = "Brandon Baars"; 110 | TargetAttributes = { 111 | 8F9A47FC23C56D3F00D2B40F = { 112 | CreatedOnToolsVersion = 11.3; 113 | }; 114 | }; 115 | }; 116 | buildConfigurationList = 8F9A47F823C56D3F00D2B40F /* Build configuration list for PBXProject "ImageCarousel" */; 117 | compatibilityVersion = "Xcode 9.3"; 118 | developmentRegion = en; 119 | hasScannedForEncodings = 0; 120 | knownRegions = ( 121 | en, 122 | Base, 123 | ); 124 | mainGroup = 8F9A47F423C56D3F00D2B40F; 125 | productRefGroup = 8F9A47FE23C56D3F00D2B40F /* Products */; 126 | projectDirPath = ""; 127 | projectRoot = ""; 128 | targets = ( 129 | 8F9A47FC23C56D3F00D2B40F /* ImageCarousel */, 130 | ); 131 | }; 132 | /* End PBXProject section */ 133 | 134 | /* Begin PBXResourcesBuildPhase section */ 135 | 8F9A47FB23C56D3F00D2B40F /* Resources */ = { 136 | isa = PBXResourcesBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | 8F9A480D23C56D4000D2B40F /* LaunchScreen.storyboard in Resources */, 140 | 8F9A480A23C56D4000D2B40F /* Preview Assets.xcassets in Resources */, 141 | 8F9A480723C56D4000D2B40F /* Assets.xcassets in Resources */, 142 | ); 143 | runOnlyForDeploymentPostprocessing = 0; 144 | }; 145 | /* End PBXResourcesBuildPhase section */ 146 | 147 | /* Begin PBXSourcesBuildPhase section */ 148 | 8F9A47F923C56D3F00D2B40F /* Sources */ = { 149 | isa = PBXSourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | 8F9A480123C56D3F00D2B40F /* AppDelegate.swift in Sources */, 153 | 8F9A480323C56D3F00D2B40F /* SceneDelegate.swift in Sources */, 154 | 8F9A481523C576F000D2B40F /* ImageCarouselView.swift in Sources */, 155 | 8F9A480523C56D3F00D2B40F /* ContentView.swift in Sources */, 156 | ); 157 | runOnlyForDeploymentPostprocessing = 0; 158 | }; 159 | /* End PBXSourcesBuildPhase section */ 160 | 161 | /* Begin PBXVariantGroup section */ 162 | 8F9A480B23C56D4000D2B40F /* LaunchScreen.storyboard */ = { 163 | isa = PBXVariantGroup; 164 | children = ( 165 | 8F9A480C23C56D4000D2B40F /* Base */, 166 | ); 167 | name = LaunchScreen.storyboard; 168 | sourceTree = ""; 169 | }; 170 | /* End PBXVariantGroup section */ 171 | 172 | /* Begin XCBuildConfiguration section */ 173 | 8F9A480F23C56D4000D2B40F /* Debug */ = { 174 | isa = XCBuildConfiguration; 175 | buildSettings = { 176 | ALWAYS_SEARCH_USER_PATHS = NO; 177 | CLANG_ANALYZER_NONNULL = YES; 178 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 179 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 180 | CLANG_CXX_LIBRARY = "libc++"; 181 | CLANG_ENABLE_MODULES = YES; 182 | CLANG_ENABLE_OBJC_ARC = YES; 183 | CLANG_ENABLE_OBJC_WEAK = YES; 184 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 185 | CLANG_WARN_BOOL_CONVERSION = YES; 186 | CLANG_WARN_COMMA = YES; 187 | CLANG_WARN_CONSTANT_CONVERSION = YES; 188 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 189 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 190 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 191 | CLANG_WARN_EMPTY_BODY = YES; 192 | CLANG_WARN_ENUM_CONVERSION = YES; 193 | CLANG_WARN_INFINITE_RECURSION = YES; 194 | CLANG_WARN_INT_CONVERSION = YES; 195 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 196 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 197 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 198 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 199 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 200 | CLANG_WARN_STRICT_PROTOTYPES = YES; 201 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 202 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 203 | CLANG_WARN_UNREACHABLE_CODE = YES; 204 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 205 | COPY_PHASE_STRIP = NO; 206 | DEBUG_INFORMATION_FORMAT = dwarf; 207 | ENABLE_STRICT_OBJC_MSGSEND = YES; 208 | ENABLE_TESTABILITY = YES; 209 | GCC_C_LANGUAGE_STANDARD = gnu11; 210 | GCC_DYNAMIC_NO_PIC = NO; 211 | GCC_NO_COMMON_BLOCKS = YES; 212 | GCC_OPTIMIZATION_LEVEL = 0; 213 | GCC_PREPROCESSOR_DEFINITIONS = ( 214 | "DEBUG=1", 215 | "$(inherited)", 216 | ); 217 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 218 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 219 | GCC_WARN_UNDECLARED_SELECTOR = YES; 220 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 221 | GCC_WARN_UNUSED_FUNCTION = YES; 222 | GCC_WARN_UNUSED_VARIABLE = YES; 223 | IPHONEOS_DEPLOYMENT_TARGET = 13.2; 224 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 225 | MTL_FAST_MATH = YES; 226 | ONLY_ACTIVE_ARCH = YES; 227 | SDKROOT = iphoneos; 228 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 229 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 230 | }; 231 | name = Debug; 232 | }; 233 | 8F9A481023C56D4000D2B40F /* Release */ = { 234 | isa = XCBuildConfiguration; 235 | buildSettings = { 236 | ALWAYS_SEARCH_USER_PATHS = NO; 237 | CLANG_ANALYZER_NONNULL = YES; 238 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 239 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 240 | CLANG_CXX_LIBRARY = "libc++"; 241 | CLANG_ENABLE_MODULES = YES; 242 | CLANG_ENABLE_OBJC_ARC = YES; 243 | CLANG_ENABLE_OBJC_WEAK = YES; 244 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 245 | CLANG_WARN_BOOL_CONVERSION = YES; 246 | CLANG_WARN_COMMA = YES; 247 | CLANG_WARN_CONSTANT_CONVERSION = YES; 248 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 249 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 250 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 251 | CLANG_WARN_EMPTY_BODY = YES; 252 | CLANG_WARN_ENUM_CONVERSION = YES; 253 | CLANG_WARN_INFINITE_RECURSION = YES; 254 | CLANG_WARN_INT_CONVERSION = YES; 255 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 256 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 257 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 258 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 259 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 260 | CLANG_WARN_STRICT_PROTOTYPES = YES; 261 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 262 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 263 | CLANG_WARN_UNREACHABLE_CODE = YES; 264 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 265 | COPY_PHASE_STRIP = NO; 266 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 267 | ENABLE_NS_ASSERTIONS = NO; 268 | ENABLE_STRICT_OBJC_MSGSEND = YES; 269 | GCC_C_LANGUAGE_STANDARD = gnu11; 270 | GCC_NO_COMMON_BLOCKS = YES; 271 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 272 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 273 | GCC_WARN_UNDECLARED_SELECTOR = YES; 274 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 275 | GCC_WARN_UNUSED_FUNCTION = YES; 276 | GCC_WARN_UNUSED_VARIABLE = YES; 277 | IPHONEOS_DEPLOYMENT_TARGET = 13.2; 278 | MTL_ENABLE_DEBUG_INFO = NO; 279 | MTL_FAST_MATH = YES; 280 | SDKROOT = iphoneos; 281 | SWIFT_COMPILATION_MODE = wholemodule; 282 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 283 | VALIDATE_PRODUCT = YES; 284 | }; 285 | name = Release; 286 | }; 287 | 8F9A481223C56D4000D2B40F /* Debug */ = { 288 | isa = XCBuildConfiguration; 289 | buildSettings = { 290 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 291 | CODE_SIGN_STYLE = Automatic; 292 | DEVELOPMENT_ASSET_PATHS = "\"ImageCarousel/Preview Content\""; 293 | DEVELOPMENT_TEAM = 4TWWRT697R; 294 | ENABLE_PREVIEWS = YES; 295 | INFOPLIST_FILE = ImageCarousel/Info.plist; 296 | LD_RUNPATH_SEARCH_PATHS = ( 297 | "$(inherited)", 298 | "@executable_path/Frameworks", 299 | ); 300 | PRODUCT_BUNDLE_IDENTIFIER = com.BB.ImageCarousel; 301 | PRODUCT_NAME = "$(TARGET_NAME)"; 302 | SWIFT_VERSION = 5.0; 303 | TARGETED_DEVICE_FAMILY = "1,2"; 304 | }; 305 | name = Debug; 306 | }; 307 | 8F9A481323C56D4000D2B40F /* Release */ = { 308 | isa = XCBuildConfiguration; 309 | buildSettings = { 310 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 311 | CODE_SIGN_STYLE = Automatic; 312 | DEVELOPMENT_ASSET_PATHS = "\"ImageCarousel/Preview Content\""; 313 | DEVELOPMENT_TEAM = 4TWWRT697R; 314 | ENABLE_PREVIEWS = YES; 315 | INFOPLIST_FILE = ImageCarousel/Info.plist; 316 | LD_RUNPATH_SEARCH_PATHS = ( 317 | "$(inherited)", 318 | "@executable_path/Frameworks", 319 | ); 320 | PRODUCT_BUNDLE_IDENTIFIER = com.BB.ImageCarousel; 321 | PRODUCT_NAME = "$(TARGET_NAME)"; 322 | SWIFT_VERSION = 5.0; 323 | TARGETED_DEVICE_FAMILY = "1,2"; 324 | }; 325 | name = Release; 326 | }; 327 | /* End XCBuildConfiguration section */ 328 | 329 | /* Begin XCConfigurationList section */ 330 | 8F9A47F823C56D3F00D2B40F /* Build configuration list for PBXProject "ImageCarousel" */ = { 331 | isa = XCConfigurationList; 332 | buildConfigurations = ( 333 | 8F9A480F23C56D4000D2B40F /* Debug */, 334 | 8F9A481023C56D4000D2B40F /* Release */, 335 | ); 336 | defaultConfigurationIsVisible = 0; 337 | defaultConfigurationName = Release; 338 | }; 339 | 8F9A481123C56D4000D2B40F /* Build configuration list for PBXNativeTarget "ImageCarousel" */ = { 340 | isa = XCConfigurationList; 341 | buildConfigurations = ( 342 | 8F9A481223C56D4000D2B40F /* Debug */, 343 | 8F9A481323C56D4000D2B40F /* Release */, 344 | ); 345 | defaultConfigurationIsVisible = 0; 346 | defaultConfigurationName = Release; 347 | }; 348 | /* End XCConfigurationList section */ 349 | }; 350 | rootObject = 8F9A47F523C56D3F00D2B40F /* Project object */; 351 | } 352 | -------------------------------------------------------------------------------- /ImageCarousel/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ImageCarousel 4 | // 5 | // Created by Brandon Baars on 1/7/20. 6 | // Copyright © 2020 Brandon Baars. 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 | -------------------------------------------------------------------------------- /ImageCarousel/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 | } -------------------------------------------------------------------------------- /ImageCarousel/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ImageCarousel/Assets.xcassets/image_carousel_1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "black-cassette-tape-on-top-of-red-and-yellow-surface-1626481.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ImageCarousel/Assets.xcassets/image_carousel_1.imageset/black-cassette-tape-on-top-of-red-and-yellow-surface-1626481.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bbaars/SwiftUI-Image-Carousel/f833e8218c3f83ad391b10e8a5d0b672bef3a0d5/ImageCarousel/Assets.xcassets/image_carousel_1.imageset/black-cassette-tape-on-top-of-red-and-yellow-surface-1626481.jpg -------------------------------------------------------------------------------- /ImageCarousel/Assets.xcassets/image_carousel_2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "man-in-bus-247929.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ImageCarousel/Assets.xcassets/image_carousel_2.imageset/man-in-bus-247929.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bbaars/SwiftUI-Image-Carousel/f833e8218c3f83ad391b10e8a5d0b672bef3a0d5/ImageCarousel/Assets.xcassets/image_carousel_2.imageset/man-in-bus-247929.jpg -------------------------------------------------------------------------------- /ImageCarousel/Assets.xcassets/image_carousel_3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "black-crt-tv-showing-gray-screen-704555.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ImageCarousel/Assets.xcassets/image_carousel_3.imageset/black-crt-tv-showing-gray-screen-704555.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bbaars/SwiftUI-Image-Carousel/f833e8218c3f83ad391b10e8a5d0b672bef3a0d5/ImageCarousel/Assets.xcassets/image_carousel_3.imageset/black-crt-tv-showing-gray-screen-704555.jpg -------------------------------------------------------------------------------- /ImageCarousel/Assets.xcassets/person.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "adolescent-adult-black-and-white-casual-270968 2.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ImageCarousel/Assets.xcassets/person.imageset/adolescent-adult-black-and-white-casual-270968 2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bbaars/SwiftUI-Image-Carousel/f833e8218c3f83ad391b10e8a5d0b672bef3a0d5/ImageCarousel/Assets.xcassets/person.imageset/adolescent-adult-black-and-white-casual-270968 2.jpg -------------------------------------------------------------------------------- /ImageCarousel/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 | -------------------------------------------------------------------------------- /ImageCarousel/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // ImageCarousel 4 | // 5 | // Created by Brandon Baars on 1/7/20. 6 | // Copyright © 2020 Brandon Baars. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | extension Font { 12 | static func avenirNext(size: Int) -> Font { 13 | return Font.custom("Avenir Next", size: CGFloat(size)) 14 | } 15 | 16 | static func avenirNextRegular(size: Int) -> Font { 17 | return Font.custom("AvenirNext-Regular", size: CGFloat(size)) 18 | } 19 | } 20 | 21 | struct ContentView: View { 22 | var body: some View { 23 | ScrollView { 24 | GeometryReader { geometry in 25 | ImageCarouselView(numberOfImages: 3) { 26 | Image("image_carousel_1") 27 | .resizable() 28 | .scaledToFill() 29 | .frame(width: geometry.size.width, height: geometry.size.height) 30 | .clipped() 31 | Image("image_carousel_2") 32 | .resizable() 33 | .scaledToFill() 34 | .frame(width: geometry.size.width, height: geometry.size.height) 35 | .clipped() 36 | Image("image_carousel_3") 37 | .resizable() 38 | .scaledToFill() 39 | .frame(width: geometry.size.width, height: geometry.size.height) 40 | .clipped() 41 | } 42 | }.frame(height: 300, alignment: .center) 43 | 44 | VStack(alignment: .leading, spacing: 10) { 45 | HStack { 46 | Image("person") 47 | .resizable() 48 | .scaledToFill() 49 | .frame(width: 55, height: 55) 50 | .clipShape(Circle()) 51 | .shadow(radius: 4) 52 | 53 | VStack(alignment: .leading) { 54 | Text("Article Written By") 55 | .font(.avenirNext(size: 12)) 56 | .foregroundColor(.gray) 57 | Text("Brandon Baars") 58 | .font(.avenirNext(size: 17)) 59 | } 60 | } 61 | 62 | Text("07 January 2019 • 5 min read") 63 | .font(.avenirNextRegular(size: 12)) 64 | .foregroundColor(.gray) 65 | 66 | Text("How to build an image carousel") 67 | .font(.avenirNext(size: 28)) 68 | 69 | Text(loremIpsum) 70 | .lineLimit(nil) 71 | .font(.avenirNextRegular(size: 17)) 72 | } 73 | .padding(.horizontal) 74 | .padding(.top, 16.0) 75 | }.edgesIgnoringSafeArea(.all) 76 | } 77 | } 78 | 79 | struct ContentView_Previews: PreviewProvider { 80 | static var previews: some View { 81 | ContentView() 82 | } 83 | } 84 | 85 | let loremIpsum = """ 86 | Lorem ipsum dolor sit amet consectetur adipiscing elit donec, gravida commodo hac non mattis augue duis vitae inceptos, laoreet taciti at vehicula cum arcu dictum. Cras netus vivamus sociis pulvinar est erat, quisque imperdiet velit a justo maecenas, pretium gravida ut himenaeos nam. Tellus quis libero sociis class nec hendrerit, id proin facilisis praesent bibendum vehicula tristique, fringilla augue vitae primis turpis. 87 | 88 | Lorem ipsum dolor sit amet consectetur adipiscing elit donec, gravida commodo hac non mattis augue duis vitae inceptos, laoreet taciti at vehicula cum arcu dictum. Cras netus vivamus sociis pulvinar est erat, quisque imperdiet velit a justo maecenas, pretium gravida ut himenaeos nam. Tellus quis libero sociis class nec hendrerit, id proin facilisis praesent bibendum vehicula tristique, fringilla augue vitae primis turpis. 89 | """ 90 | 91 | /// Backgrounds 92 | // https://www.pexels.com/photo/man-in-bus-247929/ 93 | // https://www.pexels.com/photo/black-crt-tv-showing-gray-screen-704555/ 94 | // https://www.pexels.com/photo/black-cassette-tape-on-top-of-red-and-yellow-surface-1626481/ 95 | 96 | /// Person 97 | // https://www.pexels.com/photo/adolescent-adult-black-and-white-casual-270968/ 98 | -------------------------------------------------------------------------------- /ImageCarousel/ImageCarouselView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ImageCarouselView.swift 3 | // ImageCarousel 4 | // 5 | // Created by Brandon Baars on 1/7/20. 6 | // Copyright © 2020 Brandon Baars. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | import Combine 11 | 12 | struct ImageCarouselView: View { 13 | private var numberOfImages: Int 14 | private var content: Content 15 | @State var slideGesture: CGSize = CGSize.zero 16 | @State private var currentIndex: Int = 0 17 | private let timer = Timer.publish(every: 3, on: .main, in: .common).autoconnect() 18 | 19 | init(numberOfImages: Int, @ViewBuilder content: () -> Content) { 20 | self.numberOfImages = numberOfImages 21 | self.content = content() 22 | } 23 | 24 | var body: some View { 25 | GeometryReader { geometry in 26 | // 1 27 | ZStack(alignment: .bottom) { 28 | HStack(spacing: 0) { 29 | self.content 30 | } 31 | .frame(width: geometry.size.width, height: geometry.size.height, alignment: .leading) 32 | .offset(x: CGFloat(self.currentIndex) * -geometry.size.width, y: 0) 33 | .animation(.spring()) 34 | // Comment .onReceive method, to omit the Slider with time 35 | .onReceive(self.timer) { _ in 36 | self.currentIndex = (self.currentIndex + 1) % (self.numberOfImages == 0 ? 1 : self.numberOfImages)} 37 | // Comment .gesture method, to omit the Swipe function 38 | .gesture(DragGesture().onChanged{ value in 39 | self.slideGesture = value.translation 40 | } 41 | .onEnded{ value in 42 | if self.slideGesture.width < -50 { 43 | if self.currentIndex < self.numberOfImages - 1 { 44 | withAnimation { 45 | self.currentIndex += 1 46 | } 47 | } 48 | } 49 | if self.slideGesture.width > 50 { 50 | if self.currentIndex > 0 { 51 | withAnimation { 52 | self.currentIndex -= 1 53 | } 54 | } 55 | } 56 | self.slideGesture = .zero 57 | }) 58 | 59 | // 2 60 | HStack(spacing: 3) { 61 | // 3 62 | ForEach(0.. 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 | -------------------------------------------------------------------------------- /ImageCarousel/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ImageCarousel/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // ImageCarousel 4 | // 5 | // Created by Brandon Baars on 1/7/20. 6 | // Copyright © 2020 Brandon Baars. 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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Brandon Baars 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 | # SwiftUI-Image-Carousel 2 | 3 | ![](https://media.giphy.com/media/cgeCvqxj8bypKSmcqi/giphy.gif) 4 | --------------------------------------------------------------------------------