Skip to content

Commit

Permalink
Made a Swift Package out of this Drawer component
Browse files Browse the repository at this point in the history
  • Loading branch information
shadone committed Mar 16, 2020
1 parent 4422281 commit 58ca04e
Show file tree
Hide file tree
Showing 25 changed files with 115 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,41 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 52;
objects = {

/* Begin PBXBuildFile section */
29161AC22359D8C600B2C564 /* DrawerSnapPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29161AC12359D8C600B2C564 /* DrawerSnapPoint.swift */; };
656D4D872416FC220079233B /* DrawerConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 656D4D862416FC220079233B /* DrawerConfiguration.swift */; };
656D4D882417AA360079233B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 920165812355A8FD006D5B51 /* ViewController.swift */; };
656D4D8A2417C5380079233B /* DrawerAnimatedTransitioning.swift in Sources */ = {isa = PBXBuildFile; fileRef = 656D4D892417C5380079233B /* DrawerAnimatedTransitioning.swift */; };
9201657E2355A8FD006D5B51 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9201657D2355A8FD006D5B51 /* AppDelegate.swift */; };
920165852355A8FD006D5B51 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 920165832355A8FD006D5B51 /* Main.storyboard */; };
920165872355A900006D5B51 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 920165862355A900006D5B51 /* Assets.xcassets */; };
9201658A2355A900006D5B51 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 920165882355A900006D5B51 /* LaunchScreen.storyboard */; };
920165932355CC59006D5B51 /* DrawerPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 920165922355CC59006D5B51 /* DrawerPresentationController.swift */; };
920165952355CC6B006D5B51 /* DrawerTransitioningDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 920165942355CC6B006D5B51 /* DrawerTransitioningDelegate.swift */; };
920165972355CC7D006D5B51 /* DrawerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 920165962355CC7D006D5B51 /* DrawerViewController.swift */; };
920165992355F811006D5B51 /* SquareSegmentedControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 920165982355F811006D5B51 /* SquareSegmentedControl.swift */; };
921E2206236C2BED00B1C1FA /* StaticViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 921E2204236C2BED00B1C1FA /* StaticViewController.swift */; };
921E2207236C2BED00B1C1FA /* TableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 921E2205236C2BED00B1C1FA /* TableViewController.swift */; };
9222AE252359B14B00051F06 /* PSPDFTouchForwardingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9222AE242359B14B00051F06 /* PSPDFTouchForwardingView.swift */; };
92CC2BA3241FAB560016E443 /* Drawer in Frameworks */ = {isa = PBXBuildFile; productRef = 92CC2BA2241FAB560016E443 /* Drawer */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
29161AC12359D8C600B2C564 /* DrawerSnapPoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DrawerSnapPoint.swift; sourceTree = "<group>"; };
656D4D862416FC220079233B /* DrawerConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DrawerConfiguration.swift; sourceTree = "<group>"; };
656D4D892417C5380079233B /* DrawerAnimatedTransitioning.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DrawerAnimatedTransitioning.swift; sourceTree = "<group>"; };
9201657A2355A8FD006D5B51 /* DrawerTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DrawerTest.app; sourceTree = BUILT_PRODUCTS_DIR; };
9201657D2355A8FD006D5B51 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
920165812355A8FD006D5B51 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
920165842355A8FD006D5B51 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
920165862355A900006D5B51 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
920165892355A900006D5B51 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
9201658B2355A900006D5B51 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
920165922355CC59006D5B51 /* DrawerPresentationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DrawerPresentationController.swift; sourceTree = "<group>"; };
920165942355CC6B006D5B51 /* DrawerTransitioningDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DrawerTransitioningDelegate.swift; sourceTree = "<group>"; };
920165962355CC7D006D5B51 /* DrawerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DrawerViewController.swift; sourceTree = "<group>"; };
920165982355F811006D5B51 /* SquareSegmentedControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SquareSegmentedControl.swift; sourceTree = "<group>"; };
921E2204236C2BED00B1C1FA /* StaticViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StaticViewController.swift; sourceTree = "<group>"; };
921E2205236C2BED00B1C1FA /* TableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableViewController.swift; sourceTree = "<group>"; };
9222AE242359B14B00051F06 /* PSPDFTouchForwardingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PSPDFTouchForwardingView.swift; sourceTree = "<group>"; };
92FEDEB5241FAA7A00E27822 /* Drawer */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Drawer; path = ..; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
920165772355A8FD006D5B51 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
92CC2BA3241FAB560016E443 /* Drawer in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -60,6 +49,8 @@
children = (
9201657C2355A8FD006D5B51 /* DrawerTest */,
9201657B2355A8FD006D5B51 /* Products */,
92FEDEB5241FAA7A00E27822 /* Drawer */,
92CC2BA1241FAB560016E443 /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -76,7 +67,6 @@
children = (
9201657D2355A8FD006D5B51 /* AppDelegate.swift */,
920165862355A900006D5B51 /* Assets.xcassets */,
920165912355CC4B006D5B51 /* Drawer */,
9201658B2355A900006D5B51 /* Info.plist */,
920165882355A900006D5B51 /* LaunchScreen.storyboard */,
920165832355A8FD006D5B51 /* Main.storyboard */,
Expand All @@ -88,18 +78,11 @@
path = DrawerTest;
sourceTree = "<group>";
};
920165912355CC4B006D5B51 /* Drawer */ = {
92CC2BA1241FAB560016E443 /* Frameworks */ = {
isa = PBXGroup;
children = (
656D4D862416FC220079233B /* DrawerConfiguration.swift */,
920165922355CC59006D5B51 /* DrawerPresentationController.swift */,
29161AC12359D8C600B2C564 /* DrawerSnapPoint.swift */,
920165942355CC6B006D5B51 /* DrawerTransitioningDelegate.swift */,
920165962355CC7D006D5B51 /* DrawerViewController.swift */,
9222AE242359B14B00051F06 /* PSPDFTouchForwardingView.swift */,
656D4D892417C5380079233B /* DrawerAnimatedTransitioning.swift */,
);
path = Drawer;
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
Expand All @@ -118,6 +101,9 @@
dependencies = (
);
name = DrawerTest;
packageProductDependencies = (
92CC2BA2241FAB560016E443 /* Drawer */,
);
productName = DrawerTest;
productReference = 9201657A2355A8FD006D5B51 /* DrawerTest.app */;
productType = "com.apple.product-type.application";
Expand Down Expand Up @@ -173,18 +159,11 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
920165952355CC6B006D5B51 /* DrawerTransitioningDelegate.swift in Sources */,
9201657E2355A8FD006D5B51 /* AppDelegate.swift in Sources */,
921E2207236C2BED00B1C1FA /* TableViewController.swift in Sources */,
656D4D8A2417C5380079233B /* DrawerAnimatedTransitioning.swift in Sources */,
920165932355CC59006D5B51 /* DrawerPresentationController.swift in Sources */,
656D4D882417AA360079233B /* ViewController.swift in Sources */,
921E2206236C2BED00B1C1FA /* StaticViewController.swift in Sources */,
656D4D872416FC220079233B /* DrawerConfiguration.swift in Sources */,
920165992355F811006D5B51 /* SquareSegmentedControl.swift in Sources */,
920165972355CC7D006D5B51 /* DrawerViewController.swift in Sources */,
9222AE252359B14B00051F06 /* PSPDFTouchForwardingView.swift in Sources */,
29161AC22359D8C600B2C564 /* DrawerSnapPoint.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -384,6 +363,13 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCSwiftPackageProductDependency section */
92CC2BA2241FAB560016E443 /* Drawer */ = {
isa = XCSwiftPackageProductDependency;
productName = Drawer;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 920165722355A8FD006D5B51 /* Project object */;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import UIKit
import Drawer

class ViewController: UIViewController {
let stackView: UIStackView = {
Expand Down
29 changes: 29 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Drawer",
platforms: [.iOS("11.0")],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Drawer",
targets: ["Drawer"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
.target(
name: "Drawer",
dependencies: [],
path: "Sources/Drawer"),
.testTarget(
name: "DrawerTests",
dependencies: ["Drawer"],
path: "Tests/DrawerTests"),
]
)
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Drawer

A draggable drawer component similar to the search bar in Apple Maps.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,24 @@

import UIKit

struct DrawerConfiguration {
var snapPoints: [DrawerSnapPoint] = [.middle, .dismiss]
var defaultSnapPoint: DrawerSnapPoint = .middle
public struct DrawerConfiguration {
var snapPoints: [DrawerSnapPoint]
var defaultSnapPoint: DrawerSnapPoint

var drawerWidth: CGFloat?
var animationDuration: TimeInterval = 0.3
var shouldAllowTouchPassthrough: Bool = false
var animationDuration: TimeInterval
var shouldAllowTouchPassthrough: Bool

public init(
snapPoints: [DrawerSnapPoint] = [.middle, .dismiss],
defaultSnapPoint: DrawerSnapPoint = .middle,
drawerWidth: CGFloat? = nil,
animationDuration: TimeInterval = 0.3,
shouldAllowTouchPassthrough: Bool = false) {
self.snapPoints = snapPoints
self.defaultSnapPoint = defaultSnapPoint
self.drawerWidth = drawerWidth
self.animationDuration = animationDuration
self.shouldAllowTouchPassthrough = shouldAllowTouchPassthrough
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import UIKit

enum DrawerSnapPoint: Equatable {
public enum DrawerSnapPoint: Equatable {
case top
case middle
case bottom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import UIKit

protocol DrawerViewControllerDelegate: class {
public protocol DrawerViewControllerDelegate: class {
func drawerViewController(_ viewController: DrawerViewController, didScrollTopTo yPoint: CGFloat)
func drawerViewController(_ viewController: DrawerViewController, didSnapTo point: DrawerSnapPoint)

Expand All @@ -28,7 +28,7 @@ protocol DrawerViewControllerDelegate: class {
func drawerViewControllerDidDismiss(_ viewController: DrawerViewController)
}

class DrawerViewController: UIViewController {
public class DrawerViewController: UIViewController {
let dragIndicatorView: UIView = {
let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
Expand All @@ -37,7 +37,7 @@ class DrawerViewController: UIViewController {
return view
}()

override var modalPresentationStyle: UIModalPresentationStyle {
override public var modalPresentationStyle: UIModalPresentationStyle {
get {.custom }
set { }
}
Expand All @@ -50,12 +50,12 @@ class DrawerViewController: UIViewController {
self.presentationController as? DrawerPresentationController
}

weak var delegate: DrawerViewControllerDelegate?
public weak var delegate: DrawerViewControllerDelegate?

var configuration: DrawerConfiguration = DrawerConfiguration()
public private(set) var configuration: DrawerConfiguration = DrawerConfiguration()

init(viewController: UIViewController? = nil,
configuration: DrawerConfiguration = DrawerConfiguration()) {
public init(viewController: UIViewController? = nil,
configuration: DrawerConfiguration = DrawerConfiguration()) {

self.viewController = viewController
self.configuration = configuration
Expand All @@ -71,7 +71,7 @@ class DrawerViewController: UIViewController {
super.init(coder: coder)
}

override func viewDidLoad() {
override public func viewDidLoad() {
super.viewDidLoad()
setup()
}
Expand Down
14 changes: 14 additions & 0 deletions Tests/DrawerTests/DrawerTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import XCTest
@testable import Drawer

final class DrawerTests: XCTestCase {
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct
// results.
}

static var allTests = [
("testExample", testExample),
]
}
9 changes: 9 additions & 0 deletions Tests/DrawerTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import XCTest

#if !canImport(ObjectiveC)
public func allTests() -> [XCTestCaseEntry] {
return [
testCase(DrawerTests.allTests),
]
}
#endif
7 changes: 7 additions & 0 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import XCTest

import DrawerTests

var tests = [XCTestCaseEntry]()
tests += DrawerTests.allTests()
XCTMain(tests)

0 comments on commit 58ca04e

Please sign in to comment.