diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index fa71def6..6361f46b 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -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() { diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift index fe37a2c0..33ea4d13 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift @@ -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) } }