year in review testing animation on label

Signed-off-by: Jarrod Courtney <jarrod.courtney@verizon.com>
This commit is contained in:
Jarrod Courtney 2024-04-11 11:13:26 -05:00
parent add7eee2f7
commit 2fd4f3552f
2 changed files with 15 additions and 0 deletions

View File

@ -185,6 +185,13 @@ public typealias ActionBlock = () -> ()
setNeedsUpdate()
}
private func fadeIn(duration: TimeInterval = 1.5, completion: ((Bool) -> Void)? = nil) {
self.alpha = 0.0
UIView.animate(withDuration: duration, delay: 0.2, animations: {
self.alpha = 1.0
}, completion: completion)
}
public func viewModelDidUpdate() {
shouldMaskWhileRecording = viewModel.shouldMaskRecordedView ?? false
text = viewModel.text
@ -226,6 +233,10 @@ public typealias ActionBlock = () -> ()
attributes = attributeModels
}
if let animate = viewModel.animationEnabled, animate == true {
self.fadeIn()
}
}
open override func updateAccessibility() {

View File

@ -31,6 +31,7 @@ import VDS
public var shouldMaskRecordedView: Bool? = false
public var accessibilityTraits: UIAccessibilityTraits?
public var inverted: Bool = false
public var animationEnabled: Bool?
//--------------------------------------------------
// MARK: - Keys
@ -55,6 +56,7 @@ import VDS
case numberOfLines
case shouldMaskRecordedView
case accessibilityTraits
case animationEnabled
}
enum AttributeTypeKey: String, CodingKey {
@ -104,6 +106,7 @@ import VDS
numberOfLines = try typeContainer.decodeIfPresent(Int.self, forKey: .numberOfLines)
shouldMaskRecordedView = try typeContainer.decodeIfPresent(Bool.self, forKey: .shouldMaskRecordedView) ?? false
accessibilityTraits = try typeContainer.decodeIfPresent(UIAccessibilityTraits.self, forKey: .accessibilityTraits)
animationEnabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .animationEnabled)
// Later make protocol based validate outside of decoding?
if let attributes = attributes {
@ -131,6 +134,7 @@ import VDS
try container.encodeIfPresent(numberOfLines, forKey: .numberOfLines)
try container.encodeIfPresent(shouldMaskRecordedView, forKey: .shouldMaskRecordedView)
try container.encodeIfPresent(accessibilityTraits, forKey: .accessibilityTraits)
try container.encodeIfPresent(animationEnabled, forKey: .animationEnabled)
}
}