Skip to content

Commit

Permalink
💫 :: [#87] ConfirmationDialog / Dialog 등장 시 Animation
Browse files Browse the repository at this point in the history
  • Loading branch information
baekteun committed Jul 24, 2023
1 parent 8eb9685 commit 3724cdf
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Anim
import UIKit

struct ModalAnim: Anim {
func animate(view: UIView, completion: @escaping () -> Void) {
let scaleAffineTransform = CGAffineTransform(scaleX: 0.8, y: 0.8)

let transformFrom = view.transform
let transformTo = view.transform.concatenating(scaleAffineTransform)
UIView.performWithoutAnimation {
view.transform = transformTo
}

let springTimingParameters = UISpringTimingParameters(
mass: 0.2,
stiffness: 98.4,
damping: 4.95,
initialVelocity: .init(dx: 0, dy: 0)
)
let animator = UIViewPropertyAnimator(duration: 0.2, timingParameters: springTimingParameters)
animator.addAnimations {
view.transform = transformFrom
}
animator.addCompletion { _ in
completion()
}
animator.startAnimation()
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Anim
import BaseFeature
import CombineUtility
import DesignSystem
Expand Down Expand Up @@ -28,12 +29,21 @@ final class ConfirmationDialogViewController: BaseModalViewController<Confirmati
super.init(store: store)
self.titleLabel.text = title
self.descriptionLabel.text = description
self.contentView.alpha = 0
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
contentView.anim(anim: .concurrent([
.fadeIn(0.2),
ModalAnim()
]))
}

override func addView() {
super.addView()
confirmButton.addSubviews {
Expand Down
2 changes: 1 addition & 1 deletion Tuist/Dependencies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let dependencies = Dependencies(
carthage: nil,
swiftPackageManager: SwiftPackageManagerDependencies(
[
.remote(url: "https://github.com/GSM-MSG/Anim.git", requirement: .exact("1.0.0")),
.remote(url: "https://github.com/GSM-MSG/Anim.git", requirement: .exact("1.1.0")),
.remote(url: "https://github.com/GSM-MSG/Miniature.git", requirement: .exact("1.3.1")),
.remote(url: "https://github.com/baekteun/NeiSwift.git", requirement: .exact("2.0.2")),
.remote(url: "https://github.com/krzysztofzablocki/Inject.git", requirement: .exact("1.2.3")),
Expand Down

0 comments on commit 3724cdf

Please sign in to comment.