From 90d57b0842c050f95ef5e4a5f7d8f6f4a27a987c Mon Sep 17 00:00:00 2001 From: Fernando Moya de Rivas Date: Tue, 30 Jun 2020 12:24:40 +0100 Subject: [PATCH 1/2] Fixing infinitePager with no elements --- Sources/SwiftUIPager/Pager+Helper.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/SwiftUIPager/Pager+Helper.swift b/Sources/SwiftUIPager/Pager+Helper.swift index 1bf0f1a..e97a089 100644 --- a/Sources/SwiftUIPager/Pager+Helper.swift +++ b/Sources/SwiftUIPager/Pager+Helper.swift @@ -49,6 +49,7 @@ extension Pager { let newPage = -Int((totalOffset / pageDistance).rounded()) + page guard isInifinitePager else { return max(min(newPage, numberOfPages - 1), 0) } + guard numberOfPages > 0 else { return 0 } return max((newPage + numberOfPages) % numberOfPages, 0) } @@ -139,12 +140,14 @@ extension Pager { /// Lower bound of the data displaed var lowerPageDisplayed: Int { guard isInifinitePager else { return max(0, page - maximumNumberOfPages / 2) } + guard numberOfPages > 0 else { return 0 } return ((page - maximumNumberOfPages / 2) + numberOfPages) % numberOfPages } /// Upper bound of the data displaed var upperPageDisplayed: Int { guard isInifinitePager else { return min(numberOfPages - 1, page + maximumNumberOfPages / 2) } + guard numberOfPages > 0 else { return 0 } return (Int((Float(maximumNumberOfPages) / 2).rounded(.up)) + page) % numberOfPages } From c50dba92a563019e84c23eccbdca49d9c8ca164d Mon Sep 17 00:00:00 2001 From: Fernando Moya de Rivas Date: Wed, 1 Jul 2020 17:05:20 +0100 Subject: [PATCH 2/2] Bump to 1.6.2 --- SwiftUIPager.podspec | 2 +- SwiftUIPager.xcodeproj/project.pbxproj | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/SwiftUIPager.podspec b/SwiftUIPager.podspec index 412214b..a436578 100644 --- a/SwiftUIPager.podspec +++ b/SwiftUIPager.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "SwiftUIPager" - s.version = "1.6.1" + s.version = "1.6.2" s.summary = "Native pager for SwiftUI. Easily to use, easy to customize." s.description = <<-DESC diff --git a/SwiftUIPager.xcodeproj/project.pbxproj b/SwiftUIPager.xcodeproj/project.pbxproj index f362de0..02ea47a 100644 --- a/SwiftUIPager.xcodeproj/project.pbxproj +++ b/SwiftUIPager.xcodeproj/project.pbxproj @@ -544,7 +544,7 @@ "$(inherited)", "$(SDKROOT)/usr/lib/swift", ); - MARKETING_VERSION = 1.6.1; + MARKETING_VERSION = 1.6.2; PRODUCT_BUNDLE_IDENTIFIER = com.fmoyader.SwiftUIPager; PRODUCT_NAME = SwiftUIPager; SDKROOT = macosx; @@ -577,7 +577,7 @@ "$(inherited)", "$(SDKROOT)/usr/lib/swift", ); - MARKETING_VERSION = 1.6.1; + MARKETING_VERSION = 1.6.2; PRODUCT_BUNDLE_IDENTIFIER = com.fmoyader.SwiftUIPager; PRODUCT_NAME = SwiftUIPager; SDKROOT = macosx; @@ -609,7 +609,7 @@ "$(inherited)", "$(SDKROOT)/usr/lib/swift", ); - MARKETING_VERSION = 1.6.1; + MARKETING_VERSION = 1.6.2; PRODUCT_BUNDLE_IDENTIFIER = com.fmoyader.SwiftUIPager; PRODUCT_NAME = SwiftUIPager; SDKROOT = watchos; @@ -642,7 +642,7 @@ "$(inherited)", "$(SDKROOT)/usr/lib/swift", ); - MARKETING_VERSION = 1.6.1; + MARKETING_VERSION = 1.6.2; PRODUCT_BUNDLE_IDENTIFIER = com.fmoyader.SwiftUIPager; PRODUCT_NAME = SwiftUIPager; SDKROOT = watchos; @@ -673,7 +673,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 1.6.1; + MARKETING_VERSION = 1.6.2; PRODUCT_BUNDLE_IDENTIFIER = com.fmoyader.SwiftUIPager; PRODUCT_NAME = SwiftUIPager; SKIP_INSTALL = YES; @@ -702,7 +702,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 1.6.1; + MARKETING_VERSION = 1.6.2; PRODUCT_BUNDLE_IDENTIFIER = com.fmoyader.SwiftUIPager; PRODUCT_NAME = SwiftUIPager; SKIP_INSTALL = YES; @@ -731,7 +731,7 @@ "$(inherited)", "$(SDKROOT)/usr/lib/swift", ); - MARKETING_VERSION = 1.6.1; + MARKETING_VERSION = 1.6.2; PRODUCT_BUNDLE_IDENTIFIER = com.fmoyader.SwiftUIPager; PRODUCT_NAME = SwiftUIPager; SDKROOT = appletvos; @@ -763,7 +763,7 @@ "$(inherited)", "$(SDKROOT)/usr/lib/swift", ); - MARKETING_VERSION = 1.6.1; + MARKETING_VERSION = 1.6.2; PRODUCT_BUNDLE_IDENTIFIER = com.fmoyader.SwiftUIPager; PRODUCT_NAME = SwiftUIPager; SDKROOT = appletvos; @@ -940,7 +940,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 1.6.1; + MARKETING_VERSION = 1.6.2; PRODUCT_BUNDLE_IDENTIFIER = com.fmoyader.SwiftUIPager; PRODUCT_NAME = SwiftUIPager; SKIP_INSTALL = YES; @@ -970,7 +970,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 1.6.1; + MARKETING_VERSION = 1.6.2; PRODUCT_BUNDLE_IDENTIFIER = com.fmoyader.SwiftUIPager; PRODUCT_NAME = SwiftUIPager; SKIP_INSTALL = YES;