mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-434 Sets | Enhancement | Allow possibility to change data view source after its initial setup (#2692)
This commit is contained in:
parent
8f2b27babc
commit
46ceb1ef41
5 changed files with 41 additions and 8 deletions
|
@ -82,6 +82,7 @@ class ObjectTypeChangeFragment :
|
|||
}
|
||||
|
||||
override fun onStart() {
|
||||
expand()
|
||||
with(lifecycleScope) {
|
||||
jobs += subscribe(vm.results) { observeViews(it) }
|
||||
jobs += subscribe(binding.searchObjectTypeInput.textChanges()) {
|
||||
|
|
|
@ -259,6 +259,13 @@ sealed class Event {
|
|||
val key: String,
|
||||
val relation: Relation
|
||||
) : DataView()
|
||||
|
||||
|
||||
data class SetSource(
|
||||
override val context: Id,
|
||||
val dv: Id,
|
||||
val sources: List<Id>
|
||||
) : DataView()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,14 +9,14 @@ import android.widget.TextView
|
|||
import androidx.constraintlayout.helper.widget.Flow
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
import com.anytypeio.anytype.core_ui.R
|
||||
import com.anytypeio.anytype.core_ui.extensions.color
|
||||
import com.anytypeio.anytype.core_ui.extensions.dark
|
||||
import com.anytypeio.anytype.core_ui.extensions.light
|
||||
import com.anytypeio.anytype.core_ui.menu.ObjectTypePopupMenu
|
||||
import com.anytypeio.anytype.core_utils.ext.dimen
|
||||
import com.anytypeio.anytype.core_utils.ext.setDrawableColor
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
import com.anytypeio.anytype.core_ui.extensions.color
|
||||
import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectIcon
|
||||
|
@ -274,12 +274,11 @@ class FeaturedRelationGroupWidget : ConstraintLayout {
|
|||
}
|
||||
}
|
||||
}
|
||||
// todo https://linear.app/anytype/issue/DROID-434/set-or-change-set-source
|
||||
// view.setOnClickListener {
|
||||
// click(
|
||||
// ListenerType.Relation.SetSource(sources = relation.sources)
|
||||
// )
|
||||
// }
|
||||
view.setOnClickListener {
|
||||
click(
|
||||
ListenerType.Relation.SetSource(sources = relation.sources)
|
||||
)
|
||||
}
|
||||
addView(view)
|
||||
ids.add(view.id)
|
||||
}
|
||||
|
|
|
@ -192,6 +192,15 @@ fun anytype.Event.Message.toCoreModels(
|
|||
viewer = event.viewId
|
||||
)
|
||||
}
|
||||
blockDataviewSourceSet != null -> {
|
||||
val event = blockDataviewSourceSet
|
||||
checkNotNull(event)
|
||||
Event.Command.DataView.SetSource(
|
||||
context = context,
|
||||
dv = event.id,
|
||||
sources = event.source
|
||||
)
|
||||
}
|
||||
blockSetRelation != null -> {
|
||||
val event = blockSetRelation
|
||||
checkNotNull(event)
|
||||
|
|
|
@ -134,6 +134,23 @@ class ObjectSetReducer {
|
|||
}
|
||||
)
|
||||
}
|
||||
is Command.DataView.SetSource -> {
|
||||
state.copy(
|
||||
blocks = state.blocks.map { block ->
|
||||
if (block.id == event.dv) {
|
||||
val content = block.content
|
||||
check(content is DV)
|
||||
block.copy(
|
||||
content = content.copy(
|
||||
sources = event.sources
|
||||
)
|
||||
)
|
||||
} else {
|
||||
block
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
is Command.Details.Set -> {
|
||||
state.copy(
|
||||
details = state.details.toMutableMap().apply {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue