From 77a6d5b299ba7acfc0f2067bab2a6bf516cb9a03 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sun, 26 Jul 2015 07:20:17 -0700 Subject: [PATCH] Move Plugboard project into Enigma repo --- Plugboard.xcodeproj/project.pbxproj | 295 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + Plugboard/AppDelegate.swift | 46 +++ .../AppIcon.appiconset/Contents.json | 68 ++++ Plugboard/Base.lproj/LaunchScreen.storyboard | 49 +++ Plugboard/Base.lproj/Main.storyboard | 104 ++++++ Plugboard/Info.plist | 46 +++ Plugboard/PlugboardViewController.swift | 147 +++++++++ 8 files changed, 762 insertions(+) create mode 100644 Plugboard.xcodeproj/project.pbxproj create mode 100644 Plugboard.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 Plugboard/AppDelegate.swift create mode 100644 Plugboard/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Plugboard/Base.lproj/LaunchScreen.storyboard create mode 100644 Plugboard/Base.lproj/Main.storyboard create mode 100644 Plugboard/Info.plist create mode 100644 Plugboard/PlugboardViewController.swift diff --git a/Plugboard.xcodeproj/project.pbxproj b/Plugboard.xcodeproj/project.pbxproj new file mode 100644 index 0000000..95dafd9 --- /dev/null +++ b/Plugboard.xcodeproj/project.pbxproj @@ -0,0 +1,295 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + C0B915001B647D7400313376 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B914FF1B647D7400313376 /* AppDelegate.swift */; }; + C0B915021B647D7400313376 /* PlugboardViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B915011B647D7400313376 /* PlugboardViewController.swift */; }; + C0B915051B647D7400313376 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C0B915031B647D7400313376 /* Main.storyboard */; }; + C0B915071B647D7400313376 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C0B915061B647D7400313376 /* Assets.xcassets */; }; + C0B9150A1B647D7400313376 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C0B915081B647D7400313376 /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + C0B914FC1B647D7400313376 /* Plugboard.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Plugboard.app; sourceTree = BUILT_PRODUCTS_DIR; }; + C0B914FF1B647D7400313376 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + C0B915011B647D7400313376 /* PlugboardViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlugboardViewController.swift; sourceTree = ""; }; + C0B915041B647D7400313376 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + C0B915061B647D7400313376 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + C0B915091B647D7400313376 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + C0B9150B1B647D7400313376 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + C0B914F91B647D7400313376 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + C0B914F31B647D7400313376 = { + isa = PBXGroup; + children = ( + C0B914FE1B647D7400313376 /* Plugboard */, + C0B914FD1B647D7400313376 /* Products */, + ); + sourceTree = ""; + }; + C0B914FD1B647D7400313376 /* Products */ = { + isa = PBXGroup; + children = ( + C0B914FC1B647D7400313376 /* Plugboard.app */, + ); + name = Products; + sourceTree = ""; + }; + C0B914FE1B647D7400313376 /* Plugboard */ = { + isa = PBXGroup; + children = ( + C0B914FF1B647D7400313376 /* AppDelegate.swift */, + C0B915011B647D7400313376 /* PlugboardViewController.swift */, + C0B915031B647D7400313376 /* Main.storyboard */, + C0B915061B647D7400313376 /* Assets.xcassets */, + C0B915081B647D7400313376 /* LaunchScreen.storyboard */, + C0B9150B1B647D7400313376 /* Info.plist */, + ); + path = Plugboard; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + C0B914FB1B647D7400313376 /* Plugboard */ = { + isa = PBXNativeTarget; + buildConfigurationList = C0B9150E1B647D7400313376 /* Build configuration list for PBXNativeTarget "Plugboard" */; + buildPhases = ( + C0B914F81B647D7400313376 /* Sources */, + C0B914F91B647D7400313376 /* Frameworks */, + C0B914FA1B647D7400313376 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Plugboard; + productName = Plugboard; + productReference = C0B914FC1B647D7400313376 /* Plugboard.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + C0B914F41B647D7400313376 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0700; + ORGANIZATIONNAME = "Eryn Wells"; + TargetAttributes = { + C0B914FB1B647D7400313376 = { + CreatedOnToolsVersion = 7.0; + }; + }; + }; + buildConfigurationList = C0B914F71B647D7400313376 /* Build configuration list for PBXProject "Plugboard" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = C0B914F31B647D7400313376; + productRefGroup = C0B914FD1B647D7400313376 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + C0B914FB1B647D7400313376 /* Plugboard */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + C0B914FA1B647D7400313376 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C0B9150A1B647D7400313376 /* LaunchScreen.storyboard in Resources */, + C0B915071B647D7400313376 /* Assets.xcassets in Resources */, + C0B915051B647D7400313376 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + C0B914F81B647D7400313376 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C0B915021B647D7400313376 /* PlugboardViewController.swift in Sources */, + C0B915001B647D7400313376 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + C0B915031B647D7400313376 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + C0B915041B647D7400313376 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + C0B915081B647D7400313376 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + C0B915091B647D7400313376 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + C0B9150C1B647D7400313376 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + 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_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + 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_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + C0B9150D1B647D7400313376 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + 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_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + 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_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + C0B9150F1B647D7400313376 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = Plugboard/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.ficustreesoftware.ios.Plugboard; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + C0B915101B647D7400313376 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = Plugboard/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.ficustreesoftware.ios.Plugboard; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C0B914F71B647D7400313376 /* Build configuration list for PBXProject "Plugboard" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C0B9150C1B647D7400313376 /* Debug */, + C0B9150D1B647D7400313376 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C0B9150E1B647D7400313376 /* Build configuration list for PBXNativeTarget "Plugboard" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C0B9150F1B647D7400313376 /* Debug */, + C0B915101B647D7400313376 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = C0B914F41B647D7400313376 /* Project object */; +} diff --git a/Plugboard.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Plugboard.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..daa7052 --- /dev/null +++ b/Plugboard.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Plugboard/AppDelegate.swift b/Plugboard/AppDelegate.swift new file mode 100644 index 0000000..76e5730 --- /dev/null +++ b/Plugboard/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// Plugboard +// +// Created by Eryn Wells on 7/25/15. +// Copyright © 2015 Eryn Wells. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(application: UIApplication) { + // 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. + } + + func applicationDidEnterBackground(application: UIApplication) { + // 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. + } + + func applicationWillEnterForeground(application: UIApplication) { + // 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. + } + + func applicationDidBecomeActive(application: UIApplication) { + // 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. + } + + func applicationWillTerminate(application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/Plugboard/Assets.xcassets/AppIcon.appiconset/Contents.json b/Plugboard/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..36d2c80 --- /dev/null +++ b/Plugboard/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Plugboard/Base.lproj/LaunchScreen.storyboard b/Plugboard/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..ee9cda0 --- /dev/null +++ b/Plugboard/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plugboard/Base.lproj/Main.storyboard b/Plugboard/Base.lproj/Main.storyboard new file mode 100644 index 0000000..fc203ab --- /dev/null +++ b/Plugboard/Base.lproj/Main.storyboard @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plugboard/Info.plist b/Plugboard/Info.plist new file mode 100644 index 0000000..879c6cf --- /dev/null +++ b/Plugboard/Info.plist @@ -0,0 +1,46 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Plugboard/PlugboardViewController.swift b/Plugboard/PlugboardViewController.swift new file mode 100644 index 0000000..cd5dfb8 --- /dev/null +++ b/Plugboard/PlugboardViewController.swift @@ -0,0 +1,147 @@ +// +// PlugboardViewController.swift +// Plugboard +// +// Created by Eryn Wells on 7/25/15. +// Copyright © 2015 Eryn Wells. All rights reserved. +// + +import UIKit + +class PlugboardViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout { + var alphabet: [Character]? = nil { + didSet { + collectionView?.collectionViewLayout.invalidateLayout() + } + } + + @IBOutlet var panGestureRecognizer: UIPanGestureRecognizer! + private var plugViews: [PlugLineView] = [] + + convenience init(alphabet: [Character]) { + self.init(nibName: nil, bundle: nil) + self.alphabet = alphabet + } + + override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) { + super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) + alphabet = Array("ABCDEFGHIJKLMNOPQRSTUVWXYZ".characters) + } + + required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + alphabet = Array("ABCDEFGHIJKLMNOPQRSTUVWXYZ".characters) + } + + @IBAction func connectPlugsPanGesture(recognizer: UIPanGestureRecognizer) { + switch recognizer.state { + case .Began: + let plugView = PlugLineView(frame: view.bounds) + view.addSubview(plugView) + plugViews.append(plugView) + case .Changed: + break + case .Ended: + break + case .Failed: + break + case .Cancelled: + print("drag cancelled") + case .Possible: + print("drag possible") + } + } + + // MARK: - UICollectionViewDataSource + + override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { + return 1 + } + + override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + if let alphabet = alphabet { + return alphabet.count + } + return 0 + } + + override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { + let cell = collectionView.dequeueReusableCellWithReuseIdentifier(PlugCollectionViewCell.reuseIdentifier, forIndexPath: indexPath) + if let plugCell = cell as? PlugCollectionViewCell, alphabet = alphabet { + plugCell.label.text = String(alphabet[indexPath.row]) + } + return cell + } + + // MARK: - UICollectionViewDelegateFlowLayout + + func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets { + if let size = sizeOfCellInCollectionView(collectionView) { + let lineSpacing = self.collectionView(collectionView, layout: collectionViewLayout, minimumLineSpacingForSectionAtIndex: section) + let verticalInset = CGFloat(collectionView.bounds.height - lineSpacing - size.height * 2) / 2.0 + return UIEdgeInsets(top: verticalInset, left: 0.0, bottom: verticalInset, right: 0.0) + } + return UIEdgeInsets() + } + + func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { + if let size = sizeOfCellInCollectionView(collectionView) { + return size + } + return CGSize() + } + + func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat { + if sizeOfCellInCollectionView(collectionView) != nil { + return 10 + } + return 0 + } + + private func sizeOfCellInCollectionView(collectionView: UICollectionView) -> CGSize? { + if let alphabet = alphabet { + if alphabet.count == 0 { + return nil + } + let columns = CGFloat(ceil(Double(alphabet.count) / 2.0)) + let size = floor(collectionView.bounds.width / columns) + return CGSize(width: size, height: size) + } + return nil + } +} + + +class PlugCollectionViewCell: UICollectionViewCell { + static let reuseIdentifier = "PlugCell" + @IBOutlet weak var label: UILabel! +} + + +class PlugLineView: UIView { + var startPoint: CGPoint? + var endPoint: CGPoint? + + override init(frame: CGRect) { + super.init(frame: frame) + initCommon() + } + + required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + initCommon() + } + + private func initCommon() { + opaque = false + backgroundColor = UIColor.clearColor() + } + + override func drawRect(rect: CGRect) { + if let startPoint = startPoint, endPoint = endPoint { + let path = UIBezierPath() + path.moveToPoint(startPoint) + path.addLineToPoint(endPoint) + } + } +} \ No newline at end of file