mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-09 17:44:57 +09:00
Dashboard | Fix | Cards design (#1939)
* design * dashboard item decoration * add new decoration * fix changelog * fix
This commit is contained in:
parent
11520735e7
commit
bdfee20b87
9 changed files with 45 additions and 58 deletions
|
@ -4,7 +4,8 @@
|
|||
|
||||
### Design & UX 🔳
|
||||
|
||||
* Redesigned authentification flow (#1928)
|
||||
* Redesigned authentication flow (#1928)
|
||||
* Dashboard | Fix cards width (#1939)
|
||||
|
||||
### Fixes & tech 🚒
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import androidx.recyclerview.widget.ItemTouchHelper
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_utils.ext.dimen
|
||||
import com.anytypeio.anytype.core_utils.ui.EqualSpacingItemDecoration
|
||||
import com.anytypeio.anytype.core_utils.ui.DashboardSpacingItemDecoration
|
||||
import kotlinx.android.synthetic.main.item_dashboard_page.view.*
|
||||
import kotlinx.android.synthetic.main.item_dashboard_page_archived.view.*
|
||||
import kotlinx.android.synthetic.main.item_dashboard_recent.view.*
|
||||
|
@ -41,17 +41,9 @@ class DashboardPager(
|
|||
ViewHolder.Default(parent).apply {
|
||||
itemView.rvDashboard.apply {
|
||||
val spacing = itemView.context.dimen(R.dimen.default_dashboard_item_spacing).toInt()
|
||||
val decoration = EqualSpacingItemDecoration(
|
||||
topSpacing = spacing,
|
||||
leftSpacing = spacing,
|
||||
rightSpacing = spacing,
|
||||
bottomSpacing = 0,
|
||||
displayMode = EqualSpacingItemDecoration.GRID,
|
||||
ignoreGridEdgesTop = true
|
||||
)
|
||||
layoutManager = GridLayoutManager(context, COLUMN_COUNT)
|
||||
overScrollMode = OVER_SCROLL_NEVER
|
||||
addItemDecoration(decoration)
|
||||
addItemDecoration(DashboardSpacingItemDecoration(spacing))
|
||||
setHasFixedSize(true)
|
||||
adapter = defaultAdapter
|
||||
ItemTouchHelper(dndBehavior).attachToRecyclerView(this)
|
||||
|
@ -62,17 +54,9 @@ class DashboardPager(
|
|||
ViewHolder.Recent(parent).apply {
|
||||
itemView.rvDashboardRecent.apply {
|
||||
val spacing = itemView.context.dimen(R.dimen.default_dashboard_item_spacing).toInt()
|
||||
val decoration = EqualSpacingItemDecoration(
|
||||
topSpacing = spacing,
|
||||
leftSpacing = spacing,
|
||||
rightSpacing = spacing,
|
||||
bottomSpacing = 0,
|
||||
displayMode = EqualSpacingItemDecoration.GRID,
|
||||
ignoreGridEdgesTop = true
|
||||
)
|
||||
layoutManager = GridLayoutManager(context, COLUMN_COUNT)
|
||||
overScrollMode = OVER_SCROLL_NEVER
|
||||
addItemDecoration(decoration)
|
||||
addItemDecoration(DashboardSpacingItemDecoration(spacing))
|
||||
setHasFixedSize(true)
|
||||
adapter = recentAdapter
|
||||
}
|
||||
|
@ -82,17 +66,9 @@ class DashboardPager(
|
|||
ViewHolder.Sets(parent).apply {
|
||||
itemView.rvDashboardSets.apply {
|
||||
val spacing = itemView.context.dimen(R.dimen.default_dashboard_item_spacing).toInt()
|
||||
val decoration = EqualSpacingItemDecoration(
|
||||
topSpacing = spacing,
|
||||
leftSpacing = spacing,
|
||||
rightSpacing = spacing,
|
||||
bottomSpacing = 0,
|
||||
displayMode = EqualSpacingItemDecoration.GRID,
|
||||
ignoreGridEdgesTop = true
|
||||
)
|
||||
layoutManager = GridLayoutManager(context, COLUMN_COUNT)
|
||||
overScrollMode = OVER_SCROLL_NEVER
|
||||
addItemDecoration(decoration)
|
||||
addItemDecoration(DashboardSpacingItemDecoration(spacing))
|
||||
setHasFixedSize(true)
|
||||
adapter = setsAdapter
|
||||
}
|
||||
|
@ -102,17 +78,9 @@ class DashboardPager(
|
|||
ViewHolder.Archived(parent).apply {
|
||||
itemView.rvDashboardArchived.apply {
|
||||
val spacing = itemView.context.dimen(R.dimen.default_dashboard_item_spacing).toInt()
|
||||
val decoration = EqualSpacingItemDecoration(
|
||||
topSpacing = spacing,
|
||||
leftSpacing = spacing,
|
||||
rightSpacing = spacing,
|
||||
bottomSpacing = 0,
|
||||
displayMode = EqualSpacingItemDecoration.GRID,
|
||||
ignoreGridEdgesTop = true
|
||||
)
|
||||
layoutManager = GridLayoutManager(context, COLUMN_COUNT)
|
||||
overScrollMode = OVER_SCROLL_NEVER
|
||||
addItemDecoration(decoration)
|
||||
addItemDecoration(DashboardSpacingItemDecoration(spacing))
|
||||
setHasFixedSize(true)
|
||||
adapter = archiveAdapter
|
||||
}
|
||||
|
@ -122,17 +90,9 @@ class DashboardPager(
|
|||
ViewHolder.Shared(parent).apply {
|
||||
itemView.rvDashboardShared.apply {
|
||||
val spacing = itemView.context.dimen(R.dimen.default_dashboard_item_spacing).toInt()
|
||||
val decoration = EqualSpacingItemDecoration(
|
||||
topSpacing = spacing,
|
||||
leftSpacing = spacing,
|
||||
rightSpacing = spacing,
|
||||
bottomSpacing = 0,
|
||||
displayMode = EqualSpacingItemDecoration.GRID,
|
||||
ignoreGridEdgesTop = true
|
||||
)
|
||||
layoutManager = GridLayoutManager(context, COLUMN_COUNT)
|
||||
overScrollMode = OVER_SCROLL_NEVER
|
||||
addItemDecoration(decoration)
|
||||
addItemDecoration(DashboardSpacingItemDecoration(spacing))
|
||||
setHasFixedSize(true)
|
||||
adapter = sharedAdapter
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:clipToPadding="false"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:overScrollMode="never"
|
||||
android:id="@+id/rvDashboard"
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:clipToPadding="false"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:overScrollMode="never"
|
||||
android:id="@+id/rvDashboardArchived"
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:clipToPadding="false"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:overScrollMode="never"
|
||||
android:id="@+id/rvDashboardRecent"
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:clipToPadding="false"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:overScrollMode="never"
|
||||
android:id="@+id/rvDashboardSets"
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:clipToPadding="false"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:overScrollMode="never"
|
||||
android:id="@+id/rvDashboardShared"
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
|
||||
<dimen name="footer_default_height">50dp</dimen>
|
||||
|
||||
<dimen name="default_dashboard_item_spacing">10dp</dimen>
|
||||
<dimen name="default_dashboard_item_spacing">20dp</dimen>
|
||||
<dimen name="cover_gallery_item_spacing">8dp</dimen>
|
||||
|
||||
<dimen name="indent">28dp</dimen>
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package com.anytypeio.anytype.core_utils.ui
|
||||
|
||||
import android.graphics.Rect
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
class DashboardSpacingItemDecoration(
|
||||
private val spacing: Int
|
||||
) : RecyclerView.ItemDecoration() {
|
||||
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
val position = parent.getChildAdapterPosition(view)
|
||||
val column = position % SPAN_COUNT
|
||||
|
||||
if (column == 0) {
|
||||
outRect.left = spacing - column * spacing / SPAN_COUNT
|
||||
outRect.right = ((column + 1) * spacing / SPAN_COUNT) / 2
|
||||
}
|
||||
|
||||
if (column > 0) {
|
||||
outRect.left = (spacing - column * spacing / SPAN_COUNT) / 2
|
||||
outRect.right = (column + 1) * spacing / SPAN_COUNT
|
||||
}
|
||||
|
||||
outRect.bottom = spacing / 2
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val SPAN_COUNT = 2
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue