1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-863 Editor | Refact | Fix nested styling for highlight block + Remove pre-nested-styling-setup legacy (#26)

This commit is contained in:
Evgenii Kozlov 2023-06-06 16:30:25 +02:00 committed by GitHub
parent 5da051fb00
commit 0906255bf3
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
63 changed files with 1585 additions and 3799 deletions

View file

@ -8,7 +8,6 @@ android {
defaultConfig {
buildConfigField "boolean", "USE_NEW_WINDOW_INSET_API", "true"
buildConfigField "boolean", "NESTED_DECORATION_ENABLED", "true"
}
composeOptions {

View file

@ -127,15 +127,9 @@ interface TextBlockHolder : TextHolder {
}
}
/**
* If nested decoration is enabled, [DecoratableViewHolder] should draw background for this block.
* @see [DecoratableViewHolder]
* @see [EditorDecorationContainer]
*/
@Deprecated("Pre-nested-styling legacy.")
fun setBackgroundColor(background: ThemeColor = ThemeColor.DEFAULT) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.setBlockBackgroundColor(background)
}
// Do nothing.
}
fun setMarkup(markup: Markup, clicked: (ListenerType) -> Unit, textColor: Int) {

View file

@ -11,7 +11,6 @@ import androidx.core.view.marginEnd
import androidx.core.view.marginStart
import androidx.core.view.marginTop
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
@ -28,13 +27,11 @@ interface DecoratableCardViewHolder : DecoratableViewHolder {
@CallSuper
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
decoratableContainer.decorate(decorations) { rect ->
decoratableCard.applyCardDecorations<FrameLayout.LayoutParams>(
rect = rect,
res = decoratableCard.resources
)
}
decoratableContainer.decorate(decorations) { rect ->
decoratableCard.applyCardDecorations<FrameLayout.LayoutParams>(
rect = rect,
res = decoratableCard.resources
)
}
}
}

View file

@ -37,17 +37,9 @@ class BookmarkError(
}
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.indentize(
indent = item.indent,
defIndent = dimen(R.dimen.indent),
margin = 0
)
binding.selected.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_indent) * item.indent
}
}
// Do nothing.
}
override fun select(isSelected: Boolean) {
@ -56,11 +48,9 @@ class BookmarkError(
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
super.applyDecorations(decorations)
if (BuildConfig.NESTED_DECORATION_ENABLED) {
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
}
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
}
}

View file

@ -29,17 +29,9 @@ class FileError(
clicked(ListenerType.File.Error(item.id))
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.indentize(
indent = item.indent,
defIndent = dimen(R.dimen.indent),
margin = 0
)
binding.selected.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_indent) * item.indent
}
}
// Do nothing.
}
override fun select(isSelected: Boolean) {
@ -48,11 +40,9 @@ class FileError(
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
super.applyDecorations(decorations)
if (BuildConfig.NESTED_DECORATION_ENABLED) {
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
}
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
}
}

View file

@ -29,17 +29,9 @@ class PictureError(
clicked(ListenerType.Picture.Error(item.id))
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.indentize(
indent = item.indent,
defIndent = dimen(R.dimen.indent),
margin = 0
)
binding.selected.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_indent) * item.indent
}
}
// Do nothing.
}
override fun select(isSelected: Boolean) {
@ -48,11 +40,9 @@ class PictureError(
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
super.applyDecorations(decorations)
if (BuildConfig.NESTED_DECORATION_ENABLED) {
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
}
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
}
}

View file

@ -29,17 +29,9 @@ class VideoError(
clicked(ListenerType.Video.Error(item.id))
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.indentize(
indent = item.indent,
defIndent = dimen(R.dimen.indent),
margin = 0
)
binding.selected.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_indent) * item.indent
}
}
// Do nothing.
}
override fun select(isSelected: Boolean) {
@ -48,11 +40,9 @@ class VideoError(
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
super.applyDecorations(decorations)
if (BuildConfig.NESTED_DECORATION_ENABLED) {
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
}
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
}
}

View file

@ -33,14 +33,12 @@ class File(val binding: ItemBlockFileBinding) : Media(binding.root), Decoratable
override val clickContainer: View = binding.text
private val icon = binding.graphic
private val name = binding.text
private val guideline = binding.guideline
override val decoratableContainer: EditorDecorationContainer
get() = binding.decorationContainer
init {
clickContainer.setOnTouchListener { v, e -> editorTouchProcessor.process(v, e) }
applyDefaultOffsets()
}
fun bind(item: BlockView.Media.File, clicked: (ListenerType) -> Unit) {
@ -113,10 +111,9 @@ class File(val binding: ItemBlockFileBinding) : Media(binding.root), Decoratable
clicked(ListenerType.File.View(item.id))
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
guideline.setGuidelineBegin(item.indent * dimen(R.dimen.indent))
}
// Do nothing.
}
override fun select(isSelected: Boolean) {
@ -130,39 +127,21 @@ class File(val binding: ItemBlockFileBinding) : Media(binding.root), Decoratable
if (payload.isSearchHighlightChanged) {
applySearchHighlight(item)
}
if (payload.isBackgroundColorChanged && !BuildConfig.NESTED_DECORATION_ENABLED) {
applyBackground(item.background)
}
}
}
private fun applyDefaultOffsets() {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
container.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_document_item_padding_start)
marginEnd = dimen(R.dimen.default_document_item_padding_end)
topMargin = dimen(R.dimen.default_graphic_text_root_margin_top)
bottomMargin = dimen(R.dimen.default_graphic_text_root_margin_bottom)
}
}
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
Timber.w("Trying to apply decorations $decorations")
if (BuildConfig.NESTED_DECORATION_ENABLED) {
decoratableContainer.decorate(decorations) { rect ->
binding.container.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.dp_8) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = if (rect.bottom > 0) {
rect.bottom
} else {
dimen(R.dimen.dp_2)
}
decoratableContainer.decorate(decorations) { rect ->
binding.container.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.dp_8) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = if (rect.bottom > 0) {
rect.bottom
} else {
dimen(R.dimen.dp_2)
}
}
}
}
}

View file

@ -38,20 +38,6 @@ class Picture(val binding: ItemBlockPictureBinding) : Media(binding.root), Decor
init {
clickContainer.setOnTouchListener { v, e -> editorTouchProcessor.process(v, e) }
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
binding.root.updatePadding(
top = dimen(R.dimen.dp_6),
left = dimen(R.dimen.dp_12),
right = dimen(R.dimen.dp_12),
bottom = dimen(R.dimen.dp_6)
)
binding.root.updateLayoutParams<RecyclerView.LayoutParams> {
marginStart = dimen(R.dimen.dp_8)
marginEnd = dimen(R.dimen.dp_8)
bottomMargin = dimen(R.dimen.dp_1)
topMargin = dimen(R.dimen.dp_1)
}
}
}
private val listener: RequestListener<Drawable> = object : RequestListener<Drawable> {
@ -88,31 +74,20 @@ class Picture(val binding: ItemBlockPictureBinding) : Media(binding.root), Decor
clicked(ListenerType.Picture.View(item.id))
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
itemView.indentize(
indent = item.indent,
defIndent = dimen(R.dimen.indent),
margin = dimen(R.dimen.picture_default_margin_start)
)
}
// Do nothing.
}
override fun select(isSelected: Boolean) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
itemView.isSelected = isSelected
} else {
binding.selected.isSelected = isSelected
}
binding.selected.isSelected = isSelected
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
super.applyDecorations(decorations)
if (BuildConfig.NESTED_DECORATION_ENABLED) {
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
}
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
}
}

View file

@ -125,12 +125,9 @@ class Code(
}
}
@Deprecated("Pre-nested-styling legacy.")
fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
binding.content.updateLayoutParams<FrameLayout.LayoutParams> {
leftMargin = item.indent * dimen(R.dimen.indent)
}
}
// Do nothing.
}
fun processChangePayload(
@ -251,13 +248,11 @@ class Code(
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
decoratableContainer.decorate(decorations) { rect ->
binding.content.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = rect.left
marginEnd = rect.right
bottomMargin = rect.bottom
}
decoratableContainer.decorate(decorations) { rect ->
binding.content.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = rect.left
marginEnd = rect.right
bottomMargin = rect.bottom
}
}
}

View file

@ -40,40 +40,12 @@ abstract class Divider(view: View) : BlockViewHolder(view),
clicked: (ListenerType) -> Unit,
background: ThemeColor
) = with(itemView) {
indentize(item)
container.isSelected = isItemSelected
applyBackground(background)
setOnClickListener { clicked(ListenerType.DividerClick(id)) }
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
divider.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = item.indent * dimen(R.dimen.indent)
}
}
// Do nothing.
}
private fun applyBackground(background: ThemeColor) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.setBlockBackgroundColor(background)
}
}
protected fun applyDefaultOffsets() {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
container.updatePadding(
left = dimen(R.dimen.default_document_item_padding_start),
right = dimen(R.dimen.default_document_item_padding_end)
)
root.updatePadding(
left = dimen(R.dimen.default_document_item_padding_start),
right = dimen(R.dimen.default_document_item_padding_end)
)
root.updateLayoutParams<RecyclerView.LayoutParams> {
bottomMargin = dimen(R.dimen.dp_2)
}
}
}
}

View file

@ -18,10 +18,6 @@ class DividerDots(
override val container: View = binding.container
override val decoratableContainer = binding.decorationContainer
init {
applyDefaultOffsets()
}
fun bind(item: BlockView.DividerDots, clicked: (ListenerType) -> Unit) {
super.bind(
id = item.id,
@ -33,14 +29,12 @@ class DividerDots(
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
decoratableContainer.decorate(decorations) { rect ->
val defaultIndentOffset = dimen(R.dimen.default_indent)
container.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = rect.left + defaultIndentOffset
marginEnd = rect.right + defaultIndentOffset
bottomMargin = rect.bottom + dimen(R.dimen.divider_extra_space_bottom)
}
decoratableContainer.decorate(decorations) { rect ->
val defaultIndentOffset = dimen(R.dimen.default_indent)
container.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = rect.left + defaultIndentOffset
marginEnd = rect.right + defaultIndentOffset
bottomMargin = rect.bottom + dimen(R.dimen.divider_extra_space_bottom)
}
}
}

View file

@ -18,10 +18,6 @@ class DividerLine(
override val decoratableContainer = binding.decorationContainer
override val container: View = binding.container
init {
applyDefaultOffsets()
}
fun bind(item: BlockView.DividerLine, clicked: (ListenerType) -> Unit) {
super.bind(
id = item.id,
@ -33,14 +29,12 @@ class DividerLine(
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
decoratableContainer.decorate(decorations) { rect ->
val defaultIndentOffset = dimen(R.dimen.default_indent)
container.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = rect.left + defaultIndentOffset
marginEnd = rect.right + defaultIndentOffset
bottomMargin = rect.bottom + dimen(R.dimen.divider_extra_space_bottom)
}
decoratableContainer.decorate(decorations) { rect ->
val defaultIndentOffset = dimen(R.dimen.default_indent)
container.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = rect.left + defaultIndentOffset
marginEnd = rect.right + defaultIndentOffset
bottomMargin = rect.bottom + dimen(R.dimen.divider_extra_space_bottom)
}
}
}

View file

@ -53,29 +53,18 @@ class LinkToObject(
init {
itemView.setOnTouchListener { v, e -> editorTouchProcessor.process(v, e) }
applyDefaultOffsets()
}
fun bind(
item: BlockView.LinkToObject.Default.Text,
clicked: (ListenerType) -> Unit
) {
indentize(item)
applySelectedState(item)
applyText(item)
applyDescription(item)
applyObjectType(item)
applySearchHighlight(item)
applyImageOrEmoji(item)
applyBackground(item.background)
itemView.setOnClickListener { clicked(ListenerType.LinkToObject(item.id)) }
}
@ -181,12 +170,9 @@ class LinkToObject(
title.editableText?.removeSpans<SearchTargetHighlightSpan>()
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.updateLayoutParams<RecyclerView.LayoutParams> {
marginStart = item.indent * dimen(R.dimen.indent)
}
}
// Do nothing.
}
fun processChangePayload(payloads: List<BlockViewDiffUtil.Payload>, item: BlockView) {
@ -204,9 +190,6 @@ class LinkToObject(
if (payload.isObjectIconChanged) {
applyImageOrEmoji(item)
}
if (payload.isBackgroundColorChanged) {
applyBackground(item.background)
}
if (payload.isObjectDescriptionChanged) {
applyDescription(item)
}
@ -216,36 +199,17 @@ class LinkToObject(
}
}
private fun applyBackground(background: ThemeColor) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.setBlockBackgroundColor(background)
}
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
decoratableContainer.decorate(decorations) { rect ->
binding.container.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.dp_8) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = if (rect.bottom > 0) {
rect.bottom
} else {
dimen(R.dimen.dp_2)
}
decoratableContainer.decorate(decorations) { rect ->
binding.container.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.dp_8) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = if (rect.bottom > 0) {
rect.bottom
} else {
dimen(R.dimen.dp_2)
}
}
}
}
private fun applyDefaultOffsets() {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
container.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_document_item_padding_start)
marginEnd = dimen(R.dimen.default_document_item_padding_end)
topMargin = dimen(R.dimen.default_graphic_text_root_margin_top)
bottomMargin = dimen(R.dimen.default_graphic_text_root_margin_bottom)
}
}
}
}

View file

@ -46,7 +46,6 @@ class LinkToObjectArchive(
init {
itemView.setOnTouchListener { v, e -> editorTouchProcessor.process(v, e) }
applyDefaultOffsets()
}
fun bind(
@ -70,12 +69,9 @@ class LinkToObjectArchive(
itemView.setOnClickListener { clicked(ListenerType.LinkToObjectArchived(item.id)) }
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.updateLayoutParams<RecyclerView.LayoutParams> {
marginStart = item.indent * dimen(R.dimen.indent)
}
}
// Do nothing.
}
private fun applySearchHighlight(item: BlockView.Searchable) {
@ -123,37 +119,20 @@ class LinkToObjectArchive(
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
decoratableContainer.decorate(decorations) { rect ->
binding.content.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.dp_8) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = if (rect.bottom > 0) {
rect.bottom
} else {
dimen(R.dimen.dp_2)
}
decoratableContainer.decorate(decorations) { rect ->
binding.content.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.dp_8) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = if (rect.bottom > 0) {
rect.bottom
} else {
dimen(R.dimen.dp_2)
}
binding.content.updatePadding(
left = dimen(R.dimen.default_document_content_padding_start),
right = dimen(R.dimen.default_document_item_padding_end)
)
}
}
}
private fun applyDefaultOffsets() {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
binding.content.updatePadding(
left = dimen(R.dimen.default_document_content_padding_start),
right = dimen(R.dimen.default_document_item_padding_end)
)
binding.content.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_document_item_padding_start)
marginEnd = dimen(R.dimen.default_document_item_padding_end)
topMargin = dimen(R.dimen.dp_1)
bottomMargin = dimen(R.dimen.dp_1)
}
}
}
}

View file

@ -69,12 +69,8 @@ abstract class LinkToObjectCard(
item: BlockView.LinkToObject.Default.Card,
clicked: (ListenerType) -> Unit
) {
indentize(item)
selected(item)
applyRootMargins(item)
applyName(item)
applyDescription(item)
@ -166,12 +162,9 @@ abstract class LinkToObjectCard(
titleView.editableText?.removeSpans<SearchTargetHighlightSpan>()
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
rootView.updateLayoutParams<RecyclerView.LayoutParams> {
marginStart = item.indent * dimen(R.dimen.indent)
}
}
// Do nothing.
}
protected fun processChangeBasePayloads(
@ -254,24 +247,6 @@ abstract class LinkToObjectCard(
containerView.setBlockBackgroundColor(background)
}
private fun applyRootMargins(item: BlockView.LinkToObject.Default.Card) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
if (item.isPreviousBlockMedia) {
rootView.updateLayoutParams<RecyclerView.LayoutParams> {
apply { topMargin = 0 }
}
} else {
rootView.updateLayoutParams<RecyclerView.LayoutParams> {
apply {
topMargin =
rootView.resources.getDimension(R.dimen.default_link_card_root_margin_top)
.toInt()
}
}
}
}
}
private fun applyObjectType(item: BlockView.LinkToObject.Default.Card) {
if (!item.objectTypeName.isNullOrBlank()) {
objectTypeView.text = item.objectTypeName
@ -281,30 +256,12 @@ abstract class LinkToObjectCard(
}
}
protected fun applyDefaultOffsets() {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
rootView.updatePadding(
left = dimen(R.dimen.default_document_item_padding_start),
right = dimen(R.dimen.default_document_item_padding_end)
)
rootView.updateLayoutParams<RecyclerView.LayoutParams> {
bottomMargin = dimen(R.dimen.dp_10)
}
decoratableCard.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.dp_12)
marginEnd = dimen(R.dimen.dp_12)
}
}
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
super.applyDecorations(decorations)
if (BuildConfig.NESTED_DECORATION_ENABLED) {
selectedView.applySelectorOffset<FrameLayout.LayoutParams>(
content = decoratableCard,
res = itemView.resources
)
}
selectedView.applySelectorOffset<FrameLayout.LayoutParams>(
content = decoratableCard,
res = itemView.resources
)
}
}
@ -323,7 +280,6 @@ class LinkToObjectCardSmallIcon(binding: ItemBlockObjectLinkCardSmallIconBinding
init {
itemView.setOnTouchListener { v, e -> editorTouchProcessor.process(v, e) }
applyDefaultOffsets()
}
fun bind(
@ -358,7 +314,6 @@ class LinkToObjectCardMediumIcon(binding: ItemBlockObjectLinkCardMediumIconBindi
init {
itemView.setOnTouchListener { v, e -> editorTouchProcessor.process(v, e) }
applyDefaultOffsets()
}
fun bind(
@ -394,7 +349,6 @@ class LinkToObjectCardSmallIconCover(binding: ItemBlockObjectLinkCardSmallIconCo
init {
itemView.setOnTouchListener { v, e -> editorTouchProcessor.process(v, e) }
applyDefaultOffsets()
}
fun bind(
@ -434,7 +388,6 @@ class LinkToObjectCardMediumIconCover(binding: ItemBlockObjectLinkCardMediumIcon
init {
itemView.setOnTouchListener { v, e -> editorTouchProcessor.process(v, e) }
applyDefaultOffsets()
}
fun bind(

View file

@ -37,24 +37,19 @@ class LinkToObjectDelete(
init {
itemView.setOnTouchListener { v, e -> editorTouchProcessor.process(v, e) }
applyDefaultOffsets()
}
fun bind(
item: BlockView.LinkToObject.Deleted,
clicked: (ListenerType) -> Unit
) {
indentize(item)
itemView.isSelected = item.isSelected
itemView.setOnClickListener { clicked(ListenerType.LinkToObjectDeleted(item.id)) }
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.updateLayoutParams<RecyclerView.LayoutParams> {
marginStart = item.indent * dimen(R.dimen.indent)
}
}
// Do nothing.
}
fun processChangePayload(payloads: List<BlockViewDiffUtil.Payload>, item: BlockView) {
@ -67,37 +62,20 @@ class LinkToObjectDelete(
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
decoratableContainer.decorate(decorations) { rect ->
binding.content.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.dp_8) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = if (rect.bottom > 0) {
rect.bottom
} else {
dimen(R.dimen.dp_2)
}
decoratableContainer.decorate(decorations) { rect ->
binding.content.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.dp_8) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = if (rect.bottom > 0) {
rect.bottom
} else {
dimen(R.dimen.dp_2)
}
binding.content.updatePadding(
left = dimen(R.dimen.default_document_content_padding_start),
right = dimen(R.dimen.default_document_item_padding_end)
)
}
}
}
private fun applyDefaultOffsets() {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
binding.content.updatePadding(
left = dimen(R.dimen.default_document_content_padding_start),
right = dimen(R.dimen.default_document_item_padding_end)
)
binding.content.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_document_item_padding_start)
marginEnd = dimen(R.dimen.default_document_item_padding_end)
topMargin = dimen(R.dimen.dp_1)
bottomMargin = dimen(R.dimen.dp_1)
}
}
}
}

View file

@ -15,7 +15,6 @@ class LinkToObjectLoading(binding: ItemBlockObjectLinkLoadingBinding) :
BlockViewHolder(binding.root),
BlockViewHolder.IndentableHolder {
private val root = binding.root
private val container = binding.container
fun bind(
@ -41,11 +40,8 @@ class LinkToObjectLoading(binding: ItemBlockObjectLinkLoadingBinding) :
}
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.updateLayoutParams<RecyclerView.LayoutParams> {
marginStart = item.indent * dimen(R.dimen.indent)
}
}
// Do nothing.
}
}

View file

@ -49,17 +49,6 @@ abstract class MediaPlaceholder(
)
init {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
binding.card.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_media_placeholder_card_margin_start)
marginEnd = dimen(R.dimen.default_media_placeholder_card_margin_end)
bottomMargin = dimen(R.dimen.default_media_placeholder_root_margin_bottom)
}
binding.root.updatePadding(
left = dimen(R.dimen.default_document_item_padding_start),
right = dimen(R.dimen.default_document_item_padding_end),
)
}
itemView.setOnTouchListener { v, e -> editorTouchProcessor.process(v, e) }
}
@ -68,10 +57,7 @@ abstract class MediaPlaceholder(
clicked: (ListenerType) -> Unit
) {
setup()
applyRootMargins(item)
indentize(item)
select(item.isSelected)
applyBackground(item.background)
with(itemView) {
setOnClickListener { placeholderClick(item.id, clicked) }
}
@ -83,67 +69,26 @@ abstract class MediaPlaceholder(
if (payload.isSelectionChanged) {
select(item.isSelected)
}
if (payload.isBackgroundColorChanged) {
applyBackground(item.background)
}
}
}
private fun applyRootMargins(item: BlockView.MediaPlaceholder) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
if (item.isPreviousBlockMedia) {
root.updateLayoutParams<RecyclerView.LayoutParams> {
apply { topMargin = 0 }
}
} else {
root.updateLayoutParams<RecyclerView.LayoutParams> {
apply {
topMargin =
root.resources.getDimension(R.dimen.default_media_placeholder_root_margin_top)
.toInt()
}
}
}
}
}
private fun select(isSelected: Boolean) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.isSelected = isSelected
} else {
binding.selected.isSelected = isSelected
}
}
private fun applyBackground(
bg: ThemeColor
) {
if (BuildConfig.NESTED_DECORATION_ENABLED) return
if (bg != ThemeColor.DEFAULT) {
card.setCardBackgroundColor(card.resources.veryLight(bg, 0))
} else {
card.setCardBackgroundColor(0)
}
binding.selected.isSelected = isSelected
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val leftPadding =
dimen(R.dimen.default_document_item_padding_start) + item.indent * dimen(R.dimen.indent)
root.updatePadding(left = leftPadding)
}
// Do nothing.
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
super.applyDecorations(decorations)
if (BuildConfig.NESTED_DECORATION_ENABLED) {
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
card.setCardBackgroundColor(
card.resources.veryLight(decorations.last().background, 0)
)
}
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
card.setCardBackgroundColor(
card.resources.veryLight(decorations.last().background, 0)
)
}
}

View file

@ -54,46 +54,30 @@ sealed class RelationBlockViewHolder(
applySelection(item)
}
@Deprecated("Pre-nested-styling legacy.")
fun indent(item: BlockView.Indentable, view: View) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val indent = dimen(R.dimen.indent) * item.indent
view.updatePadding(left = indent)
}
}
private fun applyDefaultOffsets(root: View) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.updatePadding(
left = dimen(R.dimen.default_document_item_padding_start),
right = dimen(R.dimen.default_document_item_padding_end)
)
root.updateLayoutParams<RecyclerView.LayoutParams> {
bottomMargin = dimen(R.dimen.dp_2)
}
}
// Do nothing
}
fun applyContentDecorations(
root: View,
decorations: List<BlockView.Decoration>
) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
if (decorations.isEmpty() || (decorations.size == 1 && decorations[0].style == BlockView.Decoration.Style.None)) {
root.updateLayoutParams<RecyclerView.LayoutParams> {
bottomMargin = dimen(R.dimen.dp_2)
}
if (decorations.isEmpty() || (decorations.size == 1 && decorations[0].style == BlockView.Decoration.Style.None)) {
root.updateLayoutParams<RecyclerView.LayoutParams> {
bottomMargin = dimen(R.dimen.dp_2)
}
decoratableContainer.decorate(decorations = decorations) { rect ->
content.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.dp_8) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = rect.bottom
}
selected.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.dp_8) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = rect.bottom
}
}
decoratableContainer.decorate(decorations = decorations) { rect ->
content.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.dp_8) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = rect.bottom
}
selected.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.dp_8) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = rect.bottom
}
}
}
@ -133,10 +117,6 @@ sealed class RelationBlockViewHolder(
abstract fun applyRelationValue(item: ObjectRelationView)
init {
applyDefaultOffsets(itemView)
}
class Placeholder(binding: ItemBlockRelationPlaceholderBinding) :
RelationBlockViewHolder(binding.root) {

View file

@ -51,24 +51,6 @@ class Bulleted(
mentionCheckedIcon = ContextCompat.getDrawable(this, R.drawable.ic_task_1_text_16)
mentionInitialsSize = resources.getDimension(R.dimen.mention_span_initials_size_default)
}
applyDefaultOffsets()
}
private fun applyDefaultOffsets() {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
binding.root.updatePadding(
left = dimen(R.dimen.default_document_item_padding_start),
right = dimen(R.dimen.default_document_item_padding_end)
)
binding.root.updateLayoutParams<RecyclerView.LayoutParams> {
topMargin = dimen(R.dimen.default_document_item_margin_top)
bottomMargin = dimen(R.dimen.default_document_item_margin_bottom)
}
binding.graphicPlusTextContainer.updatePadding(
left = dimen(R.dimen.default_document_content_padding_start),
right = dimen(R.dimen.default_document_content_padding_end),
)
}
}
override fun getMentionIconSize(): Int = mentionIconSize
@ -97,10 +79,9 @@ class Bulleted(
DrawableCompat.setTint(bullet.drawable, color)
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
indent.updateLayoutParams { width = item.indent * dimen(R.dimen.indent) }
}
// Do nothing.
}
override fun select(item: BlockView.Selectable) {
@ -108,14 +89,12 @@ class Bulleted(
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
decoratableContainer.decorate(decorations = decorations) { rect ->
binding.graphicPlusTextContainer.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_indent) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = rect.bottom
// TODO handle top and bottom offsets
}
decoratableContainer.decorate(decorations = decorations) { rect ->
binding.graphicPlusTextContainer.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_indent) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = rect.bottom
// TODO handle top and bottom offsets
}
}
}

View file

@ -95,24 +95,14 @@ class Callout(
binding.selectionView.isSelected = item.isSelected
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
binding.calloutCardContainer.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = indentOffset + (item.indent * indentOffset)
marginEnd = indentOffset
}
}
// Do nothing.
}
@Deprecated("Pre-nested-styling legacy.")
override fun setBackgroundColor(background: ThemeColor) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
binding.calloutCardContainer.setBlockBackgroundTintColor(
color = background,
default = itemView.resources.veryLight(
color = ThemeColor.GREY
)
)
}
// Do nothing.
}
override fun getMentionIconSize(): Int = mentionIconSize
@ -122,33 +112,31 @@ class Callout(
override fun getMentionInitialsSize(): Float = mentionInitialsSize
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
val indent = decorations.lastIndex
val last = decorations.last()
decoratableContainer.decorate(decorations) { rect ->
binding.calloutCardContainer.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = if (indent == 0) rect.left + indentOffset else rect.left
marginEnd = rect.right
bottomMargin = rect.bottom
}
val indent = decorations.lastIndex
val last = decorations.last()
decoratableContainer.decorate(decorations) { rect ->
binding.calloutCardContainer.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = if (indent == 0) rect.left + indentOffset else rect.left
marginEnd = rect.right
bottomMargin = rect.bottom
}
when (last.style) {
is BlockView.Decoration.Style.Callout.Start -> {
binding.calloutCardContainer.setBackgroundResource(R.drawable.rect_callout_start)
}
is BlockView.Decoration.Style.Callout.Full -> {
binding.calloutCardContainer.setBackgroundResource(R.drawable.rect_callout_full)
}
else -> {}
}
binding.calloutCardContainer.setBlockBackgroundTintColor(
color = last.background,
default = itemView.resources.getColor(R.color.palette_very_light_grey, null)
)
binding.selectionView.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.calloutCardContainer,
res = itemView.resources
)
}
when (last.style) {
is BlockView.Decoration.Style.Callout.Start -> {
binding.calloutCardContainer.setBackgroundResource(R.drawable.rect_callout_start)
}
is BlockView.Decoration.Style.Callout.Full -> {
binding.calloutCardContainer.setBackgroundResource(R.drawable.rect_callout_full)
}
else -> {}
}
binding.calloutCardContainer.setBlockBackgroundTintColor(
color = last.background,
default = itemView.resources.getColor(R.color.palette_very_light_grey, null)
)
binding.selectionView.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.calloutCardContainer,
res = itemView.resources
)
}
}

View file

@ -51,24 +51,6 @@ class Checkbox(
mentionCheckedIcon = ContextCompat.getDrawable(this, R.drawable.ic_task_1_text_16)
mentionInitialsSize = resources.getDimension(R.dimen.mention_span_initials_size_default)
}
applyDefaultOffsets()
}
private fun applyDefaultOffsets() {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
binding.root.updatePadding(
left = dimen(R.dimen.default_document_item_padding_start),
right = dimen(R.dimen.default_document_item_padding_end)
)
binding.root.updateLayoutParams<RecyclerView.LayoutParams> {
topMargin = dimen(R.dimen.default_document_item_margin_top)
bottomMargin = dimen(R.dimen.default_document_item_margin_bottom)
}
binding.graphicPlusTextContainer.updatePadding(
left = dimen(R.dimen.default_document_content_padding_start),
right = dimen(R.dimen.default_document_content_padding_end),
)
}
}
override fun bind(
@ -97,10 +79,9 @@ class Checkbox(
override fun getMentionUncheckedIcon(): Drawable? = mentionUncheckedIcon
override fun getMentionInitialsSize(): Float = mentionInitialsSize
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
checkbox.updatePadding(left = item.indent * dimen(R.dimen.indent))
}
// Do nothing.
}
override fun select(item: BlockView.Selectable) {
@ -108,14 +89,12 @@ class Checkbox(
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
decoratableContainer.decorate(decorations = decorations) { rect ->
binding.graphicPlusTextContainer.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_indent) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = rect.bottom
// TODO handle top and bottom offsets
}
decoratableContainer.decorate(decorations = decorations) { rect ->
binding.graphicPlusTextContainer.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_indent) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = rect.bottom
// TODO handle top and bottom offsets
}
}
}

View file

@ -22,11 +22,8 @@ abstract class Header<T : BlockView.Text.Header>(
abstract val header: TextInputWidget
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
header.updatePadding(
left = dimen(R.dimen.default_document_content_padding_start) + item.indent * dimen(R.dimen.indent)
)
}
// Do nothing.
}
}

View file

@ -52,14 +52,12 @@ class HeaderOne(
override fun getMentionInitialsSize(): Float = mentionInitialsSize
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
decoratableContainer.decorate(decorations) { rect ->
binding.box.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = rect.left
marginEnd = rect.right
bottomMargin = rect.bottom
// TODO handle top and bottom offsets
}
decoratableContainer.decorate(decorations) { rect ->
binding.box.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = rect.left
marginEnd = rect.right
bottomMargin = rect.bottom
// TODO handle top and bottom offsets
}
}
}

View file

@ -52,14 +52,12 @@ class HeaderThree(
override fun getMentionInitialsSize(): Float = mentionInitialsSize
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
decoratableContainer.decorate(decorations) { rect ->
binding.box.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = rect.left
marginEnd = rect.right
bottomMargin = rect.bottom
// TODO handle top and bottom offsets
}
decoratableContainer.decorate(decorations) { rect ->
binding.box.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = rect.left
marginEnd = rect.right
bottomMargin = rect.bottom
// TODO handle top and bottom offsets
}
}
}

View file

@ -52,14 +52,12 @@ class HeaderTwo(
override fun getMentionInitialsSize(): Float = mentionInitialsSize
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
decoratableContainer.decorate(decorations) { rect ->
binding.box.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = rect.left
marginEnd = rect.right
bottomMargin = rect.bottom
// TODO handle top and bottom offsets
}
decoratableContainer.decorate(decorations) { rect ->
binding.box.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = rect.left
marginEnd = rect.right
bottomMargin = rect.bottom
// TODO handle top and bottom offsets
}
}
}

View file

@ -15,9 +15,12 @@ import com.anytypeio.anytype.core_ui.features.editor.BlockViewHolder
import com.anytypeio.anytype.core_ui.features.editor.SupportNesting
import com.anytypeio.anytype.core_ui.features.editor.decoration.DecoratableViewHolder
import com.anytypeio.anytype.core_ui.features.editor.decoration.EditorDecorationContainer
import com.anytypeio.anytype.core_ui.features.editor.decoration.applySelectorOffset
import com.anytypeio.anytype.core_ui.tools.DefaultSpannableFactory
import com.anytypeio.anytype.core_ui.widgets.text.TextInputWidget
import com.anytypeio.anytype.core_utils.ext.dimen
import com.anytypeio.anytype.core_utils.ext.gone
import com.anytypeio.anytype.core_utils.ext.visible
import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
@ -28,8 +31,6 @@ class Highlight(
override val content: TextInputWidget = binding.highlightContent
override val root: View = itemView
private val indent = binding.highlightIndent
private val container = binding.highlightBlockContentContainer
override val decoratableContainer: EditorDecorationContainer = binding.decorationContainer
@ -51,35 +52,21 @@ class Highlight(
mentionCheckedIcon = ContextCompat.getDrawable(this, R.drawable.ic_task_1_text_16)
mentionInitialsSize = resources.getDimension(R.dimen.mention_span_initials_size_default)
}
applyDefaultOffsets()
}
private fun applyDefaultOffsets() {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
binding.root.updatePadding(
left = dimen(R.dimen.default_document_item_padding_start),
right = dimen(R.dimen.default_document_item_padding_end)
)
binding.root.updateLayoutParams<RecyclerView.LayoutParams> {
topMargin = dimen(R.dimen.default_highlight_content_margin_top)
bottomMargin = dimen(R.dimen.default_highlight_content_margin_bottom)
}
binding.highlightBlockContentContainer.updatePadding(
left = dimen(R.dimen.default_document_content_padding_start),
right = dimen(R.dimen.default_document_content_padding_end)
)
}
}
override fun select(item: BlockView.Selectable) {
container.isSelected = item.isSelected
if (item.isSelected) {
binding.selected.isSelected = true
binding.selected.visible()
} else {
binding.selected.isSelected = false
binding.selected.gone()
}
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
indent.updateLayoutParams { width = item.indent * dimen(R.dimen.indent) }
}
// Do nothing.
}
override fun getMentionIconSize(): Int = mentionIconSize
@ -89,33 +76,38 @@ class Highlight(
override fun getMentionInitialsSize(): Float = mentionInitialsSize
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
decoratableContainer.decorate(decorations) { rect ->
binding.highlightBlockContentContainer.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_indent) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = rect.bottom
}
decoratableContainer.decorate(decorations) { rect ->
binding.highlightBlockContentContainer.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_indent) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
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)
}
}
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)
}
}
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
}
}
else -> {
binding.highlightGlyphContainer.updateLayoutParams<LinearLayout.LayoutParams> {
bottomMargin = 0
}
}
}
}
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.highlightBlockContentContainer,
res = itemView.resources
)
binding.selected.updateLayoutParams<FrameLayout.LayoutParams> {
marginEnd = dimen(R.dimen.dp_8)
}
}
}

View file

@ -55,24 +55,6 @@ class Numbered(
mentionCheckedIcon = ContextCompat.getDrawable(this, R.drawable.ic_task_1_text_16)
mentionInitialsSize = resources.getDimension(R.dimen.mention_span_initials_size_default)
}
applyDefaultOffsets()
}
private fun applyDefaultOffsets() {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
binding.root.updatePadding(
left = dimen(R.dimen.default_document_item_padding_start),
right = dimen(R.dimen.default_document_item_padding_end)
)
binding.root.updateLayoutParams<RecyclerView.LayoutParams> {
topMargin = dimen(R.dimen.default_document_item_margin_top)
bottomMargin = dimen(R.dimen.default_document_item_margin_bottom)
}
binding.graphicPlusTextContainer.updatePadding(
left = dimen(R.dimen.default_document_content_padding_start),
right = dimen(R.dimen.default_document_content_padding_end),
)
}
}
override fun bind(
@ -121,17 +103,9 @@ class Numbered(
number.setTextColor(color)
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
number.updateLayoutParams<LinearLayout.LayoutParams> {
setMargins(
item.indent * dimen(R.dimen.indent),
0,
0,
0
)
}
}
// Do nothing
}
override fun select(item: BlockView.Selectable) {
@ -139,16 +113,14 @@ class Numbered(
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
decoratableContainer.decorate(
decorations = decorations
) { rect ->
binding.graphicPlusTextContainer.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_indent) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = rect.bottom
// TODO handle top and bottom offsets
}
decoratableContainer.decorate(
decorations = decorations
) { rect ->
binding.graphicPlusTextContainer.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_indent) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = rect.bottom
// TODO handle top and bottom offsets
}
}
}

View file

@ -48,20 +48,6 @@ class Paragraph(
mentionCheckedIcon = ContextCompat.getDrawable(this, R.drawable.ic_task_1_text_16)
mentionInitialsSize = resources.getDimension(R.dimen.mention_span_initials_size_default)
}
applyDefaultOffsets()
}
private fun applyDefaultOffsets() {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
binding.root.updatePadding(
left = dimen(R.dimen.default_document_item_padding_start),
right = dimen(R.dimen.default_document_item_padding_end)
)
binding.root.updateLayoutParams<RecyclerView.LayoutParams> {
topMargin = dimen(R.dimen.default_document_item_margin_top)
bottomMargin = dimen(R.dimen.default_document_item_margin_bottom)
}
}
}
override fun getMentionIconSize(): Int = mentionIconSize
@ -70,28 +56,19 @@ class Paragraph(
override fun getMentionUncheckedIcon(): Drawable? = mentionUncheckedIcon
override fun getMentionInitialsSize(): Float = mentionInitialsSize
/**
* Basic indentation is skipped if [BuildConfig.NESTED_DECORATION_ENABLED]
* @see applyDecorations method.
*/
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
content.updatePadding(
left = dimen(R.dimen.default_document_content_padding_start) + item.indent * dimen(R.dimen.indent)
)
}
// Do nothing.
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
decoratableContainer.decorate(
decorations = decorations
) { rect ->
content.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.dp_8) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = rect.bottom
}
decoratableContainer.decorate(
decorations = decorations
) { rect ->
content.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.dp_8) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = rect.bottom
}
}
}

View file

@ -56,24 +56,6 @@ class Toggle(
mentionCheckedIcon = ContextCompat.getDrawable(this, R.drawable.ic_task_1_text_16)
mentionInitialsSize = resources.getDimension(R.dimen.mention_span_initials_size_default)
}
applyDefaultOffsets()
}
private fun applyDefaultOffsets() {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
binding.root.updatePadding(
left = dimen(R.dimen.default_document_item_padding_start),
right = dimen(R.dimen.default_document_item_padding_end)
)
binding.root.updateLayoutParams<RecyclerView.LayoutParams> {
topMargin = dimen(R.dimen.default_document_item_margin_top)
bottomMargin = dimen(R.dimen.default_document_item_margin_bottom)
}
binding.graphicPlusTextContainer.updatePadding(
left = dimen(R.dimen.default_document_content_padding_start),
right = dimen(R.dimen.default_document_content_padding_end),
)
}
}
override fun bind(
@ -107,10 +89,9 @@ class Toggle(
override fun getMentionUncheckedIcon(): Drawable? = mentionUncheckedIcon
override fun getMentionInitialsSize(): Float = mentionInitialsSize
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
line.setGuidelineBegin(item.indent * dimen(R.dimen.indent))
}
// Do nothing.
}
override fun select(item: BlockView.Selectable) {
@ -157,16 +138,14 @@ class Toggle(
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
if (BuildConfig.NESTED_DECORATION_ENABLED) {
decoratableContainer.decorate(
decorations = decorations
) { rect ->
binding.graphicPlusTextContainer.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_indent) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = rect.bottom
// TODO handle top and bottom offsets
}
decoratableContainer.decorate(
decorations = decorations
) { rect ->
binding.graphicPlusTextContainer.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = dimen(R.dimen.default_indent) + rect.left
marginEnd = dimen(R.dimen.dp_8) + rect.right
bottomMargin = rect.bottom
// TODO handle top and bottom offsets
}
}
}

View file

@ -35,31 +35,20 @@ class BookmarkUpload(
binding.editUrl.text = url
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.indentize(
indent = item.indent,
defIndent = dimen(R.dimen.indent),
margin = dimen(R.dimen.bookmark_default_margin_start)
)
}
// Do nothing.
}
override fun select(isSelected: Boolean) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.isSelected = isSelected
} else {
binding.selected.isSelected = isSelected
}
binding.selected.isSelected = isSelected
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
super.applyDecorations(decorations)
if (BuildConfig.NESTED_DECORATION_ENABLED) {
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
}
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
}
}

View file

@ -28,31 +28,20 @@ class FileUpload(
clicked(ListenerType.File.Upload(target))
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.indentize(
indent = item.indent,
defIndent = dimen(R.dimen.indent),
margin = dimen(R.dimen.bookmark_default_margin_start)
)
}
// Do nothing.
}
override fun select(isSelected: Boolean) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.isSelected = isSelected
} else {
binding.selected.isSelected = isSelected
}
binding.selected.isSelected = isSelected
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
super.applyDecorations(decorations)
if (BuildConfig.NESTED_DECORATION_ENABLED) {
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
}
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
}
}

View file

@ -31,20 +31,6 @@ abstract class MediaUpload(
init {
itemView.setOnTouchListener { v, e -> editorTouchProcessor.process(v, e) }
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
view.updatePadding(
top = dimen(R.dimen.dp_6),
left = dimen(R.dimen.dp_12),
right = dimen(R.dimen.dp_12),
bottom = dimen(R.dimen.dp_6)
)
view.updateLayoutParams<RecyclerView.LayoutParams> {
marginStart = dimen(R.dimen.dp_8)
marginEnd = dimen(R.dimen.dp_8)
bottomMargin = dimen(R.dimen.dp_1)
topMargin = dimen(R.dimen.dp_1)
}
}
}
fun bind(

View file

@ -27,14 +27,9 @@ class PictureUpload(
clicked(ListenerType.Video.Upload(target))
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.indentize(
indent = item.indent,
defIndent = dimen(R.dimen.indent),
margin = dimen(R.dimen.bookmark_default_margin_start)
)
}
// Do nothing.
}
override fun select(isSelected: Boolean) {

View file

@ -28,31 +28,20 @@ class VideoUpload(
clicked(ListenerType.Video.Upload(target))
}
@Deprecated("Pre-nested-styling legacy.")
override fun indentize(item: BlockView.Indentable) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.indentize(
indent = item.indent,
defIndent = dimen(R.dimen.indent),
margin = dimen(R.dimen.bookmark_default_margin_start)
)
}
// Do nothing.
}
override fun select(isSelected: Boolean) {
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
root.isSelected = isSelected
} else {
binding.selected.isSelected = isSelected
}
binding.selected.isSelected = isSelected
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
super.applyDecorations(decorations)
if (BuildConfig.NESTED_DECORATION_ENABLED) {
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
}
binding.selected.applySelectorOffset<FrameLayout.LayoutParams>(
content = binding.card,
res = itemView.resources
)
}
}

View file

@ -16,9 +16,7 @@
android:layout_marginTop="1dp"
android:layout_marginBottom="1dp"
android:addStatesFromChildren="true"
android:background="@drawable/item_block_multi_select_mode_selector"
android:orientation="horizontal"
tools:background="@drawable/item_block_multi_select_selected"
tools:ignore="UselessParent">
<View
@ -50,4 +48,11 @@
</LinearLayout>
<View
android:id="@+id/selected"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:background="@drawable/item_block_multi_select_mode_selector" />
</FrameLayout>

View file

@ -301,14 +301,6 @@ class BlockAdapterTest {
),
clicked = {},
)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val expected = context.resources.getColor(R.color.palette_very_light_purple)
assertEquals(
expected = expected,
actual = (holder.root.background as ColorDrawable).color
)
}
}
@Test
@ -737,603 +729,6 @@ class BlockAdapterTest {
)
}
@Test
fun `should apply indent to paragraph view`() {
val paragraph = BlockView.Text.Paragraph(
id = MockDataFactory.randomUuid(),
text = MockDataFactory.randomString(),
indent = MockDataFactory.randomInt()
)
val views = listOf(paragraph)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, HOLDER_PARAGRAPH)
adapter.bindViewHolder(holder, 0)
check(holder is Paragraph)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.content.paddingLeft
val expected =
holder.dimen(R.dimen.default_document_content_padding_start) + paragraph.indent * holder.dimen(
R.dimen.indent
)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to header-one view`() {
val view = BlockView.Text.Header.One(
id = MockDataFactory.randomUuid(),
text = MockDataFactory.randomString(),
indent = MockDataFactory.randomInt()
)
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_HEADER_ONE)
adapter.bindViewHolder(holder, 0)
check(holder is HeaderOne)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.content.paddingLeft
val expected =
holder.dimen(R.dimen.default_document_content_padding_start) + view.indent * holder.dimen(
R.dimen.indent
)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to header-two view`() {
val view = BlockView.Text.Header.Two(
id = MockDataFactory.randomUuid(),
text = MockDataFactory.randomString(),
indent = MockDataFactory.randomInt()
)
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_HEADER_TWO)
adapter.bindViewHolder(holder, 0)
check(holder is HeaderTwo)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.content.paddingLeft
val expected =
holder.dimen(R.dimen.default_document_content_padding_start) + view.indent * holder.dimen(
R.dimen.indent
)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to header-three view`() {
val view = BlockView.Text.Header.Three(
id = MockDataFactory.randomUuid(),
text = MockDataFactory.randomString(),
indent = MockDataFactory.randomInt()
)
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_HEADER_THREE)
adapter.bindViewHolder(holder, 0)
check(holder is HeaderThree)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.content.paddingLeft
val expected =
holder.dimen(R.dimen.default_document_content_padding_start) + view.indent * holder.dimen(
R.dimen.indent
)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to checkbox view`() {
val view = StubCheckboxView()
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_CHECKBOX)
adapter.bindViewHolder(holder, 0)
check(holder is Checkbox)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.itemView.findViewById<ImageView>(R.id.checkboxIcon).paddingLeft
val expected = view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to toggle view`() {
val view = BlockView.Text.Toggle(
id = MockDataFactory.randomUuid(),
text = MockDataFactory.randomString(),
indent = MockDataFactory.randomInt(),
toggled = MockDataFactory.randomBoolean(),
isFocused = false,
marks = emptyList()
)
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_TOGGLE)
adapter.bindViewHolder(holder, 0)
check(holder is Toggle)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual =
(holder.itemView.findViewById<Guideline>(R.id.guideline).layoutParams as ConstraintLayout.LayoutParams).guideBegin
val expected = view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to file placeholder view`() {
val view = StubFilePlaceholderView()
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_FILE_PLACEHOLDER)
adapter.bindViewHolder(holder, 0)
check(holder is FilePlaceholder)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.itemView.paddingLeft
val expected =
holder.dimen(R.dimen.default_document_item_padding_start) + view.indent * holder.dimen(
R.dimen.indent
)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to file error view`() {
val view = BlockView.Error.File(
id = MockDataFactory.randomUuid(),
indent = MockDataFactory.randomInt(),
decorations = emptyList()
)
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_FILE_ERROR)
adapter.bindViewHolder(holder, 0)
check(holder is FileError)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.itemView.marginLeft
val expected = view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to file upload view`() {
val view = BlockView.Upload.File(
id = MockDataFactory.randomUuid(),
indent = MockDataFactory.randomInt()
)
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_FILE_UPLOAD)
adapter.bindViewHolder(holder, 0)
check(holder is FileUpload)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.itemView.marginLeft
val expected =
holder.dimen(R.dimen.bookmark_default_margin_start) + view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to video view`() {
val view = givenVideo()
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_VIDEO)
adapter.bindViewHolder(holder, 0)
check(holder is Video)
val actual = holder.itemView.marginLeft
val expected =
holder.dimen(R.dimen.bookmark_default_margin_start) + view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
}
@Test
fun `should apply indent to video placeholder view`() {
val view = StubVideoPlaceholderView()
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_VIDEO_PLACEHOLDER)
adapter.bindViewHolder(holder, 0)
check(holder is VideoPlaceholder)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.itemView.paddingLeft
val expected =
holder.dimen(R.dimen.default_document_item_padding_start) + view.indent * holder.dimen(
R.dimen.indent
)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to video upload view`() {
val view = BlockView.Upload.Video(
id = MockDataFactory.randomUuid(),
indent = MockDataFactory.randomInt()
)
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_VIDEO_UPLOAD)
adapter.bindViewHolder(holder, 0)
check(holder is VideoUpload)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.itemView.marginLeft
val expected =
holder.dimen(R.dimen.bookmark_default_margin_start) + view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to video error view`() {
val view = BlockView.Error.Video(
id = MockDataFactory.randomUuid(),
indent = MockDataFactory.randomInt(),
decorations = emptyList()
)
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_VIDEO_ERROR)
adapter.bindViewHolder(holder, 0)
check(holder is VideoError)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.itemView.marginLeft
val expected = view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to page view`() {
val view = BlockView.LinkToObject.Default.Text(
id = MockDataFactory.randomUuid(),
indent = MockDataFactory.randomInt(),
icon = ObjectIcon.None
)
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_OBJECT_LINK_DEFAULT)
adapter.bindViewHolder(holder, 0)
check(holder is LinkToObject)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.itemView.marginLeft
val expected = view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to bookmark placeholder view`() {
val view = StubBookmarkPlaceholderView()
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_BOOKMARK_PLACEHOLDER)
adapter.bindViewHolder(holder, 0)
check(holder is BookmarkPlaceholder)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.itemView.findViewById<ViewGroup>(R.id.root).paddingLeft
val expected =
view.indent * holder.dimen(R.dimen.indent) + holder.dimen(R.dimen.default_document_item_padding_start)
assertEquals(expected, actual)
} else {
val actual = holder.itemView.findViewById<ViewGroup>(R.id.root).paddingLeft
val expected = 0
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to picture view`() {
val view = BlockView.Media.Picture(
id = MockDataFactory.randomUuid(),
hash = MockDataFactory.randomString(),
indent = MockDataFactory.randomInt(),
mime = MockDataFactory.randomString(),
name = MockDataFactory.randomString(),
size = MockDataFactory.randomLong(),
url = MockDataFactory.randomString(),
decorations = emptyList()
)
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_PICTURE)
adapter.bindViewHolder(holder, 0)
check(holder is Picture)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.itemView.marginLeft
val expected =
holder.dimen(R.dimen.bookmark_default_margin_start) + view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to picture placeholder view`() {
val view = StubPicturePlaceholderView()
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_PICTURE_PLACEHOLDER)
adapter.bindViewHolder(holder, 0)
check(holder is PicturePlaceholder)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.itemView.paddingLeft
val expected =
holder.dimen(R.dimen.default_document_item_padding_start) + view.indent * holder.dimen(
R.dimen.indent
)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to picture error view`() {
val view = BlockView.Error.Picture(
id = MockDataFactory.randomUuid(),
indent = MockDataFactory.randomInt(),
decorations = emptyList()
)
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_PICTURE_ERROR)
adapter.bindViewHolder(holder, 0)
check(holder is PictureError)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.itemView.marginLeft
val expected = view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to picture upload view`() {
val view = BlockView.Upload.Picture(
id = MockDataFactory.randomUuid(),
indent = MockDataFactory.randomInt()
)
val views = listOf(view)
val recycler = RecyclerView(context).apply {
layoutManager = LinearLayoutManager(context)
}
val adapter = givenAdapter(views)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_PICTURE_UPLOAD)
adapter.bindViewHolder(holder, 0)
check(holder is PictureUpload)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.itemView.marginLeft
val expected =
holder.dimen(R.dimen.bookmark_default_margin_start) + view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
}
}
//@Test
fun `should apply focus to title block with payload change`() {

View file

@ -23,13 +23,11 @@ fun StubParagraphView(
searchFields: List<BlockView.Searchable.Field> = emptyList(),
backgroundColor: ThemeColor = ThemeColor.DEFAULT,
mode: BlockView.Mode = BlockView.Mode.EDIT,
decorations: List<BlockView.Decoration> = if (BuildConfig.NESTED_DECORATION_ENABLED)
listOf(
BlockView.Decoration(
background = backgroundColor
)
) else
emptyList(),
decorations: List<BlockView.Decoration> = listOf(
BlockView.Decoration(
background = backgroundColor
)
),
ghostSelection: IntRange? = null,
cursor: Int? = null,
alignment: Alignment? = null
@ -223,15 +221,12 @@ fun StubBookmarkPlaceholderView(
indent: Indent = MockDataFactory.randomInt(),
isPreviousBlockMedia: Boolean = false,
background: ThemeColor = ThemeColor.DEFAULT,
decorations: List<BlockView.Decoration> = if (BuildConfig.NESTED_DECORATION_ENABLED)
listOf(
BlockView.Decoration(
style = BlockView.Decoration.Style.Card,
background = background
)
decorations: List<BlockView.Decoration> = listOf(
BlockView.Decoration(
style = BlockView.Decoration.Style.Card,
background = background
)
else
emptyList()
)
): BlockView.MediaPlaceholder.Bookmark = BlockView.MediaPlaceholder.Bookmark(
id = id,
indent = indent,
@ -245,15 +240,12 @@ fun StubPicturePlaceholderView(
indent: Indent = MockDataFactory.randomInt(),
isPreviousBlockMedia: Boolean = false,
background: ThemeColor = ThemeColor.DEFAULT,
decorations: List<BlockView.Decoration> = if (BuildConfig.NESTED_DECORATION_ENABLED)
listOf(
BlockView.Decoration(
style = BlockView.Decoration.Style.Card,
background = background
)
decorations: List<BlockView.Decoration> = listOf(
BlockView.Decoration(
style = BlockView.Decoration.Style.Card,
background = background
)
else
emptyList()
)
): BlockView.MediaPlaceholder.Picture = BlockView.MediaPlaceholder.Picture(
id = id,
indent = indent,
@ -267,15 +259,12 @@ fun StubVideoPlaceholderView(
indent: Indent = MockDataFactory.randomInt(),
isPreviousBlockMedia: Boolean = false,
background: ThemeColor = ThemeColor.DEFAULT,
decorations: List<BlockView.Decoration> = if (BuildConfig.NESTED_DECORATION_ENABLED)
listOf(
BlockView.Decoration(
style = BlockView.Decoration.Style.Card,
background = background
)
decorations: List<BlockView.Decoration> = listOf(
BlockView.Decoration(
style = BlockView.Decoration.Style.Card,
background = background
)
else
emptyList()
)
): BlockView.MediaPlaceholder.Video = BlockView.MediaPlaceholder.Video(
id = id,
indent = indent,
@ -289,15 +278,12 @@ fun StubFilePlaceholderView(
indent: Indent = MockDataFactory.randomInt(),
isPreviousBlockMedia: Boolean = false,
background: ThemeColor = ThemeColor.DEFAULT,
decorations: List<BlockView.Decoration> = if (BuildConfig.NESTED_DECORATION_ENABLED)
listOf(
BlockView.Decoration(
style = BlockView.Decoration.Style.Card,
background = background
)
decorations: List<BlockView.Decoration> = listOf(
BlockView.Decoration(
style = BlockView.Decoration.Style.Card,
background = background
)
else
emptyList()
)
): BlockView.MediaPlaceholder.File = BlockView.MediaPlaceholder.File(
id = id,
indent = indent,

View file

@ -70,12 +70,7 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() {
adapter.onBindViewHolder(holder, 0, payloads = payload)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
assertEquals(
actual = holder.content.paddingLeft,
expected = padding + (indent.toInt() * 2)
)
}
// TODO check apply decorations
}
@Test
@ -125,12 +120,7 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() {
adapter.onBindViewHolder(holder, 0, payloads = payload)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
assertEquals(
actual = holder.content.paddingLeft,
expected = padding + (indent.toInt() * 2)
)
}
// TODO check apply decorations
}
@Test
@ -180,12 +170,7 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() {
adapter.onBindViewHolder(holder, 0, payloads = payload)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
assertEquals(
actual = holder.content.paddingLeft,
expected = padding + (indent.toInt() * 2)
)
}
// TODO check apply decorations
}
@Test
@ -235,12 +220,7 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() {
adapter.onBindViewHolder(holder, 0, payloads = payload)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
assertEquals(
actual = holder.content.paddingLeft,
expected = padding + (indent.toInt() * 2)
)
}
// TODO check apply decorations
}
@Test
@ -289,12 +269,7 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() {
adapter.onBindViewHolder(holder, 0, payloads = payload)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
assertEquals(
actual = holder.checkbox.paddingLeft,
expected = indent.toInt() * 2
)
}
// TODO check apply decorations
}
@Test
@ -344,11 +319,6 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() {
adapter.onBindViewHolder(holder, 0, payloads = payload)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
assertEquals(
actual = holder.number.marginLeft,
expected = indent.toInt() * 2
)
}
// TODO check apply decorations
}
}

View file

@ -56,7 +56,6 @@ class EditorNestedDecorationListBlockTest {
*/
@Test
fun `numbered should have two backgrounds with indentation - when current block of another block`() {
if (!BuildConfig.NESTED_DECORATION_ENABLED) return
scenario.onFragment {
// SETUP
@ -108,7 +107,6 @@ class EditorNestedDecorationListBlockTest {
*/
@Test
fun `bulleted should have two backgrounds with indentation - when current block of another block`() {
if (!BuildConfig.NESTED_DECORATION_ENABLED) return
scenario.onFragment {
// SETUP
@ -160,7 +158,6 @@ class EditorNestedDecorationListBlockTest {
*/
@Test
fun `checkbox should have two backgrounds with indentation - when current block of another block`() {
if (!BuildConfig.NESTED_DECORATION_ENABLED) return
scenario.onFragment {
// SETUP
@ -212,7 +209,6 @@ class EditorNestedDecorationListBlockTest {
*/
@Test
fun `toggle should have two backgrounds with indentation - when current block of another block`() {
if (!BuildConfig.NESTED_DECORATION_ENABLED) return
scenario.onFragment {
// SETUP

View file

@ -9,7 +9,6 @@ android {
defaultConfig {
buildConfigField "boolean", "ENABLE_LINK_APPERANCE_MENU", "true"
buildConfigField "boolean", "NESTED_DECORATION_ENABLED", "true"
buildConfigField "boolean", "USE_SIMPLE_TABLES_IN_EDITOR_EDDITING", "true"
buildConfigField "boolean", "ENABLE_WIDGETS", "false"
}

View file

@ -50,7 +50,7 @@ fun buildNestedDecorationData(
style = DecorationData.Style.None,
background = block.parseThemeBackgroundColor()
)
): NestedDecorationData = if (BuildConfig.NESTED_DECORATION_ENABLED) buildList {
): NestedDecorationData = buildList {
// Normalizing parent scheme
parentScheme.forEach { holder ->
when (val style = holder.style) {
@ -87,7 +87,7 @@ fun buildNestedDecorationData(
}
// Adding current style
add(currentDecoration)
} else emptyList()
}
fun NestedDecorationData.toBlockViewDecoration(block: Block): List<BlockView.Decoration> {
return map { holder ->

View file

@ -18,7 +18,6 @@ import com.anytypeio.anytype.domain.editor.Editor.Focus
import com.anytypeio.anytype.domain.misc.UrlBuilder
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
import com.anytypeio.anytype.domain.objects.StoreOfRelations
import com.anytypeio.anytype.presentation.BuildConfig.NESTED_DECORATION_ENABLED
import com.anytypeio.anytype.presentation.editor.Editor
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
import com.anytypeio.anytype.presentation.editor.editor.ext.getTextAndMarks
@ -332,14 +331,10 @@ class DefaultBlockViewRenderer @Inject constructor(
}
Content.Text.Style.QUOTE -> {
mCounter = 0
val normalized: NestedDecorationData = if (NESTED_DECORATION_ENABLED) {
normalizeNestedDecorationData(
block = block,
parentScheme = parentScheme
)
} else {
emptyList()
}
val normalized: NestedDecorationData = normalizeNestedDecorationData(
block = block,
parentScheme = parentScheme
)
val current = DecorationData(
style = DecorationData.Style.Highlight(
start = block.id,
@ -356,7 +351,7 @@ class DefaultBlockViewRenderer @Inject constructor(
indent = indent,
details = details,
selection = selection,
scheme = if (NESTED_DECORATION_ENABLED) normalized else emptyList()
scheme = normalized
)
)
if (block.children.isNotEmpty()) {
@ -372,10 +367,7 @@ class DefaultBlockViewRenderer @Inject constructor(
restrictions = restrictions,
selection = selection,
onRenderFlag = onRenderFlag,
parentScheme = if (NESTED_DECORATION_ENABLED)
(normalized + current)
else
emptyList()
parentScheme = (normalized + current)
)
)
}
@ -1058,18 +1050,14 @@ class DefaultBlockViewRenderer @Inject constructor(
details = details,
marks = marks
)
val current = if (NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Highlight.Itself(
hasChildren = block.children.isNotEmpty()
)
val current = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Highlight.Itself(
hasChildren = block.children.isNotEmpty()
)
)
} else {
emptyList()
}
)
return BlockView.Text.Highlight(
mode = if (mode == EditorMode.Edit) BlockView.Mode.EDIT else BlockView.Mode.READ,
id = block.id,

View file

@ -4,7 +4,6 @@ import android.os.Build
import com.anytypeio.anytype.core_models.Block
import com.anytypeio.anytype.core_models.Event
import com.anytypeio.anytype.core_models.ext.content
import com.anytypeio.anytype.presentation.BuildConfig.NESTED_DECORATION_ENABLED
import com.anytypeio.anytype.presentation.editor.editor.BlockDimensions
import com.anytypeio.anytype.presentation.editor.editor.ViewState
import com.anytypeio.anytype.presentation.editor.editor.actions.ActionItemType
@ -59,25 +58,6 @@ class BlockReadModeTest : EditorViewModelTest() {
)
) + listOf(header, title) + blocks
private val blockViewsReadMode = listOf<BlockView>(
blocks[0].let { p ->
BlockView.Text.Paragraph(
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ
)
},
blocks[1].let { p ->
BlockView.Text.Paragraph(
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ
)
}
)
private val blockViewsReadModeSelected = listOf<BlockView>(
blocks[0].let { p ->
BlockView.Text.Paragraph(
@ -85,15 +65,11 @@ class BlockReadModeTest : EditorViewModelTest() {
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
decorations = if (NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
},
blocks[1].let { p ->
@ -103,15 +79,11 @@ class BlockReadModeTest : EditorViewModelTest() {
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
isSelected = true,
decorations = if (NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
}
)
@ -123,15 +95,11 @@ class BlockReadModeTest : EditorViewModelTest() {
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.EDIT,
decorations = if (NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
},
blocks[1].let { p ->
@ -140,15 +108,11 @@ class BlockReadModeTest : EditorViewModelTest() {
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.EDIT,
decorations = if (NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
}
)
@ -212,15 +176,11 @@ class BlockReadModeTest : EditorViewModelTest() {
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
decorations = if (NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
},
blocks[1].let { p ->
@ -230,15 +190,11 @@ class BlockReadModeTest : EditorViewModelTest() {
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
isSelected = true,
decorations = if (NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
}
)
@ -314,15 +270,11 @@ class BlockReadModeTest : EditorViewModelTest() {
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
decorations = if (NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
},
blocks[1].let { p ->
@ -332,15 +284,11 @@ class BlockReadModeTest : EditorViewModelTest() {
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
decorations = if (NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
}
)

View file

@ -460,15 +460,11 @@ open class EditorViewModelTest {
id = paragraph.id,
text = paragraph.content<Block.Content.Text>().text,
background = paragraph.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -689,29 +685,21 @@ open class EditorViewModelTest {
id = paragraph.id,
text = paragraph.content.asText().text,
background = paragraph.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = added.id,
text = added.content.asText().text,
background = added.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = added.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = added.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -834,15 +822,11 @@ open class EditorViewModelTest {
id = paragraph.id,
text = paragraph.content.asText().text,
background = paragraph.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -964,15 +948,11 @@ open class EditorViewModelTest {
to = firstTimeRange.last()
)
),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -1015,15 +995,11 @@ open class EditorViewModelTest {
to = secondTimeRange.last()
)
),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -1122,15 +1098,11 @@ open class EditorViewModelTest {
to = firstTimeRange.last()
)
),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -1176,15 +1148,11 @@ open class EditorViewModelTest {
to = secondTimeRange.last()
)
),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -1338,15 +1306,11 @@ open class EditorViewModelTest {
id = paragraph.id,
text = paragraph.content.asText().text,
background = paragraph.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -1666,15 +1630,11 @@ open class EditorViewModelTest {
id = paragraph.id,
text = paragraph.content<Block.Content.Text>().text,
background = paragraph.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -1694,31 +1654,23 @@ open class EditorViewModelTest {
id = paragraph.id,
text = paragraph.content<Block.Content.Text>().text,
background = paragraph.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.One(
id = new.id,
text = new.content<Block.Content.Text>().text,
background = new.parseThemeBackgroundColor(),
indent = 0,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = new.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H1
)
decorations = listOf(
BlockView.Decoration(
background = new.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H1
)
} else {
emptyList()
}
)
)
)
)
@ -1917,29 +1869,21 @@ open class EditorViewModelTest {
id = firstChild.id,
text = firstChild.content<Block.Content.Text>().text,
background = firstChild.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = firstChild.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = firstChild.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = secondChild.id,
text = secondChild.content<Block.Content.Text>().text,
background = secondChild.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = secondChild.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = secondChild.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -1969,15 +1913,11 @@ open class EditorViewModelTest {
id = secondChild.id,
text = secondChild.content<Block.Content.Text>().text,
background = secondChild.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = secondChild.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = secondChild.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -3227,15 +3167,11 @@ open class EditorViewModelTest {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
},
paragraphs[1].let { p ->
@ -3243,15 +3179,11 @@ open class EditorViewModelTest {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
},
paragraphs[2].let { p ->
@ -3259,15 +3191,11 @@ open class EditorViewModelTest {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
}
)
@ -3410,15 +3338,11 @@ open class EditorViewModelTest {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
}
)
@ -3507,16 +3431,12 @@ open class EditorViewModelTest {
id = picture.id,
mode = BlockView.Mode.EDIT,
indent = 0,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT,
style = BlockView.Decoration.Style.Card
)
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT,
style = BlockView.Decoration.Style.Card
)
} else {
emptyList()
}
)
)
)
@ -3586,16 +3506,12 @@ open class EditorViewModelTest {
id = video.id,
mode = BlockView.Mode.EDIT,
indent = 0,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT,
style = BlockView.Decoration.Style.Card
)
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT,
style = BlockView.Decoration.Style.Card
)
} else {
emptyList()
}
)
)
)
@ -3660,16 +3576,12 @@ open class EditorViewModelTest {
id = file.id,
mode = BlockView.Mode.EDIT,
indent = 0,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT,
style = BlockView.Decoration.Style.Card
)
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT,
style = BlockView.Decoration.Style.Card
)
} else {
emptyList()
}
)
)
)
@ -4055,15 +3967,11 @@ open class EditorViewModelTest {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
},
paragraphs[1].let { p ->
@ -4071,15 +3979,11 @@ open class EditorViewModelTest {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
},
paragraphs[2].let { p ->
@ -4087,15 +3991,11 @@ open class EditorViewModelTest {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
}
)
@ -4170,15 +4070,11 @@ open class EditorViewModelTest {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
},
paragraphs[1].let { p ->
@ -4186,15 +4082,11 @@ open class EditorViewModelTest {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
},
paragraphs[2].let { p ->
@ -4202,15 +4094,11 @@ open class EditorViewModelTest {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
}
)
@ -4289,15 +4177,11 @@ open class EditorViewModelTest {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
},
paragraphs[1].let { p ->
@ -4305,15 +4189,11 @@ open class EditorViewModelTest {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
},
paragraphs[2].let { p ->
@ -4321,15 +4201,11 @@ open class EditorViewModelTest {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
}
)

View file

@ -156,15 +156,11 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
isFocused = true,
cursor = parent.content<Block.Content.Text>().text.length,
text = parent.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -278,15 +274,11 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
id = parent.id,
isFocused = false,
text = parent.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Bulleted(
id = child1.id,
@ -294,18 +286,14 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
indent = 1,
cursor = child1.content<Block.Content.Text>().text.length,
text = child1.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child1.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child1.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -419,15 +407,11 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
id = parent.id,
isFocused = false,
text = parent.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Bulleted(
indent = 1,
@ -435,18 +419,14 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
isFocused = true,
cursor = child1.content<Block.Content.Text>().text.length,
text = child1.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child1.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child1.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -531,15 +511,11 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
id = paragraph.id,
isFocused = true,
text = paragraph.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
)
)
@ -636,15 +612,11 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
id = paragraph.id,
isFocused = true,
text = paragraph.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
)
)

View file

@ -179,42 +179,30 @@ class EditorDuplicateTest : EditorPresentationTestSetup() {
id = a.id,
text = a.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.DividerLine(
id = b.id,
isSelected = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = c.id,
text = c.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = c.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = c.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -244,55 +232,39 @@ class EditorDuplicateTest : EditorPresentationTestSetup() {
id = a.id,
text = a.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.DividerLine(
id = b.id,
isSelected = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.DividerLine(
id = copy.id,
isSelected = false,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = copy.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = copy.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = c.id,
text = c.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = c.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = c.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -356,15 +328,11 @@ class EditorDuplicateTest : EditorPresentationTestSetup() {
text = a.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
isSelected = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = b.id,
@ -372,32 +340,24 @@ class EditorDuplicateTest : EditorPresentationTestSetup() {
mode = BlockView.Mode.READ,
isSelected = true,
indent = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = c.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = c.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = c.id,
text = c.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = c.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = c.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)

View file

@ -172,15 +172,11 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
@ -281,15 +277,11 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
@ -390,15 +382,11 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
@ -511,15 +499,11 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
@ -651,15 +635,11 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
@ -773,15 +753,11 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
@ -901,15 +877,11 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)

View file

@ -111,15 +111,11 @@ class EditorGranularChangeTest : EditorPresentationTestSetup() {
BlockView.Text.Checkbox(
id = checkbox.id,
text = checkbox.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = checkbox.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = checkbox.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -137,15 +133,11 @@ class EditorGranularChangeTest : EditorPresentationTestSetup() {
id = checkbox.id,
text = checkbox.content<Block.Content.Text>().text,
isChecked = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = checkbox.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = checkbox.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)

View file

@ -156,15 +156,11 @@ class EditorLatexBlockTest : EditorPresentationTestSetup() {
isFocused = false,
text = p.content<TXT>().text,
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Latex(
id = latex.id,

View file

@ -391,15 +391,11 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
isFocused = false,
isChecked = false,
indent = 0,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
} else {
emptyList()
}
)
)
)
)
@ -439,15 +435,11 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
id = child,
text = "",
isFocused = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
} else {
emptyList()
}
)
)
)
)
@ -525,15 +517,11 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
text = "",
isFocused = false,
indent = 0,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
} else {
emptyList()
}
)
)
)
)
@ -573,15 +561,11 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
id = child,
text = "",
isFocused = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
} else {
emptyList()
}
)
)
)
)
@ -680,15 +664,11 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
isFocused = false,
indent = 0,
isEmpty = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
} else {
emptyList()
}
)
)
)
)
@ -728,15 +708,11 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
id = child,
text = "",
isFocused = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
} else {
emptyList()
}
)
)
)
)
@ -815,15 +791,11 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
isFocused = false,
indent = 0,
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
} else {
emptyList()
}
)
)
)
)
@ -863,15 +835,11 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
id = child,
text = "",
isFocused = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
} else {
emptyList()
}
)
)
)
)

View file

@ -99,15 +99,11 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
id = child.id,
text = child.content<TXT>().text,
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = child.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = child.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
@ -168,15 +164,11 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
id = child.id,
text = child.content<TXT>().text,
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = child.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = child.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
@ -237,15 +229,11 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
id = child.id,
text = child.content<TXT>().text,
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = child.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = child.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
@ -309,15 +297,11 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
BlockView.LinkToObject.Default.Text(
id = link.id,
icon = ObjectIcon.None,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = link.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = link.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
@ -424,15 +408,11 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
)
),
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
@ -531,16 +511,12 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
title = bookmarkTitle,
mode = BlockView.Mode.READ,
isPreviousBlockMedia = false,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = bookmark.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Card
)
decorations = listOf(
BlockView.Decoration(
background = bookmark.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Card
)
} else {
emptyList()
}
)
)
)
@ -624,16 +600,12 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
name = null,
size = null,
url = builder.file(file.content<Block.Content.File>().hash),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT,
style = BlockView.Decoration.Style.None
)
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT,
style = BlockView.Decoration.Style.None
)
} else {
emptyList()
}
)
)
)
@ -718,16 +690,12 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
size = null,
url = builder.image(picture.content<Block.Content.File>().hash),
indent = 0,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT,
style = BlockView.Decoration.Style.Card
)
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT,
style = BlockView.Decoration.Style.Card
)
} else {
emptyList()
}
)
)
)

View file

@ -125,15 +125,11 @@ class EditorMarkupObjectTest : EditorPresentationTestSetup() {
indent = 0,
text = "Start Foobar End",
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -292,15 +288,11 @@ class EditorMarkupObjectTest : EditorPresentationTestSetup() {
indent = 0,
text = "Start Link Object Mention End",
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -467,15 +459,11 @@ class EditorMarkupObjectTest : EditorPresentationTestSetup() {
indent = 0,
text = "Start Link Object Mention End",
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)

View file

@ -232,15 +232,11 @@ class EditorMentionTest : EditorPresentationTestSetup() {
indent = 0,
text = "page about Avant-Garde Jazz music",
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -400,15 +396,11 @@ class EditorMentionTest : EditorPresentationTestSetup() {
indent = 0,
text = "page about Jazz music",
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -568,15 +560,11 @@ class EditorMentionTest : EditorPresentationTestSetup() {
indent = 0,
text = "page about Untitled music",
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -937,15 +925,11 @@ class EditorMentionTest : EditorPresentationTestSetup() {
indent = 0,
text = "Start Foob end",
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -1084,15 +1068,11 @@ class EditorMentionTest : EditorPresentationTestSetup() {
indent = 0,
text = "Start Untitled end",
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)

View file

@ -199,15 +199,11 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
indent = 0,
text = parent.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
val child1View = BlockView.Text.Paragraph(
@ -218,18 +214,14 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
indent = 1,
text = child1.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child1.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child1.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
val child2View = BlockView.Text.Paragraph(
@ -240,18 +232,14 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
indent = 1,
text = child2.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child2.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child2.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
val grandchild1View = BlockView.Text.Paragraph(
@ -262,21 +250,17 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
indent = 2,
text = grandchild1.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child1.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = grandchild1.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child1.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = grandchild1.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
val grandchild2View = BlockView.Text.Paragraph(
@ -287,21 +271,17 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
indent = 2,
text = grandchild2.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child1.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = grandchild2.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child1.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = grandchild2.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
vm.state.test().apply {
@ -472,15 +452,11 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
indent = 0,
text = parent.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
val child1View = BlockView.Text.Paragraph(
@ -491,18 +467,14 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
indent = 1,
text = child1.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child1.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child1.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
val child2View = BlockView.Text.Paragraph(
@ -513,18 +485,14 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
indent = 1,
text = child2.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child2.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child2.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
vm.state.test().apply {
@ -800,15 +768,11 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
text = a.content<TXT>().text,
mode = BlockView.Mode.EDIT,
isSelected = false,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -974,45 +938,33 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
text = a.content<TXT>().text,
mode = BlockView.Mode.READ,
isSelected = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = b.id,
text = b.content<TXT>().text,
mode = BlockView.Mode.READ,
isSelected = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = c.id,
text = c.content<TXT>().text,
mode = BlockView.Mode.READ,
isSelected = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = c.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = c.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)

View file

@ -144,30 +144,22 @@ class EditorQuickStartingScrollAndMoveTest : EditorPresentationTestSetup() {
number = 1,
mode = BlockView.Mode.READ,
isSelected = false,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = b.id,
text = b.content<TXT>().text,
mode = BlockView.Mode.READ,
isSelected = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -260,30 +252,22 @@ class EditorQuickStartingScrollAndMoveTest : EditorPresentationTestSetup() {
number = 1,
mode = BlockView.Mode.EDIT,
isSelected = false,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = b.id,
text = b.content<TXT>().text,
mode = BlockView.Mode.EDIT,
isSelected = false,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)

View file

@ -118,15 +118,11 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
id = a.id,
text = a.content<Block.Content.Text>().text,
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Relation.Related(
id = b.id,
@ -138,15 +134,11 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
format = relation.format,
system = false
),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -250,29 +242,21 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Relation.Deleted(
id = relationBlock.id,
indent = 0,
isSelected = false,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = relationBlock.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = relationBlock.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
@ -378,15 +362,11 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Relation.Related(
id = relationBlock.id,
@ -401,15 +381,11 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
format = r2.format,
system = false
),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = relationBlock.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = relationBlock.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
@ -470,29 +446,21 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Relation.Placeholder(
id = relationBlock.id,
indent = 0,
isSelected = false,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = relationBlock.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = relationBlock.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)

View file

@ -284,15 +284,11 @@ class EditorScrollAndMoveTest : EditorPresentationTestSetup() {
text = a.content<TXT>().text,
mode = BlockView.Mode.EDIT,
isSelected = false,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)

View file

@ -276,160 +276,116 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() {
id = blockText1.id,
indent = 0,
text = blockText1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText1.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = blockText1.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.One(
id = blockHeaderOne1.id,
indent = 0,
text = blockHeaderOne1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderOne1.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H1
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderOne1.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H1
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = blockText2.id,
indent = 0,
text = blockText2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText2.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = blockText2.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.Two(
id = blockHeaderTwo1.id,
indent = 0,
text = blockHeaderTwo1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderTwo1.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H2
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderTwo1.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H2
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = blockText3.id,
indent = 0,
text = blockText3.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText3.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = blockText3.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.One(
id = blockHeaderOne2.id,
indent = 0,
text = blockHeaderOne2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderOne2.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H1
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderOne2.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H1
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = blockText4.id,
indent = 0,
text = blockText4.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText4.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = blockText4.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.Two(
id = blockHeaderTwo2.id,
indent = 0,
text = blockHeaderTwo2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderTwo2.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H2
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderTwo2.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H2
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = blockText5.id,
indent = 0,
text = blockText5.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText5.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = blockText5.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.Three(
id = blockHeaderThree.id,
indent = 0,
text = blockHeaderThree.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderThree.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderThree.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = blockText6.id,
indent = 0,
text = blockText6.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText6.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = blockText6.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -594,88 +550,64 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() {
id = blockText1.id,
indent = 0,
text = blockText1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText1.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = blockText1.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.One(
id = blockHeaderOne.id,
indent = 0,
text = blockHeaderOne.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderOne.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H1
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderOne.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H1
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = blockText2.id,
indent = 0,
text = blockText2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText2.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = blockText2.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.Two(
id = blockHeaderTwo.id,
indent = 0,
text = blockHeaderTwo.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderTwo.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H2
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderTwo.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H2
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = blockText3.id,
indent = 0,
text = blockText3.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText3.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = blockText3.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.Three(
id = blockHeaderThree.id,
indent = 0,
text = blockHeaderThree.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderThree.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderThree.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
} else {
emptyList()
}
)
)
)
)
@ -728,44 +660,32 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() {
id = blockText1.id,
indent = 0,
text = blockText1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText1.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = blockText1.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.One(
id = blockHeaderOne.id,
indent = 0,
text = blockHeaderOne.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderOne.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H1
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderOne.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H1
)
} else {
emptyList()
}
)
),
BlockView.Text.Paragraph(
id = blockText2.id,
indent = 0,
text = blockText2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText2.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = blockText2.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.Two(
id = blockHeaderTwo.id,
@ -776,30 +696,22 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() {
id = blockText3.id,
indent = 0,
text = blockText3.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText3.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = blockText3.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.Three(
id = blockHeaderThree.id,
indent = 0,
text = blockHeaderThree.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderThree.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderThree.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
} else {
emptyList()
}
)
)
)
)
@ -959,76 +871,56 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() {
id = blockHeaderOne1.id,
indent = 0,
text = blockHeaderOne1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderOne1.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H1
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderOne1.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H1
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.Two(
id = blockHeaderTwo1.id,
indent = 0,
text = blockHeaderTwo1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderTwo1.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H2
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderTwo1.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H2
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.Three(
id = blockHeaderThree.id,
indent = 0,
text = blockHeaderThree.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderThree.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderThree.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.Two(
id = blockHeaderTwo2.id,
indent = 0,
text = blockHeaderTwo2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderTwo2.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H2
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderTwo2.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H2
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.Three(
id = blockHeaderThree2.id,
indent = 0,
text = blockHeaderThree2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderThree2.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderThree2.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
} else {
emptyList()
}
)
)
)
)
@ -1205,76 +1097,56 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() {
id = blockHeaderOne1.id,
indent = 0,
text = blockHeaderOne1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderOne1.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H1
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderOne1.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H1
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.Two(
id = blockHeaderTwo1.id,
indent = 0,
text = blockHeaderTwo1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderTwo1.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H2
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderTwo1.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H2
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.Three(
id = blockHeaderThree.id,
indent = 0,
text = blockHeaderThree.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderThree.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderThree.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.Two(
id = blockHeaderTwo2.id,
indent = 0,
text = blockHeaderTwo2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderTwo2.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H2
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderTwo2.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H2
)
} else {
emptyList()
}
)
),
BlockView.Text.Header.Three(
id = blockHeaderThree2.id,
indent = 0,
text = blockHeaderThree2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderThree2.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
decorations = listOf(
BlockView.Decoration(
background = blockHeaderThree2.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
} else {
emptyList()
}
)
)
)
)

View file

@ -329,15 +329,11 @@ class EditorTitleTest : EditorPresentationTestSetup() {
BlockView.Text.Bulleted(
id = block.id,
text = block.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -359,15 +355,11 @@ class EditorTitleTest : EditorPresentationTestSetup() {
BlockView.Text.Bulleted(
id = block.id,
text = block.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)
@ -461,15 +453,11 @@ class EditorTitleTest : EditorPresentationTestSetup() {
BlockView.Text.Bulleted(
id = block.id,
text = block.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
)
)

View file

@ -249,15 +249,11 @@ class TableBlockRendererTest {
BlockView.Text.Bulleted(
id = block.id,
text = block.content<TXT>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
} + listOf(
BlockView.Table(
@ -275,15 +271,11 @@ class TableBlockRendererTest {
id = block.id,
text = block.content<TXT>().text,
number = idx.inc(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
decorations = listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
} else {
emptyList()
}
)
)
}
@ -420,15 +412,11 @@ class TableBlockRendererTest {
BlockView.Text.Bulleted(
id = block.id,
text = block.content<TXT>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
} else {
emptyList()
}
)
)
} + listOf(
BlockView.Table(
@ -446,15 +434,11 @@ class TableBlockRendererTest {
id = block.id,
text = block.content<TXT>().text,
number = idx.inc(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
} else {
emptyList()
}
)
)
}
@ -764,15 +748,11 @@ class TableBlockRendererTest {
BlockView.Text.Bulleted(
id = block.id,
text = block.content<TXT>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
} else {
emptyList()
}
)
)
} + listOf(
BlockView.Table(
@ -790,15 +770,11 @@ class TableBlockRendererTest {
id = block.id,
text = block.content<TXT>().text,
number = idx.inc(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
} else {
emptyList()
}
)
)
}