mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-158 Editor | Enhancement | Nested styling fixes regarding selection view in highlight blocks (#2673)
This commit is contained in:
parent
c8b351c43f
commit
0163722567
7 changed files with 68 additions and 14 deletions
|
@ -4,9 +4,9 @@ import android.content.Context
|
|||
import android.graphics.Rect
|
||||
import android.util.AttributeSet
|
||||
import android.widget.FrameLayout
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
import com.anytypeio.anytype.core_ui.R
|
||||
import com.anytypeio.anytype.core_ui.extensions.veryLight
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView.Decoration
|
||||
|
||||
class EditorDecorationContainer @JvmOverloads constructor(
|
||||
|
@ -124,7 +124,7 @@ class EditorDecorationContainer @JvmOverloads constructor(
|
|||
|
||||
// Drawing highlight line inside box
|
||||
|
||||
if (decor.style is Decoration.Style.Highlight) {
|
||||
if (decor.style is Decoration.Style.Highlight && decor.style !is Decoration.Style.Highlight.Itself) {
|
||||
if (decor.style is Decoration.Style.Highlight.End) {
|
||||
rect.bottom += highlightBottomOffset
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.anytypeio.anytype.core_ui.features.editor.holders.text
|
|||
import android.graphics.drawable.Drawable
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.core.view.updatePadding
|
||||
|
@ -96,6 +97,25 @@ class Highlight(
|
|||
bottomMargin = rect.bottom
|
||||
}
|
||||
}
|
||||
if (decorations.isNotEmpty()) {
|
||||
when (val style = decorations.last().style) {
|
||||
is BlockView.Decoration.Style.Highlight.End -> {
|
||||
binding.highlightGlyphContainer.updateLayoutParams<LinearLayout.LayoutParams> {
|
||||
bottomMargin = dimen(R.dimen.dp_6)
|
||||
}
|
||||
}
|
||||
is BlockView.Decoration.Style.Highlight.Itself -> {
|
||||
binding.highlightGlyphContainer.updateLayoutParams<LinearLayout.LayoutParams> {
|
||||
bottomMargin = if (style.hasChildren) 0 else dimen(R.dimen.dp_6)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
binding.highlightGlyphContainer.updateLayoutParams<LinearLayout.LayoutParams> {
|
||||
bottomMargin = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,7 +30,8 @@
|
|||
android:id="@+id/highlightGlyphContainer"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/default_highlight_content_margin_top">
|
||||
android:layout_marginTop="@dimen/default_highlight_content_margin_top"
|
||||
android:layout_marginBottom="6dp">
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
|
|
|
@ -200,6 +200,8 @@
|
|||
<item name="android:layout_marginStart">@dimen/default_graphic_container_right_offset</item>
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:paddingTop">4dp</item>
|
||||
<item name="android:paddingBottom">4dp</item>
|
||||
</style>
|
||||
|
||||
<style name="BlockCalloutContentStyle" parent="DefaultEditorTextStyle">
|
||||
|
|
|
@ -170,6 +170,11 @@ sealed class BlockView : ViewType {
|
|||
|
||||
object None : Style()
|
||||
sealed class Highlight : Style() {
|
||||
/**
|
||||
* [Itself] represents style of highlight block itself at a given indent level,
|
||||
* as opposed to highlight block style inherited from parent blocks.
|
||||
*/
|
||||
data class Itself(val hasChildren: Boolean = false) : Highlight()
|
||||
object Start : Highlight()
|
||||
object Middle : Highlight()
|
||||
object End : Highlight()
|
||||
|
|
|
@ -1058,7 +1058,9 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
listOf(
|
||||
BlockView.Decoration(
|
||||
background = block.parseThemeBackgroundColor(),
|
||||
style = BlockView.Decoration.Style.None
|
||||
style = BlockView.Decoration.Style.Highlight.Itself(
|
||||
hasChildren = block.children.isNotEmpty()
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
|
|
|
@ -12,8 +12,10 @@ import com.anytypeio.anytype.core_models.StubCallout
|
|||
import com.anytypeio.anytype.core_models.StubFile
|
||||
import com.anytypeio.anytype.core_models.StubParagraph
|
||||
import com.anytypeio.anytype.core_models.StubSmartBlock
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
import com.anytypeio.anytype.core_models.ext.asMap
|
||||
import com.anytypeio.anytype.core_models.ext.content
|
||||
import com.anytypeio.anytype.core_models.ext.parseThemeTextColor
|
||||
import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction
|
||||
import com.anytypeio.anytype.core_utils.const.DetailsKeys
|
||||
import com.anytypeio.anytype.domain.config.Gateway
|
||||
|
@ -27,8 +29,6 @@ import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory
|
|||
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Markup
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Markup.Companion.NON_EXISTENT_OBJECT_MENTION_NAME
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
import com.anytypeio.anytype.core_models.ext.parseThemeTextColor
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.Alignment
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
import com.anytypeio.anytype.presentation.editor.render.BlockViewRenderer
|
||||
|
@ -4540,7 +4540,10 @@ class DefaultBlockViewRendererTest {
|
|||
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
|
||||
listOf(
|
||||
BlockView.Decoration(
|
||||
background = quote.parseThemeBackgroundColor()
|
||||
background = quote.parseThemeBackgroundColor(),
|
||||
style = BlockView.Decoration.Style.Highlight.Itself(
|
||||
hasChildren = true
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
|
@ -4644,7 +4647,10 @@ class DefaultBlockViewRendererTest {
|
|||
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
|
||||
listOf(
|
||||
BlockView.Decoration(
|
||||
background = quote1.parseThemeBackgroundColor()
|
||||
background = quote1.parseThemeBackgroundColor(),
|
||||
style = BlockView.Decoration.Style.Highlight.Itself(
|
||||
hasChildren = true
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
|
@ -4666,7 +4672,10 @@ class DefaultBlockViewRendererTest {
|
|||
style = BlockView.Decoration.Style.Highlight.End
|
||||
),
|
||||
BlockView.Decoration(
|
||||
background = quote2.parseThemeBackgroundColor()
|
||||
background = quote2.parseThemeBackgroundColor(),
|
||||
style = BlockView.Decoration.Style.Highlight.Itself(
|
||||
hasChildren = false
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
|
@ -4761,7 +4770,10 @@ class DefaultBlockViewRendererTest {
|
|||
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
|
||||
listOf(
|
||||
BlockView.Decoration(
|
||||
background = quote1.parseThemeBackgroundColor()
|
||||
background = quote1.parseThemeBackgroundColor(),
|
||||
style = BlockView.Decoration.Style.Highlight.Itself(
|
||||
hasChildren = true
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
|
@ -4783,7 +4795,10 @@ class DefaultBlockViewRendererTest {
|
|||
style = BlockView.Decoration.Style.Highlight.Middle
|
||||
),
|
||||
BlockView.Decoration(
|
||||
background = quote2.parseThemeBackgroundColor()
|
||||
background = quote2.parseThemeBackgroundColor(),
|
||||
style = BlockView.Decoration.Style.Highlight.Itself(
|
||||
hasChildren = true
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
|
@ -4917,7 +4932,10 @@ class DefaultBlockViewRendererTest {
|
|||
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
|
||||
listOf(
|
||||
BlockView.Decoration(
|
||||
background = quote1.parseThemeBackgroundColor()
|
||||
background = quote1.parseThemeBackgroundColor(),
|
||||
style = BlockView.Decoration.Style.Highlight.Itself(
|
||||
true
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
|
@ -4939,7 +4957,10 @@ class DefaultBlockViewRendererTest {
|
|||
style = BlockView.Decoration.Style.Highlight.Middle
|
||||
),
|
||||
BlockView.Decoration(
|
||||
background = quote2.parseThemeBackgroundColor()
|
||||
background = quote2.parseThemeBackgroundColor(),
|
||||
style = BlockView.Decoration.Style.Highlight.Itself(
|
||||
true
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
|
@ -5120,7 +5141,10 @@ class DefaultBlockViewRendererTest {
|
|||
background = paragraph.parseThemeBackgroundColor()
|
||||
),
|
||||
BlockView.Decoration(
|
||||
background = quote.parseThemeBackgroundColor()
|
||||
background = quote.parseThemeBackgroundColor(),
|
||||
style = BlockView.Decoration.Style.Highlight.Itself(
|
||||
hasChildren = true
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue