Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetanzanella committed Dec 5, 2018
2 parents 2f74d8b + 4633314 commit 74003c4
Show file tree
Hide file tree
Showing 18 changed files with 131 additions and 78 deletions.
Binary file added Assets/animations.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/rubberBand.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/scroll.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/scrollToTranslation.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## 1.0.0 (December 2018)
## 1.0.0 (5 December 2018)

First release
16 changes: 8 additions & 8 deletions Example/OverlayContainer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
E71AC95421B04CBE00445A23 /* UIView+Constraints.swift in Sources */ = {isa = PBXBuildFile; fileRef = E71AC95321B04CBE00445A23 /* UIView+Constraints.swift */; };
E71AC95621B04CFE00445A23 /* ShortcutsLikeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E71AC95521B04CFE00445A23 /* ShortcutsLikeViewController.swift */; };
E71AC95821B04D2E00445A23 /* StackViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E71AC95721B04D2E00445A23 /* StackViewController.swift */; };
E71AC95A21B04E3F00445A23 /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E71AC95921B04E3F00445A23 /* DetailViewController.swift */; };
E71AC95C21B04E4B00445A23 /* MasterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E71AC95B21B04E4B00445A23 /* MasterViewController.swift */; };
E71AC95A21B04E3F00445A23 /* SearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E71AC95921B04E3F00445A23 /* SearchViewController.swift */; };
E71AC95C21B04E4B00445A23 /* MapsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E71AC95B21B04E4B00445A23 /* MapsViewController.swift */; };
E71AC95E21B04EC400445A23 /* UIViewController+Children.swift in Sources */ = {isa = PBXBuildFile; fileRef = E71AC95D21B04EC400445A23 /* UIViewController+Children.swift */; };
E733097821B12DF00028009E /* MapsLikeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E733097721B12DF00028009E /* MapsLikeViewController.swift */; };
E733097A21B12E120028009E /* MapsLikeViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E733097921B12E120028009E /* MapsLikeViewController.xib */; };
Expand Down Expand Up @@ -57,8 +57,8 @@
E71AC95321B04CBE00445A23 /* UIView+Constraints.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Constraints.swift"; sourceTree = "<group>"; };
E71AC95521B04CFE00445A23 /* ShortcutsLikeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortcutsLikeViewController.swift; sourceTree = "<group>"; };
E71AC95721B04D2E00445A23 /* StackViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackViewController.swift; sourceTree = "<group>"; };
E71AC95921B04E3F00445A23 /* DetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = "<group>"; };
E71AC95B21B04E4B00445A23 /* MasterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterViewController.swift; sourceTree = "<group>"; };
E71AC95921B04E3F00445A23 /* SearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchViewController.swift; sourceTree = "<group>"; };
E71AC95B21B04E4B00445A23 /* MapsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapsViewController.swift; sourceTree = "<group>"; };
E71AC95D21B04EC400445A23 /* UIViewController+Children.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Children.swift"; sourceTree = "<group>"; };
E733097721B12DF00028009E /* MapsLikeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapsLikeViewController.swift; sourceTree = "<group>"; };
E733097921B12E120028009E /* MapsLikeViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MapsLikeViewController.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -133,8 +133,8 @@
children = (
E71AC95221B04CA600445A23 /* Extension */,
607FACD51AFB9204008FA782 /* AppDelegate.swift */,
E71AC95B21B04E4B00445A23 /* MasterViewController.swift */,
E71AC95921B04E3F00445A23 /* DetailViewController.swift */,
E71AC95B21B04E4B00445A23 /* MapsViewController.swift */,
E71AC95921B04E3F00445A23 /* SearchViewController.swift */,
E7E5C0AC21B168850052AD78 /* DetailHeaderView.swift */,
E7E5C0AE21B1692A0052AD78 /* DetailHeaderView.xib */,
E74AD21F21B5948B00BE644D /* Backdrop View */,
Expand Down Expand Up @@ -415,7 +415,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
E71AC95C21B04E4B00445A23 /* MasterViewController.swift in Sources */,
E71AC95C21B04E4B00445A23 /* MapsViewController.swift in Sources */,
E71AC95621B04CFE00445A23 /* ShortcutsLikeViewController.swift in Sources */,
E71AC95E21B04EC400445A23 /* UIViewController+Children.swift in Sources */,
E7E5C0AD21B168850052AD78 /* DetailHeaderView.swift in Sources */,
Expand All @@ -424,7 +424,7 @@
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */,
E71AC95421B04CBE00445A23 /* UIView+Constraints.swift in Sources */,
E74AD22121B594A400BE644D /* BackdropExampleViewController.swift in Sources */,
E71AC95A21B04E3F00445A23 /* DetailViewController.swift in Sources */,
E71AC95A21B04E3F00445A23 /* SearchViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
12 changes: 6 additions & 6 deletions Example/OverlayContainer/BackdropExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ class BackdropExampleViewController: UIViewController {
}

private let backdropViewController = BackdropViewController()
private let detailViewController = DetailViewController()
private let masterViewController = MasterViewController()
private let searchViewController = SearchViewController()
private let mapsViewController = MapsViewController()

override func viewDidLoad() {
super.viewDidLoad()
let overlayController = OverlayContainerViewController()
overlayController.delegate = self
overlayController.viewControllers = [detailViewController]
overlayController.viewControllers = [searchViewController]
let stackController = StackViewController()
stackController.viewControllers = [
masterViewController,
mapsViewController,
backdropViewController,
overlayController
]
Expand Down Expand Up @@ -84,14 +84,14 @@ extension BackdropExampleViewController: OverlayContainerViewControllerDelegate

func overlayContainerViewController(_ containerViewController: OverlayContainerViewController,
scrollViewDrivingOverlay overlayViewController: UIViewController) -> UIScrollView? {
return (overlayViewController as? DetailViewController)?.tableView
return (overlayViewController as? SearchViewController)?.tableView
}

func overlayContainerViewController(_ containerViewController: OverlayContainerViewController,
shouldStartDraggingOverlay overlayViewController: UIViewController,
at point: CGPoint,
in coordinateSpace: UICoordinateSpace) -> Bool {
guard let header = (overlayViewController as? DetailViewController)?.header else {
guard let header = (overlayViewController as? SearchViewController)?.header else {
return false
}
return header.bounds.contains(coordinateSpace.convert(point, to: header))
Expand Down
8 changes: 4 additions & 4 deletions Example/OverlayContainer/MapsLikeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class MapsLikeViewController: UIViewController {
super.viewDidLoad()
let overlayController = OverlayContainerViewController()
overlayController.delegate = self
overlayController.viewControllers = [DetailViewController()]
overlayController.viewControllers = [SearchViewController()]
addChild(overlayController, in: overlayContainerView)
addChild(MasterViewController(), in: backgroundView)
addChild(MapsViewController(), in: backgroundView)
}

override func viewWillLayoutSubviews() {
Expand Down Expand Up @@ -88,14 +88,14 @@ extension MapsLikeViewController: OverlayContainerViewControllerDelegate {

func overlayContainerViewController(_ containerViewController: OverlayContainerViewController,
scrollViewDrivingOverlay overlayViewController: UIViewController) -> UIScrollView? {
return (overlayViewController as? DetailViewController)?.tableView
return (overlayViewController as? SearchViewController)?.tableView
}

func overlayContainerViewController(_ containerViewController: OverlayContainerViewController,
shouldStartDraggingOverlay overlayViewController: UIViewController,
at point: CGPoint,
in coordinateSpace: UICoordinateSpace) -> Bool {
guard let header = (overlayViewController as? DetailViewController)?.header else {
guard let header = (overlayViewController as? SearchViewController)?.header else {
return false
}
let convertedPoint = coordinateSpace.convert(point, to: header)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// MasterViewController.swift
// MapsViewController.swift
// OverlayContainer_Example
//
// Created by Gaétan Zanella on 29/11/2018.
Expand All @@ -9,7 +9,7 @@
import MapKit
import UIKit

class MasterViewController: UIViewController {
class MapsViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let map = MKMapView()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// DetailViewController.swift
// SearchViewController.swift
// OverlayContainer_Example
//
// Created by Gaétan Zanella on 29/11/2018.
Expand All @@ -8,24 +8,25 @@

import UIKit

class DetailViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
class SearchViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

let header = Bundle.main.loadNibNamed("DetailHeaderView", owner: nil, options: nil)![0] as! UIView
let header = Bundle.main.loadNibNamed("DetailHeaderView", owner: self, options: nil)![0] as! UIView
let tableView = UITableView()

// MARK: - UIViewController

override func loadView() {
view = UIView()
setUpView()
title = "Detail"
title = "Search"
}

// MARK: - UITableViewDataSource

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell") ?? UITableViewCell(style: .default, reuseIdentifier: "cell")
cell.textLabel?.text = "\(indexPath.row)"
cell.textLabel?.text = "Row \(indexPath.row)"
cell.textLabel?.font = UIFont.systemFont(ofSize: 17, weight: .semibold)
return cell
}

Expand Down
20 changes: 10 additions & 10 deletions Example/OverlayContainer/ShortcutsLikeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class ShortcutsLikeViewController: UIViewController {
case minimum, medium, maximum
}

private let detailViewController = DetailViewController()
private let masterViewController = MasterViewController()
private let searchViewController = SearchViewController()
private let mapsViewController = MapsViewController()

private var sizeClass: UIUserInterfaceSizeClass = .unspecified
private var needsSetup = true
Expand Down Expand Up @@ -53,22 +53,22 @@ class ShortcutsLikeViewController: UIViewController {
case .compact:
let overlayController = OverlayContainerViewController()
overlayController.delegate = self
overlayController.viewControllers = [detailViewController]
overlayController.viewControllers = [searchViewController]
let stackController = StackViewController()
stackController.viewControllers = [
masterViewController,
mapsViewController,
overlayController
]
addChild(stackController, in: view)
case .regular:
let splitController = UISplitViewController()
// (gz) 2018-12-03 Both `OverlayContainerViewController` & `StackViewController` disable autorizing mask.
// whereas `UINavigationController` & `UISplitViewController` need it.
detailViewController.view.translatesAutoresizingMaskIntoConstraints = true
masterViewController.view.translatesAutoresizingMaskIntoConstraints = true
searchViewController.view.translatesAutoresizingMaskIntoConstraints = true
mapsViewController.view.translatesAutoresizingMaskIntoConstraints = true
splitController.viewControllers = [
UINavigationController(rootViewController: detailViewController),
masterViewController
UINavigationController(rootViewController: searchViewController),
mapsViewController
]
splitController.preferredDisplayMode = .allVisible
addChild(splitController, in: view)
Expand Down Expand Up @@ -101,14 +101,14 @@ extension ShortcutsLikeViewController: OverlayContainerViewControllerDelegate {

func overlayContainerViewController(_ containerViewController: OverlayContainerViewController,
scrollViewDrivingOverlay overlayViewController: UIViewController) -> UIScrollView? {
return (overlayViewController as? DetailViewController)?.tableView
return (overlayViewController as? SearchViewController)?.tableView
}

func overlayContainerViewController(_ containerViewController: OverlayContainerViewController,
shouldStartDraggingOverlay overlayViewController: UIViewController,
at point: CGPoint,
in coordinateSpace: UICoordinateSpace) -> Bool {
guard let header = (overlayViewController as? DetailViewController)?.header else {
guard let header = (overlayViewController as? SearchViewController)?.header else {
return false
}
return header.bounds.contains(coordinateSpace.convert(point, to: header))
Expand Down
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- OverlayContainer (0.0.1)
- OverlayContainer (1.0.0)

DEPENDENCIES:
- OverlayContainer (from `../`)
Expand All @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
OverlayContainer: 526c12c01273c1fdbbc292a647dabb8830cd35ac
OverlayContainer: 10314f21257c1f4630e025838e3ff0214413f8b2

PODFILE CHECKSUM: efc38d9f3da2bf7f56757ffe850db9ee5c85cbc7

Expand Down
10 changes: 2 additions & 8 deletions OverlayContainer.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,16 @@

Pod::Spec.new do |s|
s.name = 'OverlayContainer'
s.version = '0.0.1'
s.version = '1.0.0'
s.summary = 'OverlayContainer is a UI library which makes it easier to develop overlay based interfaces.'
s.swift_version = "4.2"

# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!

s.description = <<-DESC
OverlayContainer is a UI library written in Swift. It makes it easier to develop overlay based interfaces, such as the one presented in the Apple Maps, Stocks or Shortcuts apps.
The main component of the library is the `OverlayContainerViewController`. It defines an area where a view controller can be dragged up and down, hidding or revealing the content underneath it.
DESC

s.homepage = 'https://github.com/gaetanzanella/OverlayContainer'
s.homepage = 'https://github.com/applidium/ADOverlayContainer'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'gaetanzanella' => 'gaetan.zanella@fabernovel.com' }
s.source = { :git => 'https://github.com/applidium/ADOverlayContainer.git', :tag => s.version.to_s }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ScrollViewOverlayTranslationDriver: OverlayTranslationDriver, OverlayScrol
self.translationController = translationController
self.scrollView = scrollView
scrollViewDelegateProxy.forward(to: self, delegateInvocationsFrom: scrollView)
lastContentOffsetWhileScrolling = scrollView.contentOffset
}

// MARK: - OverlayScrollViewDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

import Foundation

class OverlayContainerView: UIView {}
class OverlayContainerView: PassThroughView {}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

import Foundation

class OverlayTranslationView: UIView {}
class OverlayTranslationView: PassThroughView {}
35 changes: 26 additions & 9 deletions OverlayContainer/Classes/OverlayContainerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,17 @@ public class OverlayContainerViewController: UIViewController {
return viewControllers.last
}

/// The scroll view managing the overlay translation.
public weak var drivingScrollView: UIScrollView? {
didSet {
guard drivingScrollView !== oldValue else { return }
guard isViewLoaded else { return }
loadTranslationDrivers()
}
}

/// The overlay container's style.
public private(set) var style: OverlayStyle
public let style: OverlayStyle

private lazy var overlayPanGesture: OverlayTranslationGestureRecognizer = self.makePanGesture()
private lazy var overlayContainerView = OverlayContainerView()
Expand Down Expand Up @@ -164,36 +173,44 @@ public class OverlayContainerViewController: UIViewController {

private func loadOverlayViews() {
viewControllers.forEach { addChild($0, in: overlayContainerView) }
loadTranslationController()
loadTranslationDrivers()
}

private func loadTranslationDrivers() {
private func loadTranslationController() {
guard let translationHeightConstraint = translationHeightConstraint,
let overlayController = topViewController else {
return
return
}
let controller = HeightContrainstOverlayTranslationController(
translationController = HeightContrainstOverlayTranslationController(
translationHeightConstraint: translationHeightConstraint,
overlayViewController: overlayController,
configuration: configuration
)
controller.delegate = self
translationController?.delegate = self
}

private func loadTranslationDrivers() {
guard let translationController = translationController,
let overlayController = topViewController else {
return
}
var drivers: [OverlayTranslationDriver] = []
let panGestureDriver = PanGestureOverlayTranslationDriver(
translationController: controller,
translationController: translationController,
panGestureRecognizer: overlayPanGesture
)
drivers.append(panGestureDriver)
if let scrollView = configuration.scrollView(drivingOverlay: overlayController) {
let scrollView = drivingScrollView ?? configuration.scrollView(drivingOverlay: overlayController)
if let scrollView = scrollView {
overlayPanGesture.drivingScrollView = scrollView
let driver = ScrollViewOverlayTranslationDriver(
translationController: controller,
translationController: translationController,
scrollView: scrollView
)
drivers.append(driver)
}
translationDrivers = drivers
translationController = controller
}

private func setUpPanGesture() {
Expand Down
Loading

0 comments on commit 74003c4

Please sign in to comment.