mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3341 Primitives | Slash menu filters are updated (#2302)
This commit is contained in:
parent
8c82c1f270
commit
939d1677fe
11 changed files with 91 additions and 92 deletions
|
@ -25,12 +25,12 @@ import com.anytypeio.anytype.core_utils.diff.DefaultDiffUtil
|
|||
import com.anytypeio.anytype.core_utils.ext.dimen
|
||||
import com.anytypeio.anytype.core_utils.ext.visible
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashItem
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashRelationView
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashPropertyView
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectRelationView
|
||||
import timber.log.Timber
|
||||
|
||||
class SlashRelationsAdapter(
|
||||
private var items: List<SlashRelationView>,
|
||||
class SlashPropertiesAdapter(
|
||||
private var items: List<SlashPropertyView>,
|
||||
private val clicks: (SlashItem) -> Unit
|
||||
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
|
||||
|
@ -142,7 +142,7 @@ class SlashRelationsAdapter(
|
|||
).apply {
|
||||
updatePadding(this.itemView, defaultPadding)
|
||||
itemView.setOnClickListener {
|
||||
clicks(SlashItem.RelationNew)
|
||||
clicks(SlashItem.PropertyNew)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -160,8 +160,8 @@ class SlashRelationsAdapter(
|
|||
private fun onItemClicked(position: Int) {
|
||||
if (position != RecyclerView.NO_POSITION) {
|
||||
val view = items[position]
|
||||
check(view is SlashRelationView.Item)
|
||||
clicks(SlashItem.Relation(view))
|
||||
check(view is SlashPropertyView.Item)
|
||||
clicks(SlashItem.Property(view))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,49 +183,49 @@ class SlashRelationsAdapter(
|
|||
val item = items[position]
|
||||
when (holder) {
|
||||
is ListRelationViewHolder.Status -> {
|
||||
check(item is SlashRelationView.Item)
|
||||
check(item is SlashPropertyView.Item)
|
||||
val view = item.view
|
||||
check(view is ObjectRelationView.Status)
|
||||
holder.bind(view)
|
||||
}
|
||||
is ListRelationViewHolder.Checkbox -> {
|
||||
check(item is SlashRelationView.Item)
|
||||
check(item is SlashPropertyView.Item)
|
||||
val view = item.view
|
||||
check(view is ObjectRelationView.Checkbox)
|
||||
holder.bind(view)
|
||||
}
|
||||
is ListRelationViewHolder.Tags -> {
|
||||
check(item is SlashRelationView.Item)
|
||||
check(item is SlashPropertyView.Item)
|
||||
val view = item.view
|
||||
check(view is ObjectRelationView.Tags)
|
||||
holder.bind(view)
|
||||
}
|
||||
is ListRelationViewHolder.Object -> {
|
||||
check(item is SlashRelationView.Item)
|
||||
check(item is SlashPropertyView.Item)
|
||||
val view = item.view
|
||||
check(view is ObjectRelationView.Object)
|
||||
holder.bind(view)
|
||||
}
|
||||
is ListRelationViewHolder.File -> {
|
||||
check(item is SlashRelationView.Item)
|
||||
check(item is SlashPropertyView.Item)
|
||||
val view = item.view
|
||||
check(view is ObjectRelationView.File)
|
||||
holder.bind(view)
|
||||
}
|
||||
is ListRelationViewHolder.Default -> {
|
||||
check(item is SlashRelationView.Item)
|
||||
check(item is SlashPropertyView.Item)
|
||||
val view = item.view
|
||||
check(view is ObjectRelationView.Default)
|
||||
holder.bind(view)
|
||||
}
|
||||
is ListRelationViewHolder.Date -> {
|
||||
check(item is SlashRelationView.Item)
|
||||
check(item is SlashPropertyView.Item)
|
||||
val view = item.view
|
||||
check(view is ObjectRelationView.Date)
|
||||
holder.bind(view)
|
||||
}
|
||||
is RelationsSubheaderMenuHolder -> {
|
||||
check(item is SlashRelationView.Section)
|
||||
check(item is SlashPropertyView.Section)
|
||||
holder.bind(item)
|
||||
}
|
||||
is RelationsSubheaderOnlyMenuHolder -> {
|
||||
|
@ -240,7 +240,7 @@ class SlashRelationsAdapter(
|
|||
override fun getItemCount(): Int = items.size
|
||||
|
||||
override fun getItemViewType(position: Int): Int = when (val item = items[position]) {
|
||||
is SlashRelationView.Item -> {
|
||||
is SlashPropertyView.Item -> {
|
||||
when (item.view) {
|
||||
is ObjectRelationView.Checkbox -> R.layout.item_relation_list_relation_checkbox
|
||||
is ObjectRelationView.Object -> R.layout.item_relation_list_relation_object
|
||||
|
@ -251,12 +251,12 @@ class SlashRelationsAdapter(
|
|||
else -> R.layout.item_relation_list_relation_default
|
||||
}
|
||||
}
|
||||
is SlashRelationView.Section.SubheaderWithBack -> R.layout.item_slash_widget_subheader
|
||||
SlashRelationView.Section.Subheader -> R.layout.item_slash_widget_subheader_left
|
||||
SlashRelationView.RelationNew -> R.layout.item_relation_add_new
|
||||
is SlashPropertyView.Section.SubheaderWithBack -> R.layout.item_slash_widget_subheader
|
||||
SlashPropertyView.Section.Subheader -> R.layout.item_slash_widget_subheader_left
|
||||
SlashPropertyView.PropertyNew -> R.layout.item_relation_add_new
|
||||
}
|
||||
|
||||
fun update(update: List<SlashRelationView>) {
|
||||
fun update(update: List<SlashPropertyView>) {
|
||||
Timber.d("Updating adapter: $update")
|
||||
val differ = DefaultDiffUtil(old = items, new = update)
|
||||
val result = DiffUtil.calculateDiff(differ, false)
|
|
@ -54,7 +54,7 @@ class SlashWidget @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
private val relationsAdapter by lazy {
|
||||
SlashRelationsAdapter(
|
||||
SlashPropertiesAdapter(
|
||||
items = listOf(),
|
||||
clicks = { _clickEvents.trySend(it) }
|
||||
)
|
||||
|
|
|
@ -38,7 +38,7 @@ class MainMenuHolder(val binding: ItemSlashWidgetMainBinding) :
|
|||
textMain.setText(R.string.slash_widget_main_other)
|
||||
iconMain.setImageResource(R.drawable.ic_slash_main_other)
|
||||
}
|
||||
SlashItem.Main.Relations -> {
|
||||
SlashItem.Main.Properties -> {
|
||||
textMain.setText(R.string.slash_widget_main_relations)
|
||||
iconMain.setImageResource(R.drawable.ic_properties_purple_24)
|
||||
}
|
||||
|
|
|
@ -6,19 +6,19 @@ import com.anytypeio.anytype.core_ui.databinding.ItemSlashWidgetSubheaderBinding
|
|||
import com.anytypeio.anytype.core_ui.databinding.ItemSlashWidgetSubheaderLeftBinding
|
||||
import com.anytypeio.anytype.core_utils.ext.invisible
|
||||
import com.anytypeio.anytype.core_utils.ext.visible
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashRelationView
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashPropertyView
|
||||
|
||||
class RelationsSubheaderMenuHolder(
|
||||
val binding: ItemSlashWidgetSubheaderBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
fun bind(item: SlashRelationView.Section) = with(binding) {
|
||||
fun bind(item: SlashPropertyView.Section) = with(binding) {
|
||||
val text = when (item) {
|
||||
SlashRelationView.Section.Subheader -> {
|
||||
SlashPropertyView.Section.Subheader -> {
|
||||
flBack.invisible()
|
||||
R.string.slash_widget_main_relations
|
||||
}
|
||||
SlashRelationView.Section.SubheaderWithBack -> {
|
||||
SlashPropertyView.Section.SubheaderWithBack -> {
|
||||
flBack.visible()
|
||||
R.string.slash_widget_main_relations
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ object SlashConst {
|
|||
const val SLASH_MAIN_STYLE = "Style"
|
||||
const val SLASH_MAIN_MEDIA = "Media"
|
||||
const val SLASH_MAIN_OBJECTS = "Objects"
|
||||
const val SLASH_MAIN_RELATIONS = "Relations"
|
||||
const val SLASH_MAIN_PROPERTIES = "Properties"
|
||||
const val SLASH_MAIN_OTHER = "Other"
|
||||
const val SLASH_MAIN_ACTIONS = "Actions"
|
||||
const val SLASH_MAIN_ALIGNMENT = "Alignment"
|
||||
|
@ -58,5 +58,5 @@ object SlashConst {
|
|||
|
||||
const val SLASH_BACK = "Back"
|
||||
|
||||
const val SLASH_RELATION_NEW = "Relation new"
|
||||
const val SLASH_PROPERTY_NEW = "Property new"
|
||||
}
|
|
@ -30,7 +30,6 @@ import com.anytypeio.anytype.core_models.Position
|
|||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.RelationFormat
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.Struct
|
||||
import com.anytypeio.anytype.core_models.TextBlock
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
import com.anytypeio.anytype.core_models.Url
|
||||
|
@ -162,7 +161,7 @@ import com.anytypeio.anytype.presentation.editor.editor.slash.SlashExtensions.SL
|
|||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashExtensions.getSlashWidgetAlignmentItems
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashExtensions.getSlashWidgetStyleItems
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashItem
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashRelationView
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashPropertyView
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashWidgetState
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.convertToMarkType
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.convertToUiBlock
|
||||
|
@ -249,7 +248,6 @@ import com.anytypeio.anytype.core_models.ext.toObject
|
|||
import com.anytypeio.anytype.core_models.multiplayer.SpaceMemberPermissions
|
||||
import com.anytypeio.anytype.presentation.editor.ControlPanelMachine.Event.SAM.*
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.domain.objects.getTypeOfObject
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Intent.Clipboard.Copy
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Intent.Clipboard.Paste
|
||||
import com.anytypeio.anytype.presentation.editor.editor.ext.isAllowedToShowTypesWidget
|
||||
|
@ -262,8 +260,6 @@ import com.anytypeio.anytype.presentation.editor.model.OnEditorDatePickerEvent.O
|
|||
import com.anytypeio.anytype.presentation.editor.model.OnEditorDatePickerEvent.OnTodayClick
|
||||
import com.anytypeio.anytype.presentation.editor.model.OnEditorDatePickerEvent.OnTomorrowClick
|
||||
import com.anytypeio.anytype.presentation.extension.getFileDetailsForBlock
|
||||
import com.anytypeio.anytype.presentation.extension.getObjRelationsViews
|
||||
import com.anytypeio.anytype.presentation.extension.getRecommendedRelations
|
||||
import com.anytypeio.anytype.presentation.extension.getTypeForObject
|
||||
import com.anytypeio.anytype.presentation.extension.getUrlForFileContent
|
||||
import com.anytypeio.anytype.presentation.navigation.NavPanelState
|
||||
|
@ -275,7 +271,6 @@ import com.anytypeio.anytype.presentation.objects.hasLayoutConflict
|
|||
import com.anytypeio.anytype.presentation.objects.isTemplatesAllowed
|
||||
import com.anytypeio.anytype.presentation.objects.toViews
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectRelationView
|
||||
import com.anytypeio.anytype.presentation.relations.type
|
||||
import com.anytypeio.anytype.presentation.relations.view
|
||||
import com.anytypeio.anytype.presentation.search.ObjectSearchConstants
|
||||
import com.anytypeio.anytype.presentation.search.ObjectSearchViewModel
|
||||
|
@ -4965,11 +4960,11 @@ class EditorViewModel(
|
|||
proceedWithGettingObjectTypes(
|
||||
sorts = ObjectSearchConstants.defaultObjectTypeSearchSorts()
|
||||
) { objectTypes ->
|
||||
getRelations { relations ->
|
||||
getProperties { properties ->
|
||||
val widgetState = SlashExtensions.getUpdatedSlashWidgetState(
|
||||
text = event.filter,
|
||||
objectTypes = objectTypes.toSlashItemView(),
|
||||
relations = relations,
|
||||
properties = properties,
|
||||
viewType = slashViewType
|
||||
)
|
||||
incFilterSearchEmptyCount(widgetState)
|
||||
|
@ -5040,8 +5035,8 @@ class EditorViewModel(
|
|||
)
|
||||
)
|
||||
}
|
||||
is SlashItem.Main.Relations -> {
|
||||
getRelations { proceedWithRelations(it) }
|
||||
is SlashItem.Main.Properties -> {
|
||||
getProperties { proceedWithProperties(it) }
|
||||
}
|
||||
is SlashItem.Main.Objects -> {
|
||||
proceedWithGettingObjectTypes(
|
||||
|
@ -5158,9 +5153,9 @@ class EditorViewModel(
|
|||
controlPanelInteractor.onEvent(ControlPanelMachine.Event.Slash.OnStop)
|
||||
onAddNewObjectClicked(objectTypeView = item.objectTypeView)
|
||||
}
|
||||
is SlashItem.Relation -> {
|
||||
is SlashItem.Property -> {
|
||||
val isBlockEmpty = cutSlashFilter(targetId = targetId)
|
||||
val relationKey = item.relation.view.key
|
||||
val relationKey = item.property.view.key
|
||||
onSlashRelationItemClicked(
|
||||
relationKey = relationKey,
|
||||
targetId = targetId,
|
||||
|
@ -5207,7 +5202,7 @@ class EditorViewModel(
|
|||
is SlashItem.Subheader -> {
|
||||
Timber.d("Click on Slash Subheader, do nothing")
|
||||
}
|
||||
SlashItem.RelationNew -> {
|
||||
SlashItem.PropertyNew -> {
|
||||
dispatch(
|
||||
Command.OpenAddRelationScreen(ctx = context, target = targetId)
|
||||
)
|
||||
|
@ -5352,7 +5347,7 @@ class EditorViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
private fun getRelations(action: (List<SlashRelationView.Item>) -> Unit) {
|
||||
private fun getProperties(action: (List<SlashPropertyView.Item>) -> Unit) {
|
||||
val objectViewDetails = orchestrator.stores.details.current()
|
||||
val currentObj = objectViewDetails.getObject(vmParams.ctx)
|
||||
if (currentObj == null) {
|
||||
|
@ -5382,7 +5377,7 @@ class EditorViewModel(
|
|||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}.map {
|
||||
SlashRelationView.Item(it)
|
||||
SlashPropertyView.Item(it)
|
||||
}
|
||||
|
||||
action.invoke(properties)
|
||||
|
@ -5397,10 +5392,10 @@ class EditorViewModel(
|
|||
)
|
||||
}
|
||||
|
||||
private fun proceedWithRelations(relations: List<SlashRelationView>) {
|
||||
private fun proceedWithProperties(properties: List<SlashPropertyView>) {
|
||||
onSlashWidgetStateChanged(
|
||||
SlashWidgetState.UpdateItems.empty().copy(
|
||||
relationItems = SlashExtensions.getSlashWidgetRelationItems(relations)
|
||||
relationItems = SlashExtensions.getSlashWidgetPropertyItems(properties)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.anytypeio.anytype.presentation.editor.editor.slash
|
|||
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
import com.anytypeio.anytype.core_utils.const.SlashConst
|
||||
import com.anytypeio.anytype.core_utils.ext.parseMatchedInt
|
||||
import com.anytypeio.anytype.domain.table.CreateTable.Companion.DEFAULT_COLUMN_COUNT
|
||||
import com.anytypeio.anytype.domain.table.CreateTable.Companion.DEFAULT_MAX_COLUMN_COUNT
|
||||
|
@ -49,7 +50,7 @@ object SlashExtensions {
|
|||
SlashItem.Main.Style,
|
||||
SlashItem.Main.Media,
|
||||
SlashItem.Main.Objects,
|
||||
SlashItem.Main.Relations,
|
||||
SlashItem.Main.Properties,
|
||||
SlashItem.Main.Other,
|
||||
SlashItem.Main.Actions,
|
||||
SlashItem.Main.Alignment,
|
||||
|
@ -136,11 +137,11 @@ object SlashExtensions {
|
|||
SlashItem.SelectDate
|
||||
) + objectTypes.toSlashItemView()
|
||||
|
||||
fun getSlashWidgetRelationItems(relations: List<SlashRelationView>): List<SlashRelationView> =
|
||||
fun getSlashWidgetPropertyItems(properties: List<SlashPropertyView>): List<SlashPropertyView> =
|
||||
listOf(
|
||||
SlashRelationView.Section.SubheaderWithBack,
|
||||
SlashPropertyView.Section.SubheaderWithBack,
|
||||
//SlashRelationView.RelationNew
|
||||
) + relations
|
||||
) + properties
|
||||
|
||||
fun getSlashWidgetColorItems(color: ThemeColor?): List<SlashItem.Color.Text> =
|
||||
ThemeColor.values().map { themeColor ->
|
||||
|
@ -165,7 +166,7 @@ object SlashExtensions {
|
|||
viewType: Int,
|
||||
text: CharSequence,
|
||||
objectTypes: List<SlashItem.ObjectType>,
|
||||
relations: List<SlashRelationView.Item>
|
||||
properties: List<SlashPropertyView.Item>
|
||||
): SlashWidgetState.UpdateItems {
|
||||
val filter = text.subSequence(1, text.length).toString()
|
||||
val filteredStyle = filterSlashItems(
|
||||
|
@ -205,9 +206,9 @@ object SlashExtensions {
|
|||
filter = filter,
|
||||
items = listOf(SlashItem.Actions.LinkTo, SlashItem.SelectDate) + objectTypes
|
||||
)
|
||||
val filteredRelations = filterRelations(
|
||||
val filteredRelations = filterProperties(
|
||||
filter = filter,
|
||||
items = relations
|
||||
items = properties
|
||||
)
|
||||
return SlashWidgetState.UpdateItems.empty().copy(
|
||||
styleItems = filteredStyle,
|
||||
|
@ -251,28 +252,31 @@ object SlashExtensions {
|
|||
return updateWithSubheader(filtered)
|
||||
}
|
||||
|
||||
private fun filterRelations(
|
||||
private fun filterProperties(
|
||||
filter: String,
|
||||
items: List<SlashRelationView.Item>
|
||||
): List<SlashRelationView> {
|
||||
val filtered = mutableListOf<SlashRelationView>()
|
||||
if (SlashRelationView.RelationNew.identifier.contains(filter, true)) {
|
||||
filtered.add(SlashRelationView.RelationNew)
|
||||
}
|
||||
items: List<SlashPropertyView.Item>
|
||||
): List<SlashPropertyView> {
|
||||
val filtered = mutableListOf<SlashPropertyView>()
|
||||
// if (SlashRelationView.RelationNew.identifier.contains(filter, true)) {
|
||||
// filtered.add(SlashRelationView.RelationNew)
|
||||
// }
|
||||
|
||||
// Process property items.
|
||||
items.forEach { item ->
|
||||
if (searchBySubheadingOrName(
|
||||
filter = filter,
|
||||
subheading = SlashItem.Main.Relations.getSearchName(),
|
||||
subheading = listOf<String>(SlashConst.SLASH_MAIN_PROPERTIES, "Relations"),
|
||||
name = item.view.name
|
||||
)
|
||||
) {
|
||||
filtered.add(item)
|
||||
}
|
||||
}
|
||||
// If there are any filtered items, prepend a section header.
|
||||
return if (filtered.isEmpty()) {
|
||||
filtered
|
||||
} else {
|
||||
listOf(SlashRelationView.Section.Subheader) + filtered
|
||||
listOf(SlashPropertyView.Section.Subheader) + filtered
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,7 +341,15 @@ object SlashExtensions {
|
|||
name: String,
|
||||
abbreviation: List<String>? = null
|
||||
): Boolean = subheading.startsWith(filter, true) || name.contains(filter, true) ||
|
||||
abbreviation?.any { it.contains(filter, true) } ?: false
|
||||
abbreviation?.any { it.contains(filter, true) } == true
|
||||
|
||||
private fun searchBySubheadingOrName(
|
||||
filter: String,
|
||||
subheading: List<String>,
|
||||
name: String,
|
||||
abbreviation: List<String>? = null
|
||||
): Boolean = subheading.any { it.startsWith(filter, true) } || name.contains(filter, true) ||
|
||||
abbreviation?.any { it.contains(filter, true) } == true
|
||||
|
||||
private fun updateWithSubheader(items: List<SlashItem>): List<SlashItem> =
|
||||
if (items.isNotEmpty()) {
|
||||
|
|
|
@ -12,7 +12,7 @@ sealed class SlashWidgetState {
|
|||
val styleItems: List<SlashItem>,
|
||||
val mediaItems: List<SlashItem>,
|
||||
val objectItems: List<SlashItem>,
|
||||
val relationItems: List<SlashRelationView>,
|
||||
val relationItems: List<SlashPropertyView>,
|
||||
val otherItems: List<SlashItem>,
|
||||
val actionsItems: List<SlashItem>,
|
||||
val alignmentItems: List<SlashItem>,
|
||||
|
@ -148,8 +148,8 @@ sealed class SlashItem {
|
|||
override fun getAbbreviation(): List<String>? = null
|
||||
}
|
||||
|
||||
object Relations : Main() {
|
||||
override fun getSearchName(): String = SlashConst.SLASH_MAIN_RELATIONS
|
||||
object Properties : Main() {
|
||||
override fun getSearchName(): String = SlashConst.SLASH_MAIN_PROPERTIES
|
||||
override fun getAbbreviation(): List<String>? = null
|
||||
}
|
||||
|
||||
|
@ -305,14 +305,14 @@ sealed class SlashItem {
|
|||
}
|
||||
//endregion
|
||||
|
||||
//region RELATION
|
||||
data class Relation(val relation: SlashRelationView.Item) : SlashItem() {
|
||||
override fun getSearchName(): String = relation.view.name
|
||||
//region Properties
|
||||
data class Property(val property: SlashPropertyView.Item) : SlashItem() {
|
||||
override fun getSearchName(): String = property.view.name
|
||||
override fun getAbbreviation(): List<String>? = null
|
||||
}
|
||||
|
||||
object RelationNew : SlashItem() {
|
||||
override fun getSearchName(): String = SlashConst.SLASH_RELATION_NEW
|
||||
object PropertyNew : SlashItem() {
|
||||
override fun getSearchName(): String = SlashConst.SLASH_PROPERTY_NEW
|
||||
override fun getAbbreviation(): List<String>? = null
|
||||
}
|
||||
//endregion
|
||||
|
|
|
@ -3,12 +3,12 @@ package com.anytypeio.anytype.presentation.editor.editor.slash
|
|||
import com.anytypeio.anytype.core_utils.diff.DefaultObjectDiffIdentifier
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectRelationView
|
||||
|
||||
sealed class SlashRelationView : DefaultObjectDiffIdentifier {
|
||||
data class Item(val view: ObjectRelationView) : SlashRelationView() {
|
||||
sealed class SlashPropertyView : DefaultObjectDiffIdentifier {
|
||||
data class Item(val view: ObjectRelationView) : SlashPropertyView() {
|
||||
override val identifier: String get() = view.identifier
|
||||
}
|
||||
|
||||
sealed class Section : SlashRelationView() {
|
||||
sealed class Section : SlashPropertyView() {
|
||||
object Subheader : Section() {
|
||||
override val identifier: String get() = javaClass.simpleName
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ sealed class SlashRelationView : DefaultObjectDiffIdentifier {
|
|||
override val identifier: String get() = javaClass.simpleName
|
||||
}
|
||||
}
|
||||
object RelationNew : SlashRelationView() {
|
||||
object PropertyNew : SlashPropertyView() {
|
||||
override val identifier: String get() = javaClass.simpleName
|
||||
}
|
||||
}
|
|
@ -1,24 +1,16 @@
|
|||
package com.anytypeio.anytype.presentation.editor.editor
|
||||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.StubRelationObject
|
||||
import com.anytypeio.anytype.presentation.MockObjectTypes
|
||||
import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.types.Types
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashEvent
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashItem
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashRelationView
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashWidgetState
|
||||
import com.anytypeio.anytype.presentation.number.NumberParser
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectIcon
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectTypeView
|
||||
import com.anytypeio.anytype.presentation.objects.custom_icon.CustomIconColor
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectRelationView
|
||||
import com.anytypeio.anytype.presentation.util.DefaultCoroutineTestRule
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import kotlin.test.assertEquals
|
||||
|
|
|
@ -16,7 +16,7 @@ import com.anytypeio.anytype.presentation.editor.EditorViewModel
|
|||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashEvent
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashItem
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashRelationView
|
||||
import com.anytypeio.anytype.presentation.editor.editor.slash.SlashPropertyView
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectRelationView
|
||||
import com.anytypeio.anytype.presentation.util.DefaultCoroutineTestRule
|
||||
import com.anytypeio.anytype.presentation.util.TXT
|
||||
|
@ -129,8 +129,8 @@ class EditorSlashWidgetRelationsTest: EditorPresentationTestSetup() {
|
|||
advanceUntilIdle()
|
||||
|
||||
vm.onSlashItemClicked(
|
||||
SlashItem.Relation(
|
||||
relation = SlashRelationView.Item(
|
||||
SlashItem.Property(
|
||||
property = SlashPropertyView.Item(
|
||||
view = ObjectRelationView.Default(
|
||||
id = r2.id,
|
||||
key = r2.key,
|
||||
|
@ -260,8 +260,8 @@ class EditorSlashWidgetRelationsTest: EditorPresentationTestSetup() {
|
|||
//TESTING
|
||||
|
||||
vm.onSlashItemClicked(
|
||||
SlashItem.Relation(
|
||||
relation = SlashRelationView.Item(
|
||||
SlashItem.Property(
|
||||
property = SlashPropertyView.Item(
|
||||
view = ObjectRelationView.Default(
|
||||
key = r3.key,
|
||||
id = r3.id,
|
||||
|
@ -383,8 +383,8 @@ class EditorSlashWidgetRelationsTest: EditorPresentationTestSetup() {
|
|||
//TESTING
|
||||
|
||||
vm.onSlashItemClicked(
|
||||
SlashItem.Relation(
|
||||
relation = SlashRelationView.Item(
|
||||
SlashItem.Property(
|
||||
property = SlashPropertyView.Item(
|
||||
view = ObjectRelationView.Default(
|
||||
id = r3.id,
|
||||
key = r3.key,
|
||||
|
@ -477,8 +477,8 @@ class EditorSlashWidgetRelationsTest: EditorPresentationTestSetup() {
|
|||
//TESTING
|
||||
|
||||
vm.onSlashItemClicked(
|
||||
SlashItem.Relation(
|
||||
relation = SlashRelationView.Item(
|
||||
SlashItem.Property(
|
||||
property = SlashPropertyView.Item(
|
||||
view = ObjectRelationView.Default(
|
||||
key = r2.key,
|
||||
id = r2.id,
|
||||
|
@ -568,8 +568,8 @@ class EditorSlashWidgetRelationsTest: EditorPresentationTestSetup() {
|
|||
id = a.id,
|
||||
selection = IntRange(14, 14)
|
||||
)
|
||||
onSlashItemClicked(SlashItem.Main.Relations)
|
||||
onSlashItemClicked(SlashItem.RelationNew)
|
||||
onSlashItemClicked(SlashItem.Main.Properties)
|
||||
onSlashItemClicked(SlashItem.PropertyNew)
|
||||
|
||||
advanceUntilIdle()
|
||||
//open RelationListScreen
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue