From b4f4f85f6121466110c129c7a0a2639fe928d62d Mon Sep 17 00:00:00 2001 From: Vinayak Sareen Date: Wed, 14 Aug 2019 06:12:44 +0530 Subject: [PATCH] change --- Example/Pods/Pods.xcodeproj/project.pbxproj | 12 +++++----- Example/SVSwiper/ViewController.swift | 9 +++---- SVSwiper.podspec | 10 ++++---- SVSwiper/Classes/Constraints.swift | 24 ++++++++++++++----- SVSwiper/Classes/SVSwiperController.swift | 4 ++-- .../Classes/SVSwiperCustomCell.swift | 3 ++- 6 files changed, 38 insertions(+), 24 deletions(-) rename SVSwiperCustomCell.swift => SVSwiper/Classes/SVSwiperCustomCell.swift (94%) diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index 3302002..068f250 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -18,8 +18,8 @@ 4259B00723035BC100A57B87 /* SwiperDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4259B00523035BC100A57B87 /* SwiperDelegate.swift */; }; 4259B00923035C0D00A57B87 /* SVSwiperController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4259B00823035C0D00A57B87 /* SVSwiperController.swift */; }; 4259B00A23035C0D00A57B87 /* SVSwiperController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4259B00823035C0D00A57B87 /* SVSwiperController.swift */; }; - 4259B00C2303600100A57B87 /* SVSwiperCustomCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4259B00B2303600100A57B87 /* SVSwiperCustomCell.swift */; }; - 4259B00D2303600100A57B87 /* SVSwiperCustomCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4259B00B2303600100A57B87 /* SVSwiperCustomCell.swift */; }; + 4259B01623038B9800A57B87 /* SVSwiperCustomCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4259B01523038B9800A57B87 /* SVSwiperCustomCell.swift */; }; + 4259B01723038B9800A57B87 /* SVSwiperCustomCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4259B01523038B9800A57B87 /* SVSwiperCustomCell.swift */; }; 4532E5A8FDD4D02FB93F9AA5B2C8BCFB /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3212113385A8FBBDB272BD23C409FF61 /* Foundation.framework */; }; 7995C08CE91936F81C571031EF72F880 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3212113385A8FBBDB272BD23C409FF61 /* Foundation.framework */; }; 8E157B78DF11F8B161DE90F2C519BA50 /* Pods-SVSwiper_Tests-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 7730FF70A2A704BAB722F13B6CB2A082 /* Pods-SVSwiper_Tests-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -56,7 +56,7 @@ 4259AFFF2303597100A57B87 /* Constraints.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Constraints.swift; path = SVSwiper/Classes/Constraints.swift; sourceTree = ""; }; 4259B00523035BC100A57B87 /* SwiperDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SwiperDelegate.swift; path = SVSwiper/Classes/SwiperDelegate.swift; sourceTree = ""; }; 4259B00823035C0D00A57B87 /* SVSwiperController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SVSwiperController.swift; path = SVSwiper/Classes/SVSwiperController.swift; sourceTree = ""; }; - 4259B00B2303600100A57B87 /* SVSwiperCustomCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SVSwiperCustomCell.swift; sourceTree = ""; }; + 4259B01523038B9800A57B87 /* SVSwiperCustomCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SVSwiperCustomCell.swift; path = SVSwiper/Classes/SVSwiperCustomCell.swift; sourceTree = ""; }; 49ADA7EF2F48657D1F47796AA9401D98 /* Pods-SVSwiper_Example-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-SVSwiper_Example-acknowledgements.plist"; sourceTree = ""; }; 73ACA27008B3D56FBDED179B155DEB84 /* Pods-SVSwiper_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-SVSwiper_Example.debug.xcconfig"; sourceTree = ""; }; 7444F982D344637647B715F11D10B280 /* SVSwiper-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "SVSwiper-dummy.m"; sourceTree = ""; }; @@ -174,7 +174,7 @@ 4259AFFF2303597100A57B87 /* Constraints.swift */, 4259B00823035C0D00A57B87 /* SVSwiperController.swift */, 4259B00523035BC100A57B87 /* SwiperDelegate.swift */, - 4259B00B2303600100A57B87 /* SVSwiperCustomCell.swift */, + 4259B01523038B9800A57B87 /* SVSwiperCustomCell.swift */, 879DDFAE04B5D747BAF04EA5C617EB4C /* Pod */, 2C6978396A2C930E4BBC33272DDF7D9C /* Support Files */, ); @@ -392,7 +392,7 @@ files = ( 4259B00723035BC100A57B87 /* SwiperDelegate.swift in Sources */, 4259B001230359A500A57B87 /* Constraints.swift in Sources */, - 4259B00D2303600100A57B87 /* SVSwiperCustomCell.swift in Sources */, + 4259B01723038B9800A57B87 /* SVSwiperCustomCell.swift in Sources */, 4259B00A23035C0D00A57B87 /* SVSwiperController.swift in Sources */, 0D55EF6C123D6247F5733BF76046010F /* SVSwiper-dummy.m in Sources */, ); @@ -404,7 +404,7 @@ files = ( 4259B00623035BC100A57B87 /* SwiperDelegate.swift in Sources */, 4259B0002303597100A57B87 /* Constraints.swift in Sources */, - 4259B00C2303600100A57B87 /* SVSwiperCustomCell.swift in Sources */, + 4259B01623038B9800A57B87 /* SVSwiperCustomCell.swift in Sources */, 4259B00923035C0D00A57B87 /* SVSwiperController.swift in Sources */, 3DB5D0109F014E2EAB5BF09516A8716C /* Pods-SVSwiper_Example-dummy.m in Sources */, ); diff --git a/Example/SVSwiper/ViewController.swift b/Example/SVSwiper/ViewController.swift index 7837b06..234b86a 100644 --- a/Example/SVSwiper/ViewController.swift +++ b/Example/SVSwiper/ViewController.swift @@ -10,7 +10,8 @@ import UIKit import SVSwiper class ViewController: UIViewController { - + + override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = #colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0) @@ -25,7 +26,7 @@ class ViewController: UIViewController { self.addChildViewController(controller) guard let cview = controller.view else { return } view.addSubview(cview) - cview.fillSuperView() + cview.svFillSuperView() } } @@ -41,11 +42,11 @@ extension ViewController: SVSwiperDelegate{ } func barColor() -> UIColor { - return #colorLiteral(red: 0.2392156869, green: 0.6745098233, blue: 0.9686274529, alpha: 1) + return #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1) } func textColor() -> UIColor { - return #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1) + return #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1) } func titleTextColor() -> UIColor { diff --git a/SVSwiper.podspec b/SVSwiper.podspec index f3533ad..5817b78 100644 --- a/SVSwiper.podspec +++ b/SVSwiper.podspec @@ -21,22 +21,22 @@ Pod::Spec.new do |s| TODO: Add long description of the pod here. DESC - s.homepage = 'https://github.com/buggyman026@gmail.com/SVSwiper' + s.homepage = 'https://github.coventry.ac.uk/sareenv/SVSwiper' # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' s.license = { :type => 'MIT', :file => 'LICENSE' } - s.author = { 'buggyman026@gmail.com' => 'sareenv@uni.coventry.ac.uk' } - s.source = { :git => 'https://github.com/buggyman026@gmail.com/SVSwiper.git', :tag => s.version.to_s } + s.author = { 'Vinayak' => 'sareenv@uni.coventry.ac.uk' } + s.source = { :git => 'https://github.coventry.ac.uk/sareenv/SVSwiper.git', :tag => s.version.to_s } # s.social_media_url = 'https://twitter.com/' s.ios.deployment_target = '8.0' - s.source_files = 'SVSwiper/Classes/**/*' + s.source_files = 'SVSwiper/Classes/*.swift' # s.resource_bundles = { # 'SVSwiper' => ['SVSwiper/Assets/*.png'] # } # s.public_header_files = 'Pod/Classes/**/*.h' - # s.frameworks = 'UIKit', 'MapKit' + s.frameworks = 'UIKit' # s.dependency 'AFNetworking', '~> 2.3' end diff --git a/SVSwiper/Classes/Constraints.swift b/SVSwiper/Classes/Constraints.swift index 67b180c..5a768b1 100644 --- a/SVSwiper/Classes/Constraints.swift +++ b/SVSwiper/Classes/Constraints.swift @@ -12,7 +12,7 @@ import UIKit public extension UIView{ @available(iOS 9.0, *) - func fillSuperView (top: CGFloat=0, bottom: CGFloat=0, leading: CGFloat=0, trailing: CGFloat=0){ + func svFillSuperView (top: CGFloat=0, bottom: CGFloat=0, leading: CGFloat=0, trailing: CGFloat=0){ self.translatesAutoresizingMaskIntoConstraints = false guard let superView = self.superview else { return } self.topAnchor.constraint(equalTo: superView.topAnchor, constant: top).isActive = true @@ -21,12 +21,24 @@ public extension UIView{ self.trailingAnchor.constraint(equalTo: superView.trailingAnchor, constant: trailing).isActive = true } @available(iOS 9.0, *) - func anchor(topAnchor: NSLayoutYAxisAnchor, bottomAnchor: NSLayoutYAxisAnchor, leadingAnchor: NSLayoutXAxisAnchor, trailingAnchor: NSLayoutXAxisAnchor, padding: UIEdgeInsets = .zero){ + func svAnchor(topAnchor: NSLayoutYAxisAnchor?, bottomAnchor: NSLayoutYAxisAnchor?, leadingAnchor: NSLayoutXAxisAnchor?, trailingAnchor: NSLayoutXAxisAnchor?, padding: UIEdgeInsets = .zero){ self.translatesAutoresizingMaskIntoConstraints = false - self.topAnchor.constraint(equalTo: topAnchor, constant: padding.top) - self.bottomAnchor.constraint(equalTo: bottomAnchor, constant: padding.bottom) - self.leadingAnchor.constraint(equalTo: leadingAnchor, constant: padding.left) - self.trailingAnchor.constraint(equalTo: trailingAnchor, constant: padding.right) + + if let topAnchor = topAnchor{ + self.topAnchor.constraint(equalTo: topAnchor, constant: padding.top) + } + + if let bottomAnchor = bottomAnchor{ + self.bottomAnchor.constraint(equalTo: bottomAnchor, constant: padding.bottom) + } + + if let leadingAnchor = leadingAnchor{ + self.leadingAnchor.constraint(equalTo: leadingAnchor, constant: padding.left) + } + + if let trailingAnchor = trailingAnchor{ + self.trailingAnchor.constraint(equalTo: trailingAnchor, constant: padding.right) + } } } diff --git a/SVSwiper/Classes/SVSwiperController.swift b/SVSwiper/Classes/SVSwiperController.swift index 971f400..72a7083 100644 --- a/SVSwiper/Classes/SVSwiperController.swift +++ b/SVSwiper/Classes/SVSwiperController.swift @@ -75,7 +75,7 @@ public class SVSwiperController: UICollectionViewController, UICollectionViewDel view.addSubview(headerCell) if #available(iOS 9.0, *) { - headerCell.anchor(topAnchor: view.topAnchor, bottomAnchor: view.bottomAnchor, leadingAnchor: view.leadingAnchor, trailingAnchor: view.trailingAnchor) + headerCell.svAnchor(topAnchor: view.topAnchor, bottomAnchor: view.bottomAnchor, leadingAnchor: view.leadingAnchor, trailingAnchor: view.trailingAnchor) headerCell.widthAnchor.constraint(equalToConstant: menuBarSize?.width ?? view?.frame.width ?? 0).isActive = true headerCell.heightAnchor.constraint(equalToConstant: menuBarSize?.height ?? 0).isActive = true // change this } @@ -114,7 +114,7 @@ public class SVSwiperController: UICollectionViewController, UICollectionViewDel stackView.alignment = .center stackView.axis = .horizontal self.headerCell.addSubview(stackView) - stackView.fillSuperView() + stackView.svFillSuperView() } diff --git a/SVSwiperCustomCell.swift b/SVSwiper/Classes/SVSwiperCustomCell.swift similarity index 94% rename from SVSwiperCustomCell.swift rename to SVSwiper/Classes/SVSwiperCustomCell.swift index 8fb2d1f..f5a509c 100644 --- a/SVSwiperCustomCell.swift +++ b/SVSwiper/Classes/SVSwiperCustomCell.swift @@ -26,7 +26,7 @@ class SVSwiperCustomCell: UICollectionViewCell{ guard let childView = viewController.view else { return } self.addSubview(childView) if #available(iOS 9.0, *) { - childView.fillSuperView(top: 5) + childView.svFillSuperView(top: 5) } } @@ -36,3 +36,4 @@ class SVSwiperCustomCell: UICollectionViewCell{ super.init(coder: aDecoder) } } +