Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Remove UIKitConstants #23829

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions Modules/Sources/WordPressUI/Constants/UIKitConstants.swift

This file was deleted.

18 changes: 9 additions & 9 deletions Modules/Sources/WordPressUI/Extensions/UIView+Animations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ extension UIView {
/// Applies a fade in animation
///
public func fadeInAnimation(_ completion: ((Bool) -> Void)? = nil) {
alpha = UIKitConstants.alphaMid
alpha = 0.5

UIView.animate(withDuration: Animations.duration, animations: { [weak self] in
self?.alpha = UIKitConstants.alphaFull
self?.alpha = 1
}, completion: { success in
completion?(success)
})
Expand All @@ -83,11 +83,11 @@ extension UIView {
///
public func fadeInWithRotationAnimation(_ completion: ((Bool) -> Void)? = nil) {
transform = CGAffineTransform.makeRotation(-270, scale: 3)
alpha = UIKitConstants.alphaZero
alpha = 0

UIView.animate(withDuration: Animations.duration, animations: {
self.transform = CGAffineTransform.makeRotation(0, scale: 0.75)
self.alpha = UIKitConstants.alphaFull
self.alpha = 1
}, completion: { _ in
UIView.animate(withDuration: Animations.duration, animations: {
self.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
Expand All @@ -102,7 +102,7 @@ extension UIView {
public func fadeOutWithRotationAnimation(_ completion: ((Bool) -> Void)? = nil) {
UIView.animate(withDuration: Animations.duration, animations: {
self.transform = CGAffineTransform.makeRotation(120, scale: 3)
self.alpha = UIKitConstants.alphaZero
self.alpha = 0
}, completion: { success in
completion?(success)
})
Expand All @@ -113,7 +113,7 @@ extension UIView {
public func explodeAnimation(_ completion: ((Bool) -> Void)? = nil) {
UIView.animate(withDuration: Animations.duration, animations: {
self.transform = CGAffineTransform(scaleX: 3.0, y: 3.0)
self.alpha = UIKitConstants.alphaZero
self.alpha = 0
}, completion: { success in
completion?(success)
})
Expand All @@ -123,10 +123,10 @@ extension UIView {
///
public func implodeAnimation(_ completion: ((Bool) -> Void)? = nil) {
transform = CGAffineTransform(scaleX: 3.0, y: 3.0)
alpha = UIKitConstants.alphaZero
alpha = 0

UIView.animate(withDuration: Animations.duration, animations: {
self.alpha = UIKitConstants.alphaFull
self.alpha = 1
self.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
}, completion: { success in
completion?(success)
Expand All @@ -143,7 +143,7 @@ extension UIView {
}

self.isHidden = false
let alpha: CGFloat = isHidden ? UIKitConstants.alphaZero : UIKitConstants.alphaFull
let alpha: CGFloat = isHidden ? 0 : 1
UIView.animate(withDuration: Animations.duration, delay: 0, options: .transitionCrossDissolve, animations: {
self.alpha = alpha
}) { success in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ open class FancyAlertPresentationController: UIPresentationController, UIViewCon
private let dimmingView: UIView = {
$0.translatesAutoresizingMaskIntoConstraints = false
$0.backgroundColor = UIColor(white: 0.0, alpha: Constants.dimmingViewAlpha)
$0.alpha = UIKitConstants.alphaZero
$0.alpha = 0
return $0
}(UIView())

Expand All @@ -22,12 +22,12 @@ open class FancyAlertPresentationController: UIPresentationController, UIViewCon
containerView.pinSubviewToAllEdges(dimmingView)

guard let transitionCoordinator = presentingViewController.transitionCoordinator else {
dimmingView.alpha = UIKitConstants.alphaFull
dimmingView.alpha = 1
return
}

transitionCoordinator.animate(alongsideTransition: { _ in
self.dimmingView.alpha = UIKitConstants.alphaFull
self.dimmingView.alpha = 1
})
}

Expand All @@ -39,13 +39,13 @@ open class FancyAlertPresentationController: UIPresentationController, UIViewCon

override open func dismissalTransitionWillBegin() {
guard let coordinator = presentedViewController.transitionCoordinator else {
dimmingView.alpha = UIKitConstants.alphaZero
dimmingView.alpha = 0
return
}

coordinator.animate(alongsideTransition: {
_ in
self.dimmingView.alpha = UIKitConstants.alphaZero
self.dimmingView.alpha = 0
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ open class FancyAlertViewController: UIViewController {

@objc func fadeAllViews(visible: Bool, alongside animation: ((FancyAlertViewController) -> Void)? = nil, completion: ((Bool) -> Void)? = nil) {
UIView.animate(withDuration: Constants.fadeAnimationDuration, animations: {
self.alertView.contentViews.forEach { $0.alpha = (visible) ? UIKitConstants.alphaFull : UIKitConstants.alphaZero }
self.alertView.contentViews.forEach { $0.alpha = (visible) ? 1 : 0 }
animation?(self)
}, completion: completion)
}
Expand Down