diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index 05781db..ac767e2 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -318,7 +318,12 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0920; + TargetAttributes = { + E29686B081BF1A19ED60EB05931448BA = { + LastSwiftMigration = 0920; + }; + }; }; buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; compatibilityVersion = "Xcode 3.2"; @@ -387,20 +392,30 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGNING_REQUIRED = NO; COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "POD_CONFIGURATION_DEBUG=1", @@ -448,7 +463,8 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -464,19 +480,29 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGNING_REQUIRED = NO; COPY_PHASE_STRIP = YES; ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "POD_CONFIGURATION_RELEASE=1", "$(inherited)", @@ -490,6 +516,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; PROVISIONING_PROFILE_SPECIFIER = NO_SIGNING/; STRIP_INSTALLED_PRODUCT = NO; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SYMROOT = "${SRCROOT}/../build"; VALIDATE_PRODUCT = YES; }; @@ -555,7 +582,8 @@ PRODUCT_NAME = TGLParallaxCarousel; SDKROOT = iphoneos; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -566,6 +594,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 404E69E47F768A29BA46D942DB9BA922 /* Pods-TGLParallaxCarousel_Example.debug.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; @@ -602,6 +631,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 361C42D5A44B70D9228E672F79EA0009 /* Pods-TGLParallaxCarousel_Example.release.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; diff --git a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/TGLParallaxCarousel.xcscheme b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/TGLParallaxCarousel.xcscheme index da013e9..2bc085a 100644 --- a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/TGLParallaxCarousel.xcscheme +++ b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/TGLParallaxCarousel.xcscheme @@ -1,6 +1,6 @@ @@ -36,6 +37,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/Example/TGLParallaxCarousel.xcodeproj/project.pbxproj b/Example/TGLParallaxCarousel.xcodeproj/project.pbxproj index 2e0497a..23e3793 100644 --- a/Example/TGLParallaxCarousel.xcodeproj/project.pbxproj +++ b/Example/TGLParallaxCarousel.xcodeproj/project.pbxproj @@ -224,7 +224,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0920; ORGANIZATIONNAME = CocoaPods; TargetAttributes = { 607FACCF1AFB9204008FA782 = { @@ -428,14 +428,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -475,14 +481,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; diff --git a/Example/TGLParallaxCarousel.xcodeproj/xcshareddata/xcschemes/TGLParallaxCarousel-Example.xcscheme b/Example/TGLParallaxCarousel.xcodeproj/xcshareddata/xcschemes/TGLParallaxCarousel-Example.xcscheme index 43ec328..d0c6bd1 100644 --- a/Example/TGLParallaxCarousel.xcodeproj/xcshareddata/xcschemes/TGLParallaxCarousel-Example.xcscheme +++ b/Example/TGLParallaxCarousel.xcodeproj/xcshareddata/xcschemes/TGLParallaxCarousel-Example.xcscheme @@ -1,6 +1,6 @@ UIView { - let bundle = Bundle(for: type(of: self)) + let bundle = Bundle(for: Swift.type(of: self)) let nib = UINib(nibName: nibName, bundle: bundle) let view = nib.instantiate(withOwner: self, options: nil)[0] as! UIView return view @@ -148,16 +159,28 @@ open class TGLParallaxCarousel: UIView { mainView.addGestureRecognizer(tapGesture) } - func reloadData() { + open func reloadData() { + self.items.removeAll() + + selectedIndex = 0 + guard let delegate = delegate else { return } - + layoutIfNeeded() - + pageControl.numberOfPages = delegate.numberOfItemsInCarouselView(self) + let numberOfItems = delegate.numberOfItemsInCarouselView(self) + + //Condition if the mode is linear or circular + if(mode == .linear){ + guard self.items.count < numberOfItems else { return } + } + for index in 0.. abs(recognizer.velocity(in: self).y) else{ + return + } let targetView = recognizer.view @@ -230,7 +257,7 @@ open class TGLParallaxCarousel: UIView { let xOffset = (startGesturePoint.x - endGesturePoint.x ) * (1 / parallaxFactor) moveCarousel(xOffset) - + startGesturePoint = endGesturePoint case .ended, .cancelled, .failed: @@ -241,29 +268,33 @@ open class TGLParallaxCarousel: UIView { } } - func detectTap(_ recognizer:UITapGestureRecognizer) { + @objc func detectTap(_ recognizer:UITapGestureRecognizer) { let targetPoint: CGPoint = recognizer.location(in: recognizer.view) currentTargetLayer = mainView.layer.hitTest(targetPoint)! - - guard let targetItem = findItemOnScreen() else { return } - - let firstItemOffset = (items.first?.xDisp ?? 0) - targetItem.xDisp - let tappedIndex = -Int(round(firstItemOffset / xDisplacement)) - - if targetItem.xDisp == 0 { - self.delegate?.carouselView(self, didSelectItemAtIndex: tappedIndex) - } - else { - selectedIndex = tappedIndex + if let delegate = self.delegate{ + delegate.carouselView(self, didSelectItemAtIndex: selectedIndex) } + // guard let targetItem = findItemOnScreen() else { return } + // + // let firstItemOffset = (items.first?.xDisp ?? 0) - targetItem.xDisp + // let tappedIndex = -Int(round(firstItemOffset / xDisplacement)) + // + // self.delegate?.carouselView(self, didSelectItemAtIndex: tappedIndex) + + // if targetItem.xDisp == 0 { + // self.delegate?.carouselView(self, didSelectItemAtIndex: tappedIndex) + // } + // else { + // selectedIndex = tappedIndex + // } } // MARK: - find item fileprivate func findItemOnScreen() -> TGLParallaxCarouselItem? { currentFoundItem = nil - + for item in items { currentItem = item checkInSubviews(item) @@ -282,6 +313,12 @@ open class TGLParallaxCarousel: UIView { } fileprivate func checkView(_ view: UIView) -> Bool { + // if(view.layer.position == currentTargetLayer?.position){ + // currentFoundItem = currentItem + // return true + // } + // return false + if view.layer.isEqual(currentTargetLayer) { currentFoundItem = currentItem return true @@ -337,7 +374,7 @@ open class TGLParallaxCarousel: UIView { let offsetToAdd = xDisplacement * -CGFloat(selectedIndex) - offsetItems moveCarousel(-offsetToAdd) updatePageControl(selectedIndex) - delegate?.carouselView(self, didSelectItemAtIndex: selectedIndex) + // delegate?.carouselView(self, didSelectItemAtIndex: selectedIndex) } fileprivate func factorForXDisp(_ x: CGFloat) -> CGFloat { @@ -381,4 +418,9 @@ open class TGLParallaxCarousel: UIView { func updatePageControl(_ index: Int) { pageControl.currentPage = index } + + //Add method to hide page control + open func setPageControlHidden(hide: Bool){ + self.pageControl.isHidden = hide + } }