-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from sgr-ksmt/release/2.0
Release/2.0
- Loading branch information
Showing
19 changed files
with
420 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.