Skip to content

Commit

Permalink
Merge pull request #28 from sgr-ksmt/release/2.0
Browse files Browse the repository at this point in the history
Release/2.0
  • Loading branch information
sgr-ksmt authored Mar 11, 2017
2 parents 106dac0 + b1b4c5b commit 8479d2a
Show file tree
Hide file tree
Showing 19 changed files with 420 additions and 297 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# CHANGELOG
### v2.0
- Realistic animation like Facebook Messenger #24, #26
- Redesign of ProxyDelegate #25, #27
- Prepare Migration Guide
- Create unavailable.swift for migration from 1.x

### v1.1.1
- Fixed crash problem using WKWebView's scrollview. #18

Expand All @@ -7,8 +13,8 @@
- Edge shadow #9
- CHANGELOG.md

### v1.0 #7
Major Update. It is stable version.
### v1.0
Major Update. It is stable version. #7

#### Added
- Blur background effect #3
Expand Down
4 changes: 4 additions & 0 deletions Demo/Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
4D5A351C1DDB21F100ED9D54 /* PullToDismiss.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4D5A351A1DDB21F100ED9D54 /* PullToDismiss.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
4D5A35211DDBFD7200ED9D54 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D5A35201DDBFD7200ED9D54 /* Config.swift */; };
4D9D97C91DF0751400C10C87 /* img.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 4D9D97C81DF0751400C10C87 /* img.jpg */; };
4DB1C4991E6EF167008103D1 /* SampleWebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DB1C4981E6EF167008103D1 /* SampleWebViewController.swift */; };
4DC885401DDDF13200B282FB /* SampleTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DC8853F1DDDF13200B282FB /* SampleTableViewController.swift */; };
4DDE88051DDAA1DC00154B59 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DDE88041DDAA1DC00154B59 /* AppDelegate.swift */; };
4DDE88071DDAA1DC00154B59 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DDE88061DDAA1DC00154B59 /* ViewController.swift */; };
Expand Down Expand Up @@ -46,6 +47,7 @@
4D5A351A1DDB21F100ED9D54 /* PullToDismiss.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PullToDismiss.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4D5A35201DDBFD7200ED9D54 /* Config.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = "<group>"; };
4D9D97C81DF0751400C10C87 /* img.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = img.jpg; sourceTree = "<group>"; };
4DB1C4981E6EF167008103D1 /* SampleWebViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SampleWebViewController.swift; sourceTree = "<group>"; };
4DC8853F1DDDF13200B282FB /* SampleTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SampleTableViewController.swift; sourceTree = "<group>"; };
4DDE88011DDAA1DC00154B59 /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; };
4DDE88041DDAA1DC00154B59 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -103,6 +105,7 @@
4D19BAD51DDDE49A0027383B /* SampleCollectionLayout.swift */,
4D19BAD71DDDE8050027383B /* SampleCustomViewController.swift */,
4D19BAD91DDDE80F0027383B /* SampleCustomViewController.storyboard */,
4DB1C4981E6EF167008103D1 /* SampleWebViewController.swift */,
);
path = Demo;
sourceTree = "<group>";
Expand Down Expand Up @@ -188,6 +191,7 @@
4DE54A291DDD4B4100568F7B /* UIColor+Hex.swift in Sources */,
4DDE88051DDAA1DC00154B59 /* AppDelegate.swift in Sources */,
4D19BAD41DDDE1DD0027383B /* SampleCollectionViewController.swift in Sources */,
4DB1C4991E6EF167008103D1 /* SampleWebViewController.swift in Sources */,
4D19BAD81DDDE8050027383B /* SampleCustomViewController.swift in Sources */,
4D5A35211DDBFD7200ED9D54 /* Config.swift in Sources */,
4DC885401DDDF13200B282FB /* SampleTableViewController.swift in Sources */,
Expand Down
103 changes: 59 additions & 44 deletions Demo/Demo/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions Demo/Demo/SampleCollectionLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class SampleCollectionLayout: UICollectionViewFlowLayout {
minimumLineSpacing = 0
minimumInteritemSpacing = 0
sectionInset = .zero
let side = UIScreen.main.bounds.width / 4
itemSize = CGSize(width: side, height: side)
}

required init?(coder aDecoder: NSCoder) {
Expand Down
8 changes: 7 additions & 1 deletion Demo/Demo/SampleCollectionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SampleCollectionViewController: UICollectionViewController {
navigationController?.navigationBar.setValue(UIBarPosition.topAttached.rawValue, forKey: "barPosition")
pullToDismiss = PullToDismiss(scrollView: collectionView!)
Config.shared.adaptSetting(pullToDismiss: pullToDismiss)
pullToDismiss?.delegateProxy = self
pullToDismiss?.delegate = self
view.backgroundColor = .white
}

Expand All @@ -51,5 +51,11 @@ class SampleCollectionViewController: UICollectionViewController {
alert.addAction(UIAlertAction(title: "ok", style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}

extension SampleCollectionViewController: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let side = UIScreen.main.bounds.width / 6
return CGSize(width: side, height: side)
}
}
2 changes: 1 addition & 1 deletion Demo/Demo/SampleCustomViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SampleCustomViewController: UIViewController {
pullToDismiss = PullToDismiss(scrollView: tableView, viewController: self, navigationBar: coverView)
Config.shared.adaptSetting(pullToDismiss: pullToDismiss)
tableView.dataSource = self
pullToDismiss?.delegateProxy = self
pullToDismiss?.delegate = self
}

@IBAction func close(_: UIButton) {
Expand Down
7 changes: 3 additions & 4 deletions Demo/Demo/SampleTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SampleTableViewController: UITableViewController {
pullToDismiss?.dismissAction = { [weak self] in
self?.dismiss(nil)
}
pullToDismiss?.delegateProxy = self
pullToDismiss?.delegate = self
}

var disissBlock: (() -> Void)?
Expand Down Expand Up @@ -60,7 +60,6 @@ class SampleTableViewController: UITableViewController {
}

override func scrollViewDidScroll(_ scrollView: UIScrollView) {
// print("\(scrollView.contentOffset.y)")
}

print("\(scrollView.contentOffset.y)")
}
}
48 changes: 48 additions & 0 deletions Demo/Demo/SampleWebViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// SampleWebViewController.swift
// Demo
//
// Created by Suguru Kishimoto on 3/7/17.
// Copyright © 2017 Suguru Kishimoto. All rights reserved.
//

import UIKit
import WebKit
import PullToDismiss

class SampleWebViewController: UIViewController {

private lazy var webView: WKWebView = WKWebView(frame: .zero)
private var pullToDismiss: PullToDismiss?

override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(webView)

webView.translatesAutoresizingMaskIntoConstraints = false
let attributes: [NSLayoutAttribute] = [.top, .left, .right, .bottom]
let constraints: [NSLayoutConstraint] = attributes.map { attribute in
NSLayoutConstraint(item: webView, attribute: attribute, relatedBy: .equal, toItem: view, attribute: attribute, multiplier: 1.0, constant: 0.0)
}

view.addConstraints(constraints)

pullToDismiss = PullToDismiss(scrollView: webView.scrollView)
Config.shared.adaptSetting(pullToDismiss: pullToDismiss)
pullToDismiss?.delegate = self
view.backgroundColor = .white

webView.load(URLRequest(url: URL(string: "https://www.google.co.jp")!))
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}

}

extension SampleWebViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
print("!!!!!!!!! \(scrollView.contentOffset)")
}
}
5 changes: 4 additions & 1 deletion Demo/Demo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ViewController: UIViewController, UITextFieldDelegate {
@IBOutlet private weak var demoButton2: UIButton!
@IBOutlet private weak var demoButton3: UIButton!
@IBOutlet private weak var demoButton4: UIButton!
@IBOutlet private weak var demoButton5: UIButton!
@IBOutlet private weak var backgroundSwitch: UISegmentedControl!
@IBOutlet private weak var colorTextField: UITextField!
@IBOutlet private weak var currentColorView: UIView!
Expand All @@ -27,7 +28,7 @@ class ViewController: UIViewController, UITextFieldDelegate {

override func viewDidLoad() {
super.viewDidLoad()
let buttons: [UIButton] = [demoButton1, demoButton2, demoButton3, demoButton4]
let buttons: [UIButton] = [demoButton1, demoButton2, demoButton3, demoButton4, demoButton5]
buttons.forEach {
$0.layer.cornerRadius = $0.frame.height / 2
$0.clipsToBounds = true
Expand Down Expand Up @@ -144,6 +145,8 @@ class ViewController: UIViewController, UITextFieldDelegate {
self?.blurSampleImageView.alpha = 1.0
})
return nav
case demoButton5:
return UINavigationController(rootViewController: SampleWebViewController())
default:
fatalError()
}
Expand Down
73 changes: 73 additions & 0 deletions Documents/PullToDismiss2MigrationGuide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# PullToDismiss 2 Migration Guide

PullToDismiss 2.0 has several breaking changes.

## change delegateProxy to delegate

- Aefore 2.0

```swift
pullToDismiss?.delegateProxy = self
```

- 2.0〜

```swift
pullToDismiss?.delegate = self
```

## Custom class (subclass) is no longer needed
Since PullToDismiss 2.0, all scroll view's delegate is available without creating custom class.

- Before 2.0

```swift
import PullToDismiss

class CustomPullToDismiss: PullToDismiss {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return tableViewDelegate?.tableView?(tableView, heightForRowAt: indexPath) ?? 44.0
}
}

class SampleViewController: UIViewController {
@IBOutlet private weak var tableView: UITableView!
private var pullToDismiss: PullToDismiss?
override func viewDidLoad() {
super.viewDidLoad()
pullToDismiss = CustomPullToDismiss(scrollView: tableView)
pullToDismiss?.delegateProxy = self
}
}

extension SampleViewController: UITableViewDelegate {
// called by CustomPullToDismiss
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return indexPath.section == 0 ? 44.0 : 60.0
}

// ...
}
```

- 2.0〜

```swift
import PullToDismiss

class SampleViewController: UIViewController {
@IBOutlet private weak var tableView: UITableView!
private var pullToDismiss: PullToDismiss?
override func viewDidLoad() {
super.viewDidLoad()
pullToDismiss = PullToDismiss(scrollView: tableView)
pullToDismiss?.delegate = self
}
}

extension SampleViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return indexPath.section == 0 ? 44.0 : 60.0
}
}
```
26 changes: 22 additions & 4 deletions PullToDismiss.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
objects = {

/* Begin PBXBuildFile section */
4D22AC5C1E6E36B20006EDA0 /* DelegateProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D22AC5A1E6E36B20006EDA0 /* DelegateProxy.h */; settings = {ATTRIBUTES = (Public, ); }; };
4D22AC5D1E6E36B20006EDA0 /* DelegateProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D22AC5B1E6E36B20006EDA0 /* DelegateProxy.m */; };
4D2B82BA1E73E835008DD411 /* Unavailable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D2B82B91E73E835008DD411 /* Unavailable.swift */; };
4D2F15C31DF2D570000A5172 /* BackgroundEffect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D2F15C21DF2D570000A5172 /* BackgroundEffect.swift */; };
4D5A35191DDB21DB00ED9D54 /* PullToDismiss.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D5A35181DDB21DB00ED9D54 /* PullToDismiss.swift */; };
4D5A351F1DDBF18B00ED9D54 /* PullToDismiss+Proxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D5A351E1DDBF18B00ED9D54 /* PullToDismiss+Proxy.swift */; };
4D63E6A01E6E38F100FEA3D0 /* ScrollViewDelegateProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D63E69F1E6E38F100FEA3D0 /* ScrollViewDelegateProxy.swift */; };
4D870AAB1DDAA0CD00575A28 /* PullToDismiss.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D870AA11DDAA0CD00575A28 /* PullToDismiss.framework */; };
4D870AB01DDAA0CD00575A28 /* PullToDismissTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D870AAF1DDAA0CD00575A28 /* PullToDismissTests.swift */; };
4D870AB21DDAA0CD00575A28 /* PullToDismiss.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D870AA41DDAA0CD00575A28 /* PullToDismiss.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand All @@ -29,9 +32,12 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
4D22AC5A1E6E36B20006EDA0 /* DelegateProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DelegateProxy.h; sourceTree = "<group>"; };
4D22AC5B1E6E36B20006EDA0 /* DelegateProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DelegateProxy.m; sourceTree = "<group>"; };
4D2B82B91E73E835008DD411 /* Unavailable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Unavailable.swift; sourceTree = "<group>"; };
4D2F15C21DF2D570000A5172 /* BackgroundEffect.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackgroundEffect.swift; sourceTree = "<group>"; };
4D5A35181DDB21DB00ED9D54 /* PullToDismiss.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PullToDismiss.swift; sourceTree = "<group>"; };
4D5A351E1DDBF18B00ED9D54 /* PullToDismiss+Proxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PullToDismiss+Proxy.swift"; sourceTree = "<group>"; };
4D63E69F1E6E38F100FEA3D0 /* ScrollViewDelegateProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScrollViewDelegateProxy.swift; sourceTree = "<group>"; };
4D870AA11DDAA0CD00575A28 /* PullToDismiss.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PullToDismiss.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4D870AA41DDAA0CD00575A28 /* PullToDismiss.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PullToDismiss.h; sourceTree = "<group>"; };
4D870AA51DDAA0CD00575A28 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -67,10 +73,13 @@
children = (
4D5A35181DDB21DB00ED9D54 /* PullToDismiss.swift */,
4D2F15C21DF2D570000A5172 /* BackgroundEffect.swift */,
4D5A351E1DDBF18B00ED9D54 /* PullToDismiss+Proxy.swift */,
4D9D97C41DF058C700C10C87 /* CustomBlurView.swift */,
4DBDB74E1E1F69770068AA1F /* EdgeShadow.swift */,
4DBDB7501E1F6FFA0068AA1F /* UIView+EdgeShadow.swift */,
4D22AC5A1E6E36B20006EDA0 /* DelegateProxy.h */,
4D22AC5B1E6E36B20006EDA0 /* DelegateProxy.m */,
4D63E69F1E6E38F100FEA3D0 /* ScrollViewDelegateProxy.swift */,
4D2B82B91E73E835008DD411 /* Unavailable.swift */,
);
path = Sources;
sourceTree = "<group>";
Expand Down Expand Up @@ -119,6 +128,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
4D22AC5C1E6E36B20006EDA0 /* DelegateProxy.h in Headers */,
4D870AB21DDAA0CD00575A28 /* PullToDismiss.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -176,6 +186,7 @@
4D870AA01DDAA0CD00575A28 = {
CreatedOnToolsVersion = 8.1;
DevelopmentTeam = KW3G83N6K6;
LastSwiftMigration = 0820;
ProvisioningStyle = Automatic;
};
4D870AA91DDAA0CD00575A28 = {
Expand Down Expand Up @@ -242,12 +253,14 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4D2B82BA1E73E835008DD411 /* Unavailable.swift in Sources */,
4DBDB74F1E1F69770068AA1F /* EdgeShadow.swift in Sources */,
4D5A35191DDB21DB00ED9D54 /* PullToDismiss.swift in Sources */,
4D5A351F1DDBF18B00ED9D54 /* PullToDismiss+Proxy.swift in Sources */,
4DBDB7511E1F6FFA0068AA1F /* UIView+EdgeShadow.swift in Sources */,
4D2F15C31DF2D570000A5172 /* BackgroundEffect.swift in Sources */,
4D22AC5D1E6E36B20006EDA0 /* DelegateProxy.m in Sources */,
4D9D97C51DF058C700C10C87 /* CustomBlurView.swift in Sources */,
4D63E6A01E6E38F100FEA3D0 /* ScrollViewDelegateProxy.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -374,6 +387,7 @@
4D870AB61DDAA0CD00575A28 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = KW3G83N6K6;
Expand All @@ -386,13 +400,16 @@
PRODUCT_BUNDLE_IDENTIFIER = "-.PullToDismiss";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0.1;
};
name = Debug;
};
4D870AB71DDAA0CD00575A28 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = KW3G83N6K6;
Expand All @@ -405,6 +422,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "-.PullToDismiss";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_VERSION = 3.0.1;
};
name = Release;
Expand Down
1 change: 1 addition & 0 deletions PullToDismiss/PullToDismiss.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ FOUNDATION_EXPORT double PullToDismissVersionNumber;
FOUNDATION_EXPORT const unsigned char PullToDismissVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <PullToDismiss/PublicHeader.h>
#import "DelegateProxy.h"


Loading

0 comments on commit 8479d2a

Please sign in to comment.