1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-35 Editor | Enhancement | Use snackbar instead of toast (#2412)

This commit is contained in:
Mikhail 2022-07-18 20:07:15 +03:00 committed by GitHub
parent 8b0c8a32e6
commit b7091e85f8
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 9 deletions

View file

@ -23,6 +23,5 @@ if [[ "$ISSUE_ID" != "DROID-"* ]]; then
fi
if [[ "$COMMIT_TEXT" != "DROID-"* ]]; then
echo "$ISSUE_ID " > "$COMMIT_MSG_FILE"
echo "$COMMIT_TEXT" >> "$COMMIT_MSG_FILE"
echo "$ISSUE_ID" "$COMMIT_TEXT" > "$COMMIT_MSG_FILE"
fi

View file

@ -434,6 +434,11 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
.setAction(R.string.create_new_set) { vm.onCreateNewSetForType(snack.type) }
.show()
}
is Snack.UndoRedo -> {
Snackbar.make(requireView(), snack.message, Snackbar.LENGTH_SHORT).apply {
anchorView = binding.undoRedoToolbar
}.show()
}
}
}
jobs += subscribe(vm.footers) { footer ->
@ -1255,7 +1260,7 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
iconView.setIcon(ObjectIcon.Basic.Emoji(emoji))
iconView.visible()
}
!image.isNullOrBlank()-> {
!image.isNullOrBlank() -> {
iconView.setIcon(ObjectIcon.Basic.Image(image))
iconView.visible()
}
@ -1282,7 +1287,7 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
if (state.mainToolbar.isVisible) {
binding.toolbar.visible()
binding.toolbar.state = when(state.mainToolbar.targetBlockType) {
binding.toolbar.state = when (state.mainToolbar.targetBlockType) {
Main.TargetBlockType.Any -> BlockToolbarWidget.State.Any
Main.TargetBlockType.Title -> BlockToolbarWidget.State.Title
}

View file

@ -1936,11 +1936,11 @@ class EditorViewModel(
fun onActionUndoClicked() {
Timber.d("onActionUndoClicked, ")
viewModelScope.launch {
jobs += viewModelScope.launch {
orchestrator.proxies.intents.send(
Intent.Document.Undo(
context = context,
onUndoExhausted = { sendToast("Nothing to undo.") }
onUndoExhausted = { sendSnack(Snack.UndoRedo("Nothing to undo.")) }
)
)
}
@ -1948,11 +1948,11 @@ class EditorViewModel(
fun onActionRedoClicked() {
Timber.d("onActionRedoClicked, ")
viewModelScope.launch {
jobs += viewModelScope.launch {
orchestrator.proxies.intents.send(
Intent.Document.Redo(
context = context,
onRedoExhausted = { sendToast("Nothing to redo.") }
onRedoExhausted = { sendSnack(Snack.UndoRedo("Nothing to redo.")) }
)
)
}
@ -3886,11 +3886,17 @@ class EditorViewModel(
}
private fun sendToast(msg: String) {
viewModelScope.launch {
jobs += viewModelScope.launch {
_toasts.emit(msg)
}
}
private fun sendSnack(snack: Snack) {
jobs += viewModelScope.launch {
snacks.emit(snack)
}
}
/**
* Return true, when mention menu is closed, and we need absorb back button click
*/

View file

@ -4,4 +4,5 @@ import com.anytypeio.anytype.core_models.Id
sealed class Snack {
data class ObjectSetNotFound(val type: Id) : Snack()
data class UndoRedo(val message: String) : Snack()
}