All Projects → cashapp → Stagehand

cashapp / Stagehand

Licence: apache-2.0
Modern, type-safe API for building animations on iOS

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Stagehand

Notificationbanner
The easiest way to display highly customizable in app notification banners in iOS
Stars: ✭ 4,307 (+3887.96%)
Mutual labels:  ios-animation
Cariocamenu
The fastest zero-tap iOS menu.
Stars: ✭ 785 (+626.85%)
Mutual labels:  ios-animation
Rpmodalgesturetransition
You can dismiss modal by using gesture 👆 📱
Stars: ✭ 90 (-16.67%)
Mutual labels:  ios-animation
Hero
Elegant transition library for iOS & tvOS
Stars: ✭ 20,547 (+18925%)
Mutual labels:  ios-animation
Iosproject
iOS project of collected some demos for iOS App, use Objective-C
Stars: ✭ 5,357 (+4860.19%)
Mutual labels:  ios-animation
Lihalert
Advance animated alerts for iOS written in Swift
Stars: ✭ 34 (-68.52%)
Mutual labels:  ios-animation
Jthamburgerbutton
An animated hamburger button for iOS.
Stars: ✭ 358 (+231.48%)
Mutual labels:  ios-animation
Nvactivityindicatorview
A collection of awesome loading animations
Stars: ✭ 10,031 (+9187.96%)
Mutual labels:  ios-animation
Macaw
Powerful and easy-to-use vector graphics Swift library with SVG support
Stars: ✭ 5,756 (+5229.63%)
Mutual labels:  ios-animation
Fsdairportfliplabel
UILabel like old Airport flipping labels
Stars: ✭ 79 (-26.85%)
Mutual labels:  ios-animation
Lottie Ios
An iOS library to natively render After Effects vector animations
Stars: ✭ 22,295 (+20543.52%)
Mutual labels:  ios-animation
Pinterestsegment
A Pinterest-like segment control with masking animation.
Stars: ✭ 560 (+418.52%)
Mutual labels:  ios-animation
Sizeslidebutton
A fun Swift UIControl for picking a size
Stars: ✭ 46 (-57.41%)
Mutual labels:  ios-animation
Chromacolorpicker
🎨 An intuitive iOS color picker built in Swift.
Stars: ✭ 434 (+301.85%)
Mutual labels:  ios-animation
Tkrubberindicator
A rubber animation pagecontrol
Stars: ✭ 1,337 (+1137.96%)
Mutual labels:  ios-animation
Jzmultichoicescirclebutton
🔘 Multi choice circle button with cool 3d parallax effect, but seriously don't use this in production now, I will rewrite it to a delegate based UIControl when I am available.
Stars: ✭ 380 (+251.85%)
Mutual labels:  ios-animation
Tkswitchercollection
An animation switch collection
Stars: ✭ 877 (+712.04%)
Mutual labels:  ios-animation
Awesome Ios
A curated list of awesome iOS ecosystem, including Objective-C and Swift Projects
Stars: ✭ 38,720 (+35751.85%)
Mutual labels:  ios-animation
Tkdotsegment
TKDotSegment is a segment with dot animation
Stars: ✭ 103 (-4.63%)
Mutual labels:  ios-animation
Loadingshimmer
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.
Stars: ✭ 1,180 (+992.59%)
Mutual labels:  ios-animation

Stagehand

CI Status Version License Platform

Stagehand provides a modern, type-safe API for building animations on iOS. Stagehand is designed around a set of core ideas:

  • Composition of Structures - Stagehand makes it easy to build complex, multi-part animations that are built from small, reusable pieces that are easier to reason about.
  • Separation of Construction and Execution - Stagehand provides separate mechanisms for the construction and execution, which increases the flexibility of animations and makes concepts like queuing a series of animations work straight out of the box.
  • Compile-Time Safety - Stagehand uses modern Swift features to provide a compile-time safe API for defining animations.
  • Testability - Stagehand builds on the concept of snapshot testing to introduce a visual testing paradigm for animations.

Installation

CocoaPods

To install Stagehand via CocoaPods, simply add the following line to your Podfile:

pod 'Stagehand'

To install StagehandTesting, the animation snapshot testing utilities, add the following line to your test target definition in your Podfile:

pod 'StagehandTesting'

By default, this will use Point-Free's SnapshotTesting to record snapshots and perform comparisons. To instead use Uber's iOSSnapshotTestCase as the snapshotting engine, set your test target dependency to use the iOSSnapshotTestCase subspec.

pod 'StagehandTesting/iOSSnapshotTestCase'

Swift Package Manager

To install Stagehand via Swift Package Manager, add the following to your Package.swift:

dependencies: [
    .package(url: "https://github.com/cashapp/stagehand", from: "4.0.0"),
],

Getting Started with Stagehand

An animation begins with the construction of an Animation. An Animation is generic over a type of element and acts as a definition of how that element should be animated.

As an example, we can write an animation that highlights a view by fading its alpha to 0.8 and back:

var highlightAnimation = Animation<UIView>()
highlightAnimation.addKeyframe(for: \.alpha, at: 0, value: 1)
highlightAnimation.addKeyframe(for: \.alpha, at: 0.5, value: 0.8)
highlightAnimation.addKeyframe(for: \.alpha, at: 1, value: 1)

Let's say we've defined a view, which we'll call BinaryView, that has two subviews, leftView and rightView, and we want to highlight each of the subviews in sequence. We can define an animation for our BinaryView with two child animations:

var binaryAnimation = Animation<BinaryView>()
binaryAnimation.addChild(highlightAnimation, for: \.leftView, startingAt: 0, relativeDuration: 0.5)
binaryAnimation.addChild(highlightAnimation, for: \.rightView, startingAt: 0.5, relativeDuration: 0.5)

Once we've set up our view and we're ready to execute our animation, we can call the perform method to start animating:

let view = BinaryView()
// ...

binaryAnimation.perform(on: view)

Running the Demo App

Stagehand ships with a demo app that shows examples of many of the features provided by Stagehand. To run the demo app, open the Example directory and run:

bundle install
bundle exec pod install
open Stagehand.xcworkspace

From here, you can run the demo app and see a variety of examples for how to use the framework. In that workspace, there is also a playground that includes documentation and tutorials for how each feature works.

Contributing

We’re glad you’re interested in Stagehand, and we’d love to see where you take it. Please read our contributing guidelines prior to submitting a Pull Request.

License

Copyright 2020 Square, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].