refactor: Use extension for view rounded corners and shadow

This commit is contained in:
Andrea Busi
2024-06-29 16:16:00 +02:00
parent 22d78baa8a
commit ef1aaa7d71
2 changed files with 14 additions and 11 deletions
@@ -12,9 +12,7 @@ import UIKit
extension UIView {
func eqn_applyShadowAndRoundedCorners() {
// rounded corners
layer.cornerRadius = AppTheme.shared.cardCornerRadius
layer.masksToBounds = false
eqn_applyRoundedCorners()
// apply a shadow to the current view
layer.shadowColor = UIColor.black.cgColor
@@ -22,4 +20,10 @@ extension UIView {
layer.shadowOffset = CGSize(width: 0, height: 2)
layer.shadowRadius = 2
}
func eqn_applyRoundedCorners() {
// rounded corners
layer.cornerRadius = AppTheme.shared.cardCornerRadius
layer.masksToBounds = false
}
}
@@ -28,14 +28,6 @@ class EQNBaseContainerTableViewCell: UITableViewCell {
let view = UIView(frame: .zero)
view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = .white
view.layer.cornerRadius = AppTheme.shared.cardCornerRadius
view.layer.masksToBounds = false
// add shadow
view.layer.shadowColor = UIColor.black.cgColor
view.layer.shadowOpacity = 0.5
view.layer.shadowOffset = CGSize(width: 0, height: 2)
view.layer.shadowRadius = 2
return view
}()
@@ -93,6 +85,13 @@ class EQNBaseContainerTableViewCell: UITableViewCell {
setupUI()
updateUI()
}
// MARK: - View Lifecycle
override func layoutSubviews() {
super.layoutSubviews()
internalContainerView.eqn_applyShadowAndRoundedCorners()
}
// MARK: - Internal