From d5642349433e4249d2ee90bbf359214889f78cc5 Mon Sep 17 00:00:00 2001 From: Konstantin Ivanov <54908981+konstantiniiv@users.noreply.github.com> Date: Sat, 15 Oct 2022 19:13:29 +0200 Subject: [PATCH] DROID-537 Editor | Enhancement | Support nested decoration for link-to-objects and bookmark blocks (#2659) Co-authored-by: konstantiniiv --- .../editor/decoration/DecoratableViewHolder.kt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/decoration/DecoratableViewHolder.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/decoration/DecoratableViewHolder.kt index cd8bb49244..ceec78af5f 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/decoration/DecoratableViewHolder.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/decoration/DecoratableViewHolder.kt @@ -14,7 +14,6 @@ import androidx.core.view.updateLayoutParams import com.anytypeio.anytype.core_ui.BuildConfig import com.anytypeio.anytype.core_ui.R import com.anytypeio.anytype.presentation.editor.editor.model.BlockView -import com.anytypeio.anytype.presentation.editor.model.Indent interface DecoratableViewHolder { val decoratableContainer: EditorDecorationContainer @@ -24,16 +23,16 @@ interface DecoratableViewHolder { } } -interface DecoratableCardViewHolder: DecoratableViewHolder { +interface DecoratableCardViewHolder : DecoratableViewHolder { val decoratableCard: View + @CallSuper override fun applyDecorations(decorations: List) { if (BuildConfig.NESTED_DECORATION_ENABLED) { decoratableContainer.decorate(decorations) { rect -> decoratableCard.applyCardDecorations( rect = rect, - res = decoratableCard.resources, - indent = decorations.lastIndex + res = decoratableCard.resources ) } } @@ -41,15 +40,14 @@ interface DecoratableCardViewHolder: DecoratableViewHolder { } /** - * Applying decorations for card blocks (media blocks, placeholders, etc.) + * Applying decorations for card blocks (media blocks, placeholders, link-to-objects, bookmarks, etc.) */ inline fun View.applyCardDecorations( rect: Rect, - res: Resources, - indent: Indent + res: Resources ) = updateLayoutParams { val defaultIndentOffset = res.getDimension(R.dimen.default_indent).toInt() - marginStart = if (indent == 0) defaultIndentOffset + rect.left else rect.left + marginStart = defaultIndentOffset + rect.left marginEnd = defaultIndentOffset + rect.right topMargin = res.getDimension(R.dimen.card_block_extra_space_top).toInt() bottomMargin = res.getDimension(R.dimen.card_block_extra_space_bottom).toInt() + rect.bottom