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

DROID-1414 Collection | Fix | Files, objects relations (#117)

This commit is contained in:
Konstantin Ivanov 2023-07-05 12:09:31 +02:00 committed by GitHub
parent 6ea103b7f9
commit 91443fc90a
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 32 additions and 33 deletions

View file

@ -50,7 +50,7 @@ class ListViewItemRelationGroupWidget @JvmOverloads constructor(
is DefaultObjectRelationValueView.Checkbox -> {
val view = View(context).apply {
id = generateViewId()
val size = context.dimen(R.dimen.dp_16).toInt()
val size = context.dimen(R.dimen.dv_list_gallery_item_relation_height).toInt()
layoutParams = LayoutParams(size, size)
setBackgroundResource(R.drawable.ic_relation_checkbox_selector)
isSelected = relation.isChecked

View file

@ -6,6 +6,6 @@
android:color="#DFDDD0" />
<corners android:radius="3dp" />
<solid android:color="#DFDDD0" />
<padding android:left="4dp"
android:right="4dp"/>
<padding android:left="5dp"
android:right="5dp"/>
</shape>

View file

@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="@dimen/dv_list_gallery_item_relation_height"
android:orientation="horizontal">
<com.anytypeio.anytype.core_ui.widgets.ObjectIconWidget
@ -24,7 +24,8 @@
android:id="@+id/tvName"
style="@style/TextView.ContentStyle.Relations.3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:maxLength="40"
android:maxLines="1"
android:singleLine="true"
@ -39,7 +40,8 @@
style="@style/TextView.ContentStyle.Relations.3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="6dp"
android:layout_marginStart="@dimen/dv_list_gallery_item_relation_count_margin_start"
android:gravity="center_vertical"
android:background="@drawable/bg_dv_list_item_object_count"
android:textColor="@color/text_secondary"
android:maxLines="1"

View file

@ -2,20 +2,21 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="16dp"
android:layout_height="@dimen/dv_list_gallery_item_relation_height"
android:orientation="horizontal">
<TextView
style="@style/TextView.ContentStyle.Relations.3"
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:maxLength="40"
android:maxLines="1"
android:singleLine="true"
android:ellipsize="end"
android:background="@drawable/rect_dv_cell_tag_item"
android:visibility="gone"
android:gravity="center_vertical"
tools:text="Favorites"
tools:visibility="visible" />
@ -24,9 +25,10 @@
android:id="@+id/tvCount"
android:textColor="@color/text_secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/dv_list_gallery_item_relation_count_margin_start"
android:background="@drawable/bg_dv_list_item_object_count"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingStart="4dp"
android:paddingEnd="4dp"

View file

@ -327,4 +327,8 @@
<dimen name="dv_gallery_relation_height">16dp</dimen>
<dimen name="dv_gallery_relation_margin_top">4dp</dimen>
<!-- DataView, List items, relations-->
<dimen name="dv_list_gallery_item_relation_height">15dp</dimen>
<dimen name="dv_list_gallery_item_relation_count_margin_start">4dp</dimen>
</resources>

View file

@ -23,7 +23,6 @@ import timber.log.Timber
suspend fun ObjectWrapper.Basic.values(
relations: List<ObjectWrapper.Relation>,
settings: List<DVViewerRelation>,
details: Map<Id, Block.Fields>,
urlBuilder: UrlBuilder,
storeOfObjects: ObjectStore
): List<DefaultObjectRelationValueView> {
@ -135,7 +134,10 @@ suspend fun ObjectWrapper.Basic.values(
val value = DefaultObjectRelationValueView.File(
objectId = id,
relationKey = relation.key,
files = files(relation = relation.key, details = details)
files = files(
relation = relation.key,
storeOfObjects = storeOfObjects
)
)
values.add(value)
}
@ -145,8 +147,8 @@ suspend fun ObjectWrapper.Basic.values(
relationKey = relation.key,
objects = objects(
relation = relation.key,
details = details,
urlBuilder = urlBuilder
urlBuilder = urlBuilder,
storeOfObjects = storeOfObjects
)
)
values.add(value)
@ -163,14 +165,12 @@ suspend fun ObjectWrapper.Basic.values(
suspend fun ObjectWrapper.Basic.relationsFilteredByHiddenAndDescription(
relations: List<ObjectWrapper.Relation>,
settings: List<DVViewerRelation>,
details: Map<Id, Block.Fields>,
urlBuilder: UrlBuilder,
storeOfObjects: ObjectStore
): List<DefaultObjectRelationValueView> {
return values(
relations = relations.filter { it.isHidden != true && it.key != Relations.DESCRIPTION },
settings = settings,
details = details,
urlBuilder = urlBuilder,
storeOfObjects = storeOfObjects
)
@ -226,9 +226,9 @@ suspend fun ObjectWrapper.Basic.tags(
return result
}
fun ObjectWrapper.Basic.files(
suspend fun ObjectWrapper.Basic.files(
relation: Id,
details: Map<Id, Block.Fields>
storeOfObjects: ObjectStore
) : List<FileView> {
val result = mutableListOf<FileView>()
val ids : List<Id> = when(val value = map.getOrDefault(relation, null)) {
@ -237,9 +237,8 @@ fun ObjectWrapper.Basic.files(
else -> emptyList()
}
ids.forEach { id ->
val data = details[id]
if (data != null) {
val obj = ObjectWrapper.Basic(data.map)
val obj = storeOfObjects.get(id)
if (obj != null) {
result.add(
FileView(
id = obj.id,
@ -255,10 +254,10 @@ fun ObjectWrapper.Basic.files(
return result
}
fun ObjectWrapper.Basic.objects(
suspend fun ObjectWrapper.Basic.objects(
relation: Id,
details: Map<Id, Block.Fields>,
urlBuilder: UrlBuilder
urlBuilder: UrlBuilder,
storeOfObjects: ObjectStore
) : List<ObjectView> {
val result = mutableListOf<ObjectView>()
@ -267,9 +266,8 @@ fun ObjectWrapper.Basic.objects(
is List<*> -> value.typeOf()
else -> emptyList()
}
ids.forEach { id ->
val wrapper = ObjectWrapper.Basic(details[id]?.map ?: return@forEach)
val wrapper = storeOfObjects.get(id) ?: return@forEach
result.add(wrapper.toObjectView(urlBuilder))
}
return result

View file

@ -116,7 +116,6 @@ suspend fun DVViewer.render(
id = id,
items = buildListViews(
objects = objects,
details = details,
relations = visibleRelations,
urlBuilder = builder,
store = store,

View file

@ -89,7 +89,6 @@ private suspend fun ObjectWrapper.Basic.mapToDefaultItem(
relations = obj.values(
relations = filteredRelations,
urlBuilder = urlBuilder,
details = details,
settings = viewerRelations,
storeOfObjects = store
),
@ -162,7 +161,6 @@ private suspend fun ObjectWrapper.Basic.mapToCoverItem(
relations = obj.values(
relations = filteredRelations,
urlBuilder = urlBuilder,
details = details,
settings = dvViewer.viewerRelations,
storeOfObjects = store
),

View file

@ -16,7 +16,6 @@ import com.anytypeio.anytype.presentation.sets.model.Viewer
suspend fun DVViewer.buildListViews(
objects: List<Id>,
relations: List<ObjectWrapper.Relation>,
details: Map<Id, Block.Fields>,
urlBuilder: UrlBuilder,
store: ObjectStore,
objectOrderIds: List<Id>
@ -44,7 +43,6 @@ suspend fun DVViewer.buildListViews(
relations = obj.relationsFilteredByHiddenAndDescription(
relations = relations,
urlBuilder = urlBuilder,
details = details,
settings = viewerRelations,
storeOfObjects = store
),
@ -69,7 +67,6 @@ suspend fun DVViewer.buildListViews(
relations = obj.relationsFilteredByHiddenAndDescription(
relations = relations,
urlBuilder = urlBuilder,
details = details,
settings = viewerRelations,
storeOfObjects = store
),
@ -94,7 +91,6 @@ suspend fun DVViewer.buildListViews(
relations = obj.relationsFilteredByHiddenAndDescription(
relations = relations,
urlBuilder = urlBuilder,
details = details,
settings = viewerRelations,
storeOfObjects = store
),