Initial commit

This commit is contained in:
Stephen Sowole 2019-02-27 02:42:26 -08:00
commit 13f332d8f9
73 changed files with 4150 additions and 0 deletions

79
.gitignore vendored Normal file
View File

@ -0,0 +1,79 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint
.DS_Store
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
## Playgrounds
timeline.xctimeline
playground.xcworkspace
# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
.build/
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build
# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output
# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode
iOSInjectionProject/

56
CONTRIBUTING.md Executable file
View File

@ -0,0 +1,56 @@
# Contributors Guide
Interested in contributing? Awesome! Before you do though, please read our
[Code of Conduct](https://slackhq.github.io/code-of-conduct). We take it very seriously, and expect that you will as
well.
There are many ways you can contribute! :heart:
### Bug Reports and Fixes :bug:
- If you find a bug, please search for it in the [Issues](https://github.com/slackhq/PanModal/issues), and if it isn't already tracked,
[create a new issue](https://github.com/slackhq/PanModal/issues/new). Fill out the "Bug Report" section of the issue template. Even if an Issue is closed, feel free to comment and add details, it will still
be reviewed.
- Issues that have already been identified as a bug (note: able to reproduce) will be labelled `bug`.
- If you'd like to submit a fix for a bug, [send a Pull Request](#creating_a_pull_request) and mention the Issue number.
- Include tests that isolate the bug and verifies that it was fixed.
### New Features :bulb:
- If you'd like to add new functionality to this project, describe the problem you want to solve in a [new Issue](https://github.com/slackhq/PanModal/issues/new).
- Issues that have been identified as a feature request will be labelled `enhancement`.
- If you'd like to implement the new feature, please wait for feedback from the project
maintainers before spending too much time writing the code. In some cases, `enhancement`s may
not align well with the project objectives at the time.
### Tests :mag:, Documentation :books:, Miscellaneous :sparkles:
- If you'd like to improve the tests, you want to make the documentation clearer, you have an
alternative implementation of something that may have advantages over the way its currently
done, or you have any other change, we would be happy to hear about it!
- If its a trivial change, go ahead and [send a Pull Request](#creating_a_pull_request) with the changes you have in mind.
- If not, [open an Issue](https://github.com/slackhq/PanModal/issues/new) to discuss the idea first.
If you're new to our project and looking for some way to make your first contribution, look for
Issues labelled `good first contribution`.
## Requirements
For your contribution to be accepted:
- [x] You must have signed the [Contributor License Agreement (CLA)](https://cla-assistant.io/PanModal).
- [x] The test suite must be complete and pass.
- [x] The changes must be approved by code review.
- [x] Commits should be atomic and messages must be descriptive. Related issues should be mentioned by Issue number.
If the contribution doesn't meet the above criteria, you may fail our automated checks or a maintainer will discuss it with you. You can continue to improve a Pull Request by adding commits to the branch from which the PR was created.
[Interested in knowing more about about pull requests at Slack?](https://slack.engineering/on-empathy-pull-requests-979e4257d158#.awxtvmb2z)
## Creating a Pull Request
1. :fork_and_knife: Fork the repository on GitHub.
2. :runner: Clone/fetch your fork to your local development machine. It's a good idea to run the tests just
to make sure everything is in order.
3. :herb: Create a new branch and check it out.
4. :crystal_ball: Make your changes and commit them locally. Magic happens here!
5. :arrow_heading_up: Push your new branch to your fork. (e.g. `git push username fix-issue-16`).
6. :inbox_tray: Open a Pull Request on github.com from your new branch on your fork to `master` in this
repository.

48
ISSUE_TEMPLATE.md Executable file
View File

@ -0,0 +1,48 @@
### Description
Describe your issue here.
### What type of issue is this? (place an `x` in one of the `[ ]`)
- [ ] bug
- [ ] enhancement (feature request)
- [ ] question
- [ ] documentation related
- [ ] testing related
- [ ] discussion
### Requirements (place an `x` in each of the `[ ]`)
* [ ] I've read and understood the [Contributing guidelines](https://github.com/slackhq/PanModal/blob/master/CONTRIBUTING.md) and have done my best effort to follow them.
* [ ] I've read and agree to the [Code of Conduct](https://slackhq.github.io/code-of-conduct).
* [ ] I've searched for any related issues and avoided creating a duplicate issue.
---
### Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
#### Reproducible in:
{project_name} version:
{platform_name} version:
OS version(s):
#### Steps to reproduce:
1.
2.
3.
#### Expected result:
What you expected to happen
#### Actual result:
What actually happened
#### Attachments:
Logs, screenshots, screencast, sample project, funny gif, etc.

19
LICENSE Normal file
View File

@ -0,0 +1,19 @@
Copyright © 2018 Tiny Speck, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

16
PULL_REQUEST_TEMPLATE.md Executable file
View File

@ -0,0 +1,16 @@
### Summary
Describe the goal of this PR. Mention any related Issue numbers.
### Requirements (place an `x` in each `[ ]`)
* [ ] I've read and understood the [Contributing Guidelines](https://github.com/tinyspeck/PanModal/blob/master/.github/contributing.md) and have done my best effort to follow them.
* [ ] I've read and agree to the [Code of Conduct](https://slackhq.github.io/code-of-conduct).
> The following point can be removed after setting up CI (such as Travis) with coverage reports (such as Codecov)
* [ ] I've written tests to cover the new code and functionality included in this PR.
> The following point can be removed after setting up a CLA reporting tool such as cla-assistant.io
* [ ] I've read, agree to, and signed the [Contributor License Agreement (CLA)](https://cla-assistant.io/PanModal).

33
PanModal.podspec Normal file
View File

@ -0,0 +1,33 @@
#
# Be sure to run `pod lib lint PanModal.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'PanModal'
s.version = '1.0'
s.summary = 'PanModal is an elegant and highly customizable presentation API for constructing bottom sheet modals on iOS.'
# 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
PanModal is an elegant and highly customizable presentation API for constructing bottom sheet modals on iOS.
DESC
s.homepage = 'https://github.com/slackhq/PanModal'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'slack' => 'opensource@slack.com' }
s.source = { :git => 'https://github.com/slackhq/PanModal.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/slackhq
s.ios.deployment_target = '10.0'
s.source_files = 'PanModal/**/*'
end

View File

@ -0,0 +1,669 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objects = {
/* Begin PBXBuildFile section */
743CABB02225FC9F00634A5A /* UserGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 743CABAF2225FC9F00634A5A /* UserGroupViewController.swift */; };
743CABB22225FD1100634A5A /* UserGroupHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 743CABB12225FD1100634A5A /* UserGroupHeaderView.swift */; };
743CABB42225FE7700634A5A /* UserGroupMemberPresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 743CABB32225FE7700634A5A /* UserGroupMemberPresentable.swift */; };
743CABB62225FEEE00634A5A /* UserGroupHeaderPresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 743CABB52225FEEE00634A5A /* UserGroupHeaderPresentable.swift */; };
743CABB8222600C600634A5A /* UserGroupMemberCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 743CABB7222600C600634A5A /* UserGroupMemberCell.swift */; };
743CABBC22260A0300634A5A /* Lato-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 743CABBA22260A0300634A5A /* Lato-Bold.ttf */; };
743CABBD22260A0300634A5A /* Lato-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 743CABBB22260A0300634A5A /* Lato-Regular.ttf */; };
743CABC72226171500634A5A /* PanModalTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 743CABC62226171500634A5A /* PanModalTests.swift */; };
743CABD322265F2E00634A5A /* ProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 743CABD222265F2E00634A5A /* ProfileViewController.swift */; };
743CB2AA222660D100665A55 /* StackedProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 743CB2A9222660D100665A55 /* StackedProfileViewController.swift */; };
74C072A3220BA6E500124CE1 /* PanModalAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74C072A2220BA6E500124CE1 /* PanModalAnimator.swift */; };
74C072A5220BA76D00124CE1 /* PanModalHeight.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74C072A4220BA76D00124CE1 /* PanModalHeight.swift */; };
74C072A7220BA78800124CE1 /* PanModalPresentable+LayoutHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74C072A6220BA78800124CE1 /* PanModalPresentable+LayoutHelpers.swift */; };
74C072AA220BA82A00124CE1 /* UIViewController+PanModalPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74C072A9220BA82A00124CE1 /* UIViewController+PanModalPresenter.swift */; };
943904EB2226354100859537 /* BasicViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943904EA2226354100859537 /* BasicViewController.swift */; };
943904ED2226366700859537 /* AlertViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943904EC2226366700859537 /* AlertViewController.swift */; };
943904EF2226383700859537 /* NavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943904EE2226383700859537 /* NavigationController.swift */; };
943904F32226484F00859537 /* UserGroupStackedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943904F22226484F00859537 /* UserGroupStackedViewController.swift */; };
94795C9B21F0335D008045A0 /* PanModalPresentationDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94795C9A21F0335D008045A0 /* PanModalPresentationDelegate.swift */; };
94795C9D21F03368008045A0 /* PanContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94795C9C21F03368008045A0 /* PanContainerView.swift */; };
DC13905E216D90D5007A3E64 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DC13905D216D90D5007A3E64 /* Assets.xcassets */; };
DC139061216D93ED007A3E64 /* SampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC139060216D93ED007A3E64 /* SampleViewController.swift */; };
DC139070216D9458007A3E64 /* PanModalPresentationAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC139066216D9458007A3E64 /* PanModalPresentationAnimator.swift */; };
DC139071216D9458007A3E64 /* PanModalPresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC139068216D9458007A3E64 /* PanModalPresentable.swift */; };
DC139072216D9458007A3E64 /* PanModalPresentable+UIViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC139069216D9458007A3E64 /* PanModalPresentable+UIViewController.swift */; };
DC139073216D9458007A3E64 /* PanModalPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC13906A216D9458007A3E64 /* PanModalPresenter.swift */; };
DC139074216D9458007A3E64 /* PanModalPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC13906C216D9458007A3E64 /* PanModalPresentationController.swift */; };
DC139075216D9458007A3E64 /* DimmedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC13906E216D9458007A3E64 /* DimmedView.swift */; };
DCA741AE216D90410021F2F2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCA741AD216D90410021F2F2 /* AppDelegate.swift */; };
DCC0EE7C21917F2500208DBC /* PanModalPresentable+Defaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCC0EE7B21917F2500208DBC /* PanModalPresentable+Defaults.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
743CABC92226171500634A5A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = DCA741A2216D90410021F2F2 /* Project object */;
proxyType = 1;
remoteGlobalIDString = DCA741A9216D90410021F2F2;
remoteInfo = PanModal;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
743CABAF2225FC9F00634A5A /* UserGroupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserGroupViewController.swift; sourceTree = "<group>"; };
743CABB12225FD1100634A5A /* UserGroupHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserGroupHeaderView.swift; sourceTree = "<group>"; };
743CABB32225FE7700634A5A /* UserGroupMemberPresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserGroupMemberPresentable.swift; sourceTree = "<group>"; };
743CABB52225FEEE00634A5A /* UserGroupHeaderPresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserGroupHeaderPresentable.swift; sourceTree = "<group>"; };
743CABB7222600C600634A5A /* UserGroupMemberCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserGroupMemberCell.swift; sourceTree = "<group>"; };
743CABBA22260A0300634A5A /* Lato-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Lato-Bold.ttf"; sourceTree = "<group>"; };
743CABBB22260A0300634A5A /* Lato-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Lato-Regular.ttf"; sourceTree = "<group>"; };
743CABC42226171500634A5A /* PanModalTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PanModalTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
743CABC62226171500634A5A /* PanModalTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PanModalTests.swift; sourceTree = "<group>"; };
743CABC82226171500634A5A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
743CABD222265F2E00634A5A /* ProfileViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileViewController.swift; sourceTree = "<group>"; };
743CB2A9222660D100665A55 /* StackedProfileViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackedProfileViewController.swift; sourceTree = "<group>"; };
74C072A2220BA6E500124CE1 /* PanModalAnimator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PanModalAnimator.swift; sourceTree = "<group>"; };
74C072A4220BA76D00124CE1 /* PanModalHeight.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PanModalHeight.swift; sourceTree = "<group>"; };
74C072A6220BA78800124CE1 /* PanModalPresentable+LayoutHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PanModalPresentable+LayoutHelpers.swift"; sourceTree = "<group>"; };
74C072A9220BA82A00124CE1 /* UIViewController+PanModalPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+PanModalPresenter.swift"; sourceTree = "<group>"; };
943904EA2226354100859537 /* BasicViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BasicViewController.swift; sourceTree = "<group>"; };
943904EC2226366700859537 /* AlertViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertViewController.swift; sourceTree = "<group>"; };
943904EE2226383700859537 /* NavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationController.swift; sourceTree = "<group>"; };
943904F22226484F00859537 /* UserGroupStackedViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserGroupStackedViewController.swift; sourceTree = "<group>"; };
94795C9A21F0335D008045A0 /* PanModalPresentationDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PanModalPresentationDelegate.swift; sourceTree = "<group>"; };
94795C9C21F03368008045A0 /* PanContainerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PanContainerView.swift; sourceTree = "<group>"; };
DC13905D216D90D5007A3E64 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
DC139060216D93ED007A3E64 /* SampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleViewController.swift; sourceTree = "<group>"; };
DC139066216D9458007A3E64 /* PanModalPresentationAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PanModalPresentationAnimator.swift; sourceTree = "<group>"; };
DC139068216D9458007A3E64 /* PanModalPresentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PanModalPresentable.swift; sourceTree = "<group>"; };
DC139069216D9458007A3E64 /* PanModalPresentable+UIViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PanModalPresentable+UIViewController.swift"; sourceTree = "<group>"; };
DC13906A216D9458007A3E64 /* PanModalPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PanModalPresenter.swift; sourceTree = "<group>"; };
DC13906C216D9458007A3E64 /* PanModalPresentationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PanModalPresentationController.swift; sourceTree = "<group>"; };
DC13906E216D9458007A3E64 /* DimmedView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DimmedView.swift; sourceTree = "<group>"; };
DCA741AA216D90410021F2F2 /* PanModal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PanModal.app; sourceTree = BUILT_PRODUCTS_DIR; };
DCA741AD216D90410021F2F2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
DCA741B9216D90420021F2F2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
DCC0EE7B21917F2500208DBC /* PanModalPresentable+Defaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PanModalPresentable+Defaults.swift"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
743CABC12226171500634A5A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
DCA741A7216D90410021F2F2 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
743CABAE2225FC4A00634A5A /* User Groups */ = {
isa = PBXGroup;
children = (
743CABAF2225FC9F00634A5A /* UserGroupViewController.swift */,
743CABBF2226105700634A5A /* Presentables */,
743CABBE2226105200634A5A /* Views */,
);
path = "User Groups";
sourceTree = "<group>";
};
743CABB92226093700634A5A /* Fonts */ = {
isa = PBXGroup;
children = (
743CABBA22260A0300634A5A /* Lato-Bold.ttf */,
743CABBB22260A0300634A5A /* Lato-Regular.ttf */,
);
path = Fonts;
sourceTree = "<group>";
};
743CABBE2226105200634A5A /* Views */ = {
isa = PBXGroup;
children = (
743CABB12225FD1100634A5A /* UserGroupHeaderView.swift */,
743CABB7222600C600634A5A /* UserGroupMemberCell.swift */,
);
path = Views;
sourceTree = "<group>";
};
743CABBF2226105700634A5A /* Presentables */ = {
isa = PBXGroup;
children = (
743CABB52225FEEE00634A5A /* UserGroupHeaderPresentable.swift */,
743CABB32225FE7700634A5A /* UserGroupMemberPresentable.swift */,
);
path = Presentables;
sourceTree = "<group>";
};
743CABC52226171500634A5A /* Tests */ = {
isa = PBXGroup;
children = (
743CABC62226171500634A5A /* PanModalTests.swift */,
743CABC82226171500634A5A /* Info.plist */,
);
path = Tests;
sourceTree = "<group>";
};
743CABD122265F0400634A5A /* User Groups (Navigation Controller) */ = {
isa = PBXGroup;
children = (
943904EE2226383700859537 /* NavigationController.swift */,
743CABD222265F2E00634A5A /* ProfileViewController.swift */,
);
path = "User Groups (Navigation Controller)";
sourceTree = "<group>";
};
743CB2AB222661EA00665A55 /* User Groups (Stacked) */ = {
isa = PBXGroup;
children = (
943904F22226484F00859537 /* UserGroupStackedViewController.swift */,
743CB2A9222660D100665A55 /* StackedProfileViewController.swift */,
);
path = "User Groups (Stacked)";
sourceTree = "<group>";
};
74C072A8220BA80700124CE1 /* Presenter */ = {
isa = PBXGroup;
children = (
DC13906A216D9458007A3E64 /* PanModalPresenter.swift */,
74C072A9220BA82A00124CE1 /* UIViewController+PanModalPresenter.swift */,
);
path = Presenter;
sourceTree = "<group>";
};
DC13905F216D93AB007A3E64 /* Resources */ = {
isa = PBXGroup;
children = (
743CABB92226093700634A5A /* Fonts */,
DC13905D216D90D5007A3E64 /* Assets.xcassets */,
DCA741B9216D90420021F2F2 /* Info.plist */,
);
path = Resources;
sourceTree = "<group>";
};
DC139062216D9431007A3E64 /* PanModal */ = {
isa = PBXGroup;
children = (
DC139065216D9458007A3E64 /* Animator */,
DC13906B216D9458007A3E64 /* Controller */,
DC139063216D9458007A3E64 /* Delegate */,
DC139067216D9458007A3E64 /* Presentable */,
74C072A8220BA80700124CE1 /* Presenter */,
DC13906D216D9458007A3E64 /* View */,
);
path = PanModal;
sourceTree = "<group>";
};
DC139063216D9458007A3E64 /* Delegate */ = {
isa = PBXGroup;
children = (
94795C9A21F0335D008045A0 /* PanModalPresentationDelegate.swift */,
);
path = Delegate;
sourceTree = "<group>";
};
DC139065216D9458007A3E64 /* Animator */ = {
isa = PBXGroup;
children = (
74C072A2220BA6E500124CE1 /* PanModalAnimator.swift */,
DC139066216D9458007A3E64 /* PanModalPresentationAnimator.swift */,
);
path = Animator;
sourceTree = "<group>";
};
DC139067216D9458007A3E64 /* Presentable */ = {
isa = PBXGroup;
children = (
74C072A4220BA76D00124CE1 /* PanModalHeight.swift */,
DC139068216D9458007A3E64 /* PanModalPresentable.swift */,
DCC0EE7B21917F2500208DBC /* PanModalPresentable+Defaults.swift */,
DC139069216D9458007A3E64 /* PanModalPresentable+UIViewController.swift */,
74C072A6220BA78800124CE1 /* PanModalPresentable+LayoutHelpers.swift */,
);
path = Presentable;
sourceTree = "<group>";
};
DC13906B216D9458007A3E64 /* Controller */ = {
isa = PBXGroup;
children = (
DC13906C216D9458007A3E64 /* PanModalPresentationController.swift */,
);
path = Controller;
sourceTree = "<group>";
};
DC13906D216D9458007A3E64 /* View */ = {
isa = PBXGroup;
children = (
DC13906E216D9458007A3E64 /* DimmedView.swift */,
94795C9C21F03368008045A0 /* PanContainerView.swift */,
);
path = View;
sourceTree = "<group>";
};
DC139079216D9AAA007A3E64 /* View Controllers */ = {
isa = PBXGroup;
children = (
943904EC2226366700859537 /* AlertViewController.swift */,
943904EA2226354100859537 /* BasicViewController.swift */,
743CB2AB222661EA00665A55 /* User Groups (Stacked) */,
743CABD122265F0400634A5A /* User Groups (Navigation Controller) */,
743CABAE2225FC4A00634A5A /* User Groups */,
);
path = "View Controllers";
sourceTree = "<group>";
};
DCA741A1216D90410021F2F2 = {
isa = PBXGroup;
children = (
DCA741AC216D90410021F2F2 /* Sample */,
DC139062216D9431007A3E64 /* PanModal */,
743CABC52226171500634A5A /* Tests */,
DCA741AB216D90410021F2F2 /* Products */,
);
sourceTree = "<group>";
};
DCA741AB216D90410021F2F2 /* Products */ = {
isa = PBXGroup;
children = (
DCA741AA216D90410021F2F2 /* PanModal.app */,
743CABC42226171500634A5A /* PanModalTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
DCA741AC216D90410021F2F2 /* Sample */ = {
isa = PBXGroup;
children = (
DCA741AD216D90410021F2F2 /* AppDelegate.swift */,
DC139060216D93ED007A3E64 /* SampleViewController.swift */,
DC139079216D9AAA007A3E64 /* View Controllers */,
DC13905F216D93AB007A3E64 /* Resources */,
);
path = Sample;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
743CABC32226171500634A5A /* PanModalTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 743CABCB2226171500634A5A /* Build configuration list for PBXNativeTarget "PanModalTests" */;
buildPhases = (
743CABC02226171500634A5A /* Sources */,
743CABC12226171500634A5A /* Frameworks */,
743CABC22226171500634A5A /* Resources */,
);
buildRules = (
);
dependencies = (
743CABCA2226171500634A5A /* PBXTargetDependency */,
);
name = PanModalTests;
productName = PanModalTests;
productReference = 743CABC42226171500634A5A /* PanModalTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
DCA741A9216D90410021F2F2 /* PanModal */ = {
isa = PBXNativeTarget;
buildConfigurationList = DCA741BC216D90420021F2F2 /* Build configuration list for PBXNativeTarget "PanModal" */;
buildPhases = (
DCA741A6216D90410021F2F2 /* Sources */,
DCA741A7216D90410021F2F2 /* Frameworks */,
DCA741A8216D90410021F2F2 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = PanModal;
productName = PanModal;
productReference = DCA741AA216D90410021F2F2 /* PanModal.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
DCA741A2216D90410021F2F2 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1010;
LastUpgradeCheck = 1000;
ORGANIZATIONNAME = Detail;
TargetAttributes = {
743CABC32226171500634A5A = {
CreatedOnToolsVersion = 10.1;
TestTargetID = DCA741A9216D90410021F2F2;
};
DCA741A9216D90410021F2F2 = {
CreatedOnToolsVersion = 10.0;
};
};
};
buildConfigurationList = DCA741A5216D90410021F2F2 /* Build configuration list for PBXProject "PanModal" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = DCA741A1216D90410021F2F2;
productRefGroup = DCA741AB216D90410021F2F2 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
DCA741A9216D90410021F2F2 /* PanModal */,
743CABC32226171500634A5A /* PanModalTests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
743CABC22226171500634A5A /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
DCA741A8216D90410021F2F2 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DC13905E216D90D5007A3E64 /* Assets.xcassets in Resources */,
743CABBD22260A0300634A5A /* Lato-Regular.ttf in Resources */,
743CABBC22260A0300634A5A /* Lato-Bold.ttf in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
743CABC02226171500634A5A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
743CABC72226171500634A5A /* PanModalTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
DCA741A6216D90410021F2F2 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
743CABB42225FE7700634A5A /* UserGroupMemberPresentable.swift in Sources */,
74C072A3220BA6E500124CE1 /* PanModalAnimator.swift in Sources */,
743CABB8222600C600634A5A /* UserGroupMemberCell.swift in Sources */,
743CABB62225FEEE00634A5A /* UserGroupHeaderPresentable.swift in Sources */,
743CB2AA222660D100665A55 /* StackedProfileViewController.swift in Sources */,
943904EB2226354100859537 /* BasicViewController.swift in Sources */,
DC139073216D9458007A3E64 /* PanModalPresenter.swift in Sources */,
943904EF2226383700859537 /* NavigationController.swift in Sources */,
74C072A5220BA76D00124CE1 /* PanModalHeight.swift in Sources */,
94795C9B21F0335D008045A0 /* PanModalPresentationDelegate.swift in Sources */,
943904F32226484F00859537 /* UserGroupStackedViewController.swift in Sources */,
74C072AA220BA82A00124CE1 /* UIViewController+PanModalPresenter.swift in Sources */,
943904ED2226366700859537 /* AlertViewController.swift in Sources */,
743CABB22225FD1100634A5A /* UserGroupHeaderView.swift in Sources */,
DC139072216D9458007A3E64 /* PanModalPresentable+UIViewController.swift in Sources */,
DC139074216D9458007A3E64 /* PanModalPresentationController.swift in Sources */,
DC139071216D9458007A3E64 /* PanModalPresentable.swift in Sources */,
DC139061216D93ED007A3E64 /* SampleViewController.swift in Sources */,
743CABB02225FC9F00634A5A /* UserGroupViewController.swift in Sources */,
DCC0EE7C21917F2500208DBC /* PanModalPresentable+Defaults.swift in Sources */,
94795C9D21F03368008045A0 /* PanContainerView.swift in Sources */,
74C072A7220BA78800124CE1 /* PanModalPresentable+LayoutHelpers.swift in Sources */,
DC139075216D9458007A3E64 /* DimmedView.swift in Sources */,
743CABD322265F2E00634A5A /* ProfileViewController.swift in Sources */,
DC139070216D9458007A3E64 /* PanModalPresentationAnimator.swift in Sources */,
DCA741AE216D90410021F2F2 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
743CABCA2226171500634A5A /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = DCA741A9216D90410021F2F2 /* PanModal */;
targetProxy = 743CABC92226171500634A5A /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
743CABCC2226171500634A5A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = Tests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = slack.PanModalTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PanModal.app/PanModal";
};
name = Debug;
};
743CABCD2226171500634A5A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = Tests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = slack.PanModalTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PanModal.app/PanModal";
};
name = Release;
};
DCA741BA216D90420021F2F2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
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 = 10.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
DCA741BB216D90420021F2F2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "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 = gnu11;
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 = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
DCA741BD216D90420021F2F2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 6UF7FN999R;
INFOPLIST_FILE = "$(SRCROOT)/Sample/Resources/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.PanModal;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
DCA741BE216D90420021F2F2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 6UF7FN999R;
INFOPLIST_FILE = "$(SRCROOT)/Sample/Resources/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.PanModal;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
743CABCB2226171500634A5A /* Build configuration list for PBXNativeTarget "PanModalTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
743CABCC2226171500634A5A /* Debug */,
743CABCD2226171500634A5A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
DCA741A5216D90410021F2F2 /* Build configuration list for PBXProject "PanModal" */ = {
isa = XCConfigurationList;
buildConfigurations = (
DCA741BA216D90420021F2F2 /* Debug */,
DCA741BB216D90420021F2F2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
DCA741BC216D90420021F2F2 /* Build configuration list for PBXNativeTarget "PanModal" */ = {
isa = XCConfigurationList;
buildConfigurations = (
DCA741BD216D90420021F2F2 /* Debug */,
DCA741BE216D90420021F2F2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = DCA741A2216D90410021F2F2 /* Project object */;
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:PanModal.xcodeproj">
</FileRef>
</Workspace>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,34 @@
//
// PanModalAnimator.swift
// PanModal
//
// Copyright © 2019 Tiny Speck, Inc. All rights reserved.
//
import UIKit
/**
Helper animation function to keep animations consistent.
*/
struct PanModalAnimator {
/**
Constant Animation Properties
*/
struct Constants {
static let transitionDuration: TimeInterval = 0.5
}
static func animate(_ animations: @escaping PanModalPresentable.AnimationBlockType,
config: PanModalPresentable?,
_ completion: PanModalPresentable.AnimationCompletionType? = nil) {
UIView.animate(withDuration: Constants.transitionDuration,
delay: 0,
usingSpringWithDamping: config?.springDamping ?? 1.0,
initialSpringVelocity: 0,
options: [.curveEaseInOut, .allowUserInteraction, .beginFromCurrentState],
animations: animations,
completion: completion)
}
}

View File

@ -0,0 +1,138 @@
//
// PanModalPresentationAnimator.swift
// PanModal
//
// Copyright © 2019 Tiny Speck, Inc. All rights reserved.
//
import UIKit
/**
Handles the animation of the presentedViewController as it is presented or dismissed.
This is a vertical animation that
- Animates up from the bottom of the screen
- Dismisses from the top to the bottom of the screen
This can be used as a standalone object for transition animation,
but is primarily used in the PanModalPresentationDelegate for handling pan modal transitions.
- Note: The presentedViewController can conform to PanModalPresentable to adjust
it's starting position through manipulating the shortFormHeight
*/
public class PanModalPresentationAnimator: NSObject {
/**
Enum representing the possible transition styles
*/
public enum TransitionStyle {
case presentation
case dismissal
}
// MARK: - Properties
/**
The transition style
*/
private let transitionStyle: TransitionStyle
/**
Haptic feedback generator (during presentation)
*/
private var feedbackGenerator: UISelectionFeedbackGenerator?
// MARK: - Initializers
required public init(transitionStyle: TransitionStyle) {
self.transitionStyle = transitionStyle
super.init()
/**
Prepare haptic feedback, only during the presentation state
*/
if case .presentation = transitionStyle {
feedbackGenerator = UISelectionFeedbackGenerator()
feedbackGenerator?.prepare()
}
}
/**
Animate presented view controller presentation
*/
private func animatePresentation(transitionContext: UIViewControllerContextTransitioning) {
guard let toVC = transitionContext.viewController(forKey: .to)
else { return }
let presentable = toVC as? PanModalPresentable.LayoutType
// Presents the view in shortForm position, initially
let yPos: CGFloat = presentable?.shortFormYPos ?? 0.0
// Use panView as presentingView if it already exists within the containerView
let panView: UIView = transitionContext.containerView.panContainerView ?? toVC.view
// Move presented view offscreen (from the bottom)
panView.frame = transitionContext.finalFrame(for: toVC)
panView.frame.origin.y = transitionContext.containerView.frame.height
// Haptic feedback
if presentable?.isHapticFeedbackEnabled == true {
feedbackGenerator?.selectionChanged()
}
PanModalAnimator.animate({
panView.frame.origin.y = yPos
}, config: presentable) { [weak self] didComplete in
transitionContext.completeTransition(didComplete)
self?.feedbackGenerator = nil
}
}
/**
Animate presented view controller dismissal
*/
private func animateDismissal(transitionContext: UIViewControllerContextTransitioning) {
guard let fromVC = transitionContext.viewController(forKey: .from)
else { return }
let presentable = fromVC as? PanModalPresentable.LayoutType
let panView: UIView = transitionContext.containerView.panContainerView ?? fromVC.view
PanModalAnimator.animate({
panView.frame.origin.y = transitionContext.containerView.frame.height
}, config: presentable) { didComplete in
fromVC.view.removeFromSuperview()
transitionContext.completeTransition(didComplete)
}
}
}
// MARK: - UIViewControllerAnimatedTransitioning Delegate
extension PanModalPresentationAnimator: UIViewControllerAnimatedTransitioning {
/**
Returns the transition duration
*/
public func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return PanModalAnimator.Constants.transitionDuration
}
/**
Perfroms the appropriate animation based on the transition style
*/
public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
switch transitionStyle {
case .presentation:
animatePresentation(transitionContext: transitionContext)
case .dismissal:
animateDismissal(transitionContext: transitionContext)
}
}
}

View File

@ -0,0 +1,858 @@
//
// PanModalPresentationController.swift
// PanModal
//
// Copyright © 2019 Tiny Speck, Inc. All rights reserved.
//
import UIKit
/**
The PanModalPresentationController is the middle layer between the presentingViewController
and the presentedViewController.
It controls the coordination between the individual transition classes as well as
provides an abstraction over how the presented view is presented & displayed.
For example, we add a drag indicator view above the presented view and
a background overlay between the presenting & presented view.
The presented view's layout configuration & presentation is defined using the PanModalPresentable.
By conforming to the PanModalPresentable protocol & overriding values
the presented view can define its layout configuration & presentation.
*/
public class PanModalPresentationController: UIPresentationController {
/**
Enum representing the possible presentation states
*/
public enum PresentationState {
case shortForm
case longForm
}
/**
Constants
*/
struct Constants {
static let cornerRadius = CGFloat(8.0)
static let indicatorYOffset = CGFloat(8.0)
static let snapMovementSensitivity = CGFloat(0.7)
static let dragIndicatorSize = CGSize(width: 36.0, height: 5.0)
}
// MARK: - Properties
/**
A flag to track if the presented view is animating
*/
private var isPresentedViewAnimating = false
/**
A flag to determine if scrolling should seamlessly transition
from the pan modal container view to the scroll view
once the scroll limit has been reached.
*/
private var extendsPanScrolling = true
/**
A flag to determine if scrolling should be limited to the longFormHeight.
Return false to cap scrolling at .max height.
*/
private var anchorModalToLongForm = true
/**
The y content offset value of the embedded scroll view
*/
private var scrollViewYOffset: CGFloat = 0.0
/**
An observer for the scroll view content offset
*/
private var scrollObserver: NSKeyValueObservation?
// store the y positions so we don't have to keep re-calculating
/**
The y value for the short form presentation state
*/
private var shortFormYPosition: CGFloat = 0
/**
The y value for the long form presentation state
*/
private var longFormYPosition: CGFloat = 0
/**
Determine anchored Y postion based on the `anchorModalToLongForm` flag
*/
private var anchoredYPosition: CGFloat {
let defaultTopOffset = presentable?.topOffset ?? 0
return anchorModalToLongForm ? longFormYPosition : defaultTopOffset
}
/**
Configuration object for PanModalPresentationController
*/
private var presentable: PanModalPresentable? {
return presentedViewController as? PanModalPresentable
}
// MARK: - Views
/**
Background view used as an overlay over the presenting view
*/
private lazy var backgroundView: DimmedView = {
let view: DimmedView
if let alpha = presentable?.backgroundAlpha {
view = DimmedView(dimAlpha: alpha)
} else {
view = DimmedView()
}
view.didTap = { [weak self] _ in
self?.dismissPresentedViewController()
}
return view
}()
/**
A wrapper around the presented view so that we can modify
the presented view apperance without changing
the presented view's properties
*/
private lazy var panContainerView: PanContainerView = {
let frame = containerView?.frame ?? .zero
return PanContainerView(presentedView: presentedViewController.view, frame: frame)
}()
/**
Drag Indicator View
*/
private lazy var dragIndicatorView: UIView = {
let view = UIView()
view.backgroundColor = .lightGray
view.layer.cornerRadius = Constants.dragIndicatorSize.height / 2.0
return view
}()
/**
Override presented view to return the pan container wrapper
*/
public override var presentedView: UIView {
return panContainerView
}
// MARK: - Gesture Recognizers
/**
Gesture recognizer to detect & track pan gestures
*/
private lazy var panGestureRecognizer: UIPanGestureRecognizer = {
let gesture = UIPanGestureRecognizer(target: self, action: #selector(didPanOnPresentedView(_ :)))
gesture.minimumNumberOfTouches = 1
gesture.maximumNumberOfTouches = 1
gesture.delegate = self
return gesture
}()
// MARK: - Deinitializers
deinit {
scrollObserver?.invalidate()
}
// MARK: - Lifecycle
override public func containerViewWillLayoutSubviews() {
super.containerViewWillLayoutSubviews()
configureViewLayout()
}
override public func presentationTransitionWillBegin() {
guard let containerView = containerView
else { return }
layoutBackgroundView(in: containerView)
layoutPresentedView(in: containerView)
configureScrollViewInsets()
guard let coordinator = presentedViewController.transitionCoordinator else {
backgroundView.dimState = .max
return
}
coordinator.animate(alongsideTransition: { [weak self] _ in
self?.backgroundView.dimState = .max
})
}
override public func dismissalTransitionWillBegin() {
guard let coordinator = presentedViewController.transitionCoordinator else {
backgroundView.dimState = .off
return
}
/**
Drag indicator is drawn outside of view bounds
so hiding it on view dismiss means avoids visual bugs
*/
coordinator.animate(alongsideTransition: { [weak self] _ in
self?.dragIndicatorView.alpha = 0.0
self?.backgroundView.dimState = .off
})
}
override public func presentationTransitionDidEnd(_ completed: Bool) {
if completed { return }
backgroundView.removeFromSuperview()
}
}
// MARK: - Public Methods
public extension PanModalPresentationController {
/**
Tranisition the PanModalPresentationController
to the given presentation state
*/
public func transition(to state: PresentationState) {
guard presentable?.shouldTransition(to: state) == true
else { return }
presentable?.willTransition(to: state)
switch state {
case .shortForm:
snap(toYPosition: shortFormYPosition)
case .longForm:
snap(toYPosition: longFormYPosition)
}
}
/**
Set the content offset of the scroll view
Due to content offset observation, its not possible to programmatically
set the content offset directly on the scroll view while in the short form.
This method pauses the content offset KVO, performs the content offset chnage
and then resumes content offset observation.
*/
public func setContentOffset(offset: CGPoint) {
guard let scrollView = presentable?.panScrollable
else { return }
/**
Invalidate scroll view observer
to prevent its overriding the content offset change
*/
scrollObserver?.invalidate()
scrollObserver = nil
/**
Set scroll view offset & track scrolling
*/
scrollView.setContentOffset(offset, animated:false)
trackScrolling(scrollView)
/**
Add the scroll view observer
*/
observe(scrollView: scrollView)
}
/**
Updates the PanModalPresentationController layout
based on values in the PanModalPresentabls
- Note: This should be called whenever any
pan modal presentable value changes after the initial presentation
*/
public func setNeedsLayoutUpdate() {
configureViewLayout()
adjustPresentedViewFrame()
observe(scrollView: presentable?.panScrollable)
configureScrollViewInsets()
}
}
// MARK: - Presented View Layout Configuration
private extension PanModalPresentationController {
/**
Boolean flag to determine if the presented view is anchored
*/
var isPresentedViewAnchored: Bool {
if !isPresentedViewAnimating
&& extendsPanScrolling
&& presentedView.frame.minY <= anchoredYPosition {
return true
}
return false
}
/**
Adds the presented view to the given container view
& configures the view elements such as drag indicator, rounded corners
based on the pan modal presentable.
*/
func layoutPresentedView(in containerView: UIView) {
/**
If the presented view controller does not conform to pan modal presentable
don't configure
*/
guard let presentable = presentable
else { return }
/**
If this class is NOT used in conjunction with the PanModalPresentationAnimator
& PanModalPresentable, the presented view should be added to the container view
in the presentation animator instead of here
*/
containerView.addSubview(presentedView)
containerView.addGestureRecognizer(panGestureRecognizer)
if presentable.showDragIndicator {
addDragIndicatorView(to: presentedView)
}
if presentable.shouldRoundTopCorners {
addRoundedCorners(to: presentedView)
}
setNeedsLayoutUpdate()
adjustPanContainerBackgroundColor()
}
/**
Reduce height of presentedView so that it sits at the bottom of the screen
*/
func adjustPresentedViewFrame() {
let frame = containerView?.frame ?? .zero
let size = CGSize(width: frame.size.width, height: frame.height - anchoredYPosition)
presentedViewController.view.frame = CGRect(origin: .zero, size: size)
}
/**
Adds a background color to the pan container view
in order to avoid a gap at the bottom
during initial view presentation in longForm (when view bounces)
*/
func adjustPanContainerBackgroundColor() {
panContainerView.backgroundColor = presentedViewController.view.backgroundColor
?? presentable?.panScrollable?.backgroundColor
}
/**
Adds the background view to the view hierarchy
& configures its layout constraints.
*/
func layoutBackgroundView(in containerView: UIView) {
containerView.addSubview(backgroundView)
backgroundView.translatesAutoresizingMaskIntoConstraints = false
backgroundView.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true
backgroundView.leadingAnchor.constraint(equalTo: containerView.leadingAnchor).isActive = true
backgroundView.trailingAnchor.constraint(equalTo: containerView.trailingAnchor).isActive = true
backgroundView.bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true
}
/**
Adds the drag indicator view to the view hierarchy
& configures its layout constraints.
*/
func addDragIndicatorView(to view: UIView) {
view.addSubview(dragIndicatorView)
dragIndicatorView.translatesAutoresizingMaskIntoConstraints = false
dragIndicatorView.bottomAnchor.constraint(equalTo: view.topAnchor, constant: -Constants.indicatorYOffset).isActive = true
dragIndicatorView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
dragIndicatorView.widthAnchor.constraint(equalToConstant: Constants.dragIndicatorSize.width).isActive = true
dragIndicatorView.heightAnchor.constraint(equalToConstant: Constants.dragIndicatorSize.height).isActive = true
}
/**
Caluclates & stores the layout anchor points & options
*/
func configureViewLayout() {
guard let layoutPresentable = presentedViewController as? PanModalPresentable.LayoutType
else { return }
shortFormYPosition = layoutPresentable.shortFormYPos
longFormYPosition = layoutPresentable.longFormYPos
anchorModalToLongForm = layoutPresentable.anchorModalToLongForm
extendsPanScrolling = layoutPresentable.allowsExtendedPanScrolling
}
/**
Configures the scroll view insets
*/
func configureScrollViewInsets() {
guard
let scrollView = presentable?.panScrollable,
!scrollView.isScrolling
else { return }
/**
Disable vertical scroll indicator until we start to scroll
to avoid visual bugs
*/
scrollView.showsVerticalScrollIndicator = false
scrollView.isScrollEnabled = presentable?.isPanScrollEnabled ?? true
scrollView.scrollIndicatorInsets = presentable?.scrollIndicatorInsets ?? .zero
/**
Set the appropriate contentInset as the configuration within this class
offsets it
*/
scrollView.contentInset.bottom = presentingViewController.bottomLayoutGuide.length
/**
As we adjust the bounds during `handleScrollViewTopBounce`
we should assume that contentInsetAdjustmentBehavior will not be correct
*/
if #available(iOS 11.0, *) {
scrollView.contentInsetAdjustmentBehavior = .never
}
}
}
// MARK: - Pan Gesture Event Handler
private extension PanModalPresentationController {
/**
The designated function for handling pan gesture events
*/
@objc func didPanOnPresentedView(_ recognizer: UIPanGestureRecognizer) {
guard
presentable?.isPanScrollEnabled == true,
!shouldFail(panGestureRecognizer: recognizer),
let containerView = containerView
else {
recognizer.setTranslation(.zero, in: recognizer.view)
return
}
switch recognizer.state {
case .began, .changed:
/**
Respond accordingly to pan gesture translation
*/
respond(to: recognizer)
/**
If presentedView is translated above the longForm threshold, treat as transition
*/
if presentedView.frame.origin.y == anchoredYPosition && extendsPanScrolling {
presentable?.willTransition(to: .longForm)
}
default:
/**
Use velocity sensitivity value to restrict snapping
*/
let velocity = recognizer.velocity(in: presentedView)
if isVelocityWithinSensitivityRange(velocity.y) {
/**
If velocity is within the sensitivity range,
transition to a presentation state or dismiss entirely.
This allows the user to dismiss directly from long form
instead of going to the short form state first.
*/
if velocity.y < 0 {
transition(to: .longForm)
} else if (nearestDistance(to: presentedView.frame.minY, inDistances: [longFormYPosition, containerView.bounds.height]) == longFormYPosition
&& presentedView.frame.minY < shortFormYPosition) || presentable?.allowsDragToDismiss == false {
transition(to: .shortForm)
} else {
dismissPresentedViewController()
}
} else {
/**
The `containerView.bounds.height` is used to determine
how close the presented view is to the bottom of the screen
*/
let position = nearestDistance(to: presentedView.frame.minY, inDistances: [containerView.bounds.height, shortFormYPosition, longFormYPosition])
if position == longFormYPosition {
transition(to: .longForm)
} else if position == shortFormYPosition || presentable?.allowsDragToDismiss == false {
transition(to: .shortForm)
} else {
dismissPresentedViewController()
}
}
}
}
/**
Communicate intentions to presentable and adjust subviews in containerView
*/
func respond(to panGestureRecognizer: UIPanGestureRecognizer) {
presentable?.willRespond(to: panGestureRecognizer)
var yDisplacement = panGestureRecognizer.translation(in: presentedView).y
/**
If the presentedView is not anchored to long form, reduce the rate of movement
above the threshold
*/
if presentedView.frame.origin.y < longFormYPosition {
yDisplacement /= 2.0
}
adjust(toYPosition: presentedView.frame.origin.y + yDisplacement)
panGestureRecognizer.setTranslation(.zero, in: presentedView)
}
/**
Determines if we should fail the gesture recognizer based on certain conditions
We fail the presented view's pan gesture recognizer if we are actively scrolling on the scroll view.
This allows the user to drag whole view controller from outside scrollView touch area.
Unfortunately, cancelling a gestureRecognizer means that we lose the effect of transition scrolling
from one view to another in the same pan gesture so don't cancel
*/
func shouldFail(panGestureRecognizer: UIPanGestureRecognizer) -> Bool {
/**
Allow api consumers to override the internal conditions &
decide if the pan gesture recognizer should be prioritized.
This is the only time we should be cancelling a recognizer,
for the purpose of ensuring we're no longer tracking the scrollView
*/
guard !shouldPrioritize(panGestureRecognizer: panGestureRecognizer) else {
presentable?.panScrollable?.panGestureRecognizer.isEnabled = false
presentable?.panScrollable?.panGestureRecognizer.isEnabled = true
return false
}
guard
isPresentedViewAnchored,
let scrollView = presentable?.panScrollable,
scrollView.contentOffset.y > 0
else {
return false
}
let loc = panGestureRecognizer.location(in: presentedView)
return (scrollView.frame.contains(loc) || scrollView.isScrolling)
}
/**
Determine if the presented view's panGestureRecognizer should be prioritized over
embedded scrollView's panGestureRecognizer.
*/
func shouldPrioritize(panGestureRecognizer: UIPanGestureRecognizer) -> Bool {
return panGestureRecognizer.state == .began &&
presentable?.shouldPrioritize(panModalGestureRecognizer: panGestureRecognizer) ?? false
}
/**
Check if the given velocity is within the sensitivity range
*/
func isVelocityWithinSensitivityRange(_ velocity: CGFloat) -> Bool {
return (abs(velocity) - (1000 * (1 - Constants.snapMovementSensitivity))) > 0
}
func snap(toYPosition yPos: CGFloat) {
PanModalAnimator.animate({ [weak self] in
self?.adjust(toYPosition: yPos)
self?.isPresentedViewAnimating = true
}, config: presentable) { [weak self] didComplete in
self?.isPresentedViewAnimating = !didComplete
}
}
/**
Sets the y position of the presentedView & adjusts the backgroundView.
*/
func adjust(toYPosition yPos: CGFloat) {
presentedView.frame.origin.y = max(yPos, anchoredYPosition)
guard presentedView.frame.origin.y > shortFormYPosition else {
backgroundView.dimState = .max
return
}
let yDisplacementFromShortForm = presentedView.frame.origin.y - shortFormYPosition
/**
Once presentedView is translated below shortForm, calculate yPos relative to bottom of screen
and apply percentage to backgroundView alpha
*/
backgroundView.dimState = .percent(1.0 - (yDisplacementFromShortForm / presentedView.frame.height))
}
/**
Finds the nearest distance to a given position out of a given array of distance values
- Parameters:
- position: reference postion we are trying to find the closest distance to
- distances: array of positions we would like to compare against
*/
func nearestDistance(to position: CGFloat, inDistances distances: [CGFloat]) -> CGFloat {
guard let nearestDistance = distances.min(by: { abs(position - $0) < abs(position - $1) })
else { return position }
return nearestDistance
}
/**
Dismiss presented view
*/
func dismissPresentedViewController() {
presentable?.panModalWillDismiss()
presentedViewController.dismiss(animated: true, completion: nil)
}
}
// MARK: - UIScrollView Observer
private extension PanModalPresentationController {
/**
Creates & stores an observer on the given scroll view's content offset.
This allows us to track scrolling without overriding the scrollView delegate
*/
func observe(scrollView: UIScrollView?) {
scrollObserver?.invalidate()
scrollObserver = scrollView?.observe(\.contentOffset, options: .old) { [weak self] scrollView, change in
/**
Incase we have a situation where we have two containerViews in the same presentation
*/
guard self?.containerView != nil
else { return }
self?.didPanOnScrollView(scrollView, change: change)
}
}
/**
Scroll view content offset change event handler
Also when scrollView is scrolled to the top, we disable the scroll indicator
otherwise glitchy behaviour occurs
This is also shown in Apple Maps (reverse engineering)
which allows us to seamlessly transition scrolling from the panContainerView to the scrollView
*/
func didPanOnScrollView(_ scrollView: UIScrollView, change: NSKeyValueObservedChange<CGPoint>) {
guard
!presentedViewController.isBeingDismissed,
!presentedViewController.isBeingPresented
else { return }
if !isPresentedViewAnchored && scrollView.contentOffset.y > 0 {
/**
Hold the scrollView in place if we're actively scrolling and not handling top bounce
*/
haltScrolling(scrollView)
} else if scrollView.isScrolling || isPresentedViewAnimating {
if isPresentedViewAnchored {
/**
While we're scrolling upwards on the scrollView,
store the last content offset position
*/
trackScrolling(scrollView)
} else {
/**
Keep scroll view in place while we're panning on main view
*/
haltScrolling(scrollView)
}
} else if presentedViewController.view.isKind(of: UIScrollView.self)
&& !isPresentedViewAnimating && scrollView.contentOffset.y <= 0 {
/**
In the case where we drag down quickly on the scroll view and let go,
`handleScrollViewTopBounce` adds a nice elegant touch.
*/
handleScrollViewTopBounce(scrollView: scrollView, change: change)
} else {
trackScrolling(scrollView)
}
}
/**
Halts the scroll of a given scroll view & anchors it at the `scrollViewYOffset`
*/
func haltScrolling(_ scrollView: UIScrollView) {
scrollView.setContentOffset(CGPoint(x: 0, y: scrollViewYOffset), animated: false)
scrollView.showsVerticalScrollIndicator = false
}
/**
As the user scrolls, track & save the scroll view y offset.
This helps halt scrolling when we want to hold the scroll view in place.
*/
func trackScrolling(_ scrollView: UIScrollView) {
scrollViewYOffset = max(scrollView.contentOffset.y, 0)
scrollView.showsVerticalScrollIndicator = true
}
/**
To ensure that the scroll transition between the scrollView & the modal
is completely seamless, we need to handle the case where content offset is negative.
In this case, we follow the curve of the decelerating scroll view.
This gives the effect that the modal view and the scroll view are one view entirely.
- Note: This works best where the view behind view controller is a UIScrollView.
So, for example, a UITableViewController.
*/
func handleScrollViewTopBounce(scrollView: UIScrollView, change: NSKeyValueObservedChange<CGPoint>) {
guard let oldYValue = change.oldValue?.y
else { return }
let yOffset = scrollView.contentOffset.y
let presentedSize = containerView?.frame.size ?? .zero
/**
Decrease the view bounds by the y offset so the scroll view stays in place
and we can still get updates on its content offset
*/
presentedView.bounds.size = CGSize(width: presentedSize.width, height: presentedSize.height + yOffset)
if oldYValue > yOffset {
/**
Move the view in the opposite direction to the decreasing bounds
until half way through the deceleration so that it appears
as if we're transferring the scrollView drag momentum to the entire view
*/
presentedView.frame.origin.y = longFormYPosition - yOffset
} else {
scrollViewYOffset = 0
snap(toYPosition: longFormYPosition)
}
scrollView.showsVerticalScrollIndicator = false
}
}
// MARK: - UIGestureRecognizerDelegate
extension PanModalPresentationController: UIGestureRecognizerDelegate {
/**
Do not require any other gesture recognizers to fail
*/
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return false
}
/**
Allow simultaneous gesture recognizers only when the other gesture recognizer
is a pan gesture recognizer
*/
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return otherGestureRecognizer.isKind(of: UIPanGestureRecognizer.self)
}
}
// MARK: - UIBezierPath
private extension PanModalPresentationController {
/**
Draws top rounded corners on a given view
We have to set a custom path for corner rounding
because we render the dragIndicator outside of view bounds
*/
func addRoundedCorners(to view: UIView) {
let path = UIBezierPath()
path.move(to: CGPoint(x: 0, y: Constants.cornerRadius))
// 1. Draw left rounded corner
path.addArc(withCenter: CGPoint(x: path.currentPoint.x + Constants.cornerRadius, y: path.currentPoint.y),
radius: Constants.cornerRadius, startAngle: .pi, endAngle: 3.0 * .pi/2.0, clockwise: true)
// 2. Draw around the drag indicator view, if displayed
if presentable?.showDragIndicator == true {
let indicatorLeftEdgeXPos = view.bounds.width/2.0 - Constants.dragIndicatorSize.width/2.0
drawAroundDragIndicator(currentPath: path, indicatorLeftEdgeXPos: indicatorLeftEdgeXPos)
}
// 3. Draw line to right side of presented view, leaving space to draw rounded corner
path.addLine(to: CGPoint(x: view.bounds.width - Constants.cornerRadius, y: path.currentPoint.y))
// 4. Draw right rounded corner
path.addArc(withCenter: CGPoint(x: path.currentPoint.x, y: path.currentPoint.y + Constants.cornerRadius),
radius: Constants.cornerRadius, startAngle: 3.0 * .pi/2.0, endAngle: 0, clockwise: true)
// 5. Draw around final edges of view
path.addLine(to: CGPoint(x: path.currentPoint.x, y: view.bounds.height))
path.addLine(to: CGPoint(x: 0, y: path.currentPoint.y))
// 6. Set path as a mask to display optional drag indicator view & rounded corners
let mask = CAShapeLayer()
mask.path = path.cgPath
view.layer.mask = mask
// 7. Improve performance by rasterizing the layer
view.layer.shouldRasterize = true
view.layer.rasterizationScale = UIScreen.main.scale
}
/**
Draws a path around the drag indicator view
*/
func drawAroundDragIndicator(currentPath path: UIBezierPath, indicatorLeftEdgeXPos: CGFloat) {
let totalIndicatorOffset = Constants.indicatorYOffset + Constants.dragIndicatorSize.height
// Draw around drag indicator starting from the left
path.addLine(to: CGPoint(x: indicatorLeftEdgeXPos, y: path.currentPoint.y))
path.addLine(to: CGPoint(x: path.currentPoint.x, y: path.currentPoint.y - totalIndicatorOffset))
path.addLine(to: CGPoint(x: path.currentPoint.x + Constants.dragIndicatorSize.width, y: path.currentPoint.y))
path.addLine(to: CGPoint(x: path.currentPoint.x, y: path.currentPoint.y + totalIndicatorOffset))
}
}
// MARK: - Helper Extensions
private extension UIScrollView {
/**
A flag to determine if a scroll view is scrolling
*/
var isScrolling: Bool {
return isDragging && !isDecelerating || isTracking
}
}

View File

@ -0,0 +1,80 @@
//
// PanModalPresentationDelegate.swift
// PanModal
//
// Copyright © 2019 Tiny Speck, Inc. All rights reserved.
//
import UIKit
/**
The PanModalPresentationDelegate conforms to the various transition delegates
and vends the appropriate object for each transition controller requested.
Usage:
```
viewController.modalPresentationStyle = .custom
viewController.transitioningDelegate = PanModalPresentationDelegate.default
```
*/
public class PanModalPresentationDelegate: NSObject {
/**
Returns an instance of the delegate, retained for the duration of presentation
*/
public static var `default`: PanModalPresentationDelegate = {
return PanModalPresentationDelegate()
}()
}
extension PanModalPresentationDelegate: UIViewControllerTransitioningDelegate {
/**
Returns a modal presentation animator configured for the presenting state
*/
public func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return PanModalPresentationAnimator(transitionStyle: .presentation)
}
/**
Returns a modal presentation animator configured for the dismissing state
*/
public func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return PanModalPresentationAnimator(transitionStyle: .dismissal)
}
/**
Returns a modal presentation controller to coordinate the transition from the presenting
view controller to the presented view controller.
Changes in size class during presentation are handled via the adaptive presentation delegate
*/
public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
let controller = PanModalPresentationController(presentedViewController: presented, presenting: presenting)
controller.delegate = self
return controller
}
}
extension PanModalPresentationDelegate: UIAdaptivePresentationControllerDelegate, UIPopoverPresentationControllerDelegate {
/**
- Note: We do not adapt to size classes due to the introduction of the UIPresentationController
& deprecation of UIPopoverController (iOS 9), there is no way to have more than one
presentation controller in use during the same presentation
This is essential when transitioning from .popover to .custom on iPad split view... unless a custom popover view is also implemented
(popover uses UIPopoverPresentationController & we use PanModalPresentationController)
*/
/**
Dismisses the presented view controller
*/
public func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
controller.presentedViewController.dismiss(animated: false, completion: nil)
return .none
}
}

View File

@ -0,0 +1,38 @@
//
// PanModalHeight.swift
// SlackUI
//
// Copyright © 2019 Tiny Speck, Inc. All rights reserved.
//
import UIKit
/**
An enum that defines the possible states of the height of a pan modal container view
for a given presentation state (shortForm, longForm)
*/
public enum PanModalHeight: Equatable {
/**
Sets the height to be the maximum height (+ topOffset)
*/
case maxHeight
/**
Sets the height to be the max height with a specified top inset.
- Note: A value of 0 is equivalent to .maxHeight
*/
case maxHeightWithTopInset(CGFloat)
/**
Sets the height to be the specified content height
*/
case contentHeight(CGFloat)
/**
Sets the height to be the specified content height
& also ignores the bottomSafeAreaInset
*/
case contentHeightIgnoringSafeArea(CGFloat)
}

View File

@ -0,0 +1,100 @@
//
// PanModalPresentable+Defaults.swift
// PanModal
//
// Created by Stephen Sowole on 11/5/18.
// Copyright © 2018 Tiny Speck, Inc. All rights reserved.
//
import UIKit
/**
Default values for the PanModalPresentable.
*/
public extension PanModalPresentable where Self: UIViewController {
var topOffset: CGFloat {
return topLayoutOffset + 21.0
}
var shortFormHeight: PanModalHeight {
return longFormHeight
}
var longFormHeight: PanModalHeight {
guard let scrollView = panScrollable
else { return .maxHeight }
// called once during presentation and stored
scrollView.layoutIfNeeded()
return .contentHeight(scrollView.contentSize.height)
}
var springDamping: CGFloat {
return 0.8
}
var backgroundAlpha: CGFloat {
return 0.7
}
var scrollIndicatorInsets: UIEdgeInsets {
let top = shouldRoundTopCorners ? PanModalPresentationController.Constants.cornerRadius : 0
return UIEdgeInsets(top: CGFloat(top), left: 0, bottom: bottomLayoutOffset, right: 0)
}
var anchorModalToLongForm: Bool {
return true
}
var allowsExtendedPanScrolling: Bool {
guard let scrollView = panScrollable
else { return false }
scrollView.layoutIfNeeded()
return scrollView.contentSize.height > (scrollView.frame.height - bottomLayoutOffset)
}
var allowsDragToDismiss: Bool {
return true
}
var isPanScrollEnabled: Bool {
return true
}
var isHapticFeedbackEnabled: Bool {
return true
}
var shouldRoundTopCorners: Bool {
return isPanModalPresented
}
var showDragIndicator: Bool {
return shouldRoundTopCorners
}
func willRespond(to panGestureRecognizer: UIPanGestureRecognizer) {
}
func shouldTransition(to state: PanModalPresentationController.PresentationState) -> Bool {
return true
}
func shouldPrioritize(panModalGestureRecognizer: UIPanGestureRecognizer) -> Bool {
return false
}
func willTransition(to state: PanModalPresentationController.PresentationState) {
}
func panModalWillDismiss() {
}
}

View File

@ -0,0 +1,96 @@
//
// PanModalPresentable+LayoutHelpers.swift
// PanModal
//
// Copyright © 2018 Tiny Speck, Inc. All rights reserved.
//
import UIKit
/**
[Internal Only]
Helper extensions that handle layout in the PanModalPresentationController
*/
extension PanModalPresentable where Self: UIViewController {
/**
Cast the presentation controller to PanModalPresentationController
so we can access PanModalPresentationController properties and methods
*/
var presentedVC: PanModalPresentationController? {
return presentationController as? PanModalPresentationController
}
/**
Length of the top layout guide of the presenting view controller.
Gives us the safe area inset from the top.
*/
var topLayoutOffset: CGFloat {
return UIApplication.shared.keyWindow?.rootViewController?.topLayoutGuide.length ?? 0
}
/**
Length of the bottom layout guide of the presenting view controller.
Gives us the safe area inset from the bottom.
*/
var bottomLayoutOffset: CGFloat {
return UIApplication.shared.keyWindow?.rootViewController?.bottomLayoutGuide.length ?? 0
}
/**
Returns the short form Y postion
- Note: If voiceover is on, the `longFormYPos` is returned.
We do not support short form when voiceover is on as it would make it difficult for user to navigate.
*/
var shortFormYPos: CGFloat {
guard !UIAccessibility.isVoiceOverRunning
else { return longFormYPos }
let shortFormYPos = topMargin(from: shortFormHeight) + topOffset
// shortForm shouldn't exceed longForm
return max(shortFormYPos, longFormYPos)
}
/**
Returns the long form Y postion
- Note: We cap this value to the max possible height
to ensure content is not rendered outside of the view bounds
*/
var longFormYPos: CGFloat {
return max(topMargin(from: longFormHeight), topMargin(from: .maxHeight)) + topOffset
}
/**
Use the container view for relative positioning as this view's frame
is adjusted in PanModalPresentationController
*/
var bottomYPos: CGFloat {
guard let container = presentedVC?.containerView
else { return view.bounds.height }
return container.bounds.size.height - topOffset
}
/**
Converts a given pan modal height value into a y position value
calculated from top of view
*/
func topMargin(from: PanModalHeight) -> CGFloat {
switch from {
case .maxHeight:
return 0.0
case .maxHeightWithTopInset(let inset):
return inset
case .contentHeight(let height):
return bottomYPos - (height + bottomLayoutOffset)
case .contentHeightIgnoringSafeArea(let height):
return bottomYPos - height
}
}
}

View File

@ -0,0 +1,61 @@
//
// PanModalPresentable+UIViewController.swift
// PanModal
//
// Copyright © 2018 Tiny Speck, Inc. All rights reserved.
//
import UIKit
/**
Extends PanModalPresentable with helper methods
when the conforming object is a UIViewController
*/
public extension PanModalPresentable where Self: UIViewController {
typealias AnimationBlockType = () -> Void
typealias AnimationCompletionType = (Bool) -> Void
/**
For Presentation, the object must be a UIViewController & confrom to the PanModalPresentable protocol.
*/
typealias LayoutType = UIViewController & PanModalPresentable
/**
A function wrapper over the `transition(to state: PanModalPresentationController.PresentationState)`
function in the PanModalPresentationController.
*/
func panModalTransition(to state: PanModalPresentationController.PresentationState) {
presentedVC?.transition(to: state)
}
/**
Programmatically set the content offset of the pan scrollable.
This is required to use while in the short form presentation state,
as due to content offset observation, setting the content offset directly would fail
*/
func panModalSetContentOffset(offset: CGPoint) {
presentedVC?.setContentOffset(offset: offset)
}
/**
A function wrapper over the `setNeedsLayoutUpdate()`
function in the PanModalPresentationController.
- Note: This should be called whenever any of the values for the PanModalPresentable protocol are changed.
*/
func panModalSetNeedsLayoutUpdate() {
presentedVC?.setNeedsLayoutUpdate()
}
/**
A function wrapper over the animate function in PanModalAnimator.
This can be used for animation consistency on views within the presented view controller.
*/
func panModalAnimate(_ animationBlock: @escaping AnimationBlockType, _ completion: AnimationCompletionType? = nil) {
PanModalAnimator.animate(animationBlock, config: self, completion)
}
}

View File

@ -0,0 +1,184 @@
//
// PanModalPresentable.swift
// PanModal
//
// Copyright © 2017 Tiny Speck, Inc. All rights reserved.
//
import UIKit
/**
This is the configuration object for a view controller
that will be presented using the PanModal transition.
Usage:
```
extension UIViewController: PanModalPresentable {
func shouldRoundTopCorners: Bool { return false }
}
```
*/
public protocol PanModalPresentable {
/**
The scroll view embedded in the view controller.
Setting this value allows for seamless transition scrolling between the embedded scroll view
and the pan modal container view.
*/
var panScrollable: UIScrollView? { get }
/**
The offset between the top of the screen and the top of the pan modal container view.
Default value is the topLayoutGuide.length + 21.0.
*/
var topOffset: CGFloat { get }
/**
The height of the pan modal container view
when in the shortForm presentation state.
This value is capped to .max, if provided value exceeds the space available.
Default value is the longFormHeight.
*/
var shortFormHeight: PanModalHeight { get }
/**
The height of the pan modal container view
when in the longForm presentation state.
This value is capped to .max, if provided value exceeds the space available.
Default value is .max.
*/
var longFormHeight: PanModalHeight { get }
/**
The springDamping value used to determine the amount of 'bounce'
seen when transitioning to short/long form.
Default Value is 0.8.
*/
var springDamping: CGFloat { get }
/**
The background view alpha.
- Note: This is only utilized at the very start of the transition.
Default Value is 0.7.
*/
var backgroundAlpha: CGFloat { get }
/**
We configure the panScrollable's scrollIndicatorInsets interally so override this value
to set custom insets.
- Note: Use `panModalSetNeedsLayoutUpdate()` when updating insets.
*/
var scrollIndicatorInsets: UIEdgeInsets { get }
/**
A flag to determine if scrolling should be limited to the longFormHeight.
Return false to cap scrolling at .max height.
Default value is true.
*/
var anchorModalToLongForm: Bool { get }
/**
A flag to determine if scrolling should seamlessly transition from the pan modal container view to
the embedded scroll view once the scroll limit has been reached.
Default value is false.
Unless a scrollView is provided and the content exceeds the longForm height
*/
var allowsExtendedPanScrolling: Bool { get }
/**
A flag to determine if dismissal should be initiated when swiping down on the presented view.
Return false to fallback to the short form state instead of dismissing.
Default value is true.
*/
var allowsDragToDismiss: Bool { get }
/**
A flag to determine if scrolling should be enabled on the entire view.
- Note: Returning false will disable scrolling on the embedded scrollview as well as on the
pan modal container view.
Default value is true.
*/
var isPanScrollEnabled: Bool { get }
/**
A flag to determine if haptic feedback should be enabled during presentation.
Default value is true.
*/
var isHapticFeedbackEnabled: Bool { get }
/**
A flag to determine if the top corners should be rounded.
Default value is true.
*/
var shouldRoundTopCorners: Bool { get }
/**
A flag to determine if a drag indicator should be shown
above the pan modal container view.
Default value is true.
*/
var showDragIndicator: Bool { get }
/**
Notifies the delegate when the pan modal gesture recognizer state is either
`began` or `changed`. This method gives the delegate a chance to prepare
for the gesture recognizer state change.
For example, when the pan modal view is about to scroll.
Default value is an empty implementation.
*/
func willRespond(to panGestureRecognizer: UIPanGestureRecognizer)
/**
Asks the delegate if the pan modal gesture recognizer should be prioritized.
For example, you can use this to define a region
where you would like to restrict where the pan gesture can start.
If false, then we rely on the internal conditions of when a pan gesture
should succeed or fail, such as, if we're actively scrolling on the scrollView
Default return value is false.
*/
func shouldPrioritize(panModalGestureRecognizer: UIPanGestureRecognizer) -> Bool
/**
Asks the delegate if the pan modal should transition to a new state.
Default value is true.
*/
func shouldTransition(to state: PanModalPresentationController.PresentationState) -> Bool
/**
Notifies the delegate that the pan modal is about to transition to a new state.
Default value is an empty implementation.
*/
func willTransition(to state: PanModalPresentationController.PresentationState)
/**
Notifies the delegate that the pan modal is about to be dismissed.
Default value is an empty implementation.
*/
func panModalWillDismiss()
}

View File

@ -0,0 +1,33 @@
//
// PanModalPresenter.swift
// SlackUI
//
// Copyright © 2019 Tiny Speck, Inc. All rights reserved.
//
import UIKit
/**
A protocol for objects that will present a view controller as a PanModal
- Usage:
```
viewController.presentPanModal(viewControllerToPresent: presentingVC,
sourceView: presentingVC.view,
sourceRect: .zero)
```
*/
public protocol PanModalPresenter {
/**
A flag that returns true if the current presented view controller
is using the PanModalPresentationDelegate
*/
var isPanModalPresented: Bool { get }
/**
Presents a view controller that conforms to the PanModalPresentable protocol
*/
func presentPanModal(_ viewControllerToPresent: PanModalPresentable.LayoutType, sourceView: UIView?, sourceRect: CGRect)
}

View File

@ -0,0 +1,59 @@
//
// UIViewController+PanModalPresenterProtocol.swift
// SlackUI
//
// Copyright © 2019 Tiny Speck, Inc. All rights reserved.
//
import UIKit
/**
Extends the UIViewController to conform to the PanModalPresenter protocol
*/
extension UIViewController: PanModalPresenter {
/**
A flag that returns true if the topmost view controller in the navigation stack
was presented using the custom PanModal transition
- Warning: Calling `presentationController` in this function may cause a memory leak.
In most cases, this check will be used early in the view lifecycle and unfortunately,
there's an Apple bug that causes multiple presentationControllers to be created if
the presentationController is referenced here and called too early resulting in
a strong reference to this view controller and in turn, creating a memory leak.
*/
public var isPanModalPresented: Bool {
return (transitioningDelegate as? PanModalPresentationDelegate) != nil
}
/**
Configures a view controller for presentation using the PanModal transition
- Parameters:
- viewControllerToPresent: The view controller to be presented
- sourceView: The view containing the anchor rectangle for the popover.
- sourceRect: The rectangle in the specified view in which to anchor the popover.
- Note: sourceView & sourceRect are only required for presentation on an iPad.
*/
public func presentPanModal(_ viewControllerToPresent: PanModalPresentable.LayoutType, sourceView: UIView? = nil, sourceRect: CGRect = .zero) {
/**
Here, we deliberately do not check for size classes. More info in `PanModalPresentationDelegate`
*/
if UIDevice.current.userInterfaceIdiom == .pad {
viewControllerToPresent.modalPresentationStyle = .popover
viewControllerToPresent.popoverPresentationController?.sourceRect = sourceRect
viewControllerToPresent.popoverPresentationController?.sourceView = sourceView ?? view
viewControllerToPresent.popoverPresentationController?.delegate = PanModalPresentationDelegate.default
} else {
viewControllerToPresent.modalPresentationStyle = .custom
viewControllerToPresent.transitioningDelegate = PanModalPresentationDelegate.default
}
present(viewControllerToPresent, animated: true, completion: nil)
}
}

View File

@ -0,0 +1,78 @@
//
// DimmedView.swift
// PanModal
//
// Copyright © 2017 Tiny Speck, Inc. All rights reserved.
//
import UIKit
/**
A dim view for use as an overlay over content you want dimmed.
*/
public class DimmedView: UIView {
/**
Represents the possible states of the dimmed view.
max, off or a percentage of dimAlpha.
*/
enum DimState {
case max
case off
case percent(CGFloat)
}
// MARK: - Properties
/**
The state of the dimmed view
*/
var dimState: DimState = .off {
didSet {
switch dimState {
case .max:
alpha = dimAlpha
case .off:
alpha = 0.0
case .percent(let percentage):
let val = max(0.0, min(1.0, percentage))
alpha = dimAlpha * val
}
}
}
/**
The closure to be executed when a tap occurs
*/
var didTap: ((_ recognizer: UIGestureRecognizer) -> Void)?
/**
Tap gesture recognizer
*/
private lazy var tapGesture: UIGestureRecognizer = {
return UITapGestureRecognizer(target: self, action: #selector(didTapView))
}()
private let dimAlpha: CGFloat
// MARK: - Initializers
init(dimAlpha: CGFloat = 0.7) {
self.dimAlpha = dimAlpha
super.init(frame: .zero)
alpha = 0.0
backgroundColor = .black
addGestureRecognizer(tapGesture)
}
required public init?(coder aDecoder: NSCoder) {
fatalError()
}
// MARK: - Event Handlers
@objc private func didTapView() {
didTap?(tapGesture)
}
}

View File

@ -0,0 +1,39 @@
//
// PanContainerView.swift
// PanModal
//
// Copyright © 2018 Tiny Speck, Inc. All rights reserved.
//
import UIKit
/**
A view wrapper around the presented view in a PanModal transition.
This allows us to make modifications to the presented view without
having to do those changes directly on the view
*/
class PanContainerView: UIView {
init(presentedView: UIView, frame: CGRect) {
super.init(frame: frame)
addSubview(presentedView)
}
required init?(coder aDecoder: NSCoder) {
fatalError()
}
}
extension UIView {
/**
Convenience property for retrieving a PanContainerView instance
from the view hierachy
*/
var panContainerView: PanContainerView? {
return subviews.compactMap({ $0 as? PanContainerView }).first
}
}

140
README.md Normal file
View File

@ -0,0 +1,140 @@
<p align="center">
<img src="https://github.com/slackhq/PanModal/raw/master/Screenshots/panModal.gif" width="30%" height="30%" alt="Screenshot Preview" />
</p>
<p align="center">
<img src="https://img.shields.io/badge/Platform-iOS_10+-green.svg" alt="Platform: iOS 10.0+" />
<a href="https://developer.apple.com/swift" target="_blank"><img src="https://img.shields.io/badge/Language-Swift_4-blueviolet.svg" alt="Language: Swift 4" /></a>
<a href="https://cocoapods.org/pods/PanModal" target="_blank"><img src="https://img.shields.io/badge/CocoaPods-v1.0-red.svg" alt="CocoaPods compatible" /></a>
<a href="https://github.com/Carthage/Carthage" target="_blank"><img src="https://img.shields.io/badge/Carthage-compatible-blue.svg" alt="Carthage compatible" /></a>
<img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License: MIT" />
</p>
<p align="center">
<a href="#features">Features</a>
<a href="#compatibility">Compatibility</a>
<a href="#installation">Installation</a>
<a href="#usage">Usage</a>
<a href="#documentation">Documentation</a>
<a href="#contributing">Contributing</a>
<a href="#authors">Authors</a>
<a href="#license">License</a>
</p>
## Features
* Supports any subclass of `UIViewController`
* Seamless transition between modal and content
* Maintains 60 fps performance
## Compatibility
PanModal requires **iOS 10+** and is compatible with **Swift 4.2** projects.
## Installation
* <a href="https://guides.cocoapods.org/using/using-cocoapods.html" target="_blank">CocoaPods</a>:
```ruby
pod 'PanModal'
```
* <a href="https://github.com/Carthage/Carthage" target="_blank">Carthage</a>:
```ruby
github "slack/PanModal"
```
## Usage
PanModal was designed to be used effortlessly. Simply call `presentPanModal` in the same way you would expect to present a `UIViewController`
```swift
viewControllerA.presentPanModal(viewControllerB)
```
The presented view controller must conform to `PanModalPresentable` to take advantage of the customizable options
```swift
extension ViewControllerB: PanModalPresentable {
var panScrollable: UIScrollView? {
return nil
}
}
```
### PanScrollable
If your view controller has an embedded `UIScrollView` e.g. as is the case with `UITableViewController`, panModal will seamlessly transition pan gestures between the modal and the scroll view
```swift
class ViewControllerC: UITableViewController, PanModalPresentable {
var panScrollable: UIScrollView? {
return tableView
}
}
```
### Adjusting Heights
Height values of the panModal can be adjusted by overriding `shortFormHeight` or `longFormHeight`
```swift
extension ViewControllerC: PanModalPresentable {
var shortFormHeight: PanModalHeight {
return .contentHeight(300)
}
var longFormHeight: PanModalHeight {
return .maxHeightWithTopInset(40)
}
}
```
### Updates at Runtime
Values are stored during presentation, so when adjusting at runtime you should call `panModalSetNeedsLayoutUpdate()`
```swift
func viewDidLoad() {
hasLoaded = true
panModalSetNeedsLayoutUpdate()
panModalTransition(to: .shortForm)
}
var shortFormHeight: PanModalHeight {
if hasLoaded {
return .contentHeight(200)
}
return .maxHeight
}
```
### Sample App
Check out the [Sample App](https://github.com/slackhq/PanModal/tree/master/Sample) for more complex configurations of `PanModalPresentable`, including navigation controllers and stacked modals.
## Documentation
Option + click on any of PanModal's methods or notes for detailed documentation.
<p align="left">
<img src="https://github.com/slackhq/PanModal/blob/master/Screenshots/documentation.png" width="50%" height="50%" alt="Screenshot Preview" />
</p>
## Contributing
We're glad to be open sourcing this library. We use it in numerous places within the slack app and expect it to be easy to use as well as modify; we've added extensive documentation within the code to support that.
We will only be fixing critical bugs, thus, for any non-critical issues or feature requests we hope to be able to rely on the community using the library to add what they need. We encourage folks to create forks and are willing to review PRs created by the community. For more information, please read the [contributing guidelines](https://github.com/slackhq/PanModal/blob/master/CONTRIBUTING.md).
## Authors
[Stephen Sowole](https://github.com/tun57) • [Tosin Afolabi](https://github.com/tosinaf)
## License
<b>PanModal</b> is released under a MIT License. See LICENSE file for details.

22
Sample/AppDelegate.swift Normal file
View File

@ -0,0 +1,22 @@
//
// AppDelegate.swift
// PanModal
//
// Created by Stephen Sowole on 10/9/18.
// Copyright © 2018 PanModal. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = UINavigationController(rootViewController: SampleViewController())
window?.makeKeyAndVisible()
return true
}
}

View File

@ -0,0 +1,158 @@
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@3x.png",
"scale" : "3x"
},
{
"size" : "57x57",
"idiom" : "iphone",
"filename" : "Icon-App-57x57@1x.png",
"scale" : "1x"
},
{
"size" : "57x57",
"idiom" : "iphone",
"filename" : "Icon-App-57x57@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@3x.png",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@1x.png",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@1x.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "50x50",
"idiom" : "ipad",
"filename" : "Icon-Small-50x50@1x.png",
"scale" : "1x"
},
{
"size" : "50x50",
"idiom" : "ipad",
"filename" : "Icon-Small-50x50@2x.png",
"scale" : "2x"
},
{
"size" : "72x72",
"idiom" : "ipad",
"filename" : "Icon-App-72x72@1x.png",
"scale" : "1x"
},
{
"size" : "72x72",
"idiom" : "ipad",
"filename" : "Icon-App-72x72@2x.png",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@1x.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@2x.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "Icon-App-83.5x83.5@2x.png",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "ItunesArtwork@2x.png",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,52 @@
{
"images" : [
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "2436h",
"filename" : "iPhoneX_LaunchScreen_Placeholder.png",
"minimum-system-version" : "11.0",
"orientation" : "portrait",
"scale" : "3x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "736h",
"filename" : "iPhone6Plus_LaunchScreen_Placeholder.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "3x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "667h",
"filename" : "iPhone6_LaunchScreen_Placeholder.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"filename" : "iPhone4_LaunchScreen_Placeholder.png",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "retina4",
"filename" : "iPhone5_LaunchScreen_Placeholder.png",
"minimum-system-version" : "7.0",
"orientation" : "portrait",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIAppFonts</key>
<array>
<string>Lato-Regular.ttf</string>
<string>Lato-Bold.ttf</string>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIRequiresFullScreen</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 KiB

View File

@ -0,0 +1,110 @@
//
// SampleViewController.swift
// PanModal
//
// Created by Stephen Sowole on 10/9/18.
// Copyright © 2018 PanModal. All rights reserved.
//
import UIKit
class SampleViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
setupView()
}
private func setupView() {
title = "PanModal"
navigationController?.navigationBar.titleTextAttributes = [
.font: UIFont(name: "Lato-Bold", size: 17)!
]
tableView.register(UITableViewCell.self, forCellReuseIdentifier: String(describing: UITableViewCell.self))
tableView.tableFooterView = UIView()
tableView.separatorInset = .zero
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 60.0
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return RowType.allCases.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: UITableViewCell.self), for: indexPath)
guard let rowType = RowType(rawValue: indexPath.row) else {
return cell
}
cell.textLabel?.textAlignment = .center
cell.textLabel?.text = rowType.presentable.string
cell.textLabel?.font = UIFont(name: "Lato-Regular", size: 17.0)
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
guard let rowType = RowType(rawValue: indexPath.row) else {
return
}
presentPanModal(rowType.presentable.rowVC)
}
}
protocol RowPresentable {
var string: String { get }
var rowVC: PanModalPresentable.LayoutType { get }
}
private extension SampleViewController {
enum RowType: Int, CaseIterable {
case basic
case transparent
case userGroups
case stacked
case navController
var presentable: RowPresentable {
switch self {
case .basic: return Basic()
case .transparent: return Transparent()
case .userGroups: return UserGroup()
case .stacked: return Stacked()
case .navController: return Navigation()
}
}
struct Basic: RowPresentable {
var string: String { return "Basic" }
var rowVC: PanModalPresentable.LayoutType { return BasicViewController() }
}
struct Transparent: RowPresentable {
var string: String { return "Alert" }
var rowVC: PanModalPresentable.LayoutType { return AlertViewController() }
}
struct UserGroup: RowPresentable {
var string: String { return "User Groups" }
var rowVC: PanModalPresentable.LayoutType { return UserGroupViewController() }
}
struct Navigation: RowPresentable {
var string: String { return "User Groups (NavigationController)" }
var rowVC: PanModalPresentable.LayoutType { return NavigationController() }
}
struct Stacked: RowPresentable {
var string: String { return "User Groups (Stacked)" }
var rowVC: PanModalPresentable.LayoutType { return UserGroupStackedViewController() }
}
}
}

View File

@ -0,0 +1,86 @@
//
// AlertViewController.swift
// PanModal
//
// Created by Stephen Sowole on 2/26/19.
// Copyright © 2019 PanModal. All rights reserved.
//
import UIKit
class AlertViewController: UIViewController {
private let alertView: UIView = {
let alertView = UIView()
alertView.backgroundColor = #colorLiteral(red: 0.1019607843, green: 0.1137254902, blue: 0.1294117647, alpha: 1)
alertView.layer.cornerRadius = 20.0
alertView.translatesAutoresizingMaskIntoConstraints = false
return alertView
}()
override func viewDidLoad() {
super.viewDidLoad()
setupView()
}
private func setupView() {
layoutAlertView()
layoutLabel()
}
private func layoutAlertView() {
view.addSubview(alertView)
alertView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
alertView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20).isActive = true
alertView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20).isActive = true
if #available(iOS 11.0, *) {
let constant: CGFloat = UIApplication.shared.keyWindow?.safeAreaInsets.bottom == 0 ? -20 : 0
alertView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: constant).isActive = true
} else {
alertView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -20).isActive = true
}
}
private func layoutLabel() {
let label = UILabel()
label.text = "THIS IS AN EXAMPLE ALERT"
label.textColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
label.font = UIFont(name: "Lato-Bold", size: 16.0)
alertView.addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
label.centerXAnchor.constraint(equalTo: alertView.centerXAnchor).isActive = true
label.centerYAnchor.constraint(equalTo: alertView.centerYAnchor).isActive = true
}
}
extension AlertViewController: PanModalPresentable {
var panScrollable: UIScrollView? {
return nil
}
var shortFormHeight: PanModalHeight {
return .contentHeight(100)
}
var longFormHeight: PanModalHeight {
return shortFormHeight
}
var backgroundAlpha: CGFloat {
return 0.1
}
var shouldRoundTopCorners: Bool {
return false
}
var showDragIndicator: Bool {
return true
}
}

View File

@ -0,0 +1,32 @@
//
// BasicViewController.swift
// PanModal
//
// Created by Stephen Sowole on 2/26/19.
// Copyright © 2019 PanModal. All rights reserved.
//
import UIKit
class BasicViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = #colorLiteral(red: 0.1019607843, green: 0.1137254902, blue: 0.1294117647, alpha: 1)
}
}
extension BasicViewController: PanModalPresentable {
var panScrollable: UIScrollView? {
return nil
}
var longFormHeight: PanModalHeight {
return .maxHeightWithTopInset(200)
}
var anchorModalToLongForm: Bool {
return false
}
}

View File

@ -0,0 +1,73 @@
//
// NavigationController.swift
// PanModal
//
// Created by Stephen Sowole on 2/26/19.
// Copyright © 2019 PanModal. All rights reserved.
//
import UIKit
class NavigationController: UINavigationController, PanModalPresentable {
private let navGroups = NavUserGroups()
override func viewDidLoad() {
super.viewDidLoad()
pushViewController(navGroups, animated: false)
}
override func popViewController(animated: Bool) -> UIViewController? {
let vc = super.popViewController(animated: animated)
panModalSetNeedsLayoutUpdate()
return vc
}
override func pushViewController(_ viewController: UIViewController, animated: Bool) {
super.pushViewController(viewController, animated: animated)
panModalSetNeedsLayoutUpdate()
}
// MARK: - Pan Modal Presentable
var panScrollable: UIScrollView? {
return (topViewController as? PanModalPresentable)?.panScrollable
}
var longFormHeight: PanModalHeight {
return .maxHeight
}
var shortFormHeight: PanModalHeight {
return longFormHeight
}
}
private class NavUserGroups: UserGroupViewController {
override func viewDidLoad() {
super.viewDidLoad()
title = "iOS Engineers"
navigationController?.navigationBar.isTranslucent = false
navigationController?.navigationBar.titleTextAttributes = [
.font: UIFont(name: "Lato-Bold", size: 17)!,
.foregroundColor: #colorLiteral(red: 0.7019607843, green: 0.7058823529, blue: 0.7137254902, alpha: 1)
]
navigationController?.navigationBar.tintColor = #colorLiteral(red: 0.7019607843, green: 0.7058823529, blue: 0.7137254902, alpha: 1)
navigationController?.navigationBar.barTintColor = #colorLiteral(red: 0.1294117647, green: 0.1411764706, blue: 0.1568627451, alpha: 1)
navigationItem.backBarButtonItem = UIBarButtonItem(title:"", style: .plain, target: nil, action: nil)
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
let presentable = members[indexPath.row]
let viewController = ProfileViewController(presentable: presentable)
navigationController?.pushViewController(viewController, animated: true)
}
}

View File

@ -0,0 +1,90 @@
//
// ProfileViewController.swift
// PanModal
//
// Created by Tosin Afolabi on 2/26/19.
// Copyright © 2019 PanModal. All rights reserved.
//
import UIKit
class ProfileViewController: UIViewController {
// MARK: - Properties
let presentable: UserGroupMemberPresentable
// MARK: - Views
let avatarView: UIView = {
let view = UIView()
view.layer.cornerRadius = 6.0
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()
let nameLabel: UILabel = {
let label = UILabel()
label.textColor = #colorLiteral(red: 0.8196078431, green: 0.8235294118, blue: 0.8274509804, alpha: 1)
label.font = UIFont(name: "Lato-Bold", size: 20.0)
label.backgroundColor = .clear
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
let roleLabel: UILabel = {
let label = UILabel()
label.textColor = #colorLiteral(red: 0.7019607843, green: 0.7058823529, blue: 0.7137254902, alpha: 1)
label.backgroundColor = .clear
label.font = UIFont(name: "Lato-Regular", size: 16.0)
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
// MARK: - Initializers
init(presentable: UserGroupMemberPresentable) {
self.presentable = presentable
super.init(nibName: nil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - View Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
title = "Profile"
view.backgroundColor = #colorLiteral(red: 0.1019607843, green: 0.1137254902, blue: 0.1294117647, alpha: 1)
view.addSubview(avatarView)
view.addSubview(nameLabel)
view.addSubview(roleLabel)
nameLabel.text = presentable.name
roleLabel.text = presentable.role
avatarView.backgroundColor = presentable.avatarBackgroundColor
setupConstraints()
}
// MARK: - Layoutt
func setupConstraints() {
avatarView.widthAnchor.constraint(equalToConstant: 200.0).isActive = true
avatarView.heightAnchor.constraint(equalToConstant: 200.0).isActive = true
avatarView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
avatarView.topAnchor.constraint(equalTo: view.topAnchor, constant: 100.0).isActive = true
nameLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
nameLabel.topAnchor.constraint(equalTo: avatarView.bottomAnchor, constant: 60.0).isActive = true
roleLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
roleLabel.topAnchor.constraint(equalTo: nameLabel.bottomAnchor, constant: 8.0).isActive = true
}
}

View File

@ -0,0 +1,108 @@
//
// StackedProfileViewController.swift
// PanModal
//
// Created by Tosin Afolabi on 2/26/19.
// Copyright © 2019 PanModal. All rights reserved.
//
import UIKit
class StackedProfileViewController: UIViewController, PanModalPresentable {
// MARK: - Properties
let presentable: UserGroupMemberPresentable
// MARK: - Views
let avatarView: UIView = {
let view = UIView()
view.layer.cornerRadius = 6.0
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()
let nameLabel: UILabel = {
let label = UILabel()
label.textColor = #colorLiteral(red: 0.8196078431, green: 0.8235294118, blue: 0.8274509804, alpha: 1)
label.font = UIFont(name: "Lato-Bold", size: 20.0)
label.backgroundColor = .clear
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
let roleLabel: UILabel = {
let label = UILabel()
label.textColor = #colorLiteral(red: 0.7019607843, green: 0.7058823529, blue: 0.7137254902, alpha: 1)
label.backgroundColor = .clear
label.font = UIFont(name: "Lato-Regular", size: 15.0)
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
// MARK: - Initializers
init(presentable: UserGroupMemberPresentable) {
self.presentable = presentable
super.init(nibName: nil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - View Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
title = "Profile"
view.backgroundColor = #colorLiteral(red: 0.1019607843, green: 0.1137254902, blue: 0.1294117647, alpha: 1)
view.addSubview(avatarView)
view.addSubview(nameLabel)
view.addSubview(roleLabel)
nameLabel.text = presentable.name
roleLabel.text = presentable.role
avatarView.backgroundColor = presentable.avatarBackgroundColor
setupConstraints()
}
// MARK: - Layoutt
func setupConstraints() {
avatarView.widthAnchor.constraint(equalToConstant: 200.0).isActive = true
avatarView.heightAnchor.constraint(equalToConstant: 200.0).isActive = true
avatarView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
avatarView.topAnchor.constraint(equalTo: view.topAnchor, constant: 25.0).isActive = true
nameLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
nameLabel.topAnchor.constraint(equalTo: avatarView.bottomAnchor, constant: 20.0).isActive = true
roleLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
roleLabel.topAnchor.constraint(equalTo: nameLabel.bottomAnchor, constant: 4.0).isActive = true
}
// MARK: - Pan Modal Presentable
var panScrollable: UIScrollView? {
return nil
}
var longFormHeight: PanModalHeight {
return .contentHeight(300)
}
var anchorModalToLongForm: Bool {
return false
}
var shouldRoundTopCorners: Bool {
return true
}
}

View File

@ -0,0 +1,25 @@
//
// UserGroupStackedViewController.swift
// PanModal
//
// Created by Stephen Sowole on 2/26/19.
// Copyright © 2019 PanModal. All rights reserved.
//
import UIKit
class UserGroupStackedViewController: UserGroupViewController {
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
let presentable = members[indexPath.row]
let viewController = StackedProfileViewController(presentable: presentable)
presentPanModal(viewController)
}
override var shortFormHeight: PanModalHeight {
return longFormHeight
}
}

View File

@ -0,0 +1,17 @@
//
// UserGroupHeaderPresentable.swift
// PanModal
//
// Created by Tosin Afolabi on 2/26/19.
// Copyright © 2019 PanModal. All rights reserved.
//
import UIKit
struct UserGroupHeaderPresentable: Equatable {
let handle: String
let description: String
let memberCount: Int
}

View File

@ -0,0 +1,17 @@
//
// UserGroupMemberPresentable.swift
// PanModal
//
// Created by Tosin Afolabi on 2/26/19.
// Copyright © 2019 PanModal. All rights reserved.
//
import UIKit
struct UserGroupMemberPresentable: Equatable {
let name: String
let role: String
let avatarBackgroundColor: UIColor
}

View File

@ -0,0 +1,118 @@
//
// UserGroupViewController.swift
// PanModal
//
// Created by Tosin Afolabi on 2/26/19.
// Copyright © 2019 PanModal. All rights reserved.
//
import UIKit
class UserGroupViewController: UITableViewController, PanModalPresentable, UIGestureRecognizerDelegate {
let members: [UserGroupMemberPresentable] = [
UserGroupMemberPresentable(name: "Naida Schill ✈️", role: "Staff Engineer - Mobile DevXP", avatarBackgroundColor: #colorLiteral(red: 0.7215686275, green: 0.9098039216, blue: 0.5607843137, alpha: 1)),
UserGroupMemberPresentable(name: "Annalisa Doty", role: "iOS Engineer - NewXP", avatarBackgroundColor: #colorLiteral(red: 0.7176470588, green: 0.8784313725, blue: 0.9882352941, alpha: 1)),
UserGroupMemberPresentable(name: "Petra Gazaway 🏡", role: "Senior iOS Product Engineer - Enterprise", avatarBackgroundColor: #colorLiteral(red: 0.9725490196, green: 0.937254902, blue: 0.4666666667, alpha: 1)),
UserGroupMemberPresentable(name: "Jermaine Gill ⛷", role: "Staff Engineer - Mobile Infra", avatarBackgroundColor: #colorLiteral(red: 0.9490196078, green: 0.7568627451, blue: 0.9803921569, alpha: 1)),
UserGroupMemberPresentable(name: "Juana Brooks 🚌", role: "Staff Software Engineer", avatarBackgroundColor: #colorLiteral(red: 0.9960784314, green: 0.8823529412, blue: 0.6980392157, alpha: 1)),
UserGroupMemberPresentable(name: "Stacey Francis 🛳", role: "Senior iOS Engineer", avatarBackgroundColor: #colorLiteral(red: 0.8784313725, green: 0.8745098039, blue: 0.9921568627, alpha: 1)),
UserGroupMemberPresentable(name: "Frederick Vargas", role: "Senior iOS Engineer", avatarBackgroundColor: #colorLiteral(red: 0.7215686275, green: 0.9098039216, blue: 0.5607843137, alpha: 1)),
UserGroupMemberPresentable(name: "Michele Owens", role: "Senior iOS Engineer", avatarBackgroundColor: #colorLiteral(red: 0.7176470588, green: 0.8784313725, blue: 0.9882352941, alpha: 1)),
UserGroupMemberPresentable(name: "Freda Ramsey", role: "Senior iOS Engineer", avatarBackgroundColor: #colorLiteral(red: 0.9725490196, green: 0.937254902, blue: 0.4666666667, alpha: 1)),
UserGroupMemberPresentable(name: "Anita Thomas", role: "Senior iOS Engineer", avatarBackgroundColor: #colorLiteral(red: 0.9490196078, green: 0.7568627451, blue: 0.9803921569, alpha: 1)),
UserGroupMemberPresentable(name: "Leona Lane", role: "Senior iOS Engineer", avatarBackgroundColor: #colorLiteral(red: 0.9960784314, green: 0.8823529412, blue: 0.6980392157, alpha: 1)),
UserGroupMemberPresentable(name: "Chad Roy", role: "Senior iOS Engineer", avatarBackgroundColor: #colorLiteral(red: 0.8784313725, green: 0.8745098039, blue: 0.9921568627, alpha: 1)),
UserGroupMemberPresentable(name: "Joan Guzman", role: "Senior iOS Engineer", avatarBackgroundColor: #colorLiteral(red: 0.7215686275, green: 0.9098039216, blue: 0.5607843137, alpha: 1)),
UserGroupMemberPresentable(name: "Mike Yates", role: "Senior iOS Engineer", avatarBackgroundColor: #colorLiteral(red: 0.7176470588, green: 0.8784313725, blue: 0.9882352941, alpha: 1)),
UserGroupMemberPresentable(name: "Elbert Wilson", role: "Senior iOS Engineer", avatarBackgroundColor: #colorLiteral(red: 0.9725490196, green: 0.937254902, blue: 0.4666666667, alpha: 1)),
UserGroupMemberPresentable(name: "Anita Thomas", role: "Senior iOS Engineer", avatarBackgroundColor: #colorLiteral(red: 0.9490196078, green: 0.7568627451, blue: 0.9803921569, alpha: 1)),
UserGroupMemberPresentable(name: "Leona Lane", role: "Senior iOS Engineer", avatarBackgroundColor: #colorLiteral(red: 0.9960784314, green: 0.8823529412, blue: 0.6980392157, alpha: 1)),
UserGroupMemberPresentable(name: "Chad Roy", role: "Senior iOS Engineer", avatarBackgroundColor: #colorLiteral(red: 0.8784313725, green: 0.8745098039, blue: 0.9921568627, alpha: 1)),
UserGroupMemberPresentable(name: "Naida Schill", role: "Staff Engineer - Mobile DevXP", avatarBackgroundColor: #colorLiteral(red: 0.7215686275, green: 0.9098039216, blue: 0.5607843137, alpha: 1))
]
var isShortFormEnabled = true
let headerView = UserGroupHeaderView()
let headerPresentable = UserGroupHeaderPresentable.init(handle: "ios-engs", description: "iOS Engineers", memberCount: 10)
override func viewDidLoad() {
super.viewDidLoad()
setupTableView()
}
// MARK: - View Configurations
func setupTableView() {
tableView.separatorStyle = .none
tableView.backgroundColor = #colorLiteral(red: 0.1019607843, green: 0.1137254902, blue: 0.1294117647, alpha: 1)
tableView.register(UserGroupMemberCell.self, forCellReuseIdentifier: "cell")
}
// MARK: - UITableViewDataSource
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return members.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? UserGroupMemberCell
else { return UITableViewCell() }
cell.configure(with: members[indexPath.row])
return cell
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 60.0
}
// MARK: - UITableViewDelegate
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
headerView.configure(with: headerPresentable)
return headerView
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
}
// MARK: - Pan Modal Presentable
var panScrollable: UIScrollView? {
return tableView
}
var shortFormHeight: PanModalHeight {
return isShortFormEnabled ? .contentHeight(300.0) : longFormHeight
}
var scrollIndicatorInsets: UIEdgeInsets {
let bottomOffset = presentingViewController?.bottomLayoutGuide.length ?? 0
return UIEdgeInsets(top: headerView.frame.size.height, left: 0, bottom: bottomOffset, right: 0)
}
var anchorModalToLongForm: Bool {
return false
}
func shouldPrioritize(panModalGestureRecognizer: UIPanGestureRecognizer) -> Bool {
let location = panModalGestureRecognizer.location(in: view)
return headerView.frame.contains(location)
}
func willTransition(to state: PanModalPresentationController.PresentationState) {
guard isShortFormEnabled, case .longForm = state
else { return }
isShortFormEnabled = false
panModalSetNeedsLayoutUpdate()
}
}

View File

@ -0,0 +1,89 @@
//
// UserGroupHeaderView.swift
// PanModal
//
// Created by Tosin Afolabi on 2/26/19.
// Copyright © 2019 PanModal. All rights reserved.
//
import UIKit
class UserGroupHeaderView: UIView {
struct Constants {
static let contentInsets = UIEdgeInsets(top: 12.0, left: 16.0, bottom: 12.0, right: 16.0)
}
// MARK: - Views
let titleLabel: UILabel = {
let label = UILabel()
label.font = UIFont(name: "Lato-Bold", size: 17.0)
label.textColor = #colorLiteral(red: 0.8196078431, green: 0.8235294118, blue: 0.8274509804, alpha: 1)
return label
}()
let subtitleLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 2
label.textColor = #colorLiteral(red: 0.7019607843, green: 0.7058823529, blue: 0.7137254902, alpha: 1)
label.font = UIFont(name: "Lato-Regular", size: 13.0)
return label
}()
lazy var stackView: UIStackView = {
let stackView = UIStackView(arrangedSubviews: [titleLabel, subtitleLabel])
stackView.axis = .vertical
stackView.alignment = .leading
stackView.spacing = 4.0
stackView.translatesAutoresizingMaskIntoConstraints = false
return stackView
}()
let seperatorView: UIView = {
let view = UIView()
view.backgroundColor = #colorLiteral(red: 0.8196078431, green: 0.8235294118, blue: 0.8274509804, alpha: 1).withAlphaComponent(0.11)
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()
// MARK: - Initializers
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = #colorLiteral(red: 0.1019607843, green: 0.1137254902, blue: 0.1294117647, alpha: 1)
addSubview(stackView)
addSubview(seperatorView)
setupConstraints()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - Layout
func setupConstraints() {
stackView.topAnchor.constraint(equalTo: topAnchor, constant: Constants.contentInsets.top).isActive = true
stackView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: Constants.contentInsets.left).isActive = true
stackView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -Constants.contentInsets.right).isActive = true
stackView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -Constants.contentInsets.bottom).isActive = true
seperatorView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
seperatorView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true
seperatorView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
seperatorView.heightAnchor.constraint(equalToConstant: 1.0).isActive = true
}
// MARK: - View Configuration
func configure(with presentable: UserGroupHeaderPresentable) {
titleLabel.text = "@\(presentable.handle)"
subtitleLabel.text = "\(presentable.memberCount) members | \(presentable.description)"
}
}

View File

@ -0,0 +1,127 @@
//
// UserGroupMemberCell.swift
// PanModal
//
// Created by Tosin Afolabi on 2/26/19.
// Copyright © 2019 PanModal. All rights reserved.
//
import UIKit
class UserGroupMemberCell: UITableViewCell {
struct Constants {
static let contentInsets = UIEdgeInsets(top: 8.0, left: 16.0, bottom: 8.0, right: 16.0)
static let avatarSize = CGSize(width: 36.0, height: 36.0)
}
// MARK: - Properties
var presentable = UserGroupMemberPresentable(name: "", role: "", avatarBackgroundColor: .black)
// MARK: - Views
let avatarView: UIView = {
let view = UIView()
view.layer.cornerRadius = 8.0
return view
}()
let nameLabel: UILabel = {
let label = UILabel()
label.textColor = #colorLiteral(red: 0.8196078431, green: 0.8235294118, blue: 0.8274509804, alpha: 1)
label.font = UIFont(name: "Lato-Bold", size: 17.0)
label.backgroundColor = .clear
return label
}()
let roleLabel: UILabel = {
let label = UILabel()
label.textColor = #colorLiteral(red: 0.7019607843, green: 0.7058823529, blue: 0.7137254902, alpha: 1)
label.backgroundColor = .clear
label.font = UIFont(name: "Lato-Regular", size: 13.0)
return label
}()
lazy var memberDetailsStackView: UIStackView = {
let stackView = UIStackView(arrangedSubviews: [nameLabel, roleLabel])
stackView.axis = .vertical
stackView.alignment = .leading
stackView.translatesAutoresizingMaskIntoConstraints = false
return stackView
}()
lazy var stackView: UIStackView = {
let stackView = UIStackView(arrangedSubviews: [avatarView, memberDetailsStackView])
stackView.alignment = .center
stackView.spacing = 16.0
stackView.translatesAutoresizingMaskIntoConstraints = false
return stackView
}()
// MARK: - Initializers
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
backgroundColor = #colorLiteral(red: 0.1019607843, green: 0.1137254902, blue: 0.1294117647, alpha: 1)
isAccessibilityElement = true
let backgroundView = UIView()
backgroundView.backgroundColor = #colorLiteral(red: 0.8196078431, green: 0.8235294118, blue: 0.8274509804, alpha: 1).withAlphaComponent(0.11)
selectedBackgroundView = backgroundView
contentView.addSubview(stackView)
setupConstraints()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - Layout
func setupConstraints() {
stackView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: Constants.contentInsets.top).isActive = true
stackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: Constants.contentInsets.left).isActive = true
stackView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -Constants.contentInsets.right).isActive = true
stackView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -Constants.contentInsets.bottom).isActive = true
let avatarWidthConstriant = avatarView.widthAnchor.constraint(equalToConstant: Constants.avatarSize.width)
let avatarHeightConstraint = avatarView.heightAnchor.constraint(equalToConstant: Constants.avatarSize.height)
[avatarWidthConstriant, avatarHeightConstraint].forEach {
$0.priority = UILayoutPriority(UILayoutPriority.required.rawValue - 1)
$0.isActive = true
}
}
// MARK: - Highlight
/**
On cell selection or highlight, iOS makes all vies have a clear background
the below methods address the issue for the avatar view
*/
override func setHighlighted(_ highlighted: Bool, animated: Bool) {
super.setHighlighted(highlighted, animated: animated)
avatarView.backgroundColor = presentable.avatarBackgroundColor
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
avatarView.backgroundColor = presentable.avatarBackgroundColor
}
// MARK: - View Configuration
func configure(with presentable: UserGroupMemberPresentable) {
self.presentable = presentable
nameLabel.text = presentable.name
roleLabel.text = presentable.role
avatarView.backgroundColor = presentable.avatarBackgroundColor
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 747 KiB

BIN
Screenshots/panModal.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 MiB

22
Tests/Info.plist Normal file
View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

79
Tests/PanModalTests.swift Normal file
View File

@ -0,0 +1,79 @@
//
// PanModalTests.swift
// PanModalTests
//
// Created by Tosin Afolabi on 2/26/19.
// Copyright © 2019 PanModal. All rights reserved.
//
import XCTest
@testable import PanModal
/**
Run tests on iPhone 8 Sim
*/
class PanModalTests: XCTestCase {
class MockViewController: UIViewController, PanModalPresentable {
var panScrollable: UIScrollView? { return nil }
}
class AdjustedMockViewController: UITableViewController, PanModalPresentable {
var panScrollable: UIScrollView? { return tableView }
var shortFormHeight: PanModalHeight { return .contentHeight(300) }
var longFormHeight: PanModalHeight { return .maxHeightWithTopInset(50) }
// for testing purposes - to mimic safe area insets
var topLayoutOffset: CGFloat { return 20 }
var bottomLayoutOffset: CGFloat { return 44 }
}
private var vc: AdjustedMockViewController!
override func setUp() {
super.setUp()
vc = AdjustedMockViewController()
}
override func tearDown() {
super.tearDown()
vc = nil
}
func testPresentableDefaults() {
let vc = MockViewController()
XCTAssertEqual(vc.topOffset, 41.0)
XCTAssertEqual(vc.shortFormHeight, PanModalHeight.maxHeight)
XCTAssertEqual(vc.longFormHeight, PanModalHeight.maxHeight)
XCTAssertEqual(vc.springDamping, 0.8)
XCTAssertEqual(vc.backgroundAlpha, 0.7)
XCTAssertEqual(vc.scrollIndicatorInsets, .zero)
XCTAssertEqual(vc.anchorModalToLongForm, true)
XCTAssertEqual(vc.allowsExtendedPanScrolling, false)
XCTAssertEqual(vc.allowsDragToDismiss, true)
XCTAssertEqual(vc.isPanScrollEnabled, true)
XCTAssertEqual(vc.isHapticFeedbackEnabled, true)
XCTAssertEqual(vc.shouldRoundTopCorners, false)
XCTAssertEqual(vc.showDragIndicator, false)
XCTAssertEqual(vc.shouldRoundTopCorners, false)
}
func testPresentableYValues() {
XCTAssertEqual(vc.topLayoutOffset, 20)
XCTAssertEqual(vc.bottomLayoutOffset, 44)
XCTAssertEqual(vc.topMargin(from: .maxHeight), 0)
XCTAssertEqual(vc.topMargin(from: .maxHeightWithTopInset(40)), 40)
XCTAssertEqual(vc.topMargin(from: .contentHeight(200)), 447)
XCTAssertEqual(vc.topMargin(from: .contentHeightIgnoringSafeArea(200)), 447)
XCTAssertEqual(vc.shortFormYPos, 388)
XCTAssertEqual(vc.longFormYPos, 91)
XCTAssertEqual(vc.bottomYPos, vc.view.frame.height)
XCTAssertEqual(vc.view.frame.height, UIScreen.main.bounds.size.height - 20)
}
}