mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-1104 App | Enhancement | Design fixes 1 (#3040)
This commit is contained in:
parent
c53f6465dd
commit
5b1bb5d548
17 changed files with 114 additions and 27 deletions
|
@ -54,6 +54,8 @@ abstract class BaseObjectTypeChangeFragment :
|
|||
adapter = objectTypeAdapter
|
||||
layoutManager = LinearLayoutManager(context)
|
||||
}
|
||||
skipCollapsed()
|
||||
setFullHeightSheet()
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
|
|
|
@ -38,7 +38,8 @@
|
|||
android:gravity="center_vertical"
|
||||
android:paddingEnd="@dimen/dp_16"
|
||||
android:text="@string/remove"
|
||||
android:textColor="#F55522" />
|
||||
android:fontFamily="@font/inter_regular"
|
||||
android:textColor="@color/palette_system_red" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.anytypeio.anytype.core_models.Id
|
|||
import com.anytypeio.anytype.core_ui.R
|
||||
import com.anytypeio.anytype.core_ui.common.DefaultSectionViewHolder
|
||||
import com.anytypeio.anytype.core_ui.databinding.ItemDefaultListSectionBinding
|
||||
import com.anytypeio.anytype.core_ui.databinding.ItemObjectTypeEmptyStateBinding
|
||||
import com.anytypeio.anytype.core_ui.databinding.ItemObjectTypeItemBinding
|
||||
import com.anytypeio.anytype.core_ui.features.objects.holders.ObjectTypeHolder
|
||||
import com.anytypeio.anytype.core_ui.features.objects.holders.ObjectTypeHorizontalHolder
|
||||
|
@ -47,6 +48,13 @@ class ObjectTypeVerticalAdapter(
|
|||
)
|
||||
)
|
||||
}
|
||||
VIEW_TYPE_EMPTY_STATE -> {
|
||||
EmptyStateViewHolder(
|
||||
binding = ItemObjectTypeEmptyStateBinding.inflate(
|
||||
inflater, parent, false
|
||||
)
|
||||
)
|
||||
}
|
||||
else -> throw IllegalStateException("Unexpected view type: $viewType")
|
||||
}
|
||||
}
|
||||
|
@ -78,12 +86,25 @@ class ObjectTypeVerticalAdapter(
|
|||
else -> {}
|
||||
}
|
||||
}
|
||||
is EmptyStateViewHolder -> {
|
||||
check(item is ObjectTypeItemView.EmptyState)
|
||||
holder.bind(item.query)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class EmptyStateViewHolder(
|
||||
private val binding: ItemObjectTypeEmptyStateBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(query: String) {
|
||||
binding.tvTitle.text = binding.root.resources.getString(R.string.no_type_named, query)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int = when (data[position]) {
|
||||
is ObjectTypeItemView.Type -> VIEW_TYPE_OBJECT_TYPE
|
||||
is ObjectTypeItemView.Section -> VIEW_TYPE_SECTION
|
||||
is ObjectTypeItemView.EmptyState -> VIEW_TYPE_EMPTY_STATE
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = data.size
|
||||
|
@ -91,5 +112,6 @@ class ObjectTypeVerticalAdapter(
|
|||
companion object {
|
||||
const val VIEW_TYPE_OBJECT_TYPE = 0
|
||||
const val VIEW_TYPE_SECTION = 1
|
||||
const val VIEW_TYPE_EMPTY_STATE = 2
|
||||
}
|
||||
}
|
|
@ -128,7 +128,7 @@ class ObjectAppearanceChooseAdapter<T : ObjectAppearanceChooseSettingsView>(
|
|||
fun bind(item: ObjectAppearanceChooseSettingsView.Description) = with(binding) {
|
||||
when (item) {
|
||||
is ObjectAppearanceChooseSettingsView.Description.None -> name.setText(R.string.description_none)
|
||||
is ObjectAppearanceChooseSettingsView.Description.Added -> name.setText(R.string.description_added)
|
||||
is ObjectAppearanceChooseSettingsView.Description.Added -> name.setText(R.string.object_description)
|
||||
is ObjectAppearanceChooseSettingsView.Description.Content -> name.setText(R.string.description_content)
|
||||
}
|
||||
icon.gone()
|
||||
|
|
|
@ -120,7 +120,7 @@ class ObjectAppearanceSettingAdapter(
|
|||
private fun getValue(item: ObjectAppearanceMainSettingsView.List): Int {
|
||||
return when (item) {
|
||||
is Description -> when (item.description) {
|
||||
MenuItem.Description.ADDED -> R.string.description_added
|
||||
MenuItem.Description.ADDED -> R.string.object_description
|
||||
MenuItem.Description.CONTENT -> R.string.description_content
|
||||
MenuItem.Description.NONE -> R.string.description_none
|
||||
}
|
||||
|
|
|
@ -222,7 +222,10 @@ class FeaturedRelationGroupWidget : ConstraintLayout {
|
|||
}
|
||||
}
|
||||
is ObjectRelationView.ObjectType.Base -> {
|
||||
val view = inflateObjectTypeTextView(name = relation.name)
|
||||
val view = inflateObjectTypeTextView(
|
||||
name = relation.name,
|
||||
isFirst = index == 0
|
||||
)
|
||||
view.setOnClickListener {
|
||||
val popup = ObjectTypePopupMenu(
|
||||
context = context,
|
||||
|
@ -294,12 +297,18 @@ class FeaturedRelationGroupWidget : ConstraintLayout {
|
|||
ids.add(view.id)
|
||||
}
|
||||
is ObjectRelationView.ObjectType.Collection -> {
|
||||
val view = inflateObjectTypeTextView(name = relation.name)
|
||||
val view = inflateObjectTypeTextView(
|
||||
name = relation.name,
|
||||
isFirst = index == 0
|
||||
)
|
||||
addView(view)
|
||||
ids.add(view.id)
|
||||
}
|
||||
is ObjectRelationView.ObjectType.Set -> {
|
||||
val view = inflateObjectTypeTextView(name = relation.name)
|
||||
val view = inflateObjectTypeTextView(
|
||||
name = relation.name,
|
||||
isFirst = index == 0
|
||||
)
|
||||
view.setOnClickListener {
|
||||
val popup = ObjectSetTypePopupMenu(
|
||||
context = context,
|
||||
|
@ -334,13 +343,16 @@ class FeaturedRelationGroupWidget : ConstraintLayout {
|
|||
flow.referencedIds = ids.toIntArray()
|
||||
}
|
||||
|
||||
private fun inflateObjectTypeTextView(name: String): TextView {
|
||||
private fun inflateObjectTypeTextView(
|
||||
name: String,
|
||||
isFirst: Boolean
|
||||
): TextView {
|
||||
val textView = TextView(context).apply {
|
||||
id = View.generateViewId()
|
||||
isSingleLine = true
|
||||
maxLines = 1
|
||||
ellipsize = TextUtils.TruncateAt.END
|
||||
setPadding(4.px, 2.px, 4.px, 2.px)
|
||||
setPadding(if (isFirst) 0.px else 4.px, 2.px, 4.px, 2.px)
|
||||
setTextColor(defaultTextColor)
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, defaultTextSize)
|
||||
}
|
||||
|
@ -356,14 +368,13 @@ class FeaturedRelationGroupWidget : ConstraintLayout {
|
|||
click: (ListenerType.Relation) -> Unit,
|
||||
ids: MutableList<Int>
|
||||
) {
|
||||
val placeholder =
|
||||
buildPlaceholderView(resources.getString(R.string.query)).apply {
|
||||
val placeholder = buildPlaceholderView(resources.getString(R.string.query)).apply {
|
||||
setOnClickListener {
|
||||
click(
|
||||
ListenerType.Relation.SetQuery(queries = emptyList())
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
addView(placeholder)
|
||||
ids.add(placeholder.id)
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class ObjectTypesWidget @JvmOverloads constructor(
|
|||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private var isOpenState = true
|
||||
private var isOpenState = false
|
||||
private var onItemClick: ((Id) -> Unit)? = null
|
||||
private var onSearchClick: (() -> Unit)? = null
|
||||
private var onDoneClick: (() -> Unit)? = null
|
||||
|
@ -36,6 +36,7 @@ class ObjectTypesWidget @JvmOverloads constructor(
|
|||
|
||||
init {
|
||||
setup()
|
||||
setHiddenState()
|
||||
}
|
||||
|
||||
private fun setup() = with(binding) {
|
||||
|
@ -67,7 +68,6 @@ class ObjectTypesWidget @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
fun update(data: List<ObjectTypeView>) {
|
||||
setOpenState()
|
||||
typesAdapter.update(data)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="68dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvEmptyMessage"
|
||||
|
@ -9,6 +9,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:padding="12dp"
|
||||
android:textSize="15sp"
|
||||
android:textColor="@color/text_tertiary"
|
||||
android:text="@string/empty" />
|
||||
|
||||
|
|
40
core-ui/src/main/res/layout/item_object_type_empty_state.xml
Normal file
40
core-ui/src/main/res/layout/item_object_type_empty_state.xml
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="@font/inter_regular"
|
||||
android:gravity="center"
|
||||
android:maxLines="5"
|
||||
android:textColor="@color/text_primary"
|
||||
android:textSize="17sp"
|
||||
tools:text="There is no type named..." />
|
||||
|
||||
<TextView
|
||||
android:id="@id/tvTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter_regular"
|
||||
android:gravity="center"
|
||||
android:text="@string/try_to_create_new_one_or_search_for_something_else"
|
||||
android:textColor="@color/text_secondary"
|
||||
android:textSize="17sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
|
@ -3,14 +3,14 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="96dp"
|
||||
android:layout_width="76dp"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.anytypeio.anytype.core_ui.widgets.ObjectIconWidget
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="@dimen/dp_48"
|
||||
android:layout_height="@dimen/dp_48"
|
||||
app:emojiSize="28dp"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
app:emojiSize="24dp"
|
||||
app:hasEmojiRounded12Background="true"
|
||||
app:hasInitialRounded8Background="true"
|
||||
app:initialTextSize="22sp"
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="96dp"
|
||||
android:layout_width="76dp"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="@dimen/dp_48"
|
||||
android:layout_height="@dimen/dp_48"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
android:src="@drawable/ic_object_action_search"
|
||||
android:scaleType="center"
|
||||
android:background="@drawable/rectangle_object_in_list_emoji_icon"
|
||||
|
|
|
@ -518,7 +518,7 @@
|
|||
<string name="icon">Icon</string>
|
||||
<string name="large">Large</string>
|
||||
<string name="description_none">@string/none</string>
|
||||
<string name="description_added">Only added</string>
|
||||
<string name="object_description">Object description</string>
|
||||
<string name="description_content">Content preview</string>
|
||||
<string name="none">None</string>
|
||||
<string name="small">Small</string>
|
||||
|
@ -626,5 +626,7 @@
|
|||
<string name="menu_change_query">Change query</string>
|
||||
<string name="collections">Collections</string>
|
||||
<string name="collection_widget_description">Your collections of objects</string>
|
||||
<string name="no_type_named">There is no type named \"%1$s\"</string>
|
||||
<string name="try_to_create_new_one_or_search_for_something_else">Try to create a new one or search for something else</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -184,10 +184,10 @@
|
|||
</style>
|
||||
|
||||
<style name="BlockVideoStyle">
|
||||
<item name="android:textSize">17sp</item>
|
||||
<item name="android:textSize">15sp</item>
|
||||
<item name="android:textColor">@color/text_primary</item>
|
||||
<item name="android:inputType">textUri</item>
|
||||
<item name="android:textColorHint">@color/text_secondary</item>
|
||||
<item name="android:textColorHint">@color/text_tertiary</item>
|
||||
<item name="android:background">@null</item>
|
||||
<item name="android:fontFamily">@font/inter_regular</item>
|
||||
</style>
|
||||
|
|
|
@ -98,6 +98,10 @@ abstract class BaseBottomSheetFragment<T : ViewBinding>(
|
|||
}
|
||||
}
|
||||
|
||||
fun setFullHeightSheet() {
|
||||
sheet?.layoutParams?.height = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
}
|
||||
|
||||
abstract fun injectDependencies()
|
||||
abstract fun releaseDependencies()
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ import com.anytypeio.anytype.presentation.relations.ObjectRelationView
|
|||
import com.anytypeio.anytype.presentation.relations.getCover
|
||||
import com.anytypeio.anytype.presentation.relations.objectTypeRelation
|
||||
import com.anytypeio.anytype.presentation.relations.view
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
import timber.log.Timber
|
||||
import com.anytypeio.anytype.presentation.editor.Editor.Mode as EditorMode
|
||||
|
||||
class DefaultBlockViewRenderer @Inject constructor(
|
||||
|
@ -1756,8 +1756,8 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
): BlockView.LinkToObject.Default.Card {
|
||||
val isWithCover = inEditorAppearance.showCover
|
||||
val iconSize = inEditorAppearance.icon
|
||||
return if (isWithCover) {
|
||||
val cover = linkToObjectCardCover(obj, urlBuilder)
|
||||
val cover = linkToObjectCardCover(obj, urlBuilder)
|
||||
return if (isWithCover && cover != null) {
|
||||
if (obj.layout != ObjectType.Layout.TODO && iconSize == InEditor.Icon.MEDIUM) {
|
||||
BlockView.LinkToObject.Default.Card.MediumIconCover(
|
||||
id = id,
|
||||
|
|
|
@ -194,6 +194,9 @@ class ObjectTypeChangeViewModel(
|
|||
}
|
||||
addAll(views)
|
||||
}
|
||||
if (isEmpty() && userInput.value.isNotEmpty()) {
|
||||
add(ObjectTypeItemView.EmptyState(userInput.value))
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun proceedWithGettingMarketplaceTypes(
|
||||
|
|
|
@ -11,6 +11,7 @@ sealed class ObjectTypeItemView {
|
|||
object Library : Section()
|
||||
object Marketplace : Section()
|
||||
}
|
||||
data class EmptyState(val query: String) : ObjectTypeItemView()
|
||||
}
|
||||
|
||||
data class ObjectTypeView(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue