From ee2528f91196d21063f7445aeee1daa108e39e3c Mon Sep 17 00:00:00 2001 From: PM Villa Date: Tue, 27 Sep 2022 14:46:33 +0900 Subject: [PATCH 01/14] SPM first attempt --- {Sources => ObjC}/FXPageControl.h | 0 {Sources => ObjC}/FXPageControl.m | 0 Package.swift | 40 ++++++++++++++++ {Sources => Resources}/ButtonCell.xib | 0 Sources/PagerTabStripViewController.swift | 4 +- .../TwitterPagerTabStripViewController.swift | 21 ++++++++- XLPagerTabStrip.xcodeproj/project.pbxproj | 46 +++++++++++-------- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++ .../xcschemes/XLPagerTabStrip.xcscheme | 24 ++++------ 9 files changed, 106 insertions(+), 37 deletions(-) rename {Sources => ObjC}/FXPageControl.h (100%) rename {Sources => ObjC}/FXPageControl.m (100%) create mode 100644 Package.swift rename {Sources => Resources}/ButtonCell.xib (100%) create mode 100644 XLPagerTabStrip.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Sources/FXPageControl.h b/ObjC/FXPageControl.h similarity index 100% rename from Sources/FXPageControl.h rename to ObjC/FXPageControl.h diff --git a/Sources/FXPageControl.m b/ObjC/FXPageControl.m similarity index 100% rename from Sources/FXPageControl.m rename to ObjC/FXPageControl.m diff --git a/Package.swift b/Package.swift new file mode 100644 index 00000000..10c9a1de --- /dev/null +++ b/Package.swift @@ -0,0 +1,40 @@ +// swift-tools-version: 5.4 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "XLPagerTabStrip", + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "XLPagerTabStrip", + targets: ["XLPagerTabStrip"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + .package( + url: "https://github.com/Climbatize/FXPageControl.git", + .upToNextMajor(from: "1.5.1") + ) + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "XLPagerTabStrip", + dependencies: ["FXPageControl"], + path: "Sources/", + resources: [ + .process("Resources") + ]), + .testTarget( + name: "XLPagerTabStripTests", + dependencies: ["XLPagerTabStrip"], + path: "Tests/"), + ], + swiftLanguageVersions: [ + .v5 + ] +) diff --git a/Sources/ButtonCell.xib b/Resources/ButtonCell.xib similarity index 100% rename from Sources/ButtonCell.xib rename to Resources/ButtonCell.xib diff --git a/Sources/PagerTabStripViewController.swift b/Sources/PagerTabStripViewController.swift index 9aedb7d6..c51d5e1a 100644 --- a/Sources/PagerTabStripViewController.swift +++ b/Sources/PagerTabStripViewController.swift @@ -32,7 +32,7 @@ public protocol IndicatorInfoProvider { } -public protocol PagerTabStripDelegate: class { +public protocol PagerTabStripDelegate: AnyObject { func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int) } @@ -42,7 +42,7 @@ public protocol PagerTabStripIsProgressiveDelegate: PagerTabStripDelegate { func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool) } -public protocol PagerTabStripDataSource: class { +public protocol PagerTabStripDataSource: AnyObject { func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] } diff --git a/Sources/TwitterPagerTabStripViewController.swift b/Sources/TwitterPagerTabStripViewController.swift index c37215a2..5caa1a3b 100644 --- a/Sources/TwitterPagerTabStripViewController.swift +++ b/Sources/TwitterPagerTabStripViewController.swift @@ -24,6 +24,23 @@ import Foundation +extension UIWindow { + static var isLandscape: Bool { + return UIApplication.shared.windows + .first? + .windowScene? + .interfaceOrientation + .isLandscape ?? false + } + static var isPortrait: Bool { + return UIApplication.shared.windows + .first? + .windowScene? + .interfaceOrientation + .isPortrait ?? false + } +} + public struct TwitterPagerTabStripSettings { public struct Style { @@ -178,7 +195,7 @@ open class TwitterPagerTabStripViewController: PagerTabStripViewController, Page let navTitleLabel: UILabel = { let label = UILabel() label.text = indicatorInfo.title - label.font = UIApplication.shared.statusBarOrientation.isPortrait ? settings.style.portraitTitleFont : settings.style.landscapeTitleFont + label.font = UIWindow.isPortrait ? settings.style.portraitTitleFont : settings.style.landscapeTitleFont label.textColor = settings.style.titleColor label.alpha = 0 return label @@ -192,7 +209,7 @@ open class TwitterPagerTabStripViewController: PagerTabStripViewController, Page private func setNavigationViewItemsPosition(updateAlpha: Bool) { guard let distance = distanceValue else { return } - let isPortrait = UIApplication.shared.statusBarOrientation.isPortrait + let isPortrait = UIWindow.isPortrait let navBarHeight: CGFloat = navigationController!.navigationBar.frame.size.height for (index, label) in childTitleLabels.enumerated() { if updateAlpha { diff --git a/XLPagerTabStrip.xcodeproj/project.pbxproj b/XLPagerTabStrip.xcodeproj/project.pbxproj index d29c60e9..9dc9507a 100644 --- a/XLPagerTabStrip.xcodeproj/project.pbxproj +++ b/XLPagerTabStrip.xcodeproj/project.pbxproj @@ -15,13 +15,13 @@ 28E098C01C5003130083B788 /* SwipeDirection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28E098BF1C5003130083B788 /* SwipeDirection.swift */; }; 28F828811C494B2C00330CF4 /* XLPagerTabStrip.h in Headers */ = {isa = PBXBuildFile; fileRef = 28F828801C494B2C00330CF4 /* XLPagerTabStrip.h */; settings = {ATTRIBUTES = (Public, ); }; }; 28F828881C494B2C00330CF4 /* XLPagerTabStrip.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28F8287D1C494B2C00330CF4 /* XLPagerTabStrip.framework */; }; + 3174BB1228E2B81700847CF0 /* FXPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 3174BB1028E2B81700847CF0 /* FXPageControl.m */; }; + 3174BB1328E2B81700847CF0 /* FXPageControl.h in Headers */ = {isa = PBXBuildFile; fileRef = 3174BB1128E2B81700847CF0 /* FXPageControl.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3174BB1828E2C46A00847CF0 /* ButtonCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3174BB1728E2C46A00847CF0 /* ButtonCell.xib */; }; CB0986C41C51391600DF7087 /* ButtonBarPagerTabStripViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB0986C31C51391600DF7087 /* ButtonBarPagerTabStripViewController.swift */; }; CB0986C61C51395E00DF7087 /* ButtonBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB0986C51C51395E00DF7087 /* ButtonBarView.swift */; }; CB0986C81C5158A000DF7087 /* ButtonBarViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB0986C71C5158A000DF7087 /* ButtonBarViewCell.swift */; }; - CB0986CA1C515D9A00DF7087 /* ButtonCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CB0986C91C515D9A00DF7087 /* ButtonCell.xib */; }; CB71C6EE1C4EB988008EC806 /* SegmentedPagerTabStripViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB71C6ED1C4EB988008EC806 /* SegmentedPagerTabStripViewController.swift */; }; - CB7D614C1C529B9500A957BA /* FXPageControl.h in Headers */ = {isa = PBXBuildFile; fileRef = CB7D614A1C529B9500A957BA /* FXPageControl.h */; settings = {ATTRIBUTES = (Public, ); }; }; - CB7D614D1C529B9500A957BA /* FXPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = CB7D614B1C529B9500A957BA /* FXPageControl.m */; }; CB86ED6B1C4D6E6C00DA463B /* PagerTabStripViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB86ED6A1C4D6E6C00DA463B /* PagerTabStripViewController.swift */; }; CBA0A1FC1C502DA300C5748C /* BarPagerTabStripViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBA0A1FA1C502DA300C5748C /* BarPagerTabStripViewController.swift */; }; CBA0A1FD1C502DA300C5748C /* BarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBA0A1FB1C502DA300C5748C /* BarView.swift */; }; @@ -51,13 +51,13 @@ 28F828871C494B2C00330CF4 /* XLPagerTabStripTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XLPagerTabStripTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 28F8288E1C494B2C00330CF4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 28F8289B1C494BF100330CF4 /* Playground.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Playground.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; + 3174BB1028E2B81700847CF0 /* FXPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FXPageControl.m; sourceTree = ""; }; + 3174BB1128E2B81700847CF0 /* FXPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FXPageControl.h; sourceTree = ""; }; + 3174BB1728E2C46A00847CF0 /* ButtonCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ButtonCell.xib; sourceTree = ""; }; CB0986C31C51391600DF7087 /* ButtonBarPagerTabStripViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ButtonBarPagerTabStripViewController.swift; sourceTree = ""; }; CB0986C51C51395E00DF7087 /* ButtonBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ButtonBarView.swift; sourceTree = ""; }; CB0986C71C5158A000DF7087 /* ButtonBarViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ButtonBarViewCell.swift; sourceTree = ""; }; - CB0986C91C515D9A00DF7087 /* ButtonCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ButtonCell.xib; sourceTree = ""; }; CB71C6ED1C4EB988008EC806 /* SegmentedPagerTabStripViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SegmentedPagerTabStripViewController.swift; sourceTree = ""; }; - CB7D614A1C529B9500A957BA /* FXPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FXPageControl.h; sourceTree = ""; }; - CB7D614B1C529B9500A957BA /* FXPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FXPageControl.m; sourceTree = ""; }; CB86ED6A1C4D6E6C00DA463B /* PagerTabStripViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = PagerTabStripViewController.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; CBA0A1FA1C502DA300C5748C /* BarPagerTabStripViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BarPagerTabStripViewController.swift; sourceTree = ""; }; CBA0A1FB1C502DA300C5748C /* BarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BarView.swift; sourceTree = ""; }; @@ -86,8 +86,6 @@ 281BFDBE1C511B890090C26F /* Views */ = { isa = PBXGroup; children = ( - CB7D614E1C529BB600A957BA /* FXPageControl */, - CB0986C91C515D9A00DF7087 /* ButtonCell.xib */, CBA0A1FB1C502DA300C5748C /* BarView.swift */, CB0986C51C51395E00DF7087 /* ButtonBarView.swift */, CB0986C71C5158A000DF7087 /* ButtonBarViewCell.swift */, @@ -149,6 +147,8 @@ 28F828971C494B4200330CF4 /* Sources */ = { isa = PBXGroup; children = ( + 3174BB0F28E2B81700847CF0 /* ObjC */, + 3174BB1628E2C46A00847CF0 /* Resources */, 281BFDBF1C511B9A0090C26F /* Controllers */, 281BFDBE1C511B890090C26F /* Views */, 28E098BD1C5002D90083B788 /* PagerTabStripError.swift */, @@ -159,14 +159,22 @@ path = Sources; sourceTree = ""; }; - CB7D614E1C529BB600A957BA /* FXPageControl */ = { + 3174BB0F28E2B81700847CF0 /* ObjC */ = { isa = PBXGroup; children = ( - CB7D614A1C529B9500A957BA /* FXPageControl.h */, - CB7D614B1C529B9500A957BA /* FXPageControl.m */, + 3174BB1028E2B81700847CF0 /* FXPageControl.m */, + 3174BB1128E2B81700847CF0 /* FXPageControl.h */, ); - name = FXPageControl; - sourceTree = ""; + path = ObjC; + sourceTree = SOURCE_ROOT; + }; + 3174BB1628E2C46A00847CF0 /* Resources */ = { + isa = PBXGroup; + children = ( + 3174BB1728E2C46A00847CF0 /* ButtonCell.xib */, + ); + path = Resources; + sourceTree = SOURCE_ROOT; }; /* End PBXGroup section */ @@ -176,7 +184,7 @@ buildActionMask = 2147483647; files = ( 28F828811C494B2C00330CF4 /* XLPagerTabStrip.h in Headers */, - CB7D614C1C529B9500A957BA /* FXPageControl.h in Headers */, + 3174BB1328E2B81700847CF0 /* FXPageControl.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -264,7 +272,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - CB0986CA1C515D9A00DF7087 /* ButtonCell.xib in Resources */, + 3174BB1828E2C46A00847CF0 /* ButtonCell.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -290,7 +298,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi"; + shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ @@ -303,7 +311,7 @@ CB0986C61C51395E00DF7087 /* ButtonBarView.swift in Sources */, CBBD43621C527E80001A748E /* TwitterPagerTabStripViewController.swift in Sources */, CBA0A1FD1C502DA300C5748C /* BarView.swift in Sources */, - CB7D614D1C529B9500A957BA /* FXPageControl.m in Sources */, + 3174BB1228E2B81700847CF0 /* FXPageControl.m in Sources */, 281BFDC31C511F120090C26F /* PagerTabStripBehaviour.swift in Sources */, CBA0A1FC1C502DA300C5748C /* BarPagerTabStripViewController.swift in Sources */, CB71C6EE1C4EB988008EC806 /* SegmentedPagerTabStripViewController.swift in Sources */, @@ -464,7 +472,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = XLPagerTabStrip/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.XLPagerTabStrip; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -489,7 +497,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = XLPagerTabStrip/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.XLPagerTabStrip; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/XLPagerTabStrip.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/XLPagerTabStrip.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/XLPagerTabStrip.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/XLPagerTabStrip.xcodeproj/xcshareddata/xcschemes/XLPagerTabStrip.xcscheme b/XLPagerTabStrip.xcodeproj/xcshareddata/xcschemes/XLPagerTabStrip.xcscheme index 3c9ff698..e69dcca7 100644 --- a/XLPagerTabStrip.xcodeproj/xcshareddata/xcschemes/XLPagerTabStrip.xcscheme +++ b/XLPagerTabStrip.xcodeproj/xcshareddata/xcschemes/XLPagerTabStrip.xcscheme @@ -1,6 +1,6 @@ + + + + @@ -39,17 +48,6 @@ - - - - - - - - Date: Tue, 27 Sep 2022 14:50:56 +0900 Subject: [PATCH 02/14] update FXPageControl --- ObjC/FXPageControl.h | 41 ++--- ObjC/FXPageControl.m | 412 +++++++++++++++++++++++++++---------------- 2 files changed, 282 insertions(+), 171 deletions(-) diff --git a/ObjC/FXPageControl.h b/ObjC/FXPageControl.h index 37a0438a..33294afc 100755 --- a/ObjC/FXPageControl.h +++ b/ObjC/FXPageControl.h @@ -1,7 +1,7 @@ // // FXPageControl.h // -// Version 1.4 +// Version 1.5 // // Created by Nick Lockwood on 07/01/2010. // Copyright 2010 Charcoal Design @@ -31,18 +31,12 @@ // -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wobjc-missing-property-synthesis" +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-missing-property-synthesis" #import -#import -#undef weak_delegate -#if __has_feature(objc_arc_weak) -#define weak_delegate weak -#else -#define weak_delegate unsafe_unretained -#endif +NS_ASSUME_NONNULL_BEGIN extern const CGPathRef FXPageControlDotShapeCircle; @@ -59,7 +53,7 @@ IB_DESIGNABLE @interface FXPageControl : UIControl - (CGSize)sizeForNumberOfPages:(NSInteger)pageCount; - (void)updateCurrentPageDisplay; -@property (nonatomic, weak_delegate) IBOutlet id delegate; +@property (nonatomic, weak) IBOutlet id delegate; @property (nonatomic, assign) IBInspectable NSInteger currentPage; @property (nonatomic, assign) IBInspectable NSInteger numberOfPages; @@ -68,21 +62,25 @@ IB_DESIGNABLE @interface FXPageControl : UIControl @property (nonatomic, assign, getter = isWrapEnabled) IBInspectable BOOL wrapEnabled; @property (nonatomic, assign, getter = isVertical) IBInspectable BOOL vertical; -@property (nonatomic, strong) IBInspectable UIImage *dotImage; @property (nonatomic, assign) IBInspectable CGPathRef dotShape; @property (nonatomic, assign) IBInspectable CGFloat dotSize; -@property (nonatomic, strong) IBInspectable UIColor *dotColor; -@property (nonatomic, strong) IBInspectable UIColor *dotShadowColor; @property (nonatomic, assign) IBInspectable CGFloat dotShadowBlur; @property (nonatomic, assign) IBInspectable CGSize dotShadowOffset; +@property (nonatomic, assign) IBInspectable CGFloat dotBorderWidth; +@property (nonatomic, strong, nullable) IBInspectable UIImage *dotImage; +@property (nonatomic, strong, nullable) IBInspectable UIColor *dotColor; +@property (nonatomic, strong, nullable) IBInspectable UIColor *dotShadowColor; +@property (nonatomic, strong, nullable) IBInspectable UIColor *dotBorderColor; -@property (nonatomic, strong) IBInspectable UIImage *selectedDotImage; @property (nonatomic, assign) IBInspectable CGPathRef selectedDotShape; @property (nonatomic, assign) IBInspectable CGFloat selectedDotSize; -@property (nonatomic, strong) IBInspectable UIColor *selectedDotColor; -@property (nonatomic, strong) IBInspectable UIColor *selectedDotShadowColor; @property (nonatomic, assign) IBInspectable CGFloat selectedDotShadowBlur; @property (nonatomic, assign) IBInspectable CGSize selectedDotShadowOffset; +@property (nonatomic, assign) IBInspectable CGFloat selectedDotBorderWidth; +@property (nonatomic, strong, nullable) IBInspectable UIImage *selectedDotImage; +@property (nonatomic, strong, nullable) IBInspectable UIColor *selectedDotColor; +@property (nonatomic, strong, nullable) IBInspectable UIColor *selectedDotShadowColor; +@property (nonatomic, strong, nullable) IBInspectable UIColor *selectedDotBorderColor; @property (nonatomic, assign) IBInspectable CGFloat dotSpacing; @@ -92,15 +90,18 @@ IB_DESIGNABLE @interface FXPageControl : UIControl @protocol FXPageControlDelegate @optional -- (UIImage *)pageControl:(FXPageControl *)pageControl imageForDotAtIndex:(NSInteger)index; +- (nullable UIImage *)pageControl:(FXPageControl *)pageControl imageForDotAtIndex:(NSInteger)index; - (CGPathRef)pageControl:(FXPageControl *)pageControl shapeForDotAtIndex:(NSInteger)index; - (UIColor *)pageControl:(FXPageControl *)pageControl colorForDotAtIndex:(NSInteger)index; -- (UIImage *)pageControl:(FXPageControl *)pageControl selectedImageForDotAtIndex:(NSInteger)index; +- (nullable UIImage *)pageControl:(FXPageControl *)pageControl selectedImageForDotAtIndex:(NSInteger)index; - (CGPathRef)pageControl:(FXPageControl *)pageControl selectedShapeForDotAtIndex:(NSInteger)index; - (UIColor *)pageControl:(FXPageControl *)pageControl selectedColorForDotAtIndex:(NSInteger)index; @end -#pragma GCC diagnostic pop +NS_ASSUME_NONNULL_END + + +#pragma clang diagnostic pop diff --git a/ObjC/FXPageControl.m b/ObjC/FXPageControl.m index 01602e8a..0f25e90b 100755 --- a/ObjC/FXPageControl.m +++ b/ObjC/FXPageControl.m @@ -1,7 +1,7 @@ // // FXPageControl.m // -// Version 1.4 +// Version 1.5 // // Created by Nick Lockwood on 07/01/2010. // Copyright 2010 Charcoal Design @@ -33,9 +33,11 @@ #import "FXPageControl.h" -#pragma GCC diagnostic ignored "-Wgnu" -#pragma GCC diagnostic ignored "-Warc-repeated-use-of-weak" -#pragma GCC diagnostic ignored "-Wdirect-ivar-access" +#pragma clang diagnostic ignored "-Wgnu" +#pragma clang diagnostic ignored "-Wfloat-equal" +#pragma clang diagnostic ignored "-Wfloat-conversion" +#pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" +#pragma clang diagnostic ignored "-Wdirect-ivar-access" #import @@ -50,49 +52,36 @@ #define LAST_SHAPE FXPageControlDotShapeTriangle -@implementation NSObject (FXPageControl) - -- (UIImage *)pageControl:(__unused FXPageControl *)pageControl imageForDotAtIndex:(__unused NSInteger)index { return nil; } -- (CGPathRef)pageControl:(__unused FXPageControl *)pageControl shapeForDotAtIndex:(__unused NSInteger)index { return NULL; } -- (UIColor *)pageControl:(__unused FXPageControl *)pageControl colorForDotAtIndex:(__unused NSInteger)index { return nil; } - -- (UIImage *)pageControl:(__unused FXPageControl *)pageControl selectedImageForDotAtIndex:(__unused NSInteger)index { return nil; } -- (CGPathRef)pageControl:(__unused FXPageControl *)pageControl selectedShapeForDotAtIndex:(__unused NSInteger)index { return NULL; } -- (UIColor *)pageControl:(__unused FXPageControl *)pageControl selectedColorForDotAtIndex:(__unused NSInteger)index { return nil; } - -@end - - @implementation FXPageControl - (void)setUp -{ +{ //needs redrawing if bounds change self.contentMode = UIViewContentModeRedraw; - - //set defaults - _dotSpacing = 10.0f; - _dotSize = 6.0f; + + //set defaults + _dotSpacing = 10.0; + _dotSize = 6.0; _dotShadowOffset = CGSizeMake(0, 1); _selectedDotShadowOffset = CGSizeMake(0, 1); } -- (id)initWithFrame:(CGRect)frame +- (instancetype)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) - { - [self setUp]; + { + [self setUp]; } return self; } -- (id)initWithCoder:(NSCoder *)aDecoder +- (instancetype)initWithCoder:(NSCoder *)aDecoder { - if ((self = [super initWithCoder:aDecoder])) - { - [self setUp]; - } - return self; + if ((self = [super initWithCoder:aDecoder])) + { + [self setUp]; + } + return self; } - (void)dealloc @@ -114,9 +103,10 @@ - (void)updateCurrentPageDisplay - (void)drawRect:(__unused CGRect)rect { - if (_numberOfPages > 1 || !_hidesForSinglePage) - { + if (_numberOfPages > 1 || !_hidesForSinglePage) + { CGContextRef context = UIGraphicsGetCurrentContext(); + CGContextClearRect(context, rect); CGSize size = [self sizeForNumberOfPages:_numberOfPages]; if (_vertical) { @@ -126,93 +116,150 @@ - (void)drawRect:(__unused CGRect)rect { CGContextTranslateCTM(context, (self.frame.size.width - size.width) / 2, self.frame.size.height / 2); } - + for (int i = 0; i < _numberOfPages; i++) - { - UIImage *dotImage = nil; + { + UIImage *dotImage = nil; UIColor *dotColor = nil; CGPathRef dotShape = NULL; CGFloat dotSize = 0; UIColor *dotShadowColor = nil; CGSize dotShadowOffset = CGSizeZero; CGFloat dotShadowBlur = 0; - - if (i == _currentPage) - { - [_selectedDotColor setFill]; - dotImage = [_delegate pageControl:self selectedImageForDotAtIndex:i] ?: _selectedDotImage; - dotShape = [_delegate pageControl:self selectedShapeForDotAtIndex:i] ?: _selectedDotShape ?: _dotShape; - dotColor = [_delegate pageControl:self selectedColorForDotAtIndex:i] ?: _selectedDotColor ?: [UIColor blackColor]; + CGFloat dotBorderWidth = 0; + UIColor *dotBorderColor = nil; + + if (i == _currentPage) + { + if ([_delegate respondsToSelector:@selector(pageControl:selectedImageForDotAtIndex:)]) + { + dotImage = [_delegate pageControl:self selectedImageForDotAtIndex:i]; + } + else + { + dotImage = _selectedDotImage; + } + if ([_delegate respondsToSelector:@selector(pageControl:selectedShapeForDotAtIndex:)]) + { + dotShape = [_delegate pageControl:self selectedShapeForDotAtIndex:i]; + } + else + { + dotShape = _selectedDotShape ?: _dotShape; + } + if ([_delegate respondsToSelector:@selector(pageControl:selectedColorForDotAtIndex:)]) + { + dotColor = [_delegate pageControl:self selectedColorForDotAtIndex:i]; + } + else + { + dotColor = _selectedDotColor ?: [UIColor blackColor]; + } dotShadowBlur = _selectedDotShadowBlur; dotShadowColor = _selectedDotShadowColor; dotShadowOffset = _selectedDotShadowOffset; + dotBorderWidth = _selectedDotBorderWidth; + dotBorderColor = _selectedDotBorderColor; dotSize = _selectedDotSize ?: _dotSize; - } - else - { - [_dotColor setFill]; - dotImage = [_delegate pageControl:self imageForDotAtIndex:i] ?: _dotImage; - dotShape = [_delegate pageControl:self shapeForDotAtIndex:i] ?: _dotShape; - dotColor = [_delegate pageControl:self colorForDotAtIndex:i] ?: _dotColor; + } + else + { + if ([_delegate respondsToSelector:@selector(pageControl:imageForDotAtIndex:)]) + { + dotImage = [_delegate pageControl:self imageForDotAtIndex:i]; + } + else + { + dotImage = _dotImage; + } + if ([_delegate respondsToSelector:@selector(pageControl:shapeForDotAtIndex:)]) + { + dotShape = [_delegate pageControl:self shapeForDotAtIndex:i]; + } + else + { + dotShape = _dotShape; + } + if ([_delegate respondsToSelector:@selector(pageControl:colorForDotAtIndex:)]) + { + dotColor = [_delegate pageControl:self colorForDotAtIndex:i]; + } + else + { + dotColor = _dotColor; + } if (!dotColor) { //fall back to selected dot color with reduced alpha - dotColor = [_delegate pageControl:self selectedColorForDotAtIndex:i] ?: _selectedDotColor ?: [UIColor blackColor]; - dotColor = [dotColor colorWithAlphaComponent:0.25f]; + if ([_delegate respondsToSelector:@selector(pageControl:selectedColorForDotAtIndex:)]) + { + dotColor = [_delegate pageControl:self selectedColorForDotAtIndex:i]; + } + else + { + dotColor = _selectedDotColor ?: [UIColor blackColor]; + } + dotColor = [dotColor colorWithAlphaComponent:0.25]; } dotShadowBlur = _dotShadowBlur; dotShadowColor = _dotShadowColor; dotShadowOffset = _dotShadowOffset; + dotBorderWidth = _dotBorderWidth; + dotBorderColor = _dotBorderColor; dotSize = _dotSize; - } - + } + + [dotColor setFill]; + CGContextSaveGState(context); CGFloat offset = (_dotSize + _dotSpacing) * i + _dotSize / 2; CGContextTranslateCTM(context, _vertical? 0: offset, _vertical? offset: 0); - + if (dotShadowColor && ![dotShadowColor isEqual:[UIColor clearColor]]) { CGContextSetShadowWithColor(context, dotShadowOffset, dotShadowBlur, dotShadowColor.CGColor); } - if (dotImage) - { - [dotImage drawInRect:CGRectMake(-dotImage.size.width / 2, -dotImage.size.height / 2, dotImage.size.width, dotImage.size.height)]; - } - else - { - [dotColor setFill]; + if (dotImage) + { + [dotImage drawInRect:CGRectMake(-dotImage.size.width / 2, -dotImage.size.height / 2, dotImage.size.width, dotImage.size.height)]; + } + else + { + [dotBorderColor setStroke]; + CGContextSetLineWidth(context, dotBorderWidth); if (!dotShape || dotShape == FXPageControlDotShapeCircle) { - CGContextFillEllipseInRect(context, CGRectMake(-dotSize / 2, -dotSize / 2, dotSize, dotSize)); + CGContextAddEllipseInRect(context, CGRectMake(-dotSize / 2, -dotSize / 2, dotSize, dotSize)); } else if (dotShape == FXPageControlDotShapeSquare) { - CGContextFillRect(context, CGRectMake(-dotSize / 2, -dotSize / 2, dotSize, dotSize)); + CGContextAddRect(context, CGRectMake(-dotSize / 2, -dotSize / 2, dotSize, dotSize)); } else if (dotShape == FXPageControlDotShapeTriangle) { - CGContextBeginPath(context); CGContextMoveToPoint(context, 0, -dotSize / 2); CGContextAddLineToPoint(context, dotSize / 2, dotSize / 2); CGContextAddLineToPoint(context, -dotSize / 2, dotSize / 2); CGContextAddLineToPoint(context, 0, -dotSize / 2); - CGContextFillPath(context); } else { - CGContextBeginPath(context); CGContextAddPath(context, dotShape); - CGContextFillPath(context); } - } + + if (dotBorderWidth == 0) + CGContextDrawPath(context, kCGPathFill); + else + CGContextDrawPath(context, kCGPathFillStroke); + } CGContextRestoreGState(context); - } - } + } + } } - (NSInteger)clampedPageValue:(NSInteger)page { - if (_wrapEnabled) + if (_wrapEnabled) { return _numberOfPages? (page + _numberOfPages) % _numberOfPages: 0; } @@ -224,150 +271,193 @@ - (NSInteger)clampedPageValue:(NSInteger)page - (void)setDotImage:(UIImage *)dotImage { - if (_dotImage != dotImage) - { - _dotImage = dotImage; - [self setNeedsDisplay]; - } + if (_dotImage != dotImage) + { + _dotImage = dotImage; + [self setNeedsDisplay]; + } } - (void)setDotShape:(CGPathRef)dotShape { - if (_dotShape != dotShape) - { + if (_dotShape != dotShape) + { if (_dotShape > LAST_SHAPE) CGPathRelease(_dotShape); _dotShape = dotShape; if (_dotShape > LAST_SHAPE) CGPathRetain(_dotShape); - [self setNeedsDisplay]; - } + [self setNeedsDisplay]; + } } - (void)setDotSize:(CGFloat)dotSize { if (ABS(_dotSize - dotSize) > 0.001) - { - _dotSize = dotSize; - [self setNeedsDisplay]; - } + { + _dotSize = dotSize; + [self setNeedsDisplay]; + [self invalidateIntrinsicContentSize]; + } } - (void)setDotColor:(UIColor *)dotColor { - if (_dotColor != dotColor) - { - _dotColor = dotColor; - [self setNeedsDisplay]; - } + if (_dotColor != dotColor) + { + _dotColor = dotColor; + [self setNeedsDisplay]; + } } - (void)setDotShadowColor:(UIColor *)dotColor { - if (_dotShadowColor != dotColor) - { - _dotShadowColor = dotColor; - [self setNeedsDisplay]; - } + if (_dotShadowColor != dotColor) + { + _dotShadowColor = dotColor; + [self setNeedsDisplay]; + } } - (void)setDotShadowBlur:(CGFloat)dotShadowBlur { - if (ABS(_dotShadowBlur - dotShadowBlur) > 0.001) - { - _dotShadowBlur = dotShadowBlur; - [self setNeedsDisplay]; - } + if (ABS(_dotShadowBlur - dotShadowBlur) > 0.001) + { + _dotShadowBlur = dotShadowBlur; + [self setNeedsDisplay]; + [self invalidateIntrinsicContentSize]; + } } - (void)setDotShadowOffset:(CGSize)dotShadowOffset { - if (!CGSizeEqualToSize(_dotShadowOffset, dotShadowOffset)) - { - _dotShadowOffset = dotShadowOffset; - [self setNeedsDisplay]; - } + if (!CGSizeEqualToSize(_dotShadowOffset, dotShadowOffset)) + { + _dotShadowOffset = dotShadowOffset; + [self setNeedsDisplay]; + [self invalidateIntrinsicContentSize]; + } +} + +- (void)setDotBorderWidth:(CGFloat)dotBorderWidth +{ + if (ABS(_dotBorderWidth - dotBorderWidth) > 0.001) + { + _dotBorderWidth = dotBorderWidth; + [self setNeedsDisplay]; + } +} + +- (void)setDotBorderColor:(UIColor *)dotBorderColor +{ + if (_dotBorderColor != dotBorderColor) + { + _dotBorderColor = dotBorderColor; + [self setNeedsDisplay]; + } } - (void)setSelectedDotImage:(UIImage *)dotImage { - if (_selectedDotImage != dotImage) - { - _selectedDotImage = dotImage; - [self setNeedsDisplay]; - } + if (_selectedDotImage != dotImage) + { + _selectedDotImage = dotImage; + [self setNeedsDisplay]; + } } - (void)setSelectedDotColor:(UIColor *)dotColor { - if (_selectedDotColor != dotColor) - { - _selectedDotColor = dotColor; - [self setNeedsDisplay]; - } + if (_selectedDotColor != dotColor) + { + _selectedDotColor = dotColor; + [self setNeedsDisplay]; + } } - (void)setSelectedDotShape:(CGPathRef)dotShape { - if (_selectedDotShape != dotShape) - { + if (_selectedDotShape != dotShape) + { if (_selectedDotShape > LAST_SHAPE) CGPathRelease(_selectedDotShape); _selectedDotShape = dotShape; if (_selectedDotShape > LAST_SHAPE) CGPathRetain(_selectedDotShape); - [self setNeedsDisplay]; - } + [self setNeedsDisplay]; + } } - (void)setSelectedDotSize:(CGFloat)dotSize { if (ABS(_selectedDotSize - dotSize) > 0.001) - { - _selectedDotSize = dotSize; - [self setNeedsDisplay]; - } + { + _selectedDotSize = dotSize; + [self setNeedsDisplay]; + [self invalidateIntrinsicContentSize]; + } } - (void)setSelectedDotShadowColor:(UIColor *)dotColor { - if (_selectedDotShadowColor != dotColor) - { - _selectedDotShadowColor = dotColor; - [self setNeedsDisplay]; - } + if (_selectedDotShadowColor != dotColor) + { + _selectedDotShadowColor = dotColor; + [self setNeedsDisplay]; + } } - (void)setSelectedDotShadowBlur:(CGFloat)dotShadowBlur { if (ABS(_selectedDotShadowBlur - dotShadowBlur) > 0.001) - { - _selectedDotShadowBlur = dotShadowBlur; - [self setNeedsDisplay]; - } + { + _selectedDotShadowBlur = dotShadowBlur; + [self setNeedsDisplay]; + [self invalidateIntrinsicContentSize]; + } } - (void)setSelectedDotShadowOffset:(CGSize)dotShadowOffset { - if (!CGSizeEqualToSize(_selectedDotShadowOffset, dotShadowOffset)) - { - _selectedDotShadowOffset = dotShadowOffset; - [self setNeedsDisplay]; - } + if (!CGSizeEqualToSize(_selectedDotShadowOffset, dotShadowOffset)) + { + _selectedDotShadowOffset = dotShadowOffset; + [self setNeedsDisplay]; + [self invalidateIntrinsicContentSize]; + } +} + +- (void)setSelectedDotBorderWidth:(CGFloat)selectedDotBorderWidth +{ + if (ABS(_selectedDotBorderWidth - selectedDotBorderWidth) > 0.001) + { + _selectedDotBorderWidth = selectedDotBorderWidth; + [self setNeedsDisplay]; + } +} + +- (void)setSelectedDotBorderColor:(UIColor *)dotColor +{ + if (_selectedDotBorderColor != dotColor) + { + _selectedDotBorderColor = dotColor; + [self setNeedsDisplay]; + } } - (void)setDotSpacing:(CGFloat)dotSpacing { if (ABS(_dotSpacing - dotSpacing) > 0.001) - { - _dotSpacing = dotSpacing; - [self setNeedsDisplay]; - } + { + _dotSpacing = dotSpacing; + [self setNeedsDisplay]; + [self invalidateIntrinsicContentSize]; + } } - (void)setDelegate:(id)delegate { - if (_delegate != delegate) - { - _delegate = delegate; - [self setNeedsDisplay]; - } + if (_delegate != delegate) + { + _delegate = delegate; + [self setNeedsDisplay]; + } } - (void)setCurrentPage:(NSInteger)page @@ -378,7 +468,7 @@ - (void)setCurrentPage:(NSInteger)page - (void)setNumberOfPages:(NSInteger)pages { - if (_numberOfPages != pages) + if (_numberOfPages != pages) { _numberOfPages = pages; if (_currentPage >= pages) @@ -386,20 +476,21 @@ - (void)setNumberOfPages:(NSInteger)pages _currentPage = pages - 1; } [self setNeedsDisplay]; + [self invalidateIntrinsicContentSize]; } } - (void)endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event { - CGPoint point = [touch locationInView:self]; + CGPoint point = [touch locationInView:self]; BOOL forward = _vertical? (point.y > self.frame.size.height / 2): (point.x > self.frame.size.width / 2); - _currentPage = [self clampedPageValue:_currentPage + (forward? 1: -1)]; + _currentPage = [self clampedPageValue:_currentPage + (forward? 1: -1)]; if (!_defersCurrentPageDisplay) { [self setNeedsDisplay]; } - [self sendActionsForControlEvents:UIControlEventValueChanged]; - [super endTrackingWithTouch:touch withEvent:event]; + [self sendActionsForControlEvents:UIControlEventValueChanged]; + [super endTrackingWithTouch:touch withEvent:event]; } - (CGSize)sizeThatFits:(__unused CGSize)size @@ -429,4 +520,23 @@ - (CGSize)intrinsicContentSize return [self sizeThatFits:self.bounds.size]; } +#pragma mark - Accessibility + +- (UIAccessibilityTraits)accessibilityTraits +{ + return UIAccessibilityTraitAdjustable; +} + +- (void)accessibilityIncrement +{ + self.currentPage = self.currentPage + 1; + [self sendActionsForControlEvents:UIControlEventValueChanged]; +} + +- (void)accessibilityDecrement +{ + self.currentPage = self.currentPage - 1; + [self sendActionsForControlEvents:UIControlEventValueChanged]; +} + @end From 3cea4d505a2137dd3736ea8a523ec13c015138b0 Mon Sep 17 00:00:00 2001 From: PM Villa Date: Tue, 27 Sep 2022 15:38:11 +0900 Subject: [PATCH 03/14] added platform to SPM --- .gitignore | 3 ++- Package.resolved | 16 ++++++++++++++++ Package.swift | 3 +++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 Package.resolved diff --git a/.gitignore b/.gitignore index ec58845f..51220252 100644 --- a/.gitignore +++ b/.gitignore @@ -51,4 +51,5 @@ playground.xcworkspace Carthage/Build -.swift-version \ No newline at end of file +.swift-version +.swiftpm/xcode diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 00000000..a6dae6f6 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "FXPageControl", + "repositoryURL": "https://github.com/Climbatize/FXPageControl.git", + "state": { + "branch": null, + "revision": "f72e8b271058fe62f943faae6743903419a6c317", + "version": "1.5.1" + } + } + ] + }, + "version": 1 +} diff --git a/Package.swift b/Package.swift index 10c9a1de..b6c70231 100644 --- a/Package.swift +++ b/Package.swift @@ -5,6 +5,9 @@ import PackageDescription let package = Package( name: "XLPagerTabStrip", + platforms: [ + .iOS(.v13) + ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( From e3e76bf4260520bd1fe221ef3720a3a892a1bb13 Mon Sep 17 00:00:00 2001 From: PM Villa Date: Tue, 27 Sep 2022 23:03:10 +0900 Subject: [PATCH 04/14] fix SPM --- Example.xcodeproj/project.pbxproj | 4 ++-- Package.resolved | 4 ++-- Package.swift | 14 +++++--------- .../BarPagerTabStripViewController.swift | 0 Sources/{ => XLPagerTabStrip}/BarView.swift | 1 + .../BaseButtonBarPagerTabStripViewController.swift | 6 ++++++ .../ButtonBarPagerTabStripViewController.swift | 6 ++++++ Sources/{ => XLPagerTabStrip}/ButtonBarView.swift | 0 .../{ => XLPagerTabStrip}/ButtonBarViewCell.swift | 0 Sources/{ => XLPagerTabStrip}/IndicatorInfo.swift | 1 + .../PagerTabStripBehaviour.swift | 0 .../{ => XLPagerTabStrip}/PagerTabStripError.swift | 0 .../PagerTabStripViewController.swift | 1 + .../XLPagerTabStrip/Resources}/ButtonCell.xib | 0 .../SegmentedPagerTabStripViewController.swift | 1 + Sources/{ => XLPagerTabStrip}/SwipeDirection.swift | 0 .../TwitterPagerTabStripViewController.swift | 4 ++++ XLPagerTabStrip.xcodeproj/project.pbxproj | 6 ++++-- 18 files changed, 33 insertions(+), 15 deletions(-) rename Sources/{ => XLPagerTabStrip}/BarPagerTabStripViewController.swift (100%) rename Sources/{ => XLPagerTabStrip}/BarView.swift (99%) rename Sources/{ => XLPagerTabStrip}/BaseButtonBarPagerTabStripViewController.swift (99%) rename Sources/{ => XLPagerTabStrip}/ButtonBarPagerTabStripViewController.swift (99%) rename Sources/{ => XLPagerTabStrip}/ButtonBarView.swift (100%) rename Sources/{ => XLPagerTabStrip}/ButtonBarViewCell.swift (100%) rename Sources/{ => XLPagerTabStrip}/IndicatorInfo.swift (99%) rename Sources/{ => XLPagerTabStrip}/PagerTabStripBehaviour.swift (100%) rename Sources/{ => XLPagerTabStrip}/PagerTabStripError.swift (100%) rename Sources/{ => XLPagerTabStrip}/PagerTabStripViewController.swift (99%) rename {Resources => Sources/XLPagerTabStrip/Resources}/ButtonCell.xib (100%) rename Sources/{ => XLPagerTabStrip}/SegmentedPagerTabStripViewController.swift (99%) rename Sources/{ => XLPagerTabStrip}/SwipeDirection.swift (100%) rename Sources/{ => XLPagerTabStrip}/TwitterPagerTabStripViewController.swift (99%) diff --git a/Example.xcodeproj/project.pbxproj b/Example.xcodeproj/project.pbxproj index c74467a3..480f0582 100644 --- a/Example.xcodeproj/project.pbxproj +++ b/Example.xcodeproj/project.pbxproj @@ -563,7 +563,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; INFOPLIST_FILE = "$(SRCROOT)/Example/Example/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.Example; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -580,7 +580,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; INFOPLIST_FILE = "$(SRCROOT)/Example/Example/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.Example; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Package.resolved b/Package.resolved index a6dae6f6..380cce86 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/Climbatize/FXPageControl.git", "state": { "branch": null, - "revision": "f72e8b271058fe62f943faae6743903419a6c317", - "version": "1.5.1" + "revision": "00327cd11f7aac797a022e87ffacdab31f8eb0a6", + "version": "1.5.3" } } ] diff --git a/Package.swift b/Package.swift index b6c70231..47ac40eb 100644 --- a/Package.swift +++ b/Package.swift @@ -27,15 +27,11 @@ let package = Package( // Targets can depend on other targets in this package, and on products in packages this package depends on. .target( name: "XLPagerTabStrip", - dependencies: ["FXPageControl"], - path: "Sources/", - resources: [ - .process("Resources") - ]), - .testTarget( - name: "XLPagerTabStripTests", - dependencies: ["XLPagerTabStrip"], - path: "Tests/"), + dependencies: ["FXPageControl"]), +// .testTarget( +// name: "XLPagerTabStripTests", +// dependencies: ["XLPagerTabStrip"], +// path: "Tests/"), ], swiftLanguageVersions: [ .v5 diff --git a/Sources/BarPagerTabStripViewController.swift b/Sources/XLPagerTabStrip/BarPagerTabStripViewController.swift similarity index 100% rename from Sources/BarPagerTabStripViewController.swift rename to Sources/XLPagerTabStrip/BarPagerTabStripViewController.swift diff --git a/Sources/BarView.swift b/Sources/XLPagerTabStrip/BarView.swift similarity index 99% rename from Sources/BarView.swift rename to Sources/XLPagerTabStrip/BarView.swift index 1183524d..843b8bc3 100644 --- a/Sources/BarView.swift +++ b/Sources/XLPagerTabStrip/BarView.swift @@ -23,6 +23,7 @@ // THE SOFTWARE. import Foundation +import UIKit open class BarView: UIView { diff --git a/Sources/BaseButtonBarPagerTabStripViewController.swift b/Sources/XLPagerTabStrip/BaseButtonBarPagerTabStripViewController.swift similarity index 99% rename from Sources/BaseButtonBarPagerTabStripViewController.swift rename to Sources/XLPagerTabStrip/BaseButtonBarPagerTabStripViewController.swift index 68684ac4..cbdde5a9 100644 --- a/Sources/BaseButtonBarPagerTabStripViewController.swift +++ b/Sources/XLPagerTabStrip/BaseButtonBarPagerTabStripViewController.swift @@ -23,6 +23,7 @@ // THE SOFTWARE. import Foundation +import UIKit open class BaseButtonBarPagerTabStripViewController: PagerTabStripViewController, PagerTabStripDataSource, PagerTabStripIsProgressiveDelegate, UICollectionViewDelegate, UICollectionViewDataSource { @@ -322,7 +323,12 @@ open class ExampleBaseButtonBarPagerTabStripViewController: BaseButtonBarPagerTa } open func initialize() { + #if SWIFT_PACKAGE + var bundle = Bundle.module + #else var bundle = Bundle(for: ButtonBarViewCell.self) + #endif + if let resourcePath = bundle.path(forResource: "XLPagerTabStrip", ofType: "bundle") { if let resourcesBundle = Bundle(path: resourcePath) { bundle = resourcesBundle diff --git a/Sources/ButtonBarPagerTabStripViewController.swift b/Sources/XLPagerTabStrip/ButtonBarPagerTabStripViewController.swift similarity index 99% rename from Sources/ButtonBarPagerTabStripViewController.swift rename to Sources/XLPagerTabStrip/ButtonBarPagerTabStripViewController.swift index 36e008d6..46464ca9 100644 --- a/Sources/ButtonBarPagerTabStripViewController.swift +++ b/Sources/XLPagerTabStrip/ButtonBarPagerTabStripViewController.swift @@ -23,6 +23,7 @@ // THE SOFTWARE. import Foundation +import UIKit public enum ButtonBarItemSpec { @@ -94,7 +95,12 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa open override func viewDidLoad() { super.viewDidLoad() + #if SWIFT_PACKAGE + var bundle = Bundle.module + #else var bundle = Bundle(for: ButtonBarViewCell.self) + #endif + if let resourcePath = bundle.path(forResource: "XLPagerTabStrip", ofType: "bundle") { if let resourcesBundle = Bundle(path: resourcePath) { bundle = resourcesBundle diff --git a/Sources/ButtonBarView.swift b/Sources/XLPagerTabStrip/ButtonBarView.swift similarity index 100% rename from Sources/ButtonBarView.swift rename to Sources/XLPagerTabStrip/ButtonBarView.swift diff --git a/Sources/ButtonBarViewCell.swift b/Sources/XLPagerTabStrip/ButtonBarViewCell.swift similarity index 100% rename from Sources/ButtonBarViewCell.swift rename to Sources/XLPagerTabStrip/ButtonBarViewCell.swift diff --git a/Sources/IndicatorInfo.swift b/Sources/XLPagerTabStrip/IndicatorInfo.swift similarity index 99% rename from Sources/IndicatorInfo.swift rename to Sources/XLPagerTabStrip/IndicatorInfo.swift index 146eb9a5..e5fff108 100644 --- a/Sources/IndicatorInfo.swift +++ b/Sources/XLPagerTabStrip/IndicatorInfo.swift @@ -23,6 +23,7 @@ // THE SOFTWARE. import Foundation +import UIKit public struct IndicatorInfo { diff --git a/Sources/PagerTabStripBehaviour.swift b/Sources/XLPagerTabStrip/PagerTabStripBehaviour.swift similarity index 100% rename from Sources/PagerTabStripBehaviour.swift rename to Sources/XLPagerTabStrip/PagerTabStripBehaviour.swift diff --git a/Sources/PagerTabStripError.swift b/Sources/XLPagerTabStrip/PagerTabStripError.swift similarity index 100% rename from Sources/PagerTabStripError.swift rename to Sources/XLPagerTabStrip/PagerTabStripError.swift diff --git a/Sources/PagerTabStripViewController.swift b/Sources/XLPagerTabStrip/PagerTabStripViewController.swift similarity index 99% rename from Sources/PagerTabStripViewController.swift rename to Sources/XLPagerTabStrip/PagerTabStripViewController.swift index c51d5e1a..781a3136 100644 --- a/Sources/PagerTabStripViewController.swift +++ b/Sources/XLPagerTabStrip/PagerTabStripViewController.swift @@ -23,6 +23,7 @@ // THE SOFTWARE. import Foundation +import UIKit // MARK: Protocols diff --git a/Resources/ButtonCell.xib b/Sources/XLPagerTabStrip/Resources/ButtonCell.xib similarity index 100% rename from Resources/ButtonCell.xib rename to Sources/XLPagerTabStrip/Resources/ButtonCell.xib diff --git a/Sources/SegmentedPagerTabStripViewController.swift b/Sources/XLPagerTabStrip/SegmentedPagerTabStripViewController.swift similarity index 99% rename from Sources/SegmentedPagerTabStripViewController.swift rename to Sources/XLPagerTabStrip/SegmentedPagerTabStripViewController.swift index cdd3fb14..f476de59 100644 --- a/Sources/SegmentedPagerTabStripViewController.swift +++ b/Sources/XLPagerTabStrip/SegmentedPagerTabStripViewController.swift @@ -23,6 +23,7 @@ // THE SOFTWARE. import Foundation +import UIKit public struct SegmentedPagerTabStripSettings { diff --git a/Sources/SwipeDirection.swift b/Sources/XLPagerTabStrip/SwipeDirection.swift similarity index 100% rename from Sources/SwipeDirection.swift rename to Sources/XLPagerTabStrip/SwipeDirection.swift diff --git a/Sources/TwitterPagerTabStripViewController.swift b/Sources/XLPagerTabStrip/TwitterPagerTabStripViewController.swift similarity index 99% rename from Sources/TwitterPagerTabStripViewController.swift rename to Sources/XLPagerTabStrip/TwitterPagerTabStripViewController.swift index 5caa1a3b..61c3aa3a 100644 --- a/Sources/TwitterPagerTabStripViewController.swift +++ b/Sources/XLPagerTabStrip/TwitterPagerTabStripViewController.swift @@ -23,6 +23,10 @@ // THE SOFTWARE. import Foundation +import UIKit +#if SWIFT_PACKAGE +import FXPageControl +#endif extension UIWindow { static var isLandscape: Bool { diff --git a/XLPagerTabStrip.xcodeproj/project.pbxproj b/XLPagerTabStrip.xcodeproj/project.pbxproj index 9dc9507a..ace7d9c3 100644 --- a/XLPagerTabStrip.xcodeproj/project.pbxproj +++ b/XLPagerTabStrip.xcodeproj/project.pbxproj @@ -156,7 +156,8 @@ 281BFDC01C511C420090C26F /* IndicatorInfo.swift */, 281BFDC21C511F120090C26F /* PagerTabStripBehaviour.swift */, ); - path = Sources; + name = Sources; + path = Sources/XLPagerTabStrip; sourceTree = ""; }; 3174BB0F28E2B81700847CF0 /* ObjC */ = { @@ -173,7 +174,8 @@ children = ( 3174BB1728E2C46A00847CF0 /* ButtonCell.xib */, ); - path = Resources; + name = Resources; + path = Sources/XLPagerTabStrip/Resources; sourceTree = SOURCE_ROOT; }; /* End PBXGroup section */ From e4837f4d933e7b639e68251f90461bb37f2dc330 Mon Sep 17 00:00:00 2001 From: PM Villa Date: Wed, 28 Sep 2022 08:55:19 +0900 Subject: [PATCH 05/14] attempt to fix crash --- Example/Example/Helpers/PostCell.swift | 6 +++--- .../Example/Instagram/InstagramExampleViewController.swift | 2 +- Example/Example/Spotify/SpotifyExampleViewController.swift | 2 +- Example/Example/Youtube/YoutubeIconCell.swift | 2 +- .../Example/YoutubeWithLabel/YoutubeIconWithLabelCell.swift | 4 ++-- Package.resolved | 4 ++-- .../XLPagerTabStrip/BarPagerTabStripViewController.swift | 2 +- .../BaseButtonBarPagerTabStripViewController.swift | 4 ---- .../ButtonBarPagerTabStripViewController.swift | 4 ---- Sources/XLPagerTabStrip/PagerTabStripViewController.swift | 2 +- .../SegmentedPagerTabStripViewController.swift | 2 +- 11 files changed, 13 insertions(+), 21 deletions(-) diff --git a/Example/Example/Helpers/PostCell.swift b/Example/Example/Helpers/PostCell.swift index b9c26721..900c2d05 100644 --- a/Example/Example/Helpers/PostCell.swift +++ b/Example/Example/Helpers/PostCell.swift @@ -26,9 +26,9 @@ import UIKit class PostCell: UITableViewCell { - @IBOutlet weak var userImage: UIImageView! - @IBOutlet weak var postName: UILabel! - @IBOutlet weak var postText: UILabel! + @IBOutlet var userImage: UIImageView! + @IBOutlet var postName: UILabel! + @IBOutlet var postText: UILabel! override func awakeFromNib() { super.awakeFromNib() diff --git a/Example/Example/Instagram/InstagramExampleViewController.swift b/Example/Example/Instagram/InstagramExampleViewController.swift index 392cae15..00f90771 100644 --- a/Example/Example/Instagram/InstagramExampleViewController.swift +++ b/Example/Example/Instagram/InstagramExampleViewController.swift @@ -27,7 +27,7 @@ import XLPagerTabStrip class InstagramExampleViewController: ButtonBarPagerTabStripViewController { - @IBOutlet weak var shadowView: UIView! + @IBOutlet var shadowView: UIView! let blueInstagramColor = UIColor(red: 37/255.0, green: 111/255.0, blue: 206/255.0, alpha: 1.0) override func viewDidLoad() { diff --git a/Example/Example/Spotify/SpotifyExampleViewController.swift b/Example/Example/Spotify/SpotifyExampleViewController.swift index 4fa26a5d..0c398680 100644 --- a/Example/Example/Spotify/SpotifyExampleViewController.swift +++ b/Example/Example/Spotify/SpotifyExampleViewController.swift @@ -27,7 +27,7 @@ import XLPagerTabStrip class SpotifyExampleViewController: ButtonBarPagerTabStripViewController { - @IBOutlet weak var shadowView: UIView! + @IBOutlet var shadowView: UIView! let graySpotifyColor = UIColor(red: 21/255.0, green: 21/255.0, blue: 24/255.0, alpha: 1.0) let darkGraySpotifyColor = UIColor(red: 19/255.0, green: 20/255.0, blue: 20/255.0, alpha: 1.0) diff --git a/Example/Example/Youtube/YoutubeIconCell.swift b/Example/Example/Youtube/YoutubeIconCell.swift index 5716b9dd..6352820b 100644 --- a/Example/Example/Youtube/YoutubeIconCell.swift +++ b/Example/Example/Youtube/YoutubeIconCell.swift @@ -27,6 +27,6 @@ import UIKit class YoutubeIconCell: UICollectionViewCell { - @IBOutlet weak var iconImage: UIImageView! + @IBOutlet var iconImage: UIImageView! } diff --git a/Example/Example/YoutubeWithLabel/YoutubeIconWithLabelCell.swift b/Example/Example/YoutubeWithLabel/YoutubeIconWithLabelCell.swift index 5371924a..c8bd17bf 100644 --- a/Example/Example/YoutubeWithLabel/YoutubeIconWithLabelCell.swift +++ b/Example/Example/YoutubeWithLabel/YoutubeIconWithLabelCell.swift @@ -27,7 +27,7 @@ import UIKit class YoutubeIconWithLabelCell: UICollectionViewCell { - @IBOutlet weak var iconImage: UIImageView! - @IBOutlet weak var iconLabel: UILabel! + @IBOutlet var iconImage: UIImageView! + @IBOutlet var iconLabel: UILabel! } diff --git a/Package.resolved b/Package.resolved index 380cce86..c1b3f061 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/Climbatize/FXPageControl.git", "state": { "branch": null, - "revision": "00327cd11f7aac797a022e87ffacdab31f8eb0a6", - "version": "1.5.3" + "revision": "83486601bcf23c0f168e2cce71b5cc42202fa484", + "version": "1.5.5" } } ] diff --git a/Sources/XLPagerTabStrip/BarPagerTabStripViewController.swift b/Sources/XLPagerTabStrip/BarPagerTabStripViewController.swift index e231268a..4c5df8de 100644 --- a/Sources/XLPagerTabStrip/BarPagerTabStripViewController.swift +++ b/Sources/XLPagerTabStrip/BarPagerTabStripViewController.swift @@ -40,7 +40,7 @@ open class BarPagerTabStripViewController: PagerTabStripViewController, PagerTab public var settings = BarPagerTabStripSettings() - @IBOutlet weak public var barView: BarView! + @IBOutlet public var barView: BarView! required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) diff --git a/Sources/XLPagerTabStrip/BaseButtonBarPagerTabStripViewController.swift b/Sources/XLPagerTabStrip/BaseButtonBarPagerTabStripViewController.swift index cbdde5a9..96641df1 100644 --- a/Sources/XLPagerTabStrip/BaseButtonBarPagerTabStripViewController.swift +++ b/Sources/XLPagerTabStrip/BaseButtonBarPagerTabStripViewController.swift @@ -323,11 +323,7 @@ open class ExampleBaseButtonBarPagerTabStripViewController: BaseButtonBarPagerTa } open func initialize() { - #if SWIFT_PACKAGE - var bundle = Bundle.module - #else var bundle = Bundle(for: ButtonBarViewCell.self) - #endif if let resourcePath = bundle.path(forResource: "XLPagerTabStrip", ofType: "bundle") { if let resourcesBundle = Bundle(path: resourcePath) { diff --git a/Sources/XLPagerTabStrip/ButtonBarPagerTabStripViewController.swift b/Sources/XLPagerTabStrip/ButtonBarPagerTabStripViewController.swift index 46464ca9..eb6fa33c 100644 --- a/Sources/XLPagerTabStrip/ButtonBarPagerTabStripViewController.swift +++ b/Sources/XLPagerTabStrip/ButtonBarPagerTabStripViewController.swift @@ -95,11 +95,7 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa open override func viewDidLoad() { super.viewDidLoad() - #if SWIFT_PACKAGE - var bundle = Bundle.module - #else var bundle = Bundle(for: ButtonBarViewCell.self) - #endif if let resourcePath = bundle.path(forResource: "XLPagerTabStrip", ofType: "bundle") { if let resourcesBundle = Bundle(path: resourcePath) { diff --git a/Sources/XLPagerTabStrip/PagerTabStripViewController.swift b/Sources/XLPagerTabStrip/PagerTabStripViewController.swift index 781a3136..30310404 100644 --- a/Sources/XLPagerTabStrip/PagerTabStripViewController.swift +++ b/Sources/XLPagerTabStrip/PagerTabStripViewController.swift @@ -52,7 +52,7 @@ public protocol PagerTabStripDataSource: AnyObject { open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate { - @IBOutlet weak public var containerView: UIScrollView! + @IBOutlet public var containerView: UIScrollView! open weak var delegate: PagerTabStripDelegate? open weak var datasource: PagerTabStripDataSource? diff --git a/Sources/XLPagerTabStrip/SegmentedPagerTabStripViewController.swift b/Sources/XLPagerTabStrip/SegmentedPagerTabStripViewController.swift index f476de59..6bd29a0a 100644 --- a/Sources/XLPagerTabStrip/SegmentedPagerTabStripViewController.swift +++ b/Sources/XLPagerTabStrip/SegmentedPagerTabStripViewController.swift @@ -36,7 +36,7 @@ public struct SegmentedPagerTabStripSettings { open class SegmentedPagerTabStripViewController: PagerTabStripViewController, PagerTabStripDataSource, PagerTabStripDelegate { - @IBOutlet weak public var segmentedControl: UISegmentedControl! + @IBOutlet public var segmentedControl: UISegmentedControl! open var settings = SegmentedPagerTabStripSettings() From db62b8297cdb626176551b03f8163c6d4cadab0e Mon Sep 17 00:00:00 2001 From: PM Villa Date: Wed, 28 Sep 2022 09:20:45 +0900 Subject: [PATCH 06/14] SPM bundle module --- .../BaseButtonBarPagerTabStripViewController.swift | 4 ++++ .../ButtonBarPagerTabStripViewController.swift | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Sources/XLPagerTabStrip/BaseButtonBarPagerTabStripViewController.swift b/Sources/XLPagerTabStrip/BaseButtonBarPagerTabStripViewController.swift index 96641df1..cbdde5a9 100644 --- a/Sources/XLPagerTabStrip/BaseButtonBarPagerTabStripViewController.swift +++ b/Sources/XLPagerTabStrip/BaseButtonBarPagerTabStripViewController.swift @@ -323,7 +323,11 @@ open class ExampleBaseButtonBarPagerTabStripViewController: BaseButtonBarPagerTa } open func initialize() { + #if SWIFT_PACKAGE + var bundle = Bundle.module + #else var bundle = Bundle(for: ButtonBarViewCell.self) + #endif if let resourcePath = bundle.path(forResource: "XLPagerTabStrip", ofType: "bundle") { if let resourcesBundle = Bundle(path: resourcePath) { diff --git a/Sources/XLPagerTabStrip/ButtonBarPagerTabStripViewController.swift b/Sources/XLPagerTabStrip/ButtonBarPagerTabStripViewController.swift index eb6fa33c..46464ca9 100644 --- a/Sources/XLPagerTabStrip/ButtonBarPagerTabStripViewController.swift +++ b/Sources/XLPagerTabStrip/ButtonBarPagerTabStripViewController.swift @@ -95,7 +95,11 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa open override func viewDidLoad() { super.viewDidLoad() + #if SWIFT_PACKAGE + var bundle = Bundle.module + #else var bundle = Bundle(for: ButtonBarViewCell.self) + #endif if let resourcePath = bundle.path(forResource: "XLPagerTabStrip", ofType: "bundle") { if let resourcesBundle = Bundle(path: resourcePath) { From 6feffe014cc7bbeddb6c1bb380f1b51e0c0e48e0 Mon Sep 17 00:00:00 2001 From: PM Villa Date: Wed, 28 Sep 2022 09:40:41 +0900 Subject: [PATCH 07/14] removed inherit module from target --- Sources/XLPagerTabStrip/Resources/ButtonCell.xib | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Sources/XLPagerTabStrip/Resources/ButtonCell.xib b/Sources/XLPagerTabStrip/Resources/ButtonCell.xib index 7025bc70..d8f15e54 100644 --- a/Sources/XLPagerTabStrip/Resources/ButtonCell.xib +++ b/Sources/XLPagerTabStrip/Resources/ButtonCell.xib @@ -1,17 +1,15 @@ - - - - + + - + - + @@ -19,7 +17,7 @@