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

DROID-933 Widgets | Enhancement | React to changes in order and number of widgets (#2887)

This commit is contained in:
Evgenii Kozlov 2023-02-03 14:22:52 +01:00 committed by GitHub
parent 1abdf1a3b0
commit 779b10cc2e
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 510 additions and 34 deletions

View file

@ -234,12 +234,13 @@ fun StubBookmark(
fun StubSmartBlock(
id: Id = MockDataFactory.randomString(),
children: List<Id> = emptyList()
children: List<Id> = emptyList(),
type: SmartBlockType = SmartBlockType.PAGE
): Block = Block(
id = id,
children = children,
fields = Block.Fields.empty(),
content = Block.Content.Smart()
content = Block.Content.Smart(type = type)
)
fun StubTable(
@ -337,4 +338,41 @@ fun StubDataViewBlock(
children = children,
fields = fields,
backgroundColor = backgroundColor
)
fun StubLinkToObjectBlock(
id: Id = MockDataFactory.randomUuid(),
target: Id,
children: List<Id> = emptyList(),
fields: Block.Fields = Block.Fields.empty(),
backgroundColor: String? = null,
) : Block = Block(
id = id,
content = Block.Content.Link(
target = target,
description = Block.Content.Link.Description.values().random(),
cardStyle = Block.Content.Link.CardStyle.values().random(),
iconSize = Block.Content.Link.IconSize.values().random(),
relations = emptySet(),
type = Block.Content.Link.Type.PAGE
),
children = children,
fields = fields,
backgroundColor = backgroundColor
)
fun StubWidgetBlock(
id: Id = MockDataFactory.randomUuid(),
layout: Block.Content.Widget.Layout,
children: List<Id> = emptyList(),
fields: Block.Fields = Block.Fields.empty(),
backgroundColor: String? = null,
) : Block = Block(
id = id,
children = children,
fields = fields,
backgroundColor = backgroundColor,
content = Block.Content.Widget(
layout = layout
)
)

View file

@ -1,5 +1,7 @@
package com.anytypeio.anytype.core_models
import com.anytypeio.anytype.core_models.restrictions.DataViewRestrictions
import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction
import com.anytypeio.anytype.test_utils.MockDataFactory
fun StubObject(
@ -32,6 +34,24 @@ fun StubObject(
)
)
fun StubObjectView(
root: Id,
type: SmartBlockType,
blocks: List<Block> = emptyList(),
details: Map<Id, Struct> = emptyMap(),
relations: List<RelationLink> = emptyList(),
objectRestrictions: List<ObjectRestriction> = emptyList(),
dataViewRestrictions: List<DataViewRestrictions> = emptyList()
): ObjectView = ObjectView(
root = root,
blocks = blocks,
details = details,
type = type,
relations = relations,
objectRestrictions = objectRestrictions,
dataViewRestrictions = dataViewRestrictions
)
fun StubObjectType(
id: String = MockDataFactory.randomUuid(),
name: String = MockDataFactory.randomString(),