mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 13:57:10 +09:00
App | Feature | Make relation object first choice (#2196)
* make relation object first choice * added dividers to relation formats list * fix paddings * code style * update order + added custom formats order Co-authored-by: konstantiniiv <ki@anytype.io>
This commit is contained in:
parent
3dabae49b9
commit
0512a31b52
6 changed files with 33 additions and 18 deletions
|
@ -72,7 +72,7 @@ object RelationCreateFromScratchForObjectModule {
|
|||
@CreateFromScratch
|
||||
fun provideState(): StateHolder<CreateFromScratchState> = StateHolder(
|
||||
initial = CreateFromScratchState(
|
||||
format = RelationFormat.SHORT_TEXT,
|
||||
format = RelationFormat.OBJECT,
|
||||
limitObjectTypes = emptyList()
|
||||
)
|
||||
)
|
||||
|
@ -122,7 +122,7 @@ object RelationCreateFromScratchForDataViewModule {
|
|||
@CreateFromScratch
|
||||
fun provideState(): StateHolder<CreateFromScratchState> = StateHolder(
|
||||
initial = CreateFromScratchState(
|
||||
format = RelationFormat.SHORT_TEXT,
|
||||
format = RelationFormat.OBJECT,
|
||||
limitObjectTypes = emptyList()
|
||||
)
|
||||
)
|
||||
|
@ -173,7 +173,7 @@ object RelationCreateFromScratchForObjectBlockModule {
|
|||
@CreateFromScratch
|
||||
fun provideState(): StateHolder<CreateFromScratchState> = StateHolder(
|
||||
initial = CreateFromScratchState(
|
||||
format = RelationFormat.SHORT_TEXT,
|
||||
format = RelationFormat.OBJECT,
|
||||
limitObjectTypes = emptyList()
|
||||
)
|
||||
)
|
||||
|
|
|
@ -4,11 +4,14 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_ui.features.relations.RelationFormatAdapter
|
||||
import com.anytypeio.anytype.core_utils.ext.arg
|
||||
import com.anytypeio.anytype.core_utils.ext.drawable
|
||||
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetFragment
|
||||
import com.anytypeio.anytype.databinding.FragmentRelationCreateFromScratchFormatPickerBinding
|
||||
import com.anytypeio.anytype.di.common.componentManager
|
||||
|
@ -41,9 +44,14 @@ class RelationCreateFromScratchFormatPickerFragment :
|
|||
binding.connectWithRecycler.apply {
|
||||
adapter = relationAdapter
|
||||
layoutManager = LinearLayoutManager(context)
|
||||
addItemDecoration(
|
||||
DividerItemDecoration(context, DividerItemDecoration.VERTICAL).apply {
|
||||
setDrawable(drawable(R.drawable.divider_relations))
|
||||
}
|
||||
)
|
||||
}
|
||||
relationAdapter.submitList(
|
||||
Relation.Format.values()
|
||||
Relation.orderedFormatList()
|
||||
.filter { !excludedFormats.contains(it) }
|
||||
.map { format ->
|
||||
RelationView.CreateFromScratch(
|
||||
|
|
|
@ -21,8 +21,8 @@ data class Relation(
|
|||
) {
|
||||
|
||||
enum class Format(val prettyName: String) {
|
||||
SHORT_TEXT("Short text"),
|
||||
LONG_TEXT("Text"),
|
||||
SHORT_TEXT("Short text"),
|
||||
NUMBER("Number"),
|
||||
STATUS("Status"),
|
||||
TAG("Tag"),
|
||||
|
@ -51,4 +51,12 @@ data class Relation(
|
|||
enum class OptionScope {
|
||||
LOCAL, RELATION, FORMAT
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun orderedFormatList(): List<Format> = listOf(
|
||||
Format.OBJECT, Format.LONG_TEXT, Format.SHORT_TEXT, Format.STATUS,
|
||||
Format.TAG, Format.DATE, Format.FILE, Format.CHECKBOX,
|
||||
Format.URL, Format.EMAIL, Format.PHONE, Format.EMOJI, Format.RELATIONS
|
||||
)
|
||||
}
|
||||
}
|
|
@ -261,11 +261,11 @@ class LimitObjectTypeAdapter(
|
|||
private val onClick: () -> Unit
|
||||
) : RecyclerView.Adapter<LimitObjectTypeAdapter.ViewHolder>() {
|
||||
|
||||
var limitObjectTypeView : LimitObjectTypeValueView? = null
|
||||
set(value) {
|
||||
field = value
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
var limitObjectTypeView: LimitObjectTypeValueView? = null
|
||||
set(value) {
|
||||
field = value
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder = ViewHolder(
|
||||
ItemRelationCreateFromScratchLimitObjectTypesBinding.inflate(
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@drawable/default_ripple"
|
||||
android:layout_height="52dp"
|
||||
android:background="@drawable/default_ripple"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.anytypeio.anytype.core_ui.widgets.RelationFormatIconWidget
|
||||
|
@ -11,7 +11,6 @@
|
|||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="20dp"
|
||||
tools:src="@drawable/ic_relation_format_text_small" />
|
||||
|
||||
<TextView
|
||||
|
@ -24,14 +23,14 @@
|
|||
tools:text="Text" />
|
||||
|
||||
<ImageView
|
||||
android:visibility="invisible"
|
||||
android:id="@+id/selectionIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_weight="0"
|
||||
android:src="@drawable/ic_relation_format_checked"
|
||||
android:id="@+id/selectionIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:visibility="invisible"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
|
@ -44,7 +44,7 @@ abstract class RelationCreateFromScratchBaseViewModel : BaseViewModel() {
|
|||
)
|
||||
|
||||
val views = MutableStateFlow(
|
||||
Relation.Format.values()
|
||||
Relation.orderedFormatList()
|
||||
.filterNot { notAllowedFormats.contains(it) }
|
||||
.map { format ->
|
||||
RelationView.CreateFromScratch(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue