Build complex, conducted animations declaratively without manually managing state.

Related tags

Animation maestro
Overview

Maestro

Build complex, conducted animations declaratively without manually managing state.

Code
struct AnimatedPieChart: View {

    private enum Trim<T>: AnimationKey {
        typealias Value = Double
    }

    private enum FirstSegmentStart { }
    private enum FirstSegmentEnd { }
    private enum SecondSegmentStart { }
    private enum SecondSegmentEnd { }
    private enum ThirdSegmentStart { }
    private enum ThirdSegmentEnd { }

    @State private var conductor = AnimationConductor(.concurrent, delay: 5) {
        Animate<Trim<FirstSegmentEnd>>(to: 0.96, curve: .easeInOut, duration: 2.5)
        Animate<Trim<FirstSegmentStart>>(to: 0.62, curve: .easeInOut, duration: 1.5)
            .delayed(by: 1)
        AnimateConcurrently {
            Animate<Trim<SecondSegmentEnd>>(to: 0.58, curve: .easeInOut, duration: 1.25)
            Animate<Trim<SecondSegmentStart>>(to: 0.33, curve: .easeInOut, duration: 0.75)
                .delayed(by: 0.5)
        }
        .delayed(by: 1.25)
        AnimateConcurrently {
            Animate<Trim<ThirdSegmentEnd>>(to: 0.29, curve: .easeInOut, duration: 0.75)
            Animate<Trim<ThirdSegmentStart>>(to: 0.18, curve: .easeInOut, duration: 0.5)
                .delayed(by: 0.25)
        }
        .delayed(by: 1.75)
    }

    var body: some View {
        ConductedView($conductor) { context in
            ZStack {
                AnimatableArc(padding: 32)
                    .trim(from: context[Trim<FirstSegmentStart>.self], to: context[Trim<FirstSegmentEnd>.self])
                    .stroke(style: StrokeStyle(lineWidth: 36, lineCap: .round, lineJoin: .round))
                    .foregroundColor(.pink)
                    .shadow(radius: 8)
                AnimatableArc(padding: 32)
                    .trim(from: context[Trim<SecondSegmentStart>.self], to: context[Trim<SecondSegmentEnd>.self])
                    .stroke(style: StrokeStyle(lineWidth: 36, lineCap: .round, lineJoin: .round))
                    .foregroundColor(.orange)
                    .shadow(radius: 8)
                AnimatableArc(padding: 32)
                    .trim(from: context[Trim<ThirdSegmentStart>.self], to: context[Trim<ThirdSegmentEnd>.self])
                    .stroke(style: StrokeStyle(lineWidth: 36, lineCap: .round, lineJoin: .round))
                    .foregroundColor(.purple)
                    .shadow(radius: 8)
            }
        }
    }

}
Result

Getting Started

Documentation is a work-in-progress and I am experimenting with setting up DocC documentation via GitHub pages (which may or may not be possible.) There are some varying code examples available under the documentation resources folder. Along with releases you can find the exported DocC archive, which you can download and open with Xcode's documentation browser. The DocC documentation currently includes the information automatically generated from the source code's header documentation.

Important

Maestro is currently in a pre-release state, specifically because it uses a private API for timing functions. There are solutions available publicly which don't involve using a private API, so once timing functions are rewritten the library will be production-ready. You can still use the library for experimentation or hobby projects, but including it in a production project comes with inherent risk.

Requirements

SDK

  • Xcode 13
  • Swift 5.5

Deployment targets

  • iOS 14.0+
  • tvOS 14.0+
  • watchOS 7.0+
  • macOS 11.0+

Installation

Swift Package Manager

From an Xcode project, you can find the interface for adding a Swift package under the Xcode project's "Swift Packages" tab. Once there, search for the URL of this reposistory, and follow the dialogs to add it to your project.

Add the following dependency to your Package.swift file:

.package(url: "https://github.com/rpwachowski/maestro", from: "0.1.0")

Then, include it as a dependency of your target:

// swift-tools-version:5.5

import PackageDescription

let package = Package(
    name: "Example",
    dependencies: [
        .package(url: "https://github.com/rpwachowski/maestro", from: "0.1.0")
    ],
    targets: [
        .target(name: "Example", dependencies: ["Maestro"])
    ]
)

Carthage

Not yet implemented

Cocoapods

Not yet implemented
You might also like...
Protoyping-Project WallAngle - With this App, you can measure the angle without searching for tools and calculations
Protoyping-Project WallAngle - With this App, you can measure the angle without searching for tools and calculations

Protoyping-Project_WallAngle This is the App that I made for the Prototyping Pro

Get a remote image's size and type without downloading the full image

FastImage FastImage 2.0 is an Swift port of the Ruby project by Stephen Sykes. It's directive is to request as little data as possible (usually just t

Physics-based animations for iOS, tvOS, and macOS.

Advance An animation library for iOS, tvOS, and macOS that uses physics-based animations (including springs) to power interactions that move and respo

Ease is an event driven animation system that combines the observer pattern with custom spring animations as observers
Ease is an event driven animation system that combines the observer pattern with custom spring animations as observers

Ease is an event driven animation system that combines the observer pattern with custom spring animations as observers. It's magic. Features Animate a

Advanced Natural Motion Animations, Simple Blocks Based Syntax
Advanced Natural Motion Animations, Simple Blocks Based Syntax

FlightAnimator Moved to Swift 3.1 Support: For Swift 3.1 - Use tag Version 0.9.9 See Installation Instructions for clarification Introduction FlightAn

Swift interpolation for gesture-driven animations
Swift interpolation for gesture-driven animations

Interpolate Interpolate is a powerful Swift interpolation framework for creating interactive gesture-driven animations. Usage The 🔑 idea of Interpola

An iOS library to natively render After Effects vector animations
An iOS library to natively render After Effects vector animations

Lottie for iOS, macOS (and Android and React Native) View documentation, FAQ, help, examples, and more at airbnb.io/lottie Lottie is a mobile library

A library to simplify iOS animations in Swift.

Updated for Swift 4.2 Requires Xcode 10 and Swift 4.2. Installation Drop in the Spring folder to your Xcode project (make sure to enable "Copy items i

Swift library for choreographing animations on the screen.
Swift library for choreographing animations on the screen.

Spruce iOS Animation Library (and Android) What is it? Spruce is a lightweight animation library that helps choreograph the animations on the screen.

Comments
  • Implement pausing

    Implement pausing

    • Introduces option to control whether an animation should be paused at initialization
    • Introduces function for pausing an animation
    • Fixes frame length calculations across platforms
    opened by rpwachowski 0
Releases(0.2.0)
Owner
Ryan Wachowski
ya'll'ready know what it is
Ryan Wachowski
Simple UIButton subclass with additional state change animations (e.g. backgroundColor) and missing features

SimpleButton UIButton subclass with animated, state-aware attributes. Easy to subclass and configure! Full API docs Usage Just create your own SimpleB

Andreas Tinoco Lobo 169 Sep 14, 2022
A UICollectionViewLayout subclass that adds custom transitions/animations to the UICollectionView without effecting your existing code.

AnimatedCollectionViewLayout Normally a UICollectionView has no transition effects when you scroll from one item to another. There are lots of ways to

Jin Wang 4.5k Jan 1, 2023
Chain multiple UIView animations without endlessly nesting in completion closures.

⛓ Chain multiple UIView animations without endlessly nesting in completion closures. Used in some of the more superfluous animations in the OK Video app.

Pim 78 Dec 26, 2022
A collection of animations for iOS. Simple, just add water animations.

DCAnimationKit A collection of animations for iOS Simply, just add water! DCAnimationKit is a category on UIView to make animations easy to perform. E

Dalton 797 Sep 23, 2022
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey ?? to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

Sagaya Abdulhafeez 150 Dec 23, 2021
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey ?? to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

Sagaya Abdulhafeez 150 Dec 23, 2021
Easily build advanced custom animations on iOS.

INTUAnimationEngine makes it easy to build advanced custom animations on iOS. INTUAnimationEngine provides a friendly interface to drive custom animat

Intuit 1.1k Dec 14, 2022
Pure SwiftUI state-driven library to present view sequences and hierarchies.

PathPresenter swiftUIOnboarding.mp4 Pure SwiftUI routing with transitions, animations, and .sheet() support. In SwiftUI, View is a function of the sta

Aleksandr Dremov 21 Nov 15, 2022
MGFlipView allows to create flipping view in easy way without worrying about flipping animation and flipping logic.

MGFlipView About If you are looking for an easy way of implement 3D flipping view, you are in the right place. MGFlipView allows to create flipping vi

Maciej Gomółka 47 Sep 28, 2022