Skip to content

Commit

Permalink
Define transition and animation delay as constants
Browse files Browse the repository at this point in the history
  • Loading branch information
salimbraksa committed May 9, 2024
1 parent 8213bfd commit fc2c176
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,17 @@ private struct Container<T: View, V: View>: View {
let icon: V
let content: T

private var transition: AnyTransition = .opacity

private let animationDuration = 0.25

private var animation: Animation {
private let insertionAnimationDelay = 0.8

private var insertionAnimation: Animation {
return removalAnimation.delay(insertionAnimationDelay)
}

private var removalAnimation: Animation {
return .smooth(duration: animationDuration)
}

Expand All @@ -56,8 +64,8 @@ private struct Container<T: View, V: View>: View {
.padding(.horizontal, .DS.Padding.double)
.transition(
.asymmetric(
insertion: .opacity.animation(animation.delay(animationDuration * 0.8)),
removal: .opacity.animation(animation)
insertion: transition.animation(insertionAnimation),
removal: transition.animation(removalAnimation)
)
)
}
Expand Down

0 comments on commit fc2c176

Please sign in to comment.