mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-10 01:51:05 +09:00
Fix/divider in sam and multi select mode (#783)
This commit is contained in:
parent
a2739366da
commit
c2f4f6c843
10 changed files with 67 additions and 10 deletions
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -1,6 +1,18 @@
|
|||
# Change log for Android @Anytype app.
|
||||
|
||||
## Version 0.0.45 (WIP)
|
||||
## Version 0.0.46 (WIP)
|
||||
|
||||
### New features 🚀
|
||||
|
||||
*
|
||||
|
||||
### Fixes & tech 🚒
|
||||
|
||||
* Divider block should be selectable in multi-select and scroll-and-move mode (#778)
|
||||
|
||||
## Version 0.0.45
|
||||
|
||||
### New features 🚀
|
||||
|
||||
* Test flight for turn-into restrictions in edit-mode and multi-select mode (#376)
|
||||
* Styling panel | Switching between block-mode and markup-mode based on selection changes (#594)
|
||||
|
|
|
@ -8,7 +8,6 @@ fun BlockView.updateSelection(newSelection: Boolean) = when (this) {
|
|||
is BlockView.Text.Header.Two -> copy(isSelected = newSelection)
|
||||
is BlockView.Text.Header.Three -> copy(isSelected = newSelection)
|
||||
is BlockView.Text.Highlight -> copy(isSelected = newSelection)
|
||||
is BlockView.Code -> copy(isSelected = newSelection)
|
||||
is BlockView.Text.Checkbox -> copy(isSelected = newSelection)
|
||||
is BlockView.Text.Bulleted -> copy(isSelected = newSelection)
|
||||
is BlockView.Text.Numbered -> copy(isSelected = newSelection)
|
||||
|
@ -29,5 +28,7 @@ fun BlockView.updateSelection(newSelection: Boolean) = when (this) {
|
|||
is BlockView.MediaPlaceholder.Picture -> copy(isSelected = newSelection)
|
||||
is BlockView.Error.Picture -> copy(isSelected = newSelection)
|
||||
is BlockView.Upload.Picture -> copy(isSelected = newSelection)
|
||||
is BlockView.Divider -> copy(isSelected = newSelection)
|
||||
is BlockView.Code -> copy(isSelected = newSelection)
|
||||
else -> this
|
||||
}
|
|
@ -1,22 +1,38 @@
|
|||
package com.agileburo.anytype.core_ui.features.editor.holders.other
|
||||
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import com.agileburo.anytype.core_ui.R
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockView
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder
|
||||
import com.agileburo.anytype.core_ui.features.page.ListenerType
|
||||
import com.agileburo.anytype.core_ui.widgets.text.EditorLongClickListener
|
||||
import com.agileburo.anytype.core_utils.ext.dimen
|
||||
import kotlinx.android.synthetic.main.item_block_divider.view.*
|
||||
|
||||
class Divider(view: View) : BlockViewHolder(view) {
|
||||
class Divider(view: View) : BlockViewHolder(view), BlockViewHolder.IndentableHolder {
|
||||
|
||||
val divider: View get() = itemView.divider
|
||||
|
||||
fun bind(
|
||||
item: BlockView.Divider,
|
||||
clicked: (ListenerType) -> Unit
|
||||
) {
|
||||
itemView.setOnLongClickListener(
|
||||
) = with(itemView) {
|
||||
indentize(item)
|
||||
isSelected = item.isSelected
|
||||
setOnClickListener { clicked(ListenerType.DividerClick(item.id)) }
|
||||
setOnLongClickListener(
|
||||
EditorLongClickListener(
|
||||
t = item.id,
|
||||
click = { onBlockLongClick(itemView, it, clicked) }
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun indentize(item: BlockView.Indentable) {
|
||||
divider.updateLayoutParams<FrameLayout.LayoutParams> {
|
||||
marginStart = item.indent * dimen(R.dimen.indent)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -586,6 +586,7 @@ class BlockAdapter(
|
|||
onSelectionChanged = onSelectionChanged
|
||||
)
|
||||
}
|
||||
is Divider -> onBindViewHolder(holder, position)
|
||||
else -> throw IllegalStateException("Unexpected view holder: $holder")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -711,8 +711,10 @@ sealed class BlockView : ViewType, Parcelable {
|
|||
*/
|
||||
@Parcelize
|
||||
data class Divider(
|
||||
override val id: String
|
||||
) : BlockView() {
|
||||
override val id: String,
|
||||
override val isSelected: Boolean = false,
|
||||
override val indent: Int = 0
|
||||
) : BlockView(), Selectable, Indentable {
|
||||
override fun getViewType() = HOLDER_DIVIDER
|
||||
}
|
||||
|
||||
|
|
|
@ -37,4 +37,6 @@ sealed class ListenerType {
|
|||
data class Page(val target: String): ListenerType()
|
||||
|
||||
data class Mention(val target: String): ListenerType()
|
||||
|
||||
data class DividerClick(val target: String) : ListenerType()
|
||||
}
|
|
@ -1,6 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
style="@style/DefaultDocumentContainerStyle"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="@drawable/item_block_multi_select_mode_selector"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<View
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
style="@style/DefaultDocumentContainerStyle"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="@drawable/item_block_multi_select_mode_selector"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<View
|
||||
android:id="@+id/ab_divider"
|
||||
android:id="@+id/divider"
|
||||
style="@style/BlockDividerStyle" />
|
||||
|
||||
</FrameLayout>
|
|
@ -1586,6 +1586,9 @@ class PageViewModel(
|
|||
is Content.File -> {
|
||||
addNewBlockAtTheEnd()
|
||||
}
|
||||
is Content.Divider -> {
|
||||
addNewBlockAtTheEnd()
|
||||
}
|
||||
else -> {
|
||||
Timber.d("Outside-click has been ignored.")
|
||||
}
|
||||
|
@ -1955,6 +1958,12 @@ class PageViewModel(
|
|||
ListenerType.TitleBlock -> {
|
||||
//Todo block view refactoring
|
||||
}
|
||||
is ListenerType.DividerClick -> {
|
||||
when (mode) {
|
||||
EditorMode.MULTI_SELECT -> onBlockMultiSelectClicked(clicked.target)
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onPlusButtonPressed() {
|
||||
|
|
|
@ -176,7 +176,7 @@ class DefaultBlockViewRenderer(
|
|||
}
|
||||
is Content.Divider -> {
|
||||
counter.reset()
|
||||
result.add(divider(block))
|
||||
result.add(divider(block, indent))
|
||||
}
|
||||
is Content.Link -> {
|
||||
counter.reset()
|
||||
|
@ -486,7 +486,13 @@ class DefaultBlockViewRenderer(
|
|||
mode = if (mode == EditorMode.EDITING) BlockView.Mode.EDIT else BlockView.Mode.READ
|
||||
)
|
||||
|
||||
private fun divider(block: Block) = BlockView.Divider(id = block.id)
|
||||
private fun divider(
|
||||
block: Block,
|
||||
indent: Int
|
||||
) = BlockView.Divider(
|
||||
id = block.id,
|
||||
indent = indent
|
||||
)
|
||||
|
||||
private fun file(
|
||||
mode: EditorMode,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue