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

DROID-225 Editor | Enhancement | Turn on feature toggle for nested styling and fix tests (#2480)

This commit is contained in:
Evgenii Kozlov 2022-08-08 17:54:51 +03:00 committed by GitHub
parent bc9fd974e4
commit 4937f933a1
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 1909 additions and 698 deletions

View file

@ -11,7 +11,7 @@ android {
targetSdkVersion config["target_sdk"]
testInstrumentationRunner config["test_runner"]
buildConfigField "boolean", "USE_NEW_WINDOW_INSET_API", "true"
buildConfigField "boolean", "NESTED_DECORATION_ENABLED", "false"
buildConfigField "boolean", "NESTED_DECORATION_ENABLED", "true"
}
testOptions {

View file

@ -262,13 +262,15 @@ class BlockAdapterTest {
// Setup
val paragraph = BlockView.Text.Paragraph(
text = MockDataFactory.randomString(),
id = MockDataFactory.randomUuid()
)
val paragraph = StubParagraphView()
val updated = paragraph.copy(
background = ThemeColor.PURPLE
background = ThemeColor.PURPLE,
decorations = listOf(
BlockView.Decoration(
background = ThemeColor.PURPLE
)
)
)
val views = listOf(paragraph)
@ -306,11 +308,13 @@ class BlockAdapterTest {
onSlashEvent = {}
)
val expected = context.resources.getColor(R.color.palette_very_light_purple)
assertEquals(
expected = expected,
actual = (holder.root.background as ColorDrawable).color
)
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
@ -823,14 +827,15 @@ class BlockAdapterTest {
check(holder is Paragraph)
val actual = holder.content.paddingLeft
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)
val expected =
holder.dimen(R.dimen.default_document_content_padding_start) + paragraph.indent * holder.dimen(
R.dimen.indent
)
assertEquals(expected, actual)
}
}
@Test
@ -856,14 +861,14 @@ class BlockAdapterTest {
check(holder is HeaderOne)
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)
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
@ -889,14 +894,16 @@ class BlockAdapterTest {
check(holder is HeaderTwo)
val actual = holder.content.paddingLeft
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
)
val expected =
holder.dimen(R.dimen.default_document_content_padding_start) + view.indent * holder.dimen(
R.dimen.indent
)
assertEquals(expected, actual)
assertEquals(expected, actual)
}
}
@Test
@ -922,25 +929,22 @@ class BlockAdapterTest {
check(holder is HeaderThree)
val actual = holder.content.paddingLeft
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
)
val expected =
holder.dimen(R.dimen.default_document_content_padding_start) + view.indent * holder.dimen(
R.dimen.indent
)
assertEquals(expected, actual)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to checkbox view`() {
val view = BlockView.Text.Checkbox(
id = MockDataFactory.randomUuid(),
text = MockDataFactory.randomString(),
indent = MockDataFactory.randomInt()
)
val view = StubCheckboxView()
val views = listOf(view)
val recycler = RecyclerView(context).apply {
@ -955,11 +959,11 @@ class BlockAdapterTest {
check(holder is Checkbox)
val actual = holder.itemView.findViewById<ImageView>(R.id.checkboxIcon).paddingLeft
val expected = view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
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
@ -988,22 +992,20 @@ class BlockAdapterTest {
check(holder is Toggle)
val actual =
(holder.itemView.findViewById<Guideline>(R.id.guideline).layoutParams as ConstraintLayout.LayoutParams).guideBegin
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)
val expected = view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to file placeholder view`() {
val view = BlockView.MediaPlaceholder.File(
id = MockDataFactory.randomUuid(),
indent = MockDataFactory.randomInt(),
isPreviousBlockMedia = false
)
val view = StubFilePlaceholderView()
val views = listOf(view)
@ -1019,12 +1021,14 @@ class BlockAdapterTest {
check(holder is FilePlaceholder)
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)
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
@ -1050,11 +1054,11 @@ class BlockAdapterTest {
check(holder is FileError)
val actual = holder.itemView.marginLeft
val expected = view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.itemView.marginLeft
val expected = view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
}
}
@Test
@ -1079,12 +1083,12 @@ class BlockAdapterTest {
check(holder is FileUpload)
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)
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
@ -1117,11 +1121,7 @@ class BlockAdapterTest {
@Test
fun `should apply indent to video placeholder view`() {
val view = BlockView.MediaPlaceholder.Video(
id = MockDataFactory.randomUuid(),
indent = MockDataFactory.randomInt(),
isPreviousBlockMedia = false
)
val view = StubVideoPlaceholderView()
val views = listOf(view)
@ -1137,12 +1137,14 @@ class BlockAdapterTest {
check(holder is VideoPlaceholder)
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)
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
@ -1167,12 +1169,14 @@ class BlockAdapterTest {
check(holder is VideoUpload)
val actual = holder.itemView.marginLeft
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)
val expected =
holder.dimen(R.dimen.bookmark_default_margin_start) + view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
assertEquals(expected, actual)
}
}
@Test
@ -1198,11 +1202,13 @@ class BlockAdapterTest {
check(holder is VideoError)
val actual = holder.itemView.marginLeft
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.itemView.marginLeft
val expected = view.indent * holder.dimen(R.dimen.indent)
val expected = view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
assertEquals(expected, actual)
}
}
@Test
@ -1228,56 +1234,17 @@ class BlockAdapterTest {
check(holder is LinkToObject)
val actual = holder.itemView.marginLeft
val expected = view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.itemView.marginLeft
val expected = view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
}
}
// Turned off the test, because Robolectric is not working with MateralCardView
// @Test
// fun `should apply indent to bookmark view`() {
//
// val view = BlockView.Bookmark.View(
// id = MockDataFactory.randomUuid(),
// indent = MockDataFactory.randomInt(),
// description = MockDataFactory.randomString(),
// title = MockDataFactory.randomString(),
// faviconUrl = MockDataFactory.randomString(),
// imageUrl = MockDataFactory.randomString(),
// url = MockDataFactory.randomString()
// )
//
// val views = listOf(view)
//
// val recycler = RecyclerView(context).apply {
// layoutManager = LinearLayoutManager(context)
// }
//
// val adapter = buildAdapter(views)
//
// val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_BOOKMARK)
//
// adapter.bindViewHolder(holder, 0)
//
// check(holder is Types.Bookmark)
//
// val actual = (holder.itemView.bookmarkRoot).marginLeft
//
// val expected = view.indent * holder.dimen(R.dimen.indent) + holder.dimen(R.dimen.dp_12)
//
// assertEquals(expected, actual)
// }
@Test
fun `should apply indent to bookmark placeholder view`() {
val view = BlockView.MediaPlaceholder.Bookmark(
id = MockDataFactory.randomUuid(),
indent = MockDataFactory.randomInt(),
isPreviousBlockMedia = false
)
val view = StubBookmarkPlaceholderView()
val views = listOf(view)
@ -1287,19 +1254,21 @@ class BlockAdapterTest {
val adapter = buildAdapter(views)
val holder =
adapter.onCreateViewHolder(recycler, Types.HOLDER_BOOKMARK_PLACEHOLDER)
val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_BOOKMARK_PLACEHOLDER)
adapter.bindViewHolder(holder, 0)
check(holder is BookmarkPlaceholder)
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)
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
@ -1330,22 +1299,20 @@ class BlockAdapterTest {
check(holder is Picture)
val actual = holder.itemView.marginLeft
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)
val expected =
holder.dimen(R.dimen.bookmark_default_margin_start) + view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
assertEquals(expected, actual)
}
}
@Test
fun `should apply indent to picture placeholder view`() {
val view = BlockView.MediaPlaceholder.Picture(
id = MockDataFactory.randomUuid(),
indent = MockDataFactory.randomInt(),
isPreviousBlockMedia = false
)
val view = StubPicturePlaceholderView()
val views = listOf(view)
@ -1361,11 +1328,14 @@ class BlockAdapterTest {
check(holder is PicturePlaceholder)
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)
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
@ -1391,11 +1361,13 @@ class BlockAdapterTest {
check(holder is PictureError)
val actual = holder.itemView.marginLeft
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
val actual = holder.itemView.marginLeft
val expected = view.indent * holder.dimen(R.dimen.indent)
val expected = view.indent * holder.dimen(R.dimen.indent)
assertEquals(expected, actual)
assertEquals(expected, actual)
}
}
@Test
@ -1420,12 +1392,11 @@ class BlockAdapterTest {
check(holder is PictureUpload)
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)
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

View file

@ -20,7 +20,13 @@ fun StubParagraphView(
searchFields: List<BlockView.Searchable.Field> = emptyList(),
backgroundColor: ThemeColor = ThemeColor.DEFAULT,
mode: BlockView.Mode = BlockView.Mode.EDIT,
decorations: List<BlockView.Decoration> = emptyList(),
decorations: List<BlockView.Decoration> = if (BuildConfig.NESTED_DECORATION_ENABLED)
listOf(
BlockView.Decoration(
background = backgroundColor
)
) else
emptyList(),
ghostSelection: IntRange? = null,
cursor: Int? = null,
alignment: Alignment? = null
@ -207,4 +213,92 @@ fun StubCalloutView(
ghostEditorSelection = ghostSelection,
cursor = cursor,
icon = icon
)
fun StubBookmarkPlaceholderView(
id: Id = MockDataFactory.randomUuid(),
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
)
)
else
emptyList()
): BlockView.MediaPlaceholder.Bookmark = BlockView.MediaPlaceholder.Bookmark(
id = id,
indent = indent,
isPreviousBlockMedia = isPreviousBlockMedia,
background = background,
decorations = decorations
)
fun StubPicturePlaceholderView(
id: Id = MockDataFactory.randomUuid(),
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
)
)
else
emptyList()
): BlockView.MediaPlaceholder.Picture = BlockView.MediaPlaceholder.Picture(
id = id,
indent = indent,
isPreviousBlockMedia = isPreviousBlockMedia,
background = background,
decorations = decorations
)
fun StubVideoPlaceholderView(
id: Id = MockDataFactory.randomUuid(),
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
)
)
else
emptyList()
): BlockView.MediaPlaceholder.Video = BlockView.MediaPlaceholder.Video(
id = id,
indent = indent,
isPreviousBlockMedia = isPreviousBlockMedia,
background = background,
decorations = decorations
)
fun StubFilePlaceholderView(
id: Id = MockDataFactory.randomUuid(),
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
)
)
else
emptyList()
): BlockView.MediaPlaceholder.File = BlockView.MediaPlaceholder.File(
id = id,
indent = indent,
isPreviousBlockMedia = isPreviousBlockMedia,
background = background,
decorations = decorations
)

View file

@ -4,7 +4,9 @@ import android.os.Build
import androidx.core.view.marginLeft
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.anytypeio.anytype.core_ui.BuildConfig
import com.anytypeio.anytype.core_ui.R
import com.anytypeio.anytype.core_ui.StubParagraphView
import com.anytypeio.anytype.core_ui.features.editor.holders.text.*
import com.anytypeio.anytype.core_utils.ext.dimen
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
@ -33,11 +35,7 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() {
val padding = context.dimen(R.dimen.default_document_content_padding_start).toInt()
val indent = context.dimen(R.dimen.indent)
val block = BlockView.Text.Paragraph(
id = MockDataFactory.randomUuid(),
text = MockDataFactory.randomString(),
indent = 0
)
val block = StubParagraphView(indent = 0)
val views = listOf(block)
@ -72,10 +70,12 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() {
adapter.onBindViewHolder(holder, 0, payloads = payload)
assertEquals(
actual = holder.content.paddingLeft,
expected = padding + (indent.toInt() * 2)
)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
assertEquals(
actual = holder.content.paddingLeft,
expected = padding + (indent.toInt() * 2)
)
}
}
@Test
@ -125,10 +125,12 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() {
adapter.onBindViewHolder(holder, 0, payloads = payload)
assertEquals(
actual = holder.content.paddingLeft,
expected = padding + (indent.toInt() * 2)
)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
assertEquals(
actual = holder.content.paddingLeft,
expected = padding + (indent.toInt() * 2)
)
}
}
@Test
@ -178,10 +180,12 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() {
adapter.onBindViewHolder(holder, 0, payloads = payload)
assertEquals(
actual = holder.content.paddingLeft,
expected = padding + (indent.toInt() * 2)
)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
assertEquals(
actual = holder.content.paddingLeft,
expected = padding + (indent.toInt() * 2)
)
}
}
@Test
@ -231,10 +235,12 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() {
adapter.onBindViewHolder(holder, 0, payloads = payload)
assertEquals(
actual = holder.content.paddingLeft,
expected = padding + (indent.toInt() * 2)
)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
assertEquals(
actual = holder.content.paddingLeft,
expected = padding + (indent.toInt() * 2)
)
}
}
@Test
@ -283,10 +289,12 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() {
adapter.onBindViewHolder(holder, 0, payloads = payload)
assertEquals(
actual = holder.checkbox.paddingLeft,
expected = indent.toInt() * 2
)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
assertEquals(
actual = holder.checkbox.paddingLeft,
expected = indent.toInt() * 2
)
}
}
@Test
@ -336,9 +344,11 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() {
adapter.onBindViewHolder(holder, 0, payloads = payload)
assertEquals(
actual = holder.number.marginLeft,
expected = indent.toInt() * 2
)
if (!BuildConfig.NESTED_DECORATION_ENABLED) {
assertEquals(
actual = holder.number.marginLeft,
expected = indent.toInt() * 2
)
}
}
}

View file

@ -12,7 +12,7 @@ android {
targetSdkVersion config["target_sdk"]
testInstrumentationRunner config["test_runner"]
buildConfigField "boolean", "ENABLE_LINK_APPERANCE_MENU", "true"
buildConfigField "boolean", "NESTED_DECORATION_ENABLED", "false"
buildConfigField "boolean", "NESTED_DECORATION_ENABLED", "true"
}
testOptions.unitTests.includeAndroidResources = true

View file

@ -4,11 +4,13 @@ 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
import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor
import com.anytypeio.anytype.presentation.util.TXT
import com.anytypeio.anytype.test_utils.MockDataFactory
import com.jraska.livedata.test
@ -82,7 +84,16 @@ class BlockReadModeTest : EditorViewModelTest() {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ
mode = BlockView.Mode.READ,
decorations = if (NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
},
blocks[1].let { p ->
@ -91,7 +102,16 @@ class BlockReadModeTest : EditorViewModelTest() {
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
isSelected = true
isSelected = true,
decorations = if (NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
}
)
@ -102,7 +122,16 @@ class BlockReadModeTest : EditorViewModelTest() {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.EDIT
mode = BlockView.Mode.EDIT,
decorations = if (NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
},
blocks[1].let { p ->
@ -110,7 +139,16 @@ class BlockReadModeTest : EditorViewModelTest() {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.EDIT
mode = BlockView.Mode.EDIT,
decorations = if (NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
}
)
@ -119,7 +157,7 @@ class BlockReadModeTest : EditorViewModelTest() {
id = title.id,
text = title.content<TXT>().text,
isFocused = false,
mode = BlockView.Mode.EDIT
mode = BlockView.Mode.EDIT,
)
private val titleReadModeView = BlockView.Title.Basic(
@ -173,7 +211,16 @@ class BlockReadModeTest : EditorViewModelTest() {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ
mode = BlockView.Mode.READ,
decorations = if (NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
},
blocks[1].let { p ->
@ -182,7 +229,16 @@ class BlockReadModeTest : EditorViewModelTest() {
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
isSelected = true
isSelected = true,
decorations = if (NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
}
)
@ -257,7 +313,16 @@ class BlockReadModeTest : EditorViewModelTest() {
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ
mode = BlockView.Mode.READ,
decorations = if (NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
},
blocks[1].let { p ->
@ -266,7 +331,16 @@ class BlockReadModeTest : EditorViewModelTest() {
isSelected = true,
marks = emptyList(),
text = p.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ
mode = BlockView.Mode.READ,
decorations = if (NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
}
)

View file

@ -2771,6 +2771,16 @@ class DefaultBlockViewRendererTest {
background = a.parseThemeBackgroundColor(),
isPreviousBlockMedia = false,
objectTypeName = null,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Card
)
)
} else {
emptyList()
}
)
)

View file

@ -10,6 +10,8 @@ import com.anytypeio.anytype.core_models.Payload
import com.anytypeio.anytype.core_models.Position
import com.anytypeio.anytype.core_models.Relation
import com.anytypeio.anytype.core_models.SmartBlockType
import com.anytypeio.anytype.core_models.StubFile
import com.anytypeio.anytype.core_models.StubParagraph
import com.anytypeio.anytype.core_models.ext.content
import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction
import com.anytypeio.anytype.core_utils.common.EventWrapper
@ -391,16 +393,7 @@ open class EditorViewModelTest {
val child = MockDataFactory.randomUuid()
val paragraph = Block(
id = child,
fields = Block.Fields(emptyMap()),
content = Block.Content.Text(
text = MockDataFactory.randomString(),
marks = emptyList(),
style = Block.Content.Text.Style.P
),
children = emptyList()
)
val paragraph = StubParagraph(id = child)
val page = listOf(
Block(
@ -441,7 +434,16 @@ open class EditorViewModelTest {
BlockView.Text.Paragraph(
id = paragraph.id,
text = paragraph.content<Block.Content.Text>().text,
background = paragraph.parseThemeBackgroundColor()
background = paragraph.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -576,15 +578,8 @@ open class EditorViewModelTest {
val root = MockDataFactory.randomUuid()
val child = MockDataFactory.randomUuid()
val paragraph = Block(
id = child,
fields = Block.Fields(emptyMap()),
content = Block.Content.Text(
text = MockDataFactory.randomString(),
marks = emptyList(),
style = Block.Content.Text.Style.P
),
children = emptyList()
val paragraph = StubParagraph(
id = child
)
val page = listOf(
@ -599,16 +594,7 @@ open class EditorViewModelTest {
paragraph
)
val added = Block(
id = MockDataFactory.randomUuid(),
fields = Block.Fields(emptyMap()),
content = Block.Content.Text(
text = MockDataFactory.randomString(),
marks = emptyList(),
style = Block.Content.Text.Style.P
),
children = emptyList()
)
val added = StubParagraph()
stubObserveEvents(
flow {
@ -660,12 +646,30 @@ open class EditorViewModelTest {
BlockView.Text.Paragraph(
id = paragraph.id,
text = paragraph.content.asText().text,
background = paragraph.parseThemeBackgroundColor()
background = paragraph.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Text.Paragraph(
id = added.id,
text = added.content.asText().text,
background = added.parseThemeBackgroundColor()
background = added.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = added.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -729,16 +733,7 @@ open class EditorViewModelTest {
val root = MockDataFactory.randomUuid()
val child = MockDataFactory.randomUuid()
val paragraph = Block(
id = child,
fields = Block.Fields(emptyMap()),
content = Block.Content.Text(
text = MockDataFactory.randomString(),
marks = emptyList(),
style = Block.Content.Text.Style.P
),
children = emptyList()
)
val paragraph = StubParagraph(id = child)
val page = listOf(
Block(
@ -796,7 +791,16 @@ open class EditorViewModelTest {
BlockView.Text.Paragraph(
id = paragraph.id,
text = paragraph.content.asText().text,
background = paragraph.parseThemeBackgroundColor()
background = paragraph.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -917,7 +921,16 @@ open class EditorViewModelTest {
from = firstTimeRange.first(),
to = firstTimeRange.last()
)
)
),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -959,7 +972,16 @@ open class EditorViewModelTest {
from = secondTimeRange.first(),
to = secondTimeRange.last()
)
)
),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -1057,7 +1079,16 @@ open class EditorViewModelTest {
from = firstTimeRange.first(),
to = firstTimeRange.last()
)
)
),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -1102,7 +1133,16 @@ open class EditorViewModelTest {
from = secondTimeRange.first(),
to = secondTimeRange.last()
)
)
),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -1119,17 +1159,10 @@ open class EditorViewModelTest {
val root = MockDataFactory.randomUuid()
val child = MockDataFactory.randomUuid()
val paragraph = Block(
val paragraph = StubParagraph(
id = child,
fields = Block.Fields(emptyMap()),
content = Block.Content.Text(
text = MockDataFactory.randomString(),
marks = emptyList(),
style = Block.Content.Text.Style.P,
color = "red"
),
children = emptyList(),
backgroundColor = "yellow"
textColor = ThemeColor.RED.code,
backgroundColor = ThemeColor.YELLOW.code
)
val page = Block(
@ -1210,16 +1243,7 @@ open class EditorViewModelTest {
val root = MockDataFactory.randomUuid()
val child = MockDataFactory.randomUuid()
val paragraph = Block(
id = child,
fields = Block.Fields(emptyMap()),
content = Block.Content.Text(
text = MockDataFactory.randomString(),
marks = emptyList(),
style = Block.Content.Text.Style.P
),
children = emptyList()
)
val paragraph = StubParagraph(id = child)
val page = Block(
id = root,
@ -1271,7 +1295,16 @@ open class EditorViewModelTest {
BlockView.Text.Paragraph(
id = paragraph.id,
text = paragraph.content.asText().text,
background = paragraph.parseThemeBackgroundColor()
background = paragraph.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -1507,16 +1540,7 @@ open class EditorViewModelTest {
val root = MockDataFactory.randomUuid()
val child = MockDataFactory.randomUuid()
val paragraph = Block(
id = child,
fields = Block.Fields(emptyMap()),
content = Block.Content.Text(
text = MockDataFactory.randomString(),
marks = emptyList(),
style = Block.Content.Text.Style.P
),
children = emptyList()
)
val paragraph = StubParagraph(id = child)
val page = Block(
id = root,
@ -1591,7 +1615,16 @@ open class EditorViewModelTest {
BlockView.Text.Paragraph(
id = paragraph.id,
text = paragraph.content<Block.Content.Text>().text,
background = paragraph.parseThemeBackgroundColor()
background = paragraph.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -1610,13 +1643,32 @@ open class EditorViewModelTest {
BlockView.Text.Paragraph(
id = paragraph.id,
text = paragraph.content<Block.Content.Text>().text,
background = paragraph.parseThemeBackgroundColor()
background = paragraph.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
indent = 0,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = new.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H1
)
)
} else {
emptyList()
}
)
)
)
@ -1753,26 +1805,12 @@ open class EditorViewModelTest {
val root = MockDataFactory.randomUuid()
val firstChild = Block(
id = "FIRST CHILD",
fields = Block.Fields(emptyMap()),
content = Block.Content.Text(
text = "FIRST CHILD TEXT",
marks = emptyList(),
style = Block.Content.Text.Style.P
),
children = emptyList()
val firstChild = StubParagraph(
id = "FIRST CHILD"
)
val secondChild = Block(
id = "SECOND CHILD",
fields = Block.Fields(emptyMap()),
content = Block.Content.Text(
text = "SECOND CHILD TEXT",
marks = emptyList(),
style = Block.Content.Text.Style.P
),
children = emptyList()
val secondChild = StubParagraph(
id = "SECOND CHILD"
)
val page = Block(
@ -1828,12 +1866,30 @@ open class EditorViewModelTest {
BlockView.Text.Paragraph(
id = firstChild.id,
text = firstChild.content<Block.Content.Text>().text,
background = firstChild.parseThemeBackgroundColor()
background = firstChild.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = firstChild.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Text.Paragraph(
id = secondChild.id,
text = secondChild.content<Block.Content.Text>().text,
background = secondChild.parseThemeBackgroundColor()
background = secondChild.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = secondChild.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -1862,7 +1918,16 @@ open class EditorViewModelTest {
BlockView.Text.Paragraph(
id = secondChild.id,
text = secondChild.content<Block.Content.Text>().text,
background = secondChild.parseThemeBackgroundColor()
background = secondChild.parseThemeBackgroundColor(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = secondChild.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -3082,36 +3147,9 @@ open class EditorViewModelTest {
// SETUP
val paragraphs = listOf(
Block(
id = MockDataFactory.randomString(),
content = Block.Content.Text(
marks = emptyList(),
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.P
),
children = emptyList(),
fields = Block.Fields.empty()
),
Block(
id = MockDataFactory.randomString(),
content = Block.Content.Text(
marks = emptyList(),
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.P
),
children = emptyList(),
fields = Block.Fields.empty()
),
Block(
id = MockDataFactory.randomString(),
content = Block.Content.Text(
marks = emptyList(),
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.P
),
children = emptyList(),
fields = Block.Fields.empty()
)
StubParagraph(),
StubParagraph(),
StubParagraph()
)
val page = listOf(
@ -3159,21 +3197,48 @@ open class EditorViewModelTest {
BlockView.Text.Paragraph(
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
},
paragraphs[1].let { p ->
BlockView.Text.Paragraph(
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
},
paragraphs[2].let { p ->
BlockView.Text.Paragraph(
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
}
)
@ -3254,7 +3319,7 @@ open class EditorViewModelTest {
vm.onTextInputClicked(target = paragraphs[2].id)
// At this momemnt, we expect that all blocks are unselected, therefore we should exit to read mode.
// At this moment, we expect that all blocks are unselected, therefore we should exit to read mode.
coroutineTestRule.advanceTime(EditorViewModel.DELAY_REFRESH_DOCUMENT_ON_EXIT_MULTI_SELECT_MODE)
@ -3268,18 +3333,7 @@ open class EditorViewModelTest {
val root = MockDataFactory.randomUuid()
val paragraphs = listOf(
Block(
id = MockDataFactory.randomString(),
content = Block.Content.Text(
marks = emptyList(),
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.P
),
children = emptyList(),
fields = Block.Fields.empty()
)
)
val paragraphs = listOf(StubParagraph())
val page = listOf(
Block(
@ -3326,7 +3380,16 @@ open class EditorViewModelTest {
BlockView.Text.Paragraph(
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
}
)
@ -3419,7 +3482,7 @@ open class EditorViewModelTest {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT,
style = BlockView.Decoration.Style.None
style = BlockView.Decoration.Style.Card
)
)
} else {
@ -3498,7 +3561,7 @@ open class EditorViewModelTest {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT,
style = BlockView.Decoration.Style.None
style = BlockView.Decoration.Style.Card
)
)
} else {
@ -3527,15 +3590,9 @@ open class EditorViewModelTest {
@Test
fun `open select file - when error in edit mode`() {
val file = Block(
id = MockDataFactory.randomUuid(),
fields = Block.Fields(emptyMap()),
content = Block.Content.File(
hash = MockDataFactory.randomString(),
type = Block.Content.File.Type.FILE,
state = Block.Content.File.State.ERROR
),
children = emptyList()
val file = StubFile(
state = Block.Content.File.State.ERROR,
type = Block.Content.File.Type.FILE,
)
val page = listOf(
@ -3578,7 +3635,7 @@ open class EditorViewModelTest {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT,
style = BlockView.Decoration.Style.None
style = BlockView.Decoration.Style.Card
)
)
} else {
@ -3884,36 +3941,9 @@ open class EditorViewModelTest {
val root = MockDataFactory.randomUuid()
val paragraphs = listOf(
Block(
id = MockDataFactory.randomString(),
content = Block.Content.Text(
marks = emptyList(),
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.P
),
children = emptyList(),
fields = Block.Fields.empty()
),
Block(
id = MockDataFactory.randomString(),
content = Block.Content.Text(
marks = emptyList(),
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.P
),
children = emptyList(),
fields = Block.Fields.empty()
),
Block(
id = MockDataFactory.randomString(),
content = Block.Content.Text(
marks = emptyList(),
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.P
),
children = emptyList(),
fields = Block.Fields.empty()
)
StubParagraph(),
StubParagraph(),
StubParagraph()
)
val page = listOf(
@ -3961,21 +3991,48 @@ open class EditorViewModelTest {
BlockView.Text.Paragraph(
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
},
paragraphs[1].let { p ->
BlockView.Text.Paragraph(
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
},
paragraphs[2].let { p ->
BlockView.Text.Paragraph(
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
}
)
@ -3999,36 +4056,9 @@ open class EditorViewModelTest {
val root = MockDataFactory.randomUuid()
val paragraphs = listOf(
Block(
id = MockDataFactory.randomString(),
content = Block.Content.Text(
marks = emptyList(),
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.P
),
children = emptyList(),
fields = Block.Fields.empty()
),
Block(
id = MockDataFactory.randomString(),
content = Block.Content.Text(
marks = emptyList(),
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.P
),
children = emptyList(),
fields = Block.Fields.empty()
),
Block(
id = MockDataFactory.randomString(),
content = Block.Content.Text(
marks = emptyList(),
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.P
),
children = emptyList(),
fields = Block.Fields.empty()
)
StubParagraph(),
StubParagraph(),
StubParagraph()
)
val page = listOf(
@ -4076,21 +4106,48 @@ open class EditorViewModelTest {
BlockView.Text.Paragraph(
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
},
paragraphs[1].let { p ->
BlockView.Text.Paragraph(
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
},
paragraphs[2].let { p ->
BlockView.Text.Paragraph(
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
}
)
@ -4121,38 +4178,7 @@ open class EditorViewModelTest {
val root = MockDataFactory.randomUuid()
val paragraphs = listOf(
Block(
id = MockDataFactory.randomString(),
content = Block.Content.Text(
marks = emptyList(),
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.P
),
children = emptyList(),
fields = Block.Fields.empty()
),
Block(
id = MockDataFactory.randomString(),
content = Block.Content.Text(
marks = emptyList(),
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.P
),
children = emptyList(),
fields = Block.Fields.empty()
),
Block(
id = MockDataFactory.randomString(),
content = Block.Content.Text(
marks = emptyList(),
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.P
),
children = emptyList(),
fields = Block.Fields.empty()
)
)
val paragraphs = listOf(StubParagraph(), StubParagraph(), StubParagraph())
val page = listOf(
Block(
@ -4199,21 +4225,48 @@ open class EditorViewModelTest {
BlockView.Text.Paragraph(
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
},
paragraphs[1].let { p ->
BlockView.Text.Paragraph(
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
},
paragraphs[2].let { p ->
BlockView.Text.Paragraph(
id = p.id,
marks = emptyList(),
text = p.content<Block.Content.Text>().text
text = p.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
}
)

View file

@ -23,8 +23,10 @@ import com.anytypeio.anytype.domain.block.interactor.UnlinkBlocks
import com.anytypeio.anytype.domain.block.interactor.UpdateText
import com.anytypeio.anytype.domain.block.interactor.UpdateTextStyle
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
import com.anytypeio.anytype.presentation.BuildConfig
import com.anytypeio.anytype.presentation.editor.EditorViewModel
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor
import com.anytypeio.anytype.presentation.util.CoroutinesTestRule
import com.anytypeio.anytype.presentation.util.TXT
import com.anytypeio.anytype.test_utils.MockDataFactory
@ -151,7 +153,16 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
id = parent.id,
isFocused = true,
cursor = parent.content<Block.Content.Text>().text.length,
text = parent.content<Block.Content.Text>().text
text = parent.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -264,14 +275,35 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
BlockView.Text.Paragraph(
id = parent.id,
isFocused = false,
text = parent.content<Block.Content.Text>().text
text = parent.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Text.Bulleted(
id = child1.id,
isFocused = true,
indent = 1,
cursor = child1.content<Block.Content.Text>().text.length,
text = child1.content<Block.Content.Text>().text
text = child1.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child1.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -384,14 +416,35 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
BlockView.Text.Paragraph(
id = parent.id,
isFocused = false,
text = parent.content<Block.Content.Text>().text
text = parent.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Text.Bulleted(
indent = 1,
id = child1.id,
isFocused = true,
cursor = child1.content<Block.Content.Text>().text.length,
text = child1.content<Block.Content.Text>().text
text = child1.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child1.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -486,7 +539,16 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
BlockView.Text.Paragraph(
id = paragraph.id,
isFocused = true,
text = paragraph.content<Block.Content.Text>().text
text = paragraph.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
)
)
@ -593,7 +655,16 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
BlockView.Text.Paragraph(
id = paragraph.id,
isFocused = true,
text = paragraph.content<Block.Content.Text>().text
text = paragraph.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
)
)

View file

@ -3,12 +3,15 @@ package com.anytypeio.anytype.presentation.editor.editor
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import com.anytypeio.anytype.core_models.Block
import com.anytypeio.anytype.core_models.Event
import com.anytypeio.anytype.core_models.StubTitle
import com.anytypeio.anytype.core_models.ext.content
import com.anytypeio.anytype.domain.block.interactor.DuplicateBlock
import com.anytypeio.anytype.presentation.BuildConfig
import com.anytypeio.anytype.presentation.MockBlockFactory
import com.anytypeio.anytype.presentation.editor.editor.actions.ActionItemType
import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor
import com.anytypeio.anytype.presentation.util.CoroutinesTestRule
import com.anytypeio.anytype.test_utils.MockDataFactory
import com.jraska.livedata.test
@ -28,16 +31,7 @@ class EditorDuplicateTest : EditorPresentationTestSetup() {
@get:Rule
val coroutineTestRule = CoroutinesTestRule()
val title = Block(
id = MockDataFactory.randomUuid(),
content = Block.Content.Text(
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.TITLE,
marks = emptyList()
),
children = emptyList(),
fields = Block.Fields.empty()
)
val title = StubTitle()
val header = Block(
id = MockDataFactory.randomUuid(),
@ -184,16 +178,43 @@ class EditorDuplicateTest : EditorPresentationTestSetup() {
BlockView.Text.Paragraph(
id = a.id,
text = a.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.DividerLine(
id = b.id,
isSelected = true
isSelected = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = c.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -222,20 +243,56 @@ class EditorDuplicateTest : EditorPresentationTestSetup() {
BlockView.Text.Paragraph(
id = a.id,
text = a.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.DividerLine(
id = b.id,
isSelected = true
isSelected = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.DividerLine(
id = copy.id,
isSelected = false
isSelected = false,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = c.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -298,19 +355,49 @@ class EditorDuplicateTest : EditorPresentationTestSetup() {
id = a.id,
text = a.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
isSelected = true
isSelected = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Text.Paragraph(
id = b.id,
text = b.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ,
isSelected = true,
indent = 1
indent = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = c.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)

View file

@ -7,6 +7,7 @@ import com.anytypeio.anytype.core_models.Relation
import com.anytypeio.anytype.core_models.Relations
import com.anytypeio.anytype.core_models.SmartBlockType
import com.anytypeio.anytype.core_models.ext.content
import com.anytypeio.anytype.presentation.BuildConfig
import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory
import com.anytypeio.anytype.presentation.editor.EditorViewModel
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
@ -157,7 +158,16 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
background = block.parseThemeBackgroundColor(),
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
@ -248,7 +258,16 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
background = block.parseThemeBackgroundColor(),
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
@ -345,7 +364,16 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
background = block.parseThemeBackgroundColor(),
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
@ -453,7 +481,16 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
background = block.parseThemeBackgroundColor(),
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
@ -570,7 +607,16 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
background = block.parseThemeBackgroundColor(),
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)

View file

@ -4,7 +4,9 @@ import androidx.arch.core.executor.testing.InstantTaskExecutorRule
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
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor
import com.anytypeio.anytype.presentation.util.CoroutinesTestRule
import com.anytypeio.anytype.test_utils.MockDataFactory
import com.jraska.livedata.test
@ -108,7 +110,16 @@ class EditorGranularChangeTest : EditorPresentationTestSetup() {
),
BlockView.Text.Checkbox(
id = checkbox.id,
text = checkbox.content<Block.Content.Text>().text
text = checkbox.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = checkbox.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -125,7 +136,16 @@ class EditorGranularChangeTest : EditorPresentationTestSetup() {
BlockView.Text.Checkbox(
id = checkbox.id,
text = checkbox.content<Block.Content.Text>().text,
isChecked = true
isChecked = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = checkbox.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)

View file

@ -3,8 +3,10 @@ package com.anytypeio.anytype.presentation.editor.editor
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import com.anytypeio.anytype.core_models.Block
import com.anytypeio.anytype.core_models.ext.content
import com.anytypeio.anytype.presentation.BuildConfig
import com.anytypeio.anytype.presentation.MockBlockFactory
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor
import com.anytypeio.anytype.presentation.util.CoroutinesTestRule
import com.anytypeio.anytype.presentation.util.TXT
import com.anytypeio.anytype.test_utils.MockDataFactory
@ -153,7 +155,16 @@ class EditorLatexBlockTest : EditorPresentationTestSetup() {
id = p.id,
isFocused = false,
text = p.content<TXT>().text,
mode = BlockView.Mode.EDIT
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = p.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Latex(
id = latex.id,

View file

@ -4,11 +4,15 @@ import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import com.anytypeio.anytype.core_models.Block
import com.anytypeio.anytype.core_models.Event
import com.anytypeio.anytype.core_models.SmartBlockType
import com.anytypeio.anytype.core_models.StubTitle
import com.anytypeio.anytype.core_models.ThemeColor
import com.anytypeio.anytype.core_models.ext.content
import com.anytypeio.anytype.domain.block.interactor.SplitBlock
import com.anytypeio.anytype.domain.block.interactor.UpdateTextStyle
import com.anytypeio.anytype.presentation.BuildConfig
import com.anytypeio.anytype.presentation.editor.EditorViewModel
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor
import com.anytypeio.anytype.presentation.util.CoroutinesTestRule
import com.anytypeio.anytype.presentation.util.TXT
import com.anytypeio.anytype.test_utils.MockDataFactory
@ -30,16 +34,7 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
@get:Rule
val coroutineTestRule = CoroutinesTestRule()
val title = Block(
id = MockDataFactory.randomUuid(),
content = Block.Content.Text(
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.TITLE,
marks = emptyList()
),
children = emptyList(),
fields = Block.Fields.empty()
)
val title = StubTitle()
val header = Block(
id = MockDataFactory.randomUuid(),
@ -332,26 +327,6 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
// SETUP
val title = Block(
id = MockDataFactory.randomUuid(),
content = Block.Content.Text(
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.TITLE,
marks = emptyList()
),
children = emptyList(),
fields = Block.Fields.empty()
)
val header = Block(
id = MockDataFactory.randomUuid(),
content = Block.Content.Layout(
type = Block.Content.Layout.Type.HEADER
),
fields = Block.Fields.empty(),
children = listOf(title.id)
)
val style = Block.Content.Text.Style.CHECKBOX
val child = MockDataFactory.randomUuid()
@ -417,7 +392,16 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
text = "",
isFocused = false,
isChecked = false,
indent = 0
indent = 0,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
)
} else {
emptyList()
}
)
)
)
@ -456,7 +440,16 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
BlockView.Text.Paragraph(
id = child,
text = "",
isFocused = true
isFocused = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
)
} else {
emptyList()
}
)
)
)
@ -469,26 +462,6 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
// SETUP
val title = Block(
id = MockDataFactory.randomUuid(),
content = Block.Content.Text(
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.TITLE,
marks = emptyList()
),
children = emptyList(),
fields = Block.Fields.empty()
)
val header = Block(
id = MockDataFactory.randomUuid(),
content = Block.Content.Layout(
type = Block.Content.Layout.Type.HEADER
),
fields = Block.Fields.empty(),
children = listOf(title.id)
)
val style = Block.Content.Text.Style.BULLET
val child = MockDataFactory.randomUuid()
@ -553,7 +526,16 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
id = child,
text = "",
isFocused = false,
indent = 0
indent = 0,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
)
} else {
emptyList()
}
)
)
)
@ -592,7 +574,16 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
BlockView.Text.Paragraph(
id = child,
text = "",
isFocused = true
isFocused = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
)
} else {
emptyList()
}
)
)
)
@ -690,7 +681,16 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
text = "",
isFocused = false,
indent = 0,
isEmpty = true
isEmpty = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
)
} else {
emptyList()
}
)
)
)
@ -729,7 +729,16 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
BlockView.Text.Paragraph(
id = child,
text = "",
isFocused = true
isFocused = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
)
} else {
emptyList()
}
)
)
)
@ -742,26 +751,6 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
// SETUP
val title = Block(
id = MockDataFactory.randomUuid(),
content = Block.Content.Text(
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.TITLE,
marks = emptyList()
),
children = emptyList(),
fields = Block.Fields.empty()
)
val header = Block(
id = MockDataFactory.randomUuid(),
content = Block.Content.Layout(
type = Block.Content.Layout.Type.HEADER
),
fields = Block.Fields.empty(),
children = listOf(title.id)
)
val style = Block.Content.Text.Style.NUMBERED
val child = MockDataFactory.randomUuid()
@ -827,7 +816,16 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
text = "",
isFocused = false,
indent = 0,
number = 1
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
)
} else {
emptyList()
}
)
)
)
@ -866,7 +864,16 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
BlockView.Text.Paragraph(
id = child,
text = "",
isFocused = true
isFocused = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
)
} else {
emptyList()
}
)
)
)

View file

@ -5,6 +5,7 @@ import com.anytypeio.anytype.core_models.Block
import com.anytypeio.anytype.core_models.ObjectType
import com.anytypeio.anytype.core_models.Relations
import com.anytypeio.anytype.core_models.SmartBlockType
import com.anytypeio.anytype.core_models.StubTitle
import com.anytypeio.anytype.core_models.ThemeColor
import com.anytypeio.anytype.core_models.ext.content
import com.anytypeio.anytype.core_utils.common.EventWrapper
@ -12,6 +13,7 @@ import com.anytypeio.anytype.presentation.BuildConfig
import com.anytypeio.anytype.presentation.MockBlockFactory
import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor
import com.anytypeio.anytype.presentation.navigation.AppNavigation
import com.anytypeio.anytype.presentation.objects.ObjectIcon
import com.anytypeio.anytype.presentation.util.CoroutinesTestRule
@ -32,16 +34,7 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
@get:Rule
val coroutineTestRule = CoroutinesTestRule()
val title = Block(
id = MockDataFactory.randomUuid(),
content = Block.Content.Text(
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.TITLE,
marks = emptyList()
),
children = emptyList(),
fields = Block.Fields.empty()
)
val title = StubTitle()
val header = Block(
id = MockDataFactory.randomUuid(),
@ -105,7 +98,16 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
BlockView.Text.Bulleted(
id = child.id,
text = child.content<TXT>().text,
mode = BlockView.Mode.EDIT
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = child.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
@ -165,7 +167,16 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
BlockView.Text.Bulleted(
id = child.id,
text = child.content<TXT>().text,
mode = BlockView.Mode.EDIT
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = child.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
@ -225,7 +236,16 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
BlockView.Text.Bulleted(
id = child.id,
text = child.content<TXT>().text,
mode = BlockView.Mode.READ
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = child.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
@ -289,6 +309,15 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
BlockView.LinkToObject.Default.Text(
id = link.id,
icon = ObjectIcon.Basic.Avatar(""),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = link.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
@ -393,7 +422,16 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
param = target
)
),
mode = BlockView.Mode.READ
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = paragraph.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
@ -484,7 +522,17 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
description = bookmarkDescription,
title = bookmarkTitle,
mode = BlockView.Mode.READ,
isPreviousBlockMedia = false
isPreviousBlockMedia = false,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = bookmark.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Card
)
)
} else {
emptyList()
}
)
)
@ -572,7 +620,7 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT,
style = BlockView.Decoration.Style.None
style = BlockView.Decoration.Style.Card
)
)
} else {
@ -666,7 +714,7 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT,
style = BlockView.Decoration.Style.None
style = BlockView.Decoration.Style.Card
)
)
} else {

View file

@ -6,9 +6,11 @@ import com.anytypeio.anytype.core_models.Block
import com.anytypeio.anytype.core_models.ObjectType.Companion.PAGE_URL
import com.anytypeio.anytype.core_models.SmartBlockType
import com.anytypeio.anytype.core_models.ext.content
import com.anytypeio.anytype.presentation.BuildConfig
import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory
import com.anytypeio.anytype.presentation.editor.EditorViewModel
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor
import com.anytypeio.anytype.presentation.util.CoroutinesTestRule
import com.anytypeio.anytype.presentation.util.TXT
import com.anytypeio.anytype.test_utils.MockDataFactory
@ -122,7 +124,16 @@ class EditorMarkupObjectTest : EditorPresentationTestSetup() {
),
indent = 0,
text = "Start Foobar End",
mode = BlockView.Mode.EDIT
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -279,7 +290,16 @@ class EditorMarkupObjectTest : EditorPresentationTestSetup() {
),
indent = 0,
text = "Start Link Object Mention End",
mode = BlockView.Mode.EDIT
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -444,7 +464,16 @@ class EditorMarkupObjectTest : EditorPresentationTestSetup() {
),
indent = 0,
text = "Start Link Object Mention End",
mode = BlockView.Mode.EDIT
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)

View file

@ -12,11 +12,13 @@ import com.anytypeio.anytype.domain.base.Result
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
import com.anytypeio.anytype.domain.icon.DocumentEmojiIconProvider
import com.anytypeio.anytype.domain.page.CreateNewDocument
import com.anytypeio.anytype.presentation.BuildConfig
import com.anytypeio.anytype.presentation.editor.EditorViewModel
import com.anytypeio.anytype.presentation.editor.editor.control.ControlPanelState
import com.anytypeio.anytype.presentation.editor.editor.mention.MentionConst.MENTION_TITLE_EMPTY
import com.anytypeio.anytype.presentation.editor.editor.mention.MentionEvent
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor
import com.anytypeio.anytype.presentation.util.CoroutinesTestRule
import com.anytypeio.anytype.presentation.util.TXT
import com.anytypeio.anytype.test_utils.MockDataFactory
@ -221,7 +223,16 @@ class EditorMentionTest : EditorPresentationTestSetup() {
),
indent = 0,
text = "page about Avant-Garde Jazz music",
mode = BlockView.Mode.EDIT
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -381,7 +392,16 @@ class EditorMentionTest : EditorPresentationTestSetup() {
),
indent = 0,
text = "page about Jazz music",
mode = BlockView.Mode.EDIT
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -541,7 +561,16 @@ class EditorMentionTest : EditorPresentationTestSetup() {
),
indent = 0,
text = "page about Untitled music",
mode = BlockView.Mode.EDIT
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -900,7 +929,16 @@ class EditorMentionTest : EditorPresentationTestSetup() {
),
indent = 0,
text = "Start Foob end",
mode = BlockView.Mode.EDIT
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -1037,7 +1075,16 @@ class EditorMentionTest : EditorPresentationTestSetup() {
),
indent = 0,
text = "Start Untitled end",
mode = BlockView.Mode.EDIT
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)

View file

@ -3,10 +3,12 @@ package com.anytypeio.anytype.presentation.editor.editor
import android.os.Build
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import com.anytypeio.anytype.core_models.Block
import com.anytypeio.anytype.core_models.StubTitle
import com.anytypeio.anytype.core_models.ThemeColor
import com.anytypeio.anytype.core_models.ext.content
import com.anytypeio.anytype.domain.block.interactor.UnlinkBlocks
import com.anytypeio.anytype.domain.clipboard.Copy
import com.anytypeio.anytype.presentation.BuildConfig
import com.anytypeio.anytype.presentation.MockBlockContentFactory.StubLinkContent
import com.anytypeio.anytype.presentation.MockBlockFactory
import com.anytypeio.anytype.presentation.MockBlockFactory.link
@ -18,6 +20,7 @@ import com.anytypeio.anytype.presentation.editor.editor.control.ControlPanelStat
import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
import com.anytypeio.anytype.presentation.editor.editor.styling.StyleToolbarState
import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor
import com.anytypeio.anytype.presentation.util.CoroutinesTestRule
import com.anytypeio.anytype.presentation.util.TXT
import com.anytypeio.anytype.test_utils.MockDataFactory
@ -43,16 +46,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
@get:Rule
val coroutineTestRule = CoroutinesTestRule()
val title = Block(
id = MockDataFactory.randomUuid(),
content = Block.Content.Text(
text = MockDataFactory.randomString(),
style = Block.Content.Text.Style.TITLE,
marks = emptyList()
),
children = emptyList(),
fields = Block.Fields.empty()
)
val title = StubTitle()
val header = Block(
id = MockDataFactory.randomUuid(),
@ -197,7 +191,16 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
marks = emptyList(),
indent = 0,
text = parent.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
val child1View = BlockView.Text.Paragraph(
@ -207,7 +210,19 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
marks = emptyList(),
indent = 1,
text = child1.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child1.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
val child2View = BlockView.Text.Paragraph(
@ -217,7 +232,19 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
marks = emptyList(),
indent = 1,
text = child2.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child2.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
val grandchild1View = BlockView.Text.Paragraph(
@ -227,7 +254,22 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
marks = emptyList(),
indent = 2,
text = grandchild1.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ
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()
)
)
} else {
emptyList()
}
)
val grandchild2View = BlockView.Text.Paragraph(
@ -237,7 +279,22 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
marks = emptyList(),
indent = 2,
text = grandchild2.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ
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()
)
)
} else {
emptyList()
}
)
vm.state.test().apply {
@ -407,7 +464,16 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
marks = emptyList(),
indent = 0,
text = parent.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
val child1View = BlockView.Text.Paragraph(
@ -417,7 +483,19 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
marks = emptyList(),
indent = 1,
text = child1.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child1.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
val child2View = BlockView.Text.Paragraph(
@ -427,7 +505,19 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
marks = emptyList(),
indent = 1,
text = child2.content<Block.Content.Text>().text,
mode = BlockView.Mode.READ
mode = BlockView.Mode.READ,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = parent.parseThemeBackgroundColor()
),
BlockView.Decoration(
background = child2.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
vm.state.test().apply {
@ -702,7 +792,16 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
id = a.id,
text = a.content<TXT>().text,
mode = BlockView.Mode.EDIT,
isSelected = false
isSelected = false,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -867,19 +966,46 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
id = a.id,
text = a.content<TXT>().text,
mode = BlockView.Mode.READ,
isSelected = true
isSelected = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
isSelected = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
isSelected = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = c.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)

View file

@ -3,10 +3,12 @@ package com.anytypeio.anytype.presentation.editor.editor
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import com.anytypeio.anytype.core_models.Block
import com.anytypeio.anytype.core_models.ext.content
import com.anytypeio.anytype.presentation.BuildConfig
import com.anytypeio.anytype.presentation.editor.EditorViewModel
import com.anytypeio.anytype.presentation.editor.editor.control.ControlPanelState
import com.anytypeio.anytype.presentation.editor.editor.control.ControlPanelState.Toolbar
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor
import com.anytypeio.anytype.presentation.util.CoroutinesTestRule
import com.anytypeio.anytype.presentation.util.TXT
import com.anytypeio.anytype.test_utils.MockDataFactory
@ -141,13 +143,31 @@ class EditorQuickStartingScrollAndMoveTest : EditorPresentationTestSetup() {
text = a.content<TXT>().text,
number = 1,
mode = BlockView.Mode.READ,
isSelected = false
isSelected = false,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
isSelected = true,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -239,13 +259,31 @@ class EditorQuickStartingScrollAndMoveTest : EditorPresentationTestSetup() {
text = a.content<TXT>().text,
number = 1,
mode = BlockView.Mode.EDIT,
isSelected = false
isSelected = false,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
isSelected = false,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)

View file

@ -5,7 +5,9 @@ import com.anytypeio.anytype.core_models.Block
import com.anytypeio.anytype.core_models.Relation
import com.anytypeio.anytype.core_models.Relations
import com.anytypeio.anytype.core_models.SmartBlockType
import com.anytypeio.anytype.core_models.StubTitle
import com.anytypeio.anytype.core_models.ext.content
import com.anytypeio.anytype.presentation.BuildConfig
import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor
@ -28,16 +30,7 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
@get:Rule
val coroutineTestRule = CoroutinesTestRule()
private val title = Block(
id = MockDataFactory.randomUuid(),
content = Block.Content.Text(
style = Block.Content.Text.Style.TITLE,
text = MockDataFactory.randomString(),
marks = emptyList()
),
children = emptyList(),
fields = Block.Fields.empty()
)
private val title = StubTitle()
private val header = Block(
id = MockDataFactory.randomUuid(),
@ -122,7 +115,16 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
BlockView.Text.Paragraph(
id = a.id,
text = a.content<Block.Content.Text>().text,
mode = BlockView.Mode.EDIT
mode = BlockView.Mode.EDIT,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Relation.Related(
id = b.id,
@ -132,7 +134,15 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
value = value,
format = relation.format
),
decorations = listOf()
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = b.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -228,13 +238,30 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
background = block.parseThemeBackgroundColor(),
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Relation.Placeholder(
id = relationBlock.id,
indent = 0,
isSelected = false,
decorations = listOf()
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = relationBlock.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
@ -332,7 +359,16 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
background = block.parseThemeBackgroundColor(),
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Relation.Related(
id = relationBlock.id,
@ -345,7 +381,15 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
isFeatured = false,
format = r2.format
),
decorations = listOf()
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = relationBlock.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
@ -444,13 +488,30 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() {
background = block.parseThemeBackgroundColor(),
text = block.content<Block.Content.Text>().text,
alignment = block.content<Block.Content.Text>().align?.toView(),
number = 1
number = 1,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Relation.Placeholder(
id = relationBlock.id,
indent = 0,
isSelected = false,
decorations = listOf()
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = relationBlock.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)

View file

@ -5,12 +5,14 @@ import com.anytypeio.anytype.core_models.Block
import com.anytypeio.anytype.core_models.Position
import com.anytypeio.anytype.core_models.ext.content
import com.anytypeio.anytype.domain.block.interactor.Move
import com.anytypeio.anytype.presentation.BuildConfig
import com.anytypeio.anytype.presentation.MockBlockFactory.link
import com.anytypeio.anytype.presentation.editor.EditorViewModel
import com.anytypeio.anytype.presentation.editor.editor.actions.ActionItemType
import com.anytypeio.anytype.presentation.editor.editor.control.ControlPanelState
import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor
import com.anytypeio.anytype.presentation.util.CoroutinesTestRule
import com.anytypeio.anytype.presentation.util.TXT
import com.anytypeio.anytype.test_utils.MockDataFactory
@ -281,7 +283,16 @@ class EditorScrollAndMoveTest : EditorPresentationTestSetup() {
id = a.id,
text = a.content<TXT>().text,
mode = BlockView.Mode.EDIT,
isSelected = false
isSelected = false,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = a.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)

View file

@ -5,6 +5,7 @@ import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import com.anytypeio.anytype.core_models.Block
import com.anytypeio.anytype.core_models.SmartBlockType
import com.anytypeio.anytype.core_models.ext.content
import com.anytypeio.anytype.presentation.BuildConfig
import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory
import com.anytypeio.anytype.presentation.editor.EditorViewModel
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
@ -275,57 +276,161 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() {
BlockView.Text.Paragraph(
id = blockText1.id,
indent = 0,
text = blockText1.content.asText().text
text = blockText1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText1.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Text.Header.One(
id = blockHeaderOne1.id,
indent = 0,
text = blockHeaderOne1.content.asText().text
text = blockHeaderOne1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
text = blockText2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText2.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Text.Header.Two(
id = blockHeaderTwo1.id,
indent = 0,
text = blockHeaderTwo1.content.asText().text
text = blockHeaderTwo1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
text = blockText3.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText3.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Text.Header.One(
id = blockHeaderOne2.id,
indent = 0,
text = blockHeaderOne2.content.asText().text
text = blockHeaderOne2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
text = blockText4.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText4.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Text.Header.Two(
id = blockHeaderTwo2.id,
indent = 0,
text = blockHeaderTwo2.content.asText().text
text = blockHeaderTwo2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
text = blockText5.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText5.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Text.Header.Three(
id = blockHeaderThree.id,
indent = 0,
text = blockHeaderThree.content.asText().text
text = blockHeaderThree.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
text = blockText6.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText6.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -489,32 +594,89 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() {
BlockView.Text.Paragraph(
id = blockText1.id,
indent = 0,
text = blockText1.content.asText().text
text = blockText1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText1.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Text.Header.One(
id = blockHeaderOne.id,
indent = 0,
text = blockHeaderOne.content.asText().text
text = blockHeaderOne.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
text = blockText2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText2.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Text.Header.Two(
id = blockHeaderTwo.id,
indent = 0,
text = blockHeaderTwo.content.asText().text
text = blockHeaderTwo.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
text = blockText3.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText3.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Text.Header.Three(
id = blockHeaderThree.id,
indent = 0,
text = blockHeaderThree.content.asText().text
text = blockHeaderThree.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderThree.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
)
} else {
emptyList()
}
)
)
)
@ -566,17 +728,45 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() {
BlockView.Text.Paragraph(
id = blockText1.id,
indent = 0,
text = blockText1.content.asText().text
text = blockText1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText1.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Text.Header.One(
id = blockHeaderOne.id,
indent = 0,
text = blockHeaderOne.content.asText().text
text = blockHeaderOne.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
text = blockText2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText2.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Text.Header.Two(
id = blockHeaderTwo.id,
@ -586,12 +776,31 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() {
BlockView.Text.Paragraph(
id = blockText3.id,
indent = 0,
text = blockText3.content.asText().text
text = blockText3.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockText3.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
),
BlockView.Text.Header.Three(
id = blockHeaderThree.id,
indent = 0,
text = blockHeaderThree.content.asText().text
text = blockHeaderThree.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderThree.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
)
} else {
emptyList()
}
)
)
)
@ -750,27 +959,77 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() {
BlockView.Text.Header.One(
id = blockHeaderOne1.id,
indent = 0,
text = blockHeaderOne1.content.asText().text
text = blockHeaderOne1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
text = blockHeaderTwo1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
text = blockHeaderThree.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
text = blockHeaderTwo2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
text = blockHeaderThree2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderThree2.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
)
} else {
emptyList()
}
)
)
)
@ -946,27 +1205,77 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() {
BlockView.Text.Header.One(
id = blockHeaderOne1.id,
indent = 0,
text = blockHeaderOne1.content.asText().text
text = blockHeaderOne1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
text = blockHeaderTwo1.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
text = blockHeaderThree.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
text = blockHeaderTwo2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
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
text = blockHeaderThree2.content.asText().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = blockHeaderThree2.parseThemeBackgroundColor(),
style = BlockView.Decoration.Style.Header.H3
)
)
} else {
emptyList()
}
)
)
)

View file

@ -9,8 +9,10 @@ import com.anytypeio.anytype.core_models.ext.content
import com.anytypeio.anytype.domain.block.interactor.SplitBlock
import com.anytypeio.anytype.domain.block.interactor.UpdateText
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
import com.anytypeio.anytype.presentation.BuildConfig
import com.anytypeio.anytype.presentation.editor.EditorViewModel
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor
import com.anytypeio.anytype.presentation.util.CoroutinesTestRule
import com.anytypeio.anytype.test_utils.MockDataFactory
import com.jraska.livedata.test
@ -326,7 +328,16 @@ class EditorTitleTest : EditorPresentationTestSetup() {
),
BlockView.Text.Bulleted(
id = block.id,
text = block.content<Block.Content.Text>().text
text = block.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -347,7 +358,16 @@ class EditorTitleTest : EditorPresentationTestSetup() {
),
BlockView.Text.Bulleted(
id = block.id,
text = block.content<Block.Content.Text>().text
text = block.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)
@ -440,7 +460,16 @@ class EditorTitleTest : EditorPresentationTestSetup() {
),
BlockView.Text.Bulleted(
id = block.id,
text = block.content<Block.Content.Text>().text
text = block.content<Block.Content.Text>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
)
)

View file

@ -21,9 +21,11 @@ import com.anytypeio.anytype.domain.editor.Editor
import com.anytypeio.anytype.domain.misc.UrlBuilder
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
import com.anytypeio.anytype.core_models.ThemeColor
import com.anytypeio.anytype.presentation.BuildConfig
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
import com.anytypeio.anytype.presentation.editor.render.BlockViewRenderer
import com.anytypeio.anytype.presentation.editor.render.DefaultBlockViewRenderer
import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor
import com.anytypeio.anytype.presentation.editor.toggle.ToggleStateHolder
import com.anytypeio.anytype.presentation.util.TXT
import kotlinx.coroutines.runBlocking
@ -34,6 +36,7 @@ import org.junit.Test
import org.mockito.Mock
import org.mockito.MockitoAnnotations
import kotlin.test.assertEquals
import kotlin.test.asserter
class TableBlockRendererTest {
@ -222,7 +225,16 @@ class TableBlockRendererTest {
) + blocksUpper.map { block: Block ->
BlockView.Text.Bulleted(
id = block.id,
text = block.content<TXT>().text
text = block.content<TXT>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
} + listOf(
BlockView.Table(
@ -236,7 +248,16 @@ class TableBlockRendererTest {
BlockView.Text.Numbered(
id = block.id,
text = block.content<TXT>().text,
number = idx.inc()
number = idx.inc(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = block.parseThemeBackgroundColor()
)
)
} else {
emptyList()
}
)
}
@ -354,7 +375,16 @@ class TableBlockRendererTest {
) + blocksUpper.map { block: Block ->
BlockView.Text.Bulleted(
id = block.id,
text = block.content<TXT>().text
text = block.content<TXT>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
)
} else {
emptyList()
}
)
} + listOf(
BlockView.Table(
@ -368,7 +398,16 @@ class TableBlockRendererTest {
BlockView.Text.Numbered(
id = block.id,
text = block.content<TXT>().text,
number = idx.inc()
number = idx.inc(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
)
} else {
emptyList()
}
)
}
@ -564,7 +603,16 @@ class TableBlockRendererTest {
) + blocksUpper.map { block: Block ->
BlockView.Text.Bulleted(
id = block.id,
text = block.content<TXT>().text
text = block.content<TXT>().text,
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
)
} else {
emptyList()
}
)
} + listOf(
BlockView.Table(
@ -578,7 +626,16 @@ class TableBlockRendererTest {
BlockView.Text.Numbered(
id = block.id,
text = block.content<TXT>().text,
number = idx.inc()
number = idx.inc(),
decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) {
listOf(
BlockView.Decoration(
background = ThemeColor.DEFAULT
)
)
} else {
emptyList()
}
)
}

View file

@ -72,13 +72,15 @@ fun StubParagraph(
text: String = MockDataFactory.randomString(),
children: List<Id> = emptyList(),
marks: List<Block.Content.Text.Mark> = emptyList(),
backgroundColor: String? = null
backgroundColor: String? = null,
textColor: String? = null
): Block = Block(
id = id,
content = StubTextContent(
text = text,
style = Block.Content.Text.Style.P,
marks = marks
marks = marks,
color = textColor
),
children = children,
fields = Block.Fields.empty(),
@ -93,7 +95,7 @@ fun StubFile(
name: String = MockDataFactory.randomString(),
size: Long = MockDataFactory.randomLong(),
type: Block.Content.File.Type? = null,
state: Block.Content.File.State? = null
state: Block.Content.File.State? = null,
) : Block = Block(
id = id,
children = children,