Skip to content

Commit

Permalink
Improve configurability of animations (jjochen#134)
Browse files Browse the repository at this point in the history
* refactor JJActionItem scaling

* Add  slide animation (WIP)

* Simplify button animation handling

* Refactor configuration example

* fix pod lint warnings

* Simplify item animation handling (WIP)

* Add slide in opening styles

* fix lint warnings

* Refactor button animation configuration into separate class

* Refactor item animation configuration into separate class

* Use closures for item layout and item animation configuration

* Create separate classes for JJItemLayout and JJItemPreparation

* Slide  from edge of screen when sliding horizontally

* Fix item scaling

* Improve item scaling

* Fix and refactor animation configuration tests

* Place items on the inner side of the button when using circular layout

* Move code arround

* Documentation, swiftformat update

* Documentation and small improvements

* Update dependencies

* Animation Configuration: Increase nimble tolerance for snapshots

* Remove unused variable

* Configure codeclimate

* improve handling of animation settings

* fix comments
  • Loading branch information
jjochen authored Feb 28, 2018
1 parent f68e0e0 commit c730427
Show file tree
Hide file tree
Showing 96 changed files with 1,212 additions and 966 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ jobs:
- store_test_results: *xcpretty-reports


build-and-test-ios10-iphone7plus:
build-and-test-ios10-iphone7:
<<: *defaults

environment:
DESTINATION: platform=iOS Simulator,OS=10.3.1,name=iPhone 7 Plus
SIMULATOR: iPhone 7 Plus (10.3.1) [
DESTINATION: platform=iOS Simulator,OS=10.3.1,name=iPhone 7
SIMULATOR: iPhone 7 (10.3.1) [

steps:
- checkout
Expand Down Expand Up @@ -150,7 +150,7 @@ jobs:

- run:
name: Build Documentation
command: bundle exec rake build_documentation
command: bundle exec rake generate_documentation


swiftlint:
Expand Down Expand Up @@ -199,6 +199,6 @@ workflows:
- lint-podspec
- swiftlint
- build-and-test-ios11-iphonex
- build-and-test-ios10-iphone7plus
- build-and-test-ios10-iphone7
- build-documentation
- push-podspec: *filter-version-tags-only
24 changes: 23 additions & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
version: "2"
checks:
argument-count:
config:
threshold: 4
complex-logic:
config:
threshold: 4
file-lines:
config:
threshold: 1000
method-complexity:
config:
threshold: 5
method-count:
config:
threshold: 20
method-lines:
config:
threshold: 40
nested-control-flow:
config:
threshold: 4
exclude_patterns:
- "Example/Tests/"
- "Example/"
- "docs/"
18 changes: 13 additions & 5 deletions Example/JJFloatingActionButton.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
199592AC1FD73F070058BEFC /* JJFloatingActionButton.xib in Resources */ = {isa = PBXBuildFile; fileRef = 199592AB1FD73F070058BEFC /* JJFloatingActionButton.xib */; };
19B10AD81FFCEF0800D70C32 /* JJFloationgActionButtonDelegateMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19B10AD71FFCEF0800D70C32 /* JJFloationgActionButtonDelegateMock.swift */; };
19B10ADA1FFD1F5600D70C32 /* JJFloatingActionButtonPlacementSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19B10AD91FFD1F5600D70C32 /* JJFloatingActionButtonPlacementSpec.swift */; };
19D311DD200F8A630023477D /* CircularPopExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19D311DC200F8A630023477D /* CircularPopExampleViewController.swift */; };
19D311DD200F8A630023477D /* CircularExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19D311DC200F8A630023477D /* CircularExampleViewController.swift */; };
19D6CE7D2046C35F009F486D /* .codeclimate.yml in Resources */ = {isa = PBXBuildFile; fileRef = 19D6CE7C2046C35F009F486D /* .codeclimate.yml */; };
19E247E61FD7E6F6009A7BA1 /* JJActionItem.xib in Resources */ = {isa = PBXBuildFile; fileRef = 19E247E41FD7E6B5009A7BA1 /* JJActionItem.xib */; };
19E247E81FD83CA7009A7BA1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 198B66091FBAE904009A17F2 /* Assets.xcassets */; };
19EDBD4520285DF100559C37 /* AnimationConfigurationSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19EDBD4420285DF100559C37 /* AnimationConfigurationSpec.swift */; };
2239EB8C92AD42AB79A037CA /* Pods_JJFloatingActionButton_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 75526023A5E4A843EAE2F986 /* Pods_JJFloatingActionButton_Example.framework */; };
D9B3C9FC35FD2B2E58308A4C /* Pods_JJFloatingActionButton_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 47ADD51D359629C3321DB781 /* Pods_JJFloatingActionButton_Tests.framework */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -72,7 +74,7 @@
198B66231FBAEDD6009A17F2 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = text; lineEnding = 0; name = LICENSE; path = ../LICENSE; sourceTree = SOURCE_ROOT; tabWidth = 2; };
198B66241FBAEDD6009A17F2 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = net.daringfireball.markdown; lineEnding = 0; name = README.md; path = ../README.md; sourceTree = SOURCE_ROOT; tabWidth = 2; };
198B66261FBAEDD6009A17F2 /* Gemfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; fileEncoding = 4; indentWidth = 2; lineEnding = 0; name = Gemfile; path = ../Gemfile; sourceTree = SOURCE_ROOT; tabWidth = 2; };
198B66271FBAEDD7009A17F2 /* JJFloatingActionButton.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; fileEncoding = 4; indentWidth = 2; lineEnding = 0; name = JJFloatingActionButton.podspec; path = ../JJFloatingActionButton.podspec; sourceTree = SOURCE_ROOT; tabWidth = 2; };
198B66271FBAEDD7009A17F2 /* JJFloatingActionButton.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; fileEncoding = 4; indentWidth = 2; lineEnding = 0; name = JJFloatingActionButton.podspec; path = ../JJFloatingActionButton.podspec; sourceTree = SOURCE_ROOT; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
198B662D1FBAEE16009A17F2 /* .gitignore */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = text; lineEnding = 0; name = .gitignore; path = ../.gitignore; sourceTree = SOURCE_ROOT; tabWidth = 2; };
198B662E1FBAEE16009A17F2 /* .swift-version */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = text; lineEnding = 0; name = ".swift-version"; path = "../.swift-version"; sourceTree = SOURCE_ROOT; tabWidth = 2; };
198EA7E31FD73F6D00F7DA3E /* JJCircleView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = JJCircleView.xib; sourceTree = "<group>"; };
Expand All @@ -81,11 +83,13 @@
19B10AD71FFCEF0800D70C32 /* JJFloationgActionButtonDelegateMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JJFloationgActionButtonDelegateMock.swift; sourceTree = "<group>"; };
19B10AD91FFD1F5600D70C32 /* JJFloatingActionButtonPlacementSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JJFloatingActionButtonPlacementSpec.swift; sourceTree = "<group>"; };
19B10ADB1FFE692100D70C32 /* Rakefile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; fileEncoding = 4; indentWidth = 2; name = Rakefile; path = ../../Rakefile; sourceTree = "<group>"; tabWidth = 2; };
19D311DC200F8A630023477D /* CircularPopExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CircularPopExampleViewController.swift; sourceTree = "<group>"; };
19D311DC200F8A630023477D /* CircularExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CircularExampleViewController.swift; sourceTree = "<group>"; };
19D6CE7C2046C35F009F486D /* .codeclimate.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = .codeclimate.yml; path = ../../.codeclimate.yml; sourceTree = "<group>"; };
19DF53B81FF59AE5006E292F /* Package.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Package.swift; path = ../../Package.swift; sourceTree = "<group>"; };
19E247E41FD7E6B5009A7BA1 /* JJActionItem.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = JJActionItem.xib; sourceTree = "<group>"; };
19E247E91FD854B1009A7BA1 /* .github_changelog_generator */ = {isa = PBXFileReference; lastKnownFileType = text; name = .github_changelog_generator; path = ../../.github_changelog_generator; sourceTree = "<group>"; };
19E247EA1FD93525009A7BA1 /* .swiftlint.yml */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = text; name = .swiftlint.yml; path = ../../.swiftlint.yml; sourceTree = "<group>"; tabWidth = 2; };
19EDBD4420285DF100559C37 /* AnimationConfigurationSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimationConfigurationSpec.swift; sourceTree = "<group>"; };
47ADD51D359629C3321DB781 /* Pods_JJFloatingActionButton_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_JJFloatingActionButton_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
6332F06691AC394EF8E25D29 /* Pods-JJFloatingActionButton_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JJFloatingActionButton_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-JJFloatingActionButton_Tests/Pods-JJFloatingActionButton_Tests.release.xcconfig"; sourceTree = "<group>"; };
75526023A5E4A843EAE2F986 /* Pods_JJFloatingActionButton_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_JJFloatingActionButton_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -140,7 +144,7 @@
198B66001FBAE904009A17F2 /* AppDelegate.swift */,
198B66021FBAE904009A17F2 /* BasicsExampleViewController.swift */,
192D1B6F2003CB8A0093064F /* ConfigurationExampleViewController.swift */,
19D311DC200F8A630023477D /* CircularPopExampleViewController.swift */,
19D311DC200F8A630023477D /* CircularExampleViewController.swift */,
198B66041FBAE904009A17F2 /* InterfaceBuilderExampleViewController.swift */,
192D1B712003CB930093064F /* SingleItemExampleViewController.swift */,
192D1B6D2003C7440093064F /* Helper.swift */,
Expand All @@ -161,6 +165,7 @@
1952693F1FD7E4CD0053C785 /* JJCircleViewSpec.swift */,
19B10AD91FFD1F5600D70C32 /* JJFloatingActionButtonPlacementSpec.swift */,
198B66171FBAE904009A17F2 /* JJFloatingActionButtonSpec.swift */,
19EDBD4420285DF100559C37 /* AnimationConfigurationSpec.swift */,
1957C8C920128AD200F1574B /* JJFloatingActionButtonDelegateSpec.swift */,
1957C8C42012815000F1574B /* JJFloatingActionButtonAppearanceSpec.swift */,
1957C8C7201283EF00F1574B /* JJActionItemAppearanceSpec.swift */,
Expand All @@ -175,6 +180,7 @@
isa = PBXGroup;
children = (
193808CF1FBCA063002EF4C0 /* .codecov.yml */,
19D6CE7C2046C35F009F486D /* .codeclimate.yml */,
19E247E91FD854B1009A7BA1 /* .github_changelog_generator */,
198B662D1FBAEE16009A17F2 /* .gitignore */,
19B10AC21FF7BDDD00D70C32 /* .jazzy.yaml */,
Expand Down Expand Up @@ -321,6 +327,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
19D6CE7D2046C35F009F486D /* .codeclimate.yml in Resources */,
194504D42003D499003B205F /* LaunchScreen.storyboard in Resources */,
198B660A1FBAE904009A17F2 /* Assets.xcassets in Resources */,
198B66081FBAE904009A17F2 /* Main.storyboard in Resources */,
Expand Down Expand Up @@ -462,7 +469,7 @@
198B66031FBAE904009A17F2 /* BasicsExampleViewController.swift in Sources */,
192D1B702003CB8A0093064F /* ConfigurationExampleViewController.swift in Sources */,
192D1B6E2003C7440093064F /* Helper.swift in Sources */,
19D311DD200F8A630023477D /* CircularPopExampleViewController.swift in Sources */,
19D311DD200F8A630023477D /* CircularExampleViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -472,6 +479,7 @@
files = (
198B66181FBAE904009A17F2 /* JJFloatingActionButtonSpec.swift in Sources */,
19B10AD81FFCEF0800D70C32 /* JJFloationgActionButtonDelegateMock.swift in Sources */,
19EDBD4520285DF100559C37 /* AnimationConfigurationSpec.swift in Sources */,
195269411FD7E53B0053C785 /* JJCircleViewSpec.swift in Sources */,
195269431FD7E6200053C785 /* UIColorExtensionsSpec.swift in Sources */,
1957C8CA20128AD200F1574B /* JJFloatingActionButtonDelegateSpec.swift in Sources */,
Expand Down
1 change: 0 additions & 1 deletion Example/JJFloatingActionButton/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Expand Down
16 changes: 8 additions & 8 deletions Example/JJFloatingActionButton/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Floating Action Button with default configuration added programmatically" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="A5M-7J-77L" userLabel="Subtitle">
<rect key="frame" x="29.5" y="363" width="316" height="33.5"/>
<rect key="frame" x="29" y="363" width="316" height="33.5"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -194,8 +194,8 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Using .circularPop as opening style" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="lMu-eY-MIV" userLabel="Subtitle">
<rect key="frame" x="16" y="33.5" width="199" height="14.5"/>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Using a circular opening style" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="lMu-eY-MIV" userLabel="Subtitle">
<rect key="frame" x="16" y="33.5" width="167.5" height="14.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<nil key="textColor"/>
Expand Down Expand Up @@ -318,14 +318,14 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="Configuration" textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="15n-db-NNG" userLabel="Title">
<rect key="frame" x="82" y="312" width="210" height="43"/>
<rect key="frame" x="82.5" y="312" width="210" height="43"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Floating Action Button with custom configuration added programmatically" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ke7-Zv-Krw" userLabel="Subtitle">
<rect key="frame" x="27.5" y="363" width="319" height="33.5"/>
<rect key="frame" x="28.5" y="363" width="319" height="33.5"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -383,10 +383,10 @@
</objects>
<point key="canvasLocation" x="2758" y="-367"/>
</scene>
<!--Circular Pop-->
<!--Circular-->
<scene sceneID="hcS-Yf-PqW">
<objects>
<viewController storyboardIdentifier="CircularPopExampleViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="WKv-VT-tfa" userLabel="Circular Pop" customClass="CircularPopExampleViewController" customModule="JJFloatingActionButton_Example" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="CircularExampleViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="WKv-VT-tfa" userLabel="Circular" customClass="CircularExampleViewController" customModule="JJFloatingActionButton_Example" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="LLN-Dv-84i">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand All @@ -398,7 +398,7 @@
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Floating Action Button with custom configuration unsing .circularPop as itemOpeningStyle" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Hpi-MM-u7d" userLabel="Subtitle">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Floating Action Button with custom configuration unsing a circular opening style" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Hpi-MM-u7d" userLabel="Subtitle">
<rect key="frame" x="28" y="363" width="319" height="33.5"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import JJFloatingActionButton
import UIKit

internal class BasicsExampleViewController: UIViewController {

fileprivate let actionButton = JJFloatingActionButton()

override func viewDidLoad() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// CircularPopExampleViewController.swift
// CircularExampleViewController.swift
//
// Copyright (c) 2017-Present Jochen Pfeiffer
//
Expand All @@ -25,15 +25,16 @@
import JJFloatingActionButton
import UIKit

internal class CircularPopExampleViewController: UIViewController {

internal class CircularExampleViewController: UIViewController {
fileprivate let actionButton = JJFloatingActionButton()

override func viewDidLoad() {
super.viewDidLoad()

actionButton.itemOpeningStyle = .circularPop(radius: 120)
actionButton.buttonOpeningStyle = .rotate(angle: .pi / 4)
actionButton.itemAnimationConfiguration = .circularSlideIn(withRadius: 120)
actionButton.buttonAnimationConfiguration = .rotation(toAngle: .pi * 3 / 4)
actionButton.buttonAnimationConfiguration.opening.duration = 0.8
actionButton.buttonAnimationConfiguration.closing.duration = 0.6

actionButton.addItem(image: #imageLiteral(resourceName: "Baloon")) { item in
Helper.showAlert(for: item)
Expand Down
Loading

0 comments on commit c730427

Please sign in to comment.