Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
davdroman committed Nov 8, 2022
1 parent 2df8cb1 commit 6e72e09
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
14 changes: 4 additions & 10 deletions Demo/Demo/Swing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ extension AnyNavigationTransition {

struct Swing: NavigationTransition {
var body: some NavigationTransition {
let angle = Angle(degrees: 70)
let offset: CGFloat = 150
let angle = 70.0
let offset = 150.0

Slide(axis: .horizontal)
MirrorPush {
OnInsertion {
Rotate(-angle)
Rotate(.degrees(-angle))
Offset(x: offset)
Opacity()
Scale(0.5)
}
OnRemoval {
Rotate(angle)
Rotate(.degrees(angle))
Offset(x: -offset)
}
}
Expand All @@ -32,9 +32,3 @@ struct Swing: NavigationTransition {
}
}
}

extension Angle {
static prefix func - (_ rhs: Self) -> Self {
.init(degrees: -rhs.degrees)
}
}
12 changes: 12 additions & 0 deletions Sources/AtomicTransition/AtomicTransition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,20 @@ public enum AtomicTransitionOperation {
case removal
}

/// Defines an `AtomicTransition` that can be mirrored. It is a specialized building block of `NavigationTransition`.
///
/// A transition that conform to these protocol expose a `Mirrored` associated type expressing the type resulting
/// from mirroring the transition.
public protocol MirrorableAtomicTransition: AtomicTransition {
associatedtype Mirrored: AtomicTransition

/// The mirrored transition.
///
/// > Note: A good indicator of a proper implementation for this function is that it should round-trip
/// > to its original value when called twice:
/// >
/// > ```swift
/// > Offset(x: 10).mirrored().mirrored() == Offset(x: 10)
/// > ```
func mirrored() -> Mirrored
}

0 comments on commit 6e72e09

Please sign in to comment.