From e2b2b9bd331af8c552f8d6764b63a2dac19e4db1 Mon Sep 17 00:00:00 2001 From: Shagun Madhikarmi Date: Fri, 7 Jan 2022 21:35:57 +0000 Subject: [PATCH 1/6] First pass at Swift PM support --- .gitignore | 3 +++ Package.swift | 26 +++++++++++++++++++ README.md | 3 +++ .../BDKCollectionIndexView.h | 0 .../BDKCollectionIndexView.m | 0 .../BDKCollectionIndexViewTests.swift | 11 ++++++++ 6 files changed, 43 insertions(+) create mode 100644 Package.swift create mode 100644 README.md rename BDKCollectionIndexView.h => Sources/BDKCollectionIndexView/BDKCollectionIndexView.h (100%) rename BDKCollectionIndexView.m => Sources/BDKCollectionIndexView/BDKCollectionIndexView.m (100%) create mode 100644 Tests/BDKCollectionIndexViewTests/BDKCollectionIndexViewTests.swift diff --git a/.gitignore b/.gitignore index 31e6fd9..f300d1c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ profile DerivedData .idea/ *.hmap + +# Swift Package Manager +.build \ No newline at end of file diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..ba6d1de --- /dev/null +++ b/Package.swift @@ -0,0 +1,26 @@ +// swift-tools-version:5.5 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "BDKCollectionIndexView", + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "BDKCollectionIndexView", + targets: ["BDKCollectionIndexView"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + 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: "BDKCollectionIndexView", + dependencies: [], + publicHeadersPath: "Sources") + ] +) diff --git a/README.md b/README.md new file mode 100644 index 0000000..1c68c71 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# BDKCollectionIndexView + +A description of this package. diff --git a/BDKCollectionIndexView.h b/Sources/BDKCollectionIndexView/BDKCollectionIndexView.h similarity index 100% rename from BDKCollectionIndexView.h rename to Sources/BDKCollectionIndexView/BDKCollectionIndexView.h diff --git a/BDKCollectionIndexView.m b/Sources/BDKCollectionIndexView/BDKCollectionIndexView.m similarity index 100% rename from BDKCollectionIndexView.m rename to Sources/BDKCollectionIndexView/BDKCollectionIndexView.m diff --git a/Tests/BDKCollectionIndexViewTests/BDKCollectionIndexViewTests.swift b/Tests/BDKCollectionIndexViewTests/BDKCollectionIndexViewTests.swift new file mode 100644 index 0000000..18cbad1 --- /dev/null +++ b/Tests/BDKCollectionIndexViewTests/BDKCollectionIndexViewTests.swift @@ -0,0 +1,11 @@ +import XCTest +@testable import BDKCollectionIndexView + +final class BDKCollectionIndexViewTests: XCTestCase { + func testExample() throws { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct + // results. + XCTAssertEqual(BDKCollectionIndexView().text, "Hello, World!") + } +} From ea44332c3f05ba6d16e6f50fde879d5e8e00a6eb Mon Sep 17 00:00:00 2001 From: Shagun Madhikarmi Date: Fri, 7 Jan 2022 21:43:10 +0000 Subject: [PATCH 2/6] Fix SwiftPM --- Package.swift | 4 ++-- Sources/BDKCollectionIndexView/BDKCollectionIndexView.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Package.swift b/Package.swift index ba6d1de..3c31275 100644 --- a/Package.swift +++ b/Package.swift @@ -5,6 +5,7 @@ import PackageDescription let package = Package( name: "BDKCollectionIndexView", + platforms: [.iOS(.v15)], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( @@ -20,7 +21,6 @@ let package = Package( // Targets can depend on other targets in this package, and on products in packages this package depends on. .target( name: "BDKCollectionIndexView", - dependencies: [], - publicHeadersPath: "Sources") + publicHeadersPath: "Sources/BDKCollectionIndexView") ] ) diff --git a/Sources/BDKCollectionIndexView/BDKCollectionIndexView.h b/Sources/BDKCollectionIndexView/BDKCollectionIndexView.h index ec11b8a..de92006 100644 --- a/Sources/BDKCollectionIndexView/BDKCollectionIndexView.h +++ b/Sources/BDKCollectionIndexView/BDKCollectionIndexView.h @@ -1,5 +1,5 @@ #import - +// @import UIKit; @protocol BDKCollectionIndexViewDelegate; /** From 57eee86913f414769f44be288c4b6dad3d6525b8 Mon Sep 17 00:00:00 2001 From: Shagun Madhikarmi Date: Fri, 7 Jan 2022 21:50:03 +0000 Subject: [PATCH 3/6] Fix Obj-C headers path --- Package.swift | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/Package.swift b/Package.swift index 3c31275..9360513 100644 --- a/Package.swift +++ b/Package.swift @@ -1,26 +1,19 @@ // swift-tools-version:5.5 -// The swift-tools-version declares the minimum version of Swift required to build this package. - import PackageDescription let package = Package( - name: "BDKCollectionIndexView", - platforms: [.iOS(.v15)], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "BDKCollectionIndexView", - targets: ["BDKCollectionIndexView"]), + name: "BDKCollectionIndexView", + platforms: [ + .iOS(.v15) ], - dependencies: [ - // Dependencies declare other packages that this package depends on. - // .package(url: /* package url */, from: "1.0.0"), + products: [ + .library(name: "BDKCollectionIndexView", + targets: ["BDKCollectionIndexView"]) ], - 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. + targets: [ .target( - name: "BDKCollectionIndexView", - publicHeadersPath: "Sources/BDKCollectionIndexView") + name: "BDKCollectionIndexView", + publicHeadersPath: "Sources/BDKCollectionIndexView" + ) ] ) From dce23594501156e8ea1033e58d8b305149350234 Mon Sep 17 00:00:00 2001 From: Shagun Madhikarmi Date: Fri, 7 Jan 2022 21:56:04 +0000 Subject: [PATCH 4/6] Remove demo project in case it interferes with SwiftPM --- .../contents.xcworkspacedata | 2 +- Project/BDKAppDelegate.h | 15 - Project/BDKAppDelegate.m | 55 --- Project/BDKCell.h | 17 - Project/BDKCell.m | 67 ---- .../project.pbxproj | 345 ------------------ .../BDKCollectionIndexView.xccheckout | 41 --- .../AppIcon.appiconset/Contents.json | 88 ----- .../LaunchImage.launchimage/Contents.json | 89 ----- Project/BDKViewController.h | 14 - Project/BDKViewController.m | 132 ------- Project/Info.plist | 43 --- Project/Prefix.pch | 16 - Project/en.lproj/InfoPlist.strings | 2 - Project/main.m | 18 - README.md | 70 +++- readme.markdown | 71 ---- 17 files changed, 70 insertions(+), 1015 deletions(-) rename {Project/BDKCollectionIndexView.xcodeproj/project.xcworkspace => .swiftpm/xcode/package.xcworkspace}/contents.xcworkspacedata (65%) delete mode 100644 Project/BDKAppDelegate.h delete mode 100644 Project/BDKAppDelegate.m delete mode 100644 Project/BDKCell.h delete mode 100644 Project/BDKCell.m delete mode 100644 Project/BDKCollectionIndexView.xcodeproj/project.pbxproj delete mode 100644 Project/BDKCollectionIndexView.xcodeproj/project.xcworkspace/xcshareddata/BDKCollectionIndexView.xccheckout delete mode 100644 Project/BDKCollectionIndexView/Images.xcassets/AppIcon.appiconset/Contents.json delete mode 100644 Project/BDKCollectionIndexView/Images.xcassets/LaunchImage.launchimage/Contents.json delete mode 100644 Project/BDKViewController.h delete mode 100644 Project/BDKViewController.m delete mode 100644 Project/Info.plist delete mode 100644 Project/Prefix.pch delete mode 100644 Project/en.lproj/InfoPlist.strings delete mode 100644 Project/main.m delete mode 100644 readme.markdown diff --git a/Project/BDKCollectionIndexView.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata similarity index 65% rename from Project/BDKCollectionIndexView.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata index 347e8f4..919434a 100644 --- a/Project/BDKCollectionIndexView.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/Project/BDKAppDelegate.h b/Project/BDKAppDelegate.h deleted file mode 100644 index 2545dbc..0000000 --- a/Project/BDKAppDelegate.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// BDKAppDelegate.h -// BDKCollectionIndexView -// -// Created by Ben Kreeger on 10/22/13. -// Copyright (c) 2013 Ben Kreeger. All rights reserved. -// - -#import - -@interface BDKAppDelegate : UIResponder - -@property (strong, nonatomic) UIWindow *window; - -@end diff --git a/Project/BDKAppDelegate.m b/Project/BDKAppDelegate.m deleted file mode 100644 index d49bf51..0000000 --- a/Project/BDKAppDelegate.m +++ /dev/null @@ -1,55 +0,0 @@ -// -// BDKAppDelegate.m -// BDKCollectionIndexView -// -// Created by Ben Kreeger on 10/22/13. -// Copyright (c) 2013 Ben Kreeger. All rights reserved. -// - -#import "BDKAppDelegate.h" - -#import "BDKViewController.h" - -@implementation BDKAppDelegate - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions -{ - self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - // Override point for customization after application launch. - self.window.backgroundColor = [UIColor whiteColor]; - BDKViewController *vc = [BDKViewController new]; - vc.title = @"BDKCollectionIndexView Example"; - UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; - self.window.rootViewController = nav; - [self.window makeKeyAndVisible]; - return YES; -} - -- (void)applicationWillResignActive:(UIApplication *)application -{ - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. -} - -- (void)applicationDidEnterBackground:(UIApplication *)application -{ - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. -} - -- (void)applicationWillEnterForeground:(UIApplication *)application -{ - // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. -} - -- (void)applicationDidBecomeActive:(UIApplication *)application -{ - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. -} - -- (void)applicationWillTerminate:(UIApplication *)application -{ - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. -} - -@end diff --git a/Project/BDKCell.h b/Project/BDKCell.h deleted file mode 100644 index 3f8e977..0000000 --- a/Project/BDKCell.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// BDKCell.h -// BDKCollectionIndexView -// -// Created by Ben Kreeger on 10/22/13. -// Copyright (c) 2013 Ben Kreeger. All rights reserved. -// - -#import - -extern NSString * const BDKCellID; - -@interface BDKCell : UICollectionViewCell - -@property (readonly) UILabel *label; - -@end diff --git a/Project/BDKCell.m b/Project/BDKCell.m deleted file mode 100644 index 7a48d70..0000000 --- a/Project/BDKCell.m +++ /dev/null @@ -1,67 +0,0 @@ -// -// BDKCell.m -// BDKCollectionIndexView -// -// Created by Ben Kreeger on 10/22/13. -// Copyright (c) 2013 Ben Kreeger. All rights reserved. -// - -#import "BDKCell.h" - -NSString * const BDKCellID = @"BDKCell"; - -@interface BDKCell () - -- (void)setup; - -@end - -@implementation BDKCell - -@synthesize label = _label; - -- (instancetype)init { - self = [super init]; - if (!self) return nil; - [self setup]; - return self; -} - -- (instancetype)initWithCoder:(NSCoder *)aDecoder { - self = [super initWithCoder:aDecoder]; - if (!self) return nil; - [self setup]; - return self; -} - -- (instancetype)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; - if (!self) return nil; - [self setup]; - return self; -} - -- (void)setup { - [self.contentView addSubview:self.label]; - self.label.frame = self.contentView.bounds; - self.layer.borderColor = [[UIColor blackColor] CGColor]; - self.layer.borderWidth = 1; -} - -- (void)prepareForReuse { - [super prepareForReuse]; - self.label.text = nil; -} - -#pragma mark - Properties - -- (UILabel *)label { - if (_label) return _label; - _label = [UILabel new]; - _label.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - _label.font = [UIFont boldSystemFontOfSize:64]; - _label.textAlignment = NSTextAlignmentCenter; - return _label; -} - -@end diff --git a/Project/BDKCollectionIndexView.xcodeproj/project.pbxproj b/Project/BDKCollectionIndexView.xcodeproj/project.pbxproj deleted file mode 100644 index 7976d26..0000000 --- a/Project/BDKCollectionIndexView.xcodeproj/project.pbxproj +++ /dev/null @@ -1,345 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 1548B4E31AD826D000B17B7A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1548B4E21AD826D000B17B7A /* Images.xcassets */; }; - C368DD731816BE1C002F428D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C368DD721816BE1C002F428D /* Foundation.framework */; }; - C368DD751816BE1C002F428D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C368DD741816BE1C002F428D /* CoreGraphics.framework */; }; - C368DD771816BE1C002F428D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C368DD761816BE1C002F428D /* UIKit.framework */; }; - C393E05E1816BE5B001D7837 /* BDKAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C393E0571816BE5B001D7837 /* BDKAppDelegate.m */; }; - C393E05F1816BE5B001D7837 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = C393E0591816BE5B001D7837 /* InfoPlist.strings */; }; - C393E0611816BE5B001D7837 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C393E05C1816BE5B001D7837 /* main.m */; }; - C393E0651816BE6C001D7837 /* BDKCollectionIndexView.m in Sources */ = {isa = PBXBuildFile; fileRef = C393E0641816BE6C001D7837 /* BDKCollectionIndexView.m */; }; - C393E06A1816C060001D7837 /* BDKViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C393E0691816C060001D7837 /* BDKViewController.m */; }; - C393E06D1816C33D001D7837 /* BDKCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C393E06C1816C33D001D7837 /* BDKCell.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 1548B4E21AD826D000B17B7A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = BDKCollectionIndexView/Images.xcassets; sourceTree = ""; }; - C368DD6F1816BE1C002F428D /* BDKCollectionIndexView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BDKCollectionIndexView.app; sourceTree = BUILT_PRODUCTS_DIR; }; - C368DD721816BE1C002F428D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - C368DD741816BE1C002F428D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; - C368DD761816BE1C002F428D /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; - C368DD8B1816BE1C002F428D /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; - C393E0561816BE5B001D7837 /* BDKAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDKAppDelegate.h; sourceTree = ""; }; - C393E0571816BE5B001D7837 /* BDKAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BDKAppDelegate.m; sourceTree = ""; }; - C393E05A1816BE5B001D7837 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = InfoPlist.strings; sourceTree = ""; }; - C393E05B1816BE5B001D7837 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - C393E05C1816BE5B001D7837 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - C393E05D1816BE5B001D7837 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; - C393E0631816BE6C001D7837 /* BDKCollectionIndexView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BDKCollectionIndexView.h; path = ../BDKCollectionIndexView.h; sourceTree = ""; }; - C393E0641816BE6C001D7837 /* BDKCollectionIndexView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BDKCollectionIndexView.m; path = ../BDKCollectionIndexView.m; sourceTree = ""; }; - C393E0681816C060001D7837 /* BDKViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDKViewController.h; sourceTree = ""; }; - C393E0691816C060001D7837 /* BDKViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BDKViewController.m; sourceTree = ""; }; - C393E06B1816C33D001D7837 /* BDKCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDKCell.h; sourceTree = ""; }; - C393E06C1816C33D001D7837 /* BDKCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BDKCell.m; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - C368DD6C1816BE1C002F428D /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - C368DD751816BE1C002F428D /* CoreGraphics.framework in Frameworks */, - C368DD771816BE1C002F428D /* UIKit.framework in Frameworks */, - C368DD731816BE1C002F428D /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - C368DD661816BE1C002F428D = { - isa = PBXGroup; - children = ( - C393E0671816BE85001D7837 /* Resources */, - C393E0661816BE7A001D7837 /* Classes */, - C393E0621816BE5F001D7837 /* BDKCollectionIndexView */, - C368DD711816BE1C002F428D /* Frameworks */, - C368DD701816BE1C002F428D /* Products */, - ); - sourceTree = ""; - }; - C368DD701816BE1C002F428D /* Products */ = { - isa = PBXGroup; - children = ( - C368DD6F1816BE1C002F428D /* BDKCollectionIndexView.app */, - ); - name = Products; - sourceTree = ""; - }; - C368DD711816BE1C002F428D /* Frameworks */ = { - isa = PBXGroup; - children = ( - C368DD721816BE1C002F428D /* Foundation.framework */, - C368DD741816BE1C002F428D /* CoreGraphics.framework */, - C368DD761816BE1C002F428D /* UIKit.framework */, - C368DD8B1816BE1C002F428D /* XCTest.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; - C393E0581816BE5B001D7837 /* en.lproj */ = { - isa = PBXGroup; - children = ( - C393E0591816BE5B001D7837 /* InfoPlist.strings */, - ); - path = en.lproj; - sourceTree = ""; - }; - C393E0621816BE5F001D7837 /* BDKCollectionIndexView */ = { - isa = PBXGroup; - children = ( - C393E0631816BE6C001D7837 /* BDKCollectionIndexView.h */, - C393E0641816BE6C001D7837 /* BDKCollectionIndexView.m */, - ); - name = BDKCollectionIndexView; - sourceTree = ""; - }; - C393E0661816BE7A001D7837 /* Classes */ = { - isa = PBXGroup; - children = ( - C393E0561816BE5B001D7837 /* BDKAppDelegate.h */, - C393E0571816BE5B001D7837 /* BDKAppDelegate.m */, - C393E05C1816BE5B001D7837 /* main.m */, - C393E05D1816BE5B001D7837 /* Prefix.pch */, - C393E0681816C060001D7837 /* BDKViewController.h */, - C393E0691816C060001D7837 /* BDKViewController.m */, - C393E06B1816C33D001D7837 /* BDKCell.h */, - C393E06C1816C33D001D7837 /* BDKCell.m */, - ); - name = Classes; - sourceTree = ""; - }; - C393E0671816BE85001D7837 /* Resources */ = { - isa = PBXGroup; - children = ( - 1548B4E21AD826D000B17B7A /* Images.xcassets */, - C393E0581816BE5B001D7837 /* en.lproj */, - C393E05B1816BE5B001D7837 /* Info.plist */, - ); - name = Resources; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - C368DD6E1816BE1C002F428D /* BDKCollectionIndexView */ = { - isa = PBXNativeTarget; - buildConfigurationList = C368DD9B1816BE1C002F428D /* Build configuration list for PBXNativeTarget "BDKCollectionIndexView" */; - buildPhases = ( - C368DD6B1816BE1C002F428D /* Sources */, - C368DD6C1816BE1C002F428D /* Frameworks */, - C368DD6D1816BE1C002F428D /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = BDKCollectionIndexView; - productName = BDKCollectionIndexView; - productReference = C368DD6F1816BE1C002F428D /* BDKCollectionIndexView.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - C368DD671816BE1C002F428D /* Project object */ = { - isa = PBXProject; - attributes = { - CLASSPREFIX = BDK; - LastUpgradeCheck = 0500; - ORGANIZATIONNAME = "Ben Kreeger"; - }; - buildConfigurationList = C368DD6A1816BE1C002F428D /* Build configuration list for PBXProject "BDKCollectionIndexView" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = C368DD661816BE1C002F428D; - productRefGroup = C368DD701816BE1C002F428D /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - C368DD6E1816BE1C002F428D /* BDKCollectionIndexView */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - C368DD6D1816BE1C002F428D /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - C393E05F1816BE5B001D7837 /* InfoPlist.strings in Resources */, - 1548B4E31AD826D000B17B7A /* Images.xcassets in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - C368DD6B1816BE1C002F428D /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - C393E0611816BE5B001D7837 /* main.m in Sources */, - C393E0651816BE6C001D7837 /* BDKCollectionIndexView.m in Sources */, - C393E06A1816C060001D7837 /* BDKViewController.m in Sources */, - C393E05E1816BE5B001D7837 /* BDKAppDelegate.m in Sources */, - C393E06D1816C33D001D7837 /* BDKCell.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - C393E0591816BE5B001D7837 /* InfoPlist.strings */ = { - isa = PBXVariantGroup; - children = ( - C393E05A1816BE5B001D7837 /* en */, - ); - name = InfoPlist.strings; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - C368DD991816BE1C002F428D /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = 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_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = 2; - }; - name = Debug; - }; - C368DD9A1816BE1C002F428D /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = 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_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = 2; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - C368DD9C1816BE1C002F428D /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = Prefix.pch; - INFOPLIST_FILE = "$(SRCROOT)/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 5.0; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - WRAPPER_EXTENSION = app; - }; - name = Debug; - }; - C368DD9D1816BE1C002F428D /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = Prefix.pch; - INFOPLIST_FILE = "$(SRCROOT)/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 5.0; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - WRAPPER_EXTENSION = app; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - C368DD6A1816BE1C002F428D /* Build configuration list for PBXProject "BDKCollectionIndexView" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C368DD991816BE1C002F428D /* Debug */, - C368DD9A1816BE1C002F428D /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - C368DD9B1816BE1C002F428D /* Build configuration list for PBXNativeTarget "BDKCollectionIndexView" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C368DD9C1816BE1C002F428D /* Debug */, - C368DD9D1816BE1C002F428D /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = C368DD671816BE1C002F428D /* Project object */; -} diff --git a/Project/BDKCollectionIndexView.xcodeproj/project.xcworkspace/xcshareddata/BDKCollectionIndexView.xccheckout b/Project/BDKCollectionIndexView.xcodeproj/project.xcworkspace/xcshareddata/BDKCollectionIndexView.xccheckout deleted file mode 100644 index d706259..0000000 --- a/Project/BDKCollectionIndexView.xcodeproj/project.xcworkspace/xcshareddata/BDKCollectionIndexView.xccheckout +++ /dev/null @@ -1,41 +0,0 @@ - - - - - IDESourceControlProjectFavoriteDictionaryKey - - IDESourceControlProjectIdentifier - FEA6B552-653A-48E5-9BFD-062182F2AE26 - IDESourceControlProjectName - BDKCollectionIndexView - IDESourceControlProjectOriginsDictionary - - E6A77159-54A1-4910-A557-8AC6F5B1B734 - ssh://github.com/kreeger/BDKCollectionIndexView.git - - IDESourceControlProjectPath - BDKCollectionIndexView/BDKCollectionIndexView.xcodeproj/project.xcworkspace - IDESourceControlProjectRelativeInstallPathDictionary - - E6A77159-54A1-4910-A557-8AC6F5B1B734 - ../../.. - - IDESourceControlProjectURL - ssh://github.com/kreeger/BDKCollectionIndexView.git - IDESourceControlProjectVersion - 110 - IDESourceControlProjectWCCIdentifier - E6A77159-54A1-4910-A557-8AC6F5B1B734 - IDESourceControlProjectWCConfigurations - - - IDESourceControlRepositoryExtensionIdentifierKey - public.vcs.git - IDESourceControlWCCIdentifierKey - E6A77159-54A1-4910-A557-8AC6F5B1B734 - IDESourceControlWCCName - BDKCollectionIndexView - - - - diff --git a/Project/BDKCollectionIndexView/Images.xcassets/AppIcon.appiconset/Contents.json b/Project/BDKCollectionIndexView/Images.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index da837d9..0000000 --- a/Project/BDKCollectionIndexView/Images.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "images" : [ - { - "idiom" : "iphone", - "scale" : "1x", - "size" : "57x57" - }, - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "57x57" - }, - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "60x60" - }, - { - "idiom" : "ipad", - "scale" : "1x", - "size" : "72x72" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "72x72" - }, - { - "idiom" : "ipad", - "scale" : "1x", - "size" : "76x76" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "76x76" - }, - { - "idiom" : "iphone", - "scale" : "1x", - "size" : "29x29" - }, - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "29x29" - }, - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "40x40" - }, - { - "idiom" : "ipad", - "scale" : "1x", - "size" : "50x50" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "50x50" - }, - { - "idiom" : "ipad", - "scale" : "1x", - "size" : "40x40" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "40x40" - }, - { - "idiom" : "ipad", - "scale" : "1x", - "size" : "29x29" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "29x29" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/Project/BDKCollectionIndexView/Images.xcassets/LaunchImage.launchimage/Contents.json b/Project/BDKCollectionIndexView/Images.xcassets/LaunchImage.launchimage/Contents.json deleted file mode 100644 index f62085c..0000000 --- a/Project/BDKCollectionIndexView/Images.xcassets/LaunchImage.launchimage/Contents.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "images" : [ - { - "idiom" : "iphone", - "scale" : "1x", - "orientation" : "portrait" - }, - { - "idiom" : "iphone", - "scale" : "2x", - "orientation" : "portrait" - }, - { - "orientation" : "portrait", - "idiom" : "iphone", - "subtype" : "retina4", - "scale" : "2x" - }, - { - "orientation" : "portrait", - "idiom" : "iphone", - "minimum-system-version" : "7.0", - "scale" : "2x" - }, - { - "orientation" : "portrait", - "idiom" : "iphone", - "minimum-system-version" : "7.0", - "subtype" : "retina4", - "scale" : "2x" - }, - { - "orientation" : "portrait", - "idiom" : "ipad", - "extent" : "to-status-bar", - "scale" : "1x" - }, - { - "orientation" : "portrait", - "idiom" : "ipad", - "extent" : "to-status-bar", - "scale" : "2x" - }, - { - "orientation" : "landscape", - "idiom" : "ipad", - "extent" : "to-status-bar", - "scale" : "1x" - }, - { - "orientation" : "landscape", - "idiom" : "ipad", - "extent" : "to-status-bar", - "scale" : "2x" - }, - { - "orientation" : "portrait", - "idiom" : "ipad", - "minimum-system-version" : "7.0", - "extent" : "full-screen", - "scale" : "1x" - }, - { - "orientation" : "portrait", - "idiom" : "ipad", - "minimum-system-version" : "7.0", - "extent" : "full-screen", - "scale" : "2x" - }, - { - "orientation" : "landscape", - "idiom" : "ipad", - "minimum-system-version" : "7.0", - "extent" : "full-screen", - "scale" : "1x" - }, - { - "orientation" : "landscape", - "idiom" : "ipad", - "minimum-system-version" : "7.0", - "extent" : "full-screen", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/Project/BDKViewController.h b/Project/BDKViewController.h deleted file mode 100644 index 0952e73..0000000 --- a/Project/BDKViewController.h +++ /dev/null @@ -1,14 +0,0 @@ -// -// BDKViewController.h -// BDKCollectionIndexView -// -// Created by Ben Kreeger on 10/22/13. -// Contributors: Adrian Maurer -// Copyright (c) 2013 Ben Kreeger. All rights reserved. -// - -#import - -@interface BDKViewController : UIViewController - -@end diff --git a/Project/BDKViewController.m b/Project/BDKViewController.m deleted file mode 100644 index f339a75..0000000 --- a/Project/BDKViewController.m +++ /dev/null @@ -1,132 +0,0 @@ -// -// BDKViewController.m -// BDKCollectionIndexView -// -// Created by Ben Kreeger on 10/22/13. -// Contributors: Adrian Maurer -// Copyright (c) 2013 Ben Kreeger. All rights reserved. -// - -#import "BDKViewController.h" - -#import "BDKCollectionIndexView.h" - -#import "BDKCell.h" - -@interface BDKViewController () - -@property (strong, nonatomic) UICollectionView *collectionView; - -@property (strong, nonatomic) UICollectionViewFlowLayout *flowLayout; - -@property (strong, nonatomic) BDKCollectionIndexView *indexView; - -@property (strong, nonatomic) NSArray *sections; - -- (void)indexViewValueChanged:(BDKCollectionIndexView *)sender; - -@end - -@implementation BDKViewController - -#pragma mark - Lifecycle - -- (void)loadView { - self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - self.view.backgroundColor = [UIColor whiteColor]; - [self.view addSubview:self.collectionView]; - [self.view addSubview:self.indexView]; -} - -- (void)viewDidLoad { - [super viewDidLoad]; - - // Create data - NSMutableArray *sections = [NSMutableArray new]; - for (NSInteger count = 0; count <= 30; count++) { - [sections addObject:[NSString stringWithFormat:@"%ld", (long)count]]; - } - - self.sections = sections.copy; - self.indexView.indexTitles = self.sections; -} - -- (void)viewWillLayoutSubviews { - const CGFloat indexWidth = 28.0f; - NSDictionary *views = @{@"iv" : self.indexView}; - - [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.indexView - attribute:NSLayoutAttributeTop - relatedBy:NSLayoutRelationEqual - toItem:self.topLayoutGuide - attribute:NSLayoutAttributeBottom - multiplier:1.0 - constant:0.0]]; - - [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[iv]-0-|" - options:0 - metrics:nil - views:views]]; - - [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[iv(w)]-0-|" - options:0 - metrics:@{@"w" : @(indexWidth)} views:views]]; -} - -#pragma mark - Properties - -- (UICollectionView *)collectionView { - if (_collectionView) return _collectionView; - _collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:self.flowLayout]; - _collectionView.dataSource = self; - _collectionView.backgroundColor = [UIColor whiteColor]; - _collectionView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; - [_collectionView registerClass:[BDKCell class] forCellWithReuseIdentifier:BDKCellID]; - return _collectionView; -} - -- (UICollectionViewFlowLayout *)flowLayout { - if (_flowLayout) return _flowLayout; - _flowLayout = [UICollectionViewFlowLayout new]; - _flowLayout.itemSize = CGSizeMake(320, 320); - return _flowLayout; -} - -- (BDKCollectionIndexView *)indexView { - if (_indexView) return _indexView; - _indexView = [BDKCollectionIndexView indexViewWithFrame:CGRectZero indexTitles:@[]]; - _indexView.translatesAutoresizingMaskIntoConstraints = NO; // auto layout - [_indexView addTarget:self action:@selector(indexViewValueChanged:) forControlEvents:UIControlEventValueChanged]; - return _indexView; -} - -#pragma mark - Actions - -- (void)indexViewValueChanged:(BDKCollectionIndexView *)sender { - NSIndexPath *path = [NSIndexPath indexPathForItem:0 inSection:sender.currentIndex]; - if (![self collectionView:self.collectionView cellForItemAtIndexPath:path]) - return; - - [self.collectionView scrollToItemAtIndexPath:path atScrollPosition:UICollectionViewScrollPositionTop animated:NO]; - CGFloat yOffset = self.collectionView.contentOffset.y; - - self.collectionView.contentOffset = CGPointMake(self.collectionView.contentOffset.x, yOffset); -} - -#pragma mark - UICollectionViewDataSource - -- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { - return [self.sections count]; -} - -- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { - return 1; -} - -- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - BDKCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:BDKCellID forIndexPath:indexPath]; - cell.label.text = self.sections[indexPath.section]; - return cell; -} - -@end diff --git a/Project/Info.plist b/Project/Info.plist deleted file mode 100644 index 59078f8..0000000 --- a/Project/Info.plist +++ /dev/null @@ -1,43 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleDisplayName - BDKCIV - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIcons - - CFBundleIcons~ipad - - CFBundleIdentifier - gr.kree.${PRODUCT_NAME:rfc1034identifier} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1.0 - LSRequiresIPhoneOS - - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - - diff --git a/Project/Prefix.pch b/Project/Prefix.pch deleted file mode 100644 index 743435c..0000000 --- a/Project/Prefix.pch +++ /dev/null @@ -1,16 +0,0 @@ -// -// Prefix header -// -// The contents of this file are implicitly included at the beginning of every source file. -// - -#import - -#ifndef __IPHONE_3_0 -#warning "This project uses features only available in iOS SDK 3.0 and later." -#endif - -#ifdef __OBJC__ - #import - #import -#endif diff --git a/Project/en.lproj/InfoPlist.strings b/Project/en.lproj/InfoPlist.strings deleted file mode 100644 index 477b28f..0000000 --- a/Project/en.lproj/InfoPlist.strings +++ /dev/null @@ -1,2 +0,0 @@ -/* Localized versions of Info.plist keys */ - diff --git a/Project/main.m b/Project/main.m deleted file mode 100644 index db7a576..0000000 --- a/Project/main.m +++ /dev/null @@ -1,18 +0,0 @@ -// -// main.m -// BDKCollectionIndexView -// -// Created by Ben Kreeger on 10/22/13. -// Copyright (c) 2013 Ben Kreeger. All rights reserved. -// - -#import - -#import "BDKAppDelegate.h" - -int main(int argc, char * argv[]) -{ - @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([BDKAppDelegate class])); - } -} diff --git a/README.md b/README.md index 1c68c71..f2e2b83 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,71 @@ # BDKCollectionIndexView -A description of this package. +An index-title-scrubber-bar, for use with a `UICollectionView` or as a replacement for the one provided by a `UITableView`. Gives a collection/table view the index title bar for `-sectionIndexTitles` that a `UITableView` gets for (almost) free. A huge thank you to @Yang from [this Stack Overflow post][so], which saved my bacon here. + +![gif](http://g.recordit.co/9vLag8rpPS.gif) + +## Usage + +To install it via [CocoaPods](http://cocoapods.org), just drop this line in your `Podfile`: + +```ruby +pod 'BDKCollectionIndexView' +``` + +And then run `pod install`, naturally. After that, create an instance of `BDKCollectionIndexView`, and add it as a subview of whatever `view` contains your `tableView` or `collectionView` (but not the `tableView` or `collectionView` itself). Then assign it a `width` value of 28 (or `height`, if you're using it as a horizontal index view). Attach whatever other layout constraints you see fit! + +```swift +override func viewDidLoad() { + super.viewDidLoad() + + let indexWidth = 28 + let frame = CGRect(x: collectionView.frame.size.width - indexWidth, + y: collectionView.frame.size.height, + width: indexWidth, + height: collectionView.frame.size.height) + var indexView = BDKCollectionIndexView(frame: frame, indexTitles: nil) + indexView.autoresizingMask = .FlexibleHeight | .FlexibleLeftMargin + indexView.addTarget(self, action: "indexViewValueChanged:", forControlEvents: .ValueChanged) + view.addSubview(indexView) +} + +func indexViewValueChanged(sender: BDKCollectionIndexView) { + let path = NSIndexPath(forItem: 0, inSection: sender.currentIndex) + collectionView.scrollToItemAtIndexPath(path, atScrollPosition: .Top, animated: false) + // If you're using a collection view, bump the y-offset by a certain number of points + // because it won't otherwise account for any section headers you may have. + collectionView.contentOffset = CGPoint(x: collectionView.contentOffset.x, + y: collectionView.contentOffset.y - 45.0) +} +``` + +Then, when you have the section index titles (rather, the label values that you want to appear on the index bar), assign that array to the index bar instance's `indexTitles` value. + +```swift +self.indexView.indexTitles = self.resultsController.sectionIndexTitles +``` + +You can modify `backgroundColor` and `touchStatusBackgroundColor` property to change the background color of the "touch status view" that appears when the view is touched. Use `tintColor` of `BDKCollectionIndexView` instance to change the color of text labels. + +Again, big thanks to @Yang for [the solution on which this is based][so]. + +## Please... + +If you use this in your project, drop me a line and let me know! I'd love to hear about it. You can hit me up [via email](mailto:benjaminkreeger@gmail.com), on [Twitter](https://twitter.com/kreeger), or [carrier pigeon](http://www.hostmedic.com/wp-content/uploads/2009/09/pigeon_camera2.jpg). + +[so]: http://stackoverflow.com/a/14443540/194869 +[pst]: https://github.com/steipete/PSTCollectionView +[ya]: http://stackoverflow.com/users/45018/yang +[gst]: https://gist.github.com/kreeger/4755877 + +## Contact + +- [Ben Kreeger](https://github.com/kreeger) + +## Contributors + +- [Adrian Maurer](https://github.com/VerticodeLabs) +- [hipwelljo](https://github.com/hipwelljo) +- [Alex Skorulis](https://github.com/skorulis) +- [Rinat Khanov](https://github.com/rinatkhanov) +- [huperniketes](https://github.com/huperniketes) diff --git a/readme.markdown b/readme.markdown deleted file mode 100644 index f2e2b83..0000000 --- a/readme.markdown +++ /dev/null @@ -1,71 +0,0 @@ -# BDKCollectionIndexView - -An index-title-scrubber-bar, for use with a `UICollectionView` or as a replacement for the one provided by a `UITableView`. Gives a collection/table view the index title bar for `-sectionIndexTitles` that a `UITableView` gets for (almost) free. A huge thank you to @Yang from [this Stack Overflow post][so], which saved my bacon here. - -![gif](http://g.recordit.co/9vLag8rpPS.gif) - -## Usage - -To install it via [CocoaPods](http://cocoapods.org), just drop this line in your `Podfile`: - -```ruby -pod 'BDKCollectionIndexView' -``` - -And then run `pod install`, naturally. After that, create an instance of `BDKCollectionIndexView`, and add it as a subview of whatever `view` contains your `tableView` or `collectionView` (but not the `tableView` or `collectionView` itself). Then assign it a `width` value of 28 (or `height`, if you're using it as a horizontal index view). Attach whatever other layout constraints you see fit! - -```swift -override func viewDidLoad() { - super.viewDidLoad() - - let indexWidth = 28 - let frame = CGRect(x: collectionView.frame.size.width - indexWidth, - y: collectionView.frame.size.height, - width: indexWidth, - height: collectionView.frame.size.height) - var indexView = BDKCollectionIndexView(frame: frame, indexTitles: nil) - indexView.autoresizingMask = .FlexibleHeight | .FlexibleLeftMargin - indexView.addTarget(self, action: "indexViewValueChanged:", forControlEvents: .ValueChanged) - view.addSubview(indexView) -} - -func indexViewValueChanged(sender: BDKCollectionIndexView) { - let path = NSIndexPath(forItem: 0, inSection: sender.currentIndex) - collectionView.scrollToItemAtIndexPath(path, atScrollPosition: .Top, animated: false) - // If you're using a collection view, bump the y-offset by a certain number of points - // because it won't otherwise account for any section headers you may have. - collectionView.contentOffset = CGPoint(x: collectionView.contentOffset.x, - y: collectionView.contentOffset.y - 45.0) -} -``` - -Then, when you have the section index titles (rather, the label values that you want to appear on the index bar), assign that array to the index bar instance's `indexTitles` value. - -```swift -self.indexView.indexTitles = self.resultsController.sectionIndexTitles -``` - -You can modify `backgroundColor` and `touchStatusBackgroundColor` property to change the background color of the "touch status view" that appears when the view is touched. Use `tintColor` of `BDKCollectionIndexView` instance to change the color of text labels. - -Again, big thanks to @Yang for [the solution on which this is based][so]. - -## Please... - -If you use this in your project, drop me a line and let me know! I'd love to hear about it. You can hit me up [via email](mailto:benjaminkreeger@gmail.com), on [Twitter](https://twitter.com/kreeger), or [carrier pigeon](http://www.hostmedic.com/wp-content/uploads/2009/09/pigeon_camera2.jpg). - -[so]: http://stackoverflow.com/a/14443540/194869 -[pst]: https://github.com/steipete/PSTCollectionView -[ya]: http://stackoverflow.com/users/45018/yang -[gst]: https://gist.github.com/kreeger/4755877 - -## Contact - -- [Ben Kreeger](https://github.com/kreeger) - -## Contributors - -- [Adrian Maurer](https://github.com/VerticodeLabs) -- [hipwelljo](https://github.com/hipwelljo) -- [Alex Skorulis](https://github.com/skorulis) -- [Rinat Khanov](https://github.com/rinatkhanov) -- [huperniketes](https://github.com/huperniketes) From e1eb5441b7a1ae5c83cafe45e0387d2ee74e1452 Mon Sep 17 00:00:00 2001 From: Shagun Madhikarmi Date: Fri, 7 Jan 2022 21:57:25 +0000 Subject: [PATCH 5/6] Updated path for import of package source files --- Package.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 9360513..9dbcf7e 100644 --- a/Package.swift +++ b/Package.swift @@ -13,7 +13,8 @@ let package = Package( targets: [ .target( name: "BDKCollectionIndexView", - publicHeadersPath: "Sources/BDKCollectionIndexView" + path: "Sources/BDKCollectionIndexView", + publicHeadersPath: "." ) ] ) From 54322011b1c0f00b36ef935d9a8a6d4f45d6993c Mon Sep 17 00:00:00 2001 From: Shagun Madhikarmi Date: Fri, 7 Jan 2022 22:12:01 +0000 Subject: [PATCH 6/6] Restore min iOS version support and update README with Swift PM instructions --- Package.swift | 2 +- README.md | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Package.swift b/Package.swift index 9dbcf7e..2ba5e9a 100644 --- a/Package.swift +++ b/Package.swift @@ -4,7 +4,7 @@ import PackageDescription let package = Package( name: "BDKCollectionIndexView", platforms: [ - .iOS(.v15) + .iOS(.v8) ], products: [ .library(name: "BDKCollectionIndexView", diff --git a/README.md b/README.md index f2e2b83..3501b18 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ An index-title-scrubber-bar, for use with a `UICollectionView` or as a replaceme ![gif](http://g.recordit.co/9vLag8rpPS.gif) -## Usage +## Setup + +### CocoaPods To install it via [CocoaPods](http://cocoapods.org), just drop this line in your `Podfile`: @@ -12,7 +14,22 @@ To install it via [CocoaPods](http://cocoapods.org), just drop this line in your pod 'BDKCollectionIndexView' ``` -And then run `pod install`, naturally. After that, create an instance of `BDKCollectionIndexView`, and add it as a subview of whatever `view` contains your `tableView` or `collectionView` (but not the `tableView` or `collectionView` itself). Then assign it a `width` value of 28 (or `height`, if you're using it as a horizontal index view). Attach whatever other layout constraints you see fit! +And then run `pod install`, naturally. + +### Swift Package Manager + +Alternatively you can integrate directly in Xcode using Swift Package Manager. You can find more info about this dependency manager [here](https://www.swift.org/package-manager/) + + To integrate using Xcode: + + File -> Swift Packages -> Add Package Dependency + + Enter package URL: https://github.com/kreeger/BDKCollectionIndexView + + See [here](https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app) for more info + +## Usage +After that, create an instance of `BDKCollectionIndexView`, and add it as a subview of whatever `view` contains your `tableView` or `collectionView` (but not the `tableView` or `collectionView` itself). Then assign it a `width` value of 28 (or `height`, if you're using it as a horizontal index view). Attach whatever other layout constraints you see fit! ```swift override func viewDidLoad() {