├── LICENSE.md ├── Pagination.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── rbreve.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist ├── Pagination ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── photo1.imageset │ │ ├── Contents.json │ │ └── photo1.jpg │ ├── photo2.imageset │ │ ├── Contents.json │ │ └── photo2.jpg │ ├── photo3.imageset │ │ ├── Contents.json │ │ └── photo3.jpg │ ├── photo4.imageset │ │ ├── Contents.json │ │ └── photo4.jpg │ └── photo5.imageset │ │ ├── Contents.json │ │ └── photo5.jpg ├── Base.lproj │ └── LaunchScreen.storyboard ├── ContentView.swift ├── Info.plist ├── Page.swift ├── PaginationView.swift ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json └── SceneDelegate.swift ├── README.md └── demo.gif /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Roberto Brevé 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 | -------------------------------------------------------------------------------- /Pagination.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 2EB73CA4237B00CE00966A30 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EB73CA3237B00CE00966A30 /* AppDelegate.swift */; }; 11 | 2EB73CA6237B00CE00966A30 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EB73CA5237B00CE00966A30 /* SceneDelegate.swift */; }; 12 | 2EB73CA8237B00CE00966A30 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EB73CA7237B00CE00966A30 /* ContentView.swift */; }; 13 | 2EB73CAA237B00D500966A30 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2EB73CA9237B00D500966A30 /* Assets.xcassets */; }; 14 | 2EB73CAD237B00D500966A30 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2EB73CAC237B00D500966A30 /* Preview Assets.xcassets */; }; 15 | 2EB73CB0237B00D500966A30 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2EB73CAE237B00D500966A30 /* LaunchScreen.storyboard */; }; 16 | 2EB73CB8237B00EF00966A30 /* PaginationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EB73CB7237B00EF00966A30 /* PaginationView.swift */; }; 17 | 2EB73CBA237B018700966A30 /* Page.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EB73CB9237B018700966A30 /* Page.swift */; }; 18 | 2EB73CBC237B290800966A30 /* LICENSE.md in Resources */ = {isa = PBXBuildFile; fileRef = 2EB73CBB237B290800966A30 /* LICENSE.md */; }; 19 | 2EB73CBE237B297400966A30 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 2EB73CBD237B297400966A30 /* README.md */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | 2EB73CA0237B00CE00966A30 /* Pagination.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Pagination.app; sourceTree = BUILT_PRODUCTS_DIR; }; 24 | 2EB73CA3237B00CE00966A30 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 25 | 2EB73CA5237B00CE00966A30 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 26 | 2EB73CA7237B00CE00966A30 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 27 | 2EB73CA9237B00D500966A30 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 28 | 2EB73CAC237B00D500966A30 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 29 | 2EB73CAF237B00D500966A30 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 30 | 2EB73CB1237B00D500966A30 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31 | 2EB73CB7237B00EF00966A30 /* PaginationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaginationView.swift; sourceTree = ""; }; 32 | 2EB73CB9237B018700966A30 /* Page.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Page.swift; sourceTree = ""; }; 33 | 2EB73CBB237B290800966A30 /* LICENSE.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = LICENSE.md; sourceTree = ""; }; 34 | 2EB73CBD237B297400966A30 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 35 | /* End PBXFileReference section */ 36 | 37 | /* Begin PBXFrameworksBuildPhase section */ 38 | 2EB73C9D237B00CE00966A30 /* Frameworks */ = { 39 | isa = PBXFrameworksBuildPhase; 40 | buildActionMask = 2147483647; 41 | files = ( 42 | ); 43 | runOnlyForDeploymentPostprocessing = 0; 44 | }; 45 | /* End PBXFrameworksBuildPhase section */ 46 | 47 | /* Begin PBXGroup section */ 48 | 2EB73C97237B00CD00966A30 = { 49 | isa = PBXGroup; 50 | children = ( 51 | 2EB73CA2237B00CE00966A30 /* Pagination */, 52 | 2EB73CA1237B00CE00966A30 /* Products */, 53 | ); 54 | sourceTree = ""; 55 | }; 56 | 2EB73CA1237B00CE00966A30 /* Products */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 2EB73CA0237B00CE00966A30 /* Pagination.app */, 60 | ); 61 | name = Products; 62 | sourceTree = ""; 63 | }; 64 | 2EB73CA2237B00CE00966A30 /* Pagination */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 2EB73CA3237B00CE00966A30 /* AppDelegate.swift */, 68 | 2EB73CA5237B00CE00966A30 /* SceneDelegate.swift */, 69 | 2EB73CA7237B00CE00966A30 /* ContentView.swift */, 70 | 2EB73CA9237B00D500966A30 /* Assets.xcassets */, 71 | 2EB73CAE237B00D500966A30 /* LaunchScreen.storyboard */, 72 | 2EB73CB1237B00D500966A30 /* Info.plist */, 73 | 2EB73CAB237B00D500966A30 /* Preview Content */, 74 | 2EB73CB7237B00EF00966A30 /* PaginationView.swift */, 75 | 2EB73CB9237B018700966A30 /* Page.swift */, 76 | 2EB73CBB237B290800966A30 /* LICENSE.md */, 77 | 2EB73CBD237B297400966A30 /* README.md */, 78 | ); 79 | path = Pagination; 80 | sourceTree = ""; 81 | }; 82 | 2EB73CAB237B00D500966A30 /* Preview Content */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | 2EB73CAC237B00D500966A30 /* Preview Assets.xcassets */, 86 | ); 87 | path = "Preview Content"; 88 | sourceTree = ""; 89 | }; 90 | /* End PBXGroup section */ 91 | 92 | /* Begin PBXNativeTarget section */ 93 | 2EB73C9F237B00CE00966A30 /* Pagination */ = { 94 | isa = PBXNativeTarget; 95 | buildConfigurationList = 2EB73CB4237B00D500966A30 /* Build configuration list for PBXNativeTarget "Pagination" */; 96 | buildPhases = ( 97 | 2EB73C9C237B00CE00966A30 /* Sources */, 98 | 2EB73C9D237B00CE00966A30 /* Frameworks */, 99 | 2EB73C9E237B00CE00966A30 /* Resources */, 100 | ); 101 | buildRules = ( 102 | ); 103 | dependencies = ( 104 | ); 105 | name = Pagination; 106 | productName = Pagination; 107 | productReference = 2EB73CA0237B00CE00966A30 /* Pagination.app */; 108 | productType = "com.apple.product-type.application"; 109 | }; 110 | /* End PBXNativeTarget section */ 111 | 112 | /* Begin PBXProject section */ 113 | 2EB73C98237B00CD00966A30 /* Project object */ = { 114 | isa = PBXProject; 115 | attributes = { 116 | LastSwiftUpdateCheck = 1100; 117 | LastUpgradeCheck = 1100; 118 | ORGANIZATIONNAME = "Roberto Breve "; 119 | TargetAttributes = { 120 | 2EB73C9F237B00CE00966A30 = { 121 | CreatedOnToolsVersion = 11.0; 122 | }; 123 | }; 124 | }; 125 | buildConfigurationList = 2EB73C9B237B00CD00966A30 /* Build configuration list for PBXProject "Pagination" */; 126 | compatibilityVersion = "Xcode 9.3"; 127 | developmentRegion = en; 128 | hasScannedForEncodings = 0; 129 | knownRegions = ( 130 | en, 131 | Base, 132 | ); 133 | mainGroup = 2EB73C97237B00CD00966A30; 134 | productRefGroup = 2EB73CA1237B00CE00966A30 /* Products */; 135 | projectDirPath = ""; 136 | projectRoot = ""; 137 | targets = ( 138 | 2EB73C9F237B00CE00966A30 /* Pagination */, 139 | ); 140 | }; 141 | /* End PBXProject section */ 142 | 143 | /* Begin PBXResourcesBuildPhase section */ 144 | 2EB73C9E237B00CE00966A30 /* Resources */ = { 145 | isa = PBXResourcesBuildPhase; 146 | buildActionMask = 2147483647; 147 | files = ( 148 | 2EB73CB0237B00D500966A30 /* LaunchScreen.storyboard in Resources */, 149 | 2EB73CAD237B00D500966A30 /* Preview Assets.xcassets in Resources */, 150 | 2EB73CBE237B297400966A30 /* README.md in Resources */, 151 | 2EB73CBC237B290800966A30 /* LICENSE.md in Resources */, 152 | 2EB73CAA237B00D500966A30 /* Assets.xcassets in Resources */, 153 | ); 154 | runOnlyForDeploymentPostprocessing = 0; 155 | }; 156 | /* End PBXResourcesBuildPhase section */ 157 | 158 | /* Begin PBXSourcesBuildPhase section */ 159 | 2EB73C9C237B00CE00966A30 /* Sources */ = { 160 | isa = PBXSourcesBuildPhase; 161 | buildActionMask = 2147483647; 162 | files = ( 163 | 2EB73CB8237B00EF00966A30 /* PaginationView.swift in Sources */, 164 | 2EB73CA4237B00CE00966A30 /* AppDelegate.swift in Sources */, 165 | 2EB73CA6237B00CE00966A30 /* SceneDelegate.swift in Sources */, 166 | 2EB73CA8237B00CE00966A30 /* ContentView.swift in Sources */, 167 | 2EB73CBA237B018700966A30 /* Page.swift in Sources */, 168 | ); 169 | runOnlyForDeploymentPostprocessing = 0; 170 | }; 171 | /* End PBXSourcesBuildPhase section */ 172 | 173 | /* Begin PBXVariantGroup section */ 174 | 2EB73CAE237B00D500966A30 /* LaunchScreen.storyboard */ = { 175 | isa = PBXVariantGroup; 176 | children = ( 177 | 2EB73CAF237B00D500966A30 /* Base */, 178 | ); 179 | name = LaunchScreen.storyboard; 180 | sourceTree = ""; 181 | }; 182 | /* End PBXVariantGroup section */ 183 | 184 | /* Begin XCBuildConfiguration section */ 185 | 2EB73CB2237B00D500966A30 /* Debug */ = { 186 | isa = XCBuildConfiguration; 187 | buildSettings = { 188 | ALWAYS_SEARCH_USER_PATHS = NO; 189 | CLANG_ANALYZER_NONNULL = YES; 190 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 191 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 192 | CLANG_CXX_LIBRARY = "libc++"; 193 | CLANG_ENABLE_MODULES = YES; 194 | CLANG_ENABLE_OBJC_ARC = YES; 195 | CLANG_ENABLE_OBJC_WEAK = YES; 196 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 197 | CLANG_WARN_BOOL_CONVERSION = YES; 198 | CLANG_WARN_COMMA = YES; 199 | CLANG_WARN_CONSTANT_CONVERSION = YES; 200 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 201 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 202 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 203 | CLANG_WARN_EMPTY_BODY = YES; 204 | CLANG_WARN_ENUM_CONVERSION = YES; 205 | CLANG_WARN_INFINITE_RECURSION = YES; 206 | CLANG_WARN_INT_CONVERSION = YES; 207 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 208 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 209 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 210 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 211 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 212 | CLANG_WARN_STRICT_PROTOTYPES = YES; 213 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 214 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 215 | CLANG_WARN_UNREACHABLE_CODE = YES; 216 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 217 | COPY_PHASE_STRIP = NO; 218 | DEBUG_INFORMATION_FORMAT = dwarf; 219 | ENABLE_STRICT_OBJC_MSGSEND = YES; 220 | ENABLE_TESTABILITY = YES; 221 | GCC_C_LANGUAGE_STANDARD = gnu11; 222 | GCC_DYNAMIC_NO_PIC = NO; 223 | GCC_NO_COMMON_BLOCKS = YES; 224 | GCC_OPTIMIZATION_LEVEL = 0; 225 | GCC_PREPROCESSOR_DEFINITIONS = ( 226 | "DEBUG=1", 227 | "$(inherited)", 228 | ); 229 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 230 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 231 | GCC_WARN_UNDECLARED_SELECTOR = YES; 232 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 233 | GCC_WARN_UNUSED_FUNCTION = YES; 234 | GCC_WARN_UNUSED_VARIABLE = YES; 235 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 236 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 237 | MTL_FAST_MATH = YES; 238 | ONLY_ACTIVE_ARCH = YES; 239 | SDKROOT = iphoneos; 240 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 241 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 242 | }; 243 | name = Debug; 244 | }; 245 | 2EB73CB3237B00D500966A30 /* Release */ = { 246 | isa = XCBuildConfiguration; 247 | buildSettings = { 248 | ALWAYS_SEARCH_USER_PATHS = NO; 249 | CLANG_ANALYZER_NONNULL = YES; 250 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 251 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 252 | CLANG_CXX_LIBRARY = "libc++"; 253 | CLANG_ENABLE_MODULES = YES; 254 | CLANG_ENABLE_OBJC_ARC = YES; 255 | CLANG_ENABLE_OBJC_WEAK = YES; 256 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 257 | CLANG_WARN_BOOL_CONVERSION = YES; 258 | CLANG_WARN_COMMA = YES; 259 | CLANG_WARN_CONSTANT_CONVERSION = YES; 260 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 261 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 262 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 263 | CLANG_WARN_EMPTY_BODY = YES; 264 | CLANG_WARN_ENUM_CONVERSION = YES; 265 | CLANG_WARN_INFINITE_RECURSION = YES; 266 | CLANG_WARN_INT_CONVERSION = YES; 267 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 268 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 269 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 270 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 271 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 272 | CLANG_WARN_STRICT_PROTOTYPES = YES; 273 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 274 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 275 | CLANG_WARN_UNREACHABLE_CODE = YES; 276 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 277 | COPY_PHASE_STRIP = NO; 278 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 279 | ENABLE_NS_ASSERTIONS = NO; 280 | ENABLE_STRICT_OBJC_MSGSEND = YES; 281 | GCC_C_LANGUAGE_STANDARD = gnu11; 282 | GCC_NO_COMMON_BLOCKS = YES; 283 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 284 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 285 | GCC_WARN_UNDECLARED_SELECTOR = YES; 286 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 287 | GCC_WARN_UNUSED_FUNCTION = YES; 288 | GCC_WARN_UNUSED_VARIABLE = YES; 289 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 290 | MTL_ENABLE_DEBUG_INFO = NO; 291 | MTL_FAST_MATH = YES; 292 | SDKROOT = iphoneos; 293 | SWIFT_COMPILATION_MODE = wholemodule; 294 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 295 | VALIDATE_PRODUCT = YES; 296 | }; 297 | name = Release; 298 | }; 299 | 2EB73CB5237B00D500966A30 /* Debug */ = { 300 | isa = XCBuildConfiguration; 301 | buildSettings = { 302 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 303 | CODE_SIGN_STYLE = Automatic; 304 | DEVELOPMENT_ASSET_PATHS = "\"Pagination/Preview Content\""; 305 | DEVELOPMENT_TEAM = M45K9UPZ39; 306 | ENABLE_PREVIEWS = YES; 307 | INFOPLIST_FILE = Pagination/Info.plist; 308 | LD_RUNPATH_SEARCH_PATHS = ( 309 | "$(inherited)", 310 | "@executable_path/Frameworks", 311 | ); 312 | PRODUCT_BUNDLE_IDENTIFIER = com.rbreve.Pagination; 313 | PRODUCT_NAME = "$(TARGET_NAME)"; 314 | SWIFT_VERSION = 5.0; 315 | TARGETED_DEVICE_FAMILY = "1,2"; 316 | }; 317 | name = Debug; 318 | }; 319 | 2EB73CB6237B00D500966A30 /* Release */ = { 320 | isa = XCBuildConfiguration; 321 | buildSettings = { 322 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 323 | CODE_SIGN_STYLE = Automatic; 324 | DEVELOPMENT_ASSET_PATHS = "\"Pagination/Preview Content\""; 325 | DEVELOPMENT_TEAM = M45K9UPZ39; 326 | ENABLE_PREVIEWS = YES; 327 | INFOPLIST_FILE = Pagination/Info.plist; 328 | LD_RUNPATH_SEARCH_PATHS = ( 329 | "$(inherited)", 330 | "@executable_path/Frameworks", 331 | ); 332 | PRODUCT_BUNDLE_IDENTIFIER = com.rbreve.Pagination; 333 | PRODUCT_NAME = "$(TARGET_NAME)"; 334 | SWIFT_VERSION = 5.0; 335 | TARGETED_DEVICE_FAMILY = "1,2"; 336 | }; 337 | name = Release; 338 | }; 339 | /* End XCBuildConfiguration section */ 340 | 341 | /* Begin XCConfigurationList section */ 342 | 2EB73C9B237B00CD00966A30 /* Build configuration list for PBXProject "Pagination" */ = { 343 | isa = XCConfigurationList; 344 | buildConfigurations = ( 345 | 2EB73CB2237B00D500966A30 /* Debug */, 346 | 2EB73CB3237B00D500966A30 /* Release */, 347 | ); 348 | defaultConfigurationIsVisible = 0; 349 | defaultConfigurationName = Release; 350 | }; 351 | 2EB73CB4237B00D500966A30 /* Build configuration list for PBXNativeTarget "Pagination" */ = { 352 | isa = XCConfigurationList; 353 | buildConfigurations = ( 354 | 2EB73CB5237B00D500966A30 /* Debug */, 355 | 2EB73CB6237B00D500966A30 /* Release */, 356 | ); 357 | defaultConfigurationIsVisible = 0; 358 | defaultConfigurationName = Release; 359 | }; 360 | /* End XCConfigurationList section */ 361 | }; 362 | rootObject = 2EB73C98237B00CD00966A30 /* Project object */; 363 | } 364 | -------------------------------------------------------------------------------- /Pagination.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Pagination.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Pagination.xcodeproj/xcuserdata/rbreve.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /Pagination.xcodeproj/xcuserdata/rbreve.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Pagination.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Pagination/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Pagination 4 | // 5 | // Created by Roberto Breve on 12.11.2019. 6 | // Copyright © 2019 Roberto Breve . 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 | -------------------------------------------------------------------------------- /Pagination/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 | } -------------------------------------------------------------------------------- /Pagination/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Pagination/Assets.xcassets/photo1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "photo1.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 | } -------------------------------------------------------------------------------- /Pagination/Assets.xcassets/photo1.imageset/photo1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rbreve/SwiftUIPagination/6cf1e936feb93eb218eef040ddae90df2fdde755/Pagination/Assets.xcassets/photo1.imageset/photo1.jpg -------------------------------------------------------------------------------- /Pagination/Assets.xcassets/photo2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "photo2.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 | } -------------------------------------------------------------------------------- /Pagination/Assets.xcassets/photo2.imageset/photo2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rbreve/SwiftUIPagination/6cf1e936feb93eb218eef040ddae90df2fdde755/Pagination/Assets.xcassets/photo2.imageset/photo2.jpg -------------------------------------------------------------------------------- /Pagination/Assets.xcassets/photo3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "photo3.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 | } -------------------------------------------------------------------------------- /Pagination/Assets.xcassets/photo3.imageset/photo3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rbreve/SwiftUIPagination/6cf1e936feb93eb218eef040ddae90df2fdde755/Pagination/Assets.xcassets/photo3.imageset/photo3.jpg -------------------------------------------------------------------------------- /Pagination/Assets.xcassets/photo4.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "photo4.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 | } -------------------------------------------------------------------------------- /Pagination/Assets.xcassets/photo4.imageset/photo4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rbreve/SwiftUIPagination/6cf1e936feb93eb218eef040ddae90df2fdde755/Pagination/Assets.xcassets/photo4.imageset/photo4.jpg -------------------------------------------------------------------------------- /Pagination/Assets.xcassets/photo5.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "photo5.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 | } -------------------------------------------------------------------------------- /Pagination/Assets.xcassets/photo5.imageset/photo5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rbreve/SwiftUIPagination/6cf1e936feb93eb218eef040ddae90df2fdde755/Pagination/Assets.xcassets/photo5.imageset/photo5.jpg -------------------------------------------------------------------------------- /Pagination/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 | -------------------------------------------------------------------------------- /Pagination/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // 3D Pagination SwiftUI 4 | // 5 | // Created by Roberto Breve on 12.11.2019. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct PageData : Identifiable { 11 | var id = UUID() 12 | var imageName : String 13 | var imageTitle : String 14 | } 15 | 16 | struct ContentView: View { 17 | // Data Source 18 | let pages = [PageData(imageName: "photo1", imageTitle: "Helsinki"), PageData(imageName: "photo2", imageTitle: "Boats"), PageData(imageName: "photo3", imageTitle: "River Dock")] 19 | 20 | var body: some View { 21 | PaginationView(pages: pages) { page in 22 | //Page is just a View with content 23 | Page(imageName: page.imageName, imageTitle: page.imageTitle) 24 | } 25 | } 26 | } 27 | 28 | 29 | -------------------------------------------------------------------------------- /Pagination/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | 37 | 38 | 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UISupportedInterfaceOrientations~ipad 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationPortraitUpsideDown 56 | UIInterfaceOrientationLandscapeLeft 57 | UIInterfaceOrientationLandscapeRight 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pagination/Page.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Page.swift 3 | // Pagination 4 | // 5 | // Created by Roberto Breve on 12.11.2019. 6 | // Copyright © 2019 Roberto Breve . All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct Page: View { 12 | var imageName = "photo1" 13 | var imageTitle: String? 14 | 15 | var body: some View { 16 | GeometryReader { proxy in 17 | VStack { 18 | Image(self.imageName) 19 | .resizable() 20 | .frame(width: proxy.size.width) 21 | .aspectRatio(contentMode: .fit) 22 | 23 | Text(self.imageTitle ?? "") 24 | .fontWeight(.black) 25 | } 26 | } 27 | } 28 | } 29 | 30 | struct Page_Previews: PreviewProvider { 31 | static var previews: some View { 32 | Page() 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Pagination/PaginationView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PaginationView.swift 3 | // 3D Pagination Effect 4 | // 5 | // Created by Roberto Breve on 11.11.2019. 6 | // Copyright © 2019 Roberto Breve . All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | 12 | struct PaginationView : View where Content: View, Pages: RandomAccessCollection, Pages.Element : Identifiable { 13 | var pages : Pages 14 | var content: (Pages.Element) -> Content 15 | 16 | @State private var translation: CGSize? = nil 17 | @State private var lastTranslation: CGFloat = 0 18 | @State private var angleTranslation: CGFloat = 0 19 | @State private var initPosition = CGFloat(0) 20 | @State private var shiftLeft = false 21 | @State private var shiftRight = false 22 | 23 | 24 | func getOffsets(size: CGFloat) -> [Pages.Element.ID: (position: CGFloat, rotation: CGFloat)] { 25 | var acumsize = CGFloat(0) 26 | var offsets = [Pages.Element.ID: (position: CGFloat, rotation: CGFloat)]() 27 | var angle = CGFloat(0) 28 | for page in pages { 29 | offsets[page.id] = (acumsize, angle) 30 | acumsize += size 31 | angle = CGFloat(-90) 32 | } 33 | return offsets 34 | } 35 | 36 | 37 | func isLeftSided(position: CGFloat, width: CGFloat) -> Bool{ 38 | if (position < 0 && position > -width ) { 39 | return true 40 | } 41 | return false 42 | } 43 | 44 | func isRightSided(position: CGFloat, width: CGFloat) -> Bool{ 45 | if (position > 0 && position < width) { 46 | return true 47 | } 48 | return false 49 | } 50 | 51 | func getRotation(position : CGFloat, width: CGFloat) -> Double { 52 | let pos = position + (self.translation?.width ?? 0) 53 | 54 | let sided = (self.translation?.width ?? 0) > CGFloat(0) ? -1 : 1 55 | if (sided > 0) { 56 | if(isLeftSided(position: pos, width: width)) { 57 | return Double((self.translation?.width ?? 0)/(width/90)) 58 | } 59 | if(isRightSided(position: pos, width: width)) { 60 | return Double((self.translation?.width ?? 0)/(width/90)) + 90 61 | } 62 | }else{ 63 | if(isLeftSided(position: pos, width: width)) { 64 | return Double((self.translation?.width ?? 0)/(width/90)) - 90 65 | } 66 | if(isRightSided(position: pos, width: width)) { 67 | return Double((self.translation?.width ?? 0)/(width/90)) 68 | } 69 | } 70 | 71 | return 0 72 | } 73 | 74 | func getAnchor(position : CGFloat, width: CGFloat) -> UnitPoint { 75 | let pos = position + self.lastTranslation 76 | if(isLeftSided(position: pos, width: width)) { 77 | return .trailing 78 | } else { 79 | return .leading 80 | } 81 | } 82 | 83 | 84 | 85 | var body: some View { 86 | GeometryReader { geometry in 87 | self.bodyHelper(containerSize: geometry.size, offsets: self.getOffsets(size: geometry.size.width)) 88 | } 89 | } 90 | 91 | private func bodyHelper(containerSize: CGSize, offsets: [Pages.Element.ID: (position: CGFloat, rotation: CGFloat)]) -> some View { 92 | ZStack { 93 | ForEach(self.pages){ 94 | self.content($0).rotation3DEffect(.degrees(self.getRotation(position: (offsets[$0.id]?.position ?? 0) + self.initPosition, width: containerSize.width )), axis: (x: 0, y: 1, z: 0), anchor: self.getAnchor(position: (offsets[$0.id]?.position ?? 0) + self.initPosition, width: containerSize.width)) 95 | .offset(x: (offsets[$0.id]?.position ?? 0 ) + (self.translation?.width ?? 0) + self.initPosition ) 96 | .gesture(DragGesture() 97 | .onChanged({ (value) in 98 | self.translation = value.translation 99 | self.lastTranslation = self.translation?.width ?? 0 100 | 101 | if(self.shiftLeft){ 102 | self.shiftLeft = false 103 | self.initPosition -= containerSize.width 104 | } 105 | 106 | if(self.shiftRight) { 107 | self.shiftRight = false 108 | self.initPosition += containerSize.width 109 | } 110 | }) 111 | .onEnded({ (value) in 112 | self.lastTranslation = self.translation?.width ?? 0 113 | withAnimation { 114 | if(self.translation!.width > CGFloat(containerSize.width/2)) { 115 | 116 | if (self.initPosition < 0) { 117 | self.translation = CGSize(width: containerSize.width, height: 0) 118 | self.shiftRight = true 119 | }else { 120 | self.translation = .zero 121 | } 122 | 123 | } 124 | else 125 | if (self.translation!.width < CGFloat(-containerSize.width/2)) && (abs(self.initPosition) < containerSize.width*CGFloat(offsets.count-1)) { 126 | 127 | self.translation = CGSize(width: -containerSize.width, height: 0) 128 | self.shiftLeft=true 129 | }else{ 130 | self.translation = .zero 131 | } 132 | 133 | } 134 | })) 135 | } 136 | 137 | } 138 | } 139 | } 140 | 141 | -------------------------------------------------------------------------------- /Pagination/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Pagination/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // Pagination 4 | // 5 | // Created by Roberto Breve on 12.11.2019. 6 | // Copyright © 2019 Roberto Breve . 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # SwiftUI Pagination with Cube Effect 3 | 4 | ![](https://raw.githubusercontent.com/rbreve/SwiftUIPagination/master/demo.gif) 5 | 6 | 7 | Let's you create pagination with a 3D effect like the instagram stories 8 | 9 | 10 | ## Usage 11 | 12 | ###### Create your custom view 13 | 14 | ``` 15 | struct Page: View { 16 | var imageName = "photo1" 17 | var imageTitle: String? 18 | 19 | var body: some View { 20 | GeometryReader { proxy in 21 | VStack { 22 | Image(self.imageName) 23 | .resizable() 24 | .frame(width: proxy.size.width) 25 | .aspectRatio(contentMode: .fit) 26 | 27 | Text(self.imageTitle ?? "") 28 | .fontWeight(.black) 29 | } 30 | } 31 | } 32 | } 33 | ``` 34 | 35 | ###### Create a data source for each view 36 | 37 | ``` 38 | struct PageData : Identifiable { 39 | var id = UUID() 40 | var imageName : String 41 | var imageTitle : String 42 | } 43 | ``` 44 | 45 | ###### Call PaginationView with your data and View. 46 | 47 | 48 | ``` 49 | 50 | struct ContentView: View { 51 | // Create your pages 52 | let pages = [PageData(imageName: "photo1", imageTitle: "Helsinki"), PageData(imageName: "photo2", imageTitle: "Boats"), PageData(imageName: "photo3", imageTitle: "River Dock")] 53 | 54 | var body: some View { 55 | PaginationView(pages: pages) { page in 56 | //Page is just a View with content 57 | Page(imageName: page.imageName, imageTitle: page.imageTitle) 58 | } 59 | } 60 | } 61 | ``` 62 | 63 | ## Contributing 64 | Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. 65 | 66 | Please make sure to update tests as appropriate. 67 | 68 | ## License 69 | [MIT](https://choosealicense.com/licenses/mit/) 70 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rbreve/SwiftUIPagination/6cf1e936feb93eb218eef040ddae90df2fdde755/demo.gif --------------------------------------------------------------------------------