From 27379544fbdf0c2859e189df93f8b29ffe79bbf2 Mon Sep 17 00:00:00 2001 From: pkurchatov Date: Tue, 26 Nov 2024 18:34:36 +0300 Subject: [PATCH] Fixed background animation for actions commit_hash:261bf87e49363c716993ae86a4eaf5449b546aa8 --- .../Extensions/DivBaseExtensionsTests.swift | 23 +++++++++++++++++++ ...ecoratingBlock+UIViewRenderableBlock.swift | 8 +++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/client/ios/DivKitTests/Extensions/DivBaseExtensionsTests.swift b/client/ios/DivKitTests/Extensions/DivBaseExtensionsTests.swift index dc413932a..1582a1972 100644 --- a/client/ios/DivKitTests/Extensions/DivBaseExtensionsTests.swift +++ b/client/ios/DivKitTests/Extensions/DivBaseExtensionsTests.swift @@ -348,6 +348,29 @@ final class DivBaseExtensionsTests: XCTestCase { assertEqual(block, expectedBlock) } + func test_WithBackgroundAndActions() { + let action = divAction(logId: "action_log_id") + let block = makeBlock( + divSeparator( + actions: [action], + background: solidBackground(color("#112233")) + ) + ) + + let expectedBlock = StateBlock( + child: DecoratingBlock( + child: separatorBlock(), + backgroundColor: color("#112233"), + actions: NonEmptyArray(action.uiAction(path: .root + "0")!), + actionAnimation: .default, + accessibilityElement: .default + ), + ids: [] + ) + + assertEqual(block, expectedBlock) + } + func test_WithLocalVariables() { let block = makeBlock( divText( diff --git a/client/ios/LayoutKit/LayoutKit/UI/Blocks/DecoratingBlock+UIViewRenderableBlock.swift b/client/ios/LayoutKit/LayoutKit/UI/Blocks/DecoratingBlock+UIViewRenderableBlock.swift index 63fe35b11..8c92129c7 100644 --- a/client/ios/LayoutKit/LayoutKit/UI/Blocks/DecoratingBlock+UIViewRenderableBlock.swift +++ b/client/ios/LayoutKit/LayoutKit/UI/Blocks/DecoratingBlock+UIViewRenderableBlock.swift @@ -178,7 +178,7 @@ private final class DecoratingView: UIControl, BlockViewProtocol, VisibleBoundsT return } - updateContentHighlightState(animated: true) + updateHighlightState(animated: true) } } @@ -188,7 +188,7 @@ private final class DecoratingView: UIControl, BlockViewProtocol, VisibleBoundsT return } - updateContentHighlightState(animated: false) + updateHighlightState(animated: false) } } @@ -399,14 +399,14 @@ private final class DecoratingView: UIControl, BlockViewProtocol, VisibleBoundsT setNeedsLayout() } - private func updateContentHighlightState(animated: Bool) { + private func updateHighlightState(animated: Bool) { updateContentBackgroundColor(animated: animated) guard let actionAnimation = model.actionAnimation(for: highlightState) else { return updateContentAlpha(animated: animated) } - childView?.perform(actionAnimation, animated: animated) + perform(actionAnimation, animated: animated) } private func updateContentAlpha(animated: Bool) {