

GitHub - cashapp/stagehand: Modern, type-safe API for building animations on iOS
source link: https://github.com/cashapp/stagehand
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md
Stagehand
Stagehand provides a modern, type-safe API for building animations on iOS. Stagehand is designed around a set of core ideas:
- Composition of Structures
- Separation of Construction and Execution
- Compiler Safety
- Testability
Installation
Stagehand is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Stagehand', '~> 1.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.
Recommend
-
24
SQLDelight See the project website for documentation and APIs SQLDelight generates typesafe kotlin APIs from your SQL statements. It veri...
-
47
C++ has a very powerful type system. More often than not, however, this type system goes underutilized, leading to error-prone code and preventable bugs. Of late, I've been working through Peter Shirley's book,
-
34
SQLDelight - Generates typesafe Kotlin APIs from SQL - cashapp/sqldelight
-
5
Improving Animations on iOS with Stagehand Adding animations to your app turns a fairly routine interaction into a more enjoyable, exciting experience. These animations make a straightforward design into something that feels polis...
-
14
Building Interactive Ionic Apps with Gestures and Animations This is a guest post from Simon Grimm, Ionic Developer Expert and educator at the Ionic Academy. Simon also created the
-
7
0:00 / 41:44 ...
-
5
POSTED ON JULY 18, 2022 TO Android, DevInfra,
-
3
US Financial Watchdog: Money Stored in Venmo/PayPal/CashApp Isn't Federally Insured
-
7
-
7
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK