mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
Feature | Sync-status badge (#1195)
This commit is contained in:
parent
ce0d55e58e
commit
826f001dd7
6 changed files with 65 additions and 4 deletions
|
@ -5,6 +5,7 @@ import android.animation.ObjectAnimator
|
|||
import android.app.Activity
|
||||
import android.app.ProgressDialog
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.Point
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
|
@ -38,7 +39,9 @@ import androidx.transition.TransitionManager
|
|||
import androidx.transition.TransitionSet
|
||||
import com.anytypeio.anytype.BuildConfig
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_ui.extensions.color
|
||||
import com.anytypeio.anytype.core_ui.extensions.isKeyboardVisible
|
||||
import com.anytypeio.anytype.core_ui.extensions.tint
|
||||
import com.anytypeio.anytype.core_ui.features.page.BlockAdapter
|
||||
import com.anytypeio.anytype.core_ui.features.page.TurnIntoActionReceiver
|
||||
import com.anytypeio.anytype.core_ui.features.page.scrollandmove.DefaultScrollAndMoveTargetDescriptor
|
||||
|
@ -61,6 +64,7 @@ import com.anytypeio.anytype.domain.block.model.Block.Content.Text
|
|||
import com.anytypeio.anytype.domain.common.Id
|
||||
import com.anytypeio.anytype.domain.ext.getFirstLinkMarkupParam
|
||||
import com.anytypeio.anytype.domain.ext.getSubstring
|
||||
import com.anytypeio.anytype.domain.status.SyncStatus
|
||||
import com.anytypeio.anytype.emojifier.Emojifier
|
||||
import com.anytypeio.anytype.ext.extractMarks
|
||||
import com.anytypeio.anytype.presentation.page.PageViewModel
|
||||
|
@ -456,7 +460,8 @@ open class PageFragment :
|
|||
topToolbar.menu
|
||||
.clicks()
|
||||
.onEach {
|
||||
vm.onDocumentMenuClicked() }
|
||||
vm.onDocumentMenuClicked()
|
||||
}
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
topToolbar.back.clicks().onEach {
|
||||
|
@ -550,6 +555,23 @@ open class PageFragment :
|
|||
.filter { it != PageViewModel.NO_SEARCH_RESULT_POSITION }
|
||||
.onEach { recycler.smoothScrollToPosition(it) }
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
vm.syncStatus.onEach { status -> bindSyncStatus(status) }.launchIn(lifecycleScope)
|
||||
}
|
||||
|
||||
private fun bindSyncStatus(status: SyncStatus?) {
|
||||
when (status) {
|
||||
SyncStatus.UNKNOWN, SyncStatus.FAILED, SyncStatus.OFFLINE -> topToolbar.status.tint(
|
||||
color = requireContext().color(R.color.sync_status_red)
|
||||
)
|
||||
SyncStatus.SYNCING -> topToolbar.status.tint(
|
||||
color = requireContext().color(R.color.sync_status_orange)
|
||||
)
|
||||
SyncStatus.SYNCED -> topToolbar.status.tint(
|
||||
color = requireContext().color(R.color.sync_status_green)
|
||||
)
|
||||
else -> topToolbar.status.tint(Color.WHITE)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
@ -832,7 +854,7 @@ open class PageFragment :
|
|||
}
|
||||
|
||||
private fun render(state: ControlPanelState) {
|
||||
|
||||
|
||||
if (state.navigationToolbar.isVisible) {
|
||||
placeholder.requestFocus()
|
||||
hideKeyboard()
|
||||
|
|
|
@ -13,6 +13,7 @@ import kotlinx.android.synthetic.main.widget_document_top_toolbar.view.*
|
|||
|
||||
class DocumentTopToolbar : ConstraintLayout {
|
||||
|
||||
val status: View get() = syncStatusBadge
|
||||
val back: View get() = toolbarBackButton
|
||||
val menu: View get() = toolbarMenu
|
||||
val container: FrameLayout get() = toolbarIconContainer
|
||||
|
|
19
core-ui/src/main/res/drawable/ic_page_more.xml
Normal file
19
core-ui/src/main/res/drawable/ic_page_more.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#ACA996"
|
||||
android:pathData="M8,12C8,12.8284 7.3284,13.5 6.5,13.5C5.6716,13.5 5,12.8284 5,12C5,11.1716 5.6716,10.5 6.5,10.5C7.3284,10.5 8,11.1716 8,12Z" />
|
||||
<path
|
||||
android:fillColor="#ACA996"
|
||||
android:pathData="M13.5,12C13.5,12.8284 12.8284,13.5 12,13.5C11.1716,13.5 10.5,12.8284 10.5,12C10.5,11.1716 11.1716,10.5 12,10.5C12.8284,10.5 13.5,11.1716 13.5,12Z" />
|
||||
<path
|
||||
android:fillColor="#ACA996"
|
||||
android:pathData="M19.5,12C19.5,12.8284 18.8284,13.5 18,13.5C17.1716,13.5 16.5,12.8284 16.5,12C16.5,11.1716 17.1716,10.5 18,10.5C18.8284,10.5 19.5,11.1716 19.5,12Z" />
|
||||
<path
|
||||
android:fillColor="#ACA996"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M12,21.5C17.2467,21.5 21.5,17.2467 21.5,12C21.5,6.7533 17.2467,2.5 12,2.5C6.7533,2.5 2.5,6.7533 2.5,12C2.5,17.2467 6.7533,21.5 12,21.5ZM12,23C18.0751,23 23,18.0751 23,12C23,5.9249 18.0751,1 12,1C5.9249,1 1,5.9249 1,12C1,18.0751 5.9249,23 12,23Z" />
|
||||
</vector>
|
|
@ -63,9 +63,21 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:src="@drawable/ic_more"
|
||||
android:src="@drawable/ic_page_more"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<View
|
||||
android:id="@+id/syncStatusBadge"
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="@drawable/circle_solid_default"
|
||||
android:backgroundTint="@color/white"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:backgroundTint="@color/anytype_text_green" />
|
||||
|
||||
</merge>
|
|
@ -1,6 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<color name="sync_status_red">#F55522</color>
|
||||
<color name="sync_status_green">#57C600</color>
|
||||
<color name="sync_status_orange">#FFB522</color>
|
||||
|
||||
<color name="anytype_text_default">#2C2B27</color>
|
||||
<color name="anytype_text_grey">#ACA996</color>
|
||||
<color name="anytype_text_yellow">#ECD91B</color>
|
||||
|
|
|
@ -46,6 +46,7 @@ import com.anytypeio.anytype.domain.misc.UrlBuilder
|
|||
import com.anytypeio.anytype.domain.page.*
|
||||
import com.anytypeio.anytype.domain.page.navigation.GetListPages
|
||||
import com.anytypeio.anytype.domain.status.InterceptThreadStatus
|
||||
import com.anytypeio.anytype.domain.status.SyncStatus
|
||||
import com.anytypeio.anytype.presentation.BuildConfig
|
||||
import com.anytypeio.anytype.presentation.common.StateReducer
|
||||
import com.anytypeio.anytype.presentation.common.SupportCommand
|
||||
|
@ -118,6 +119,8 @@ class PageViewModel(
|
|||
SelectionStateHolder by orchestrator.memory.selections,
|
||||
StateReducer<List<Block>, Event> by reducer {
|
||||
|
||||
val syncStatus = MutableStateFlow<SyncStatus?>(null)
|
||||
|
||||
val searchResultScrollPosition = MutableStateFlow(NO_SEARCH_RESULT_POSITION)
|
||||
|
||||
private val session = MutableStateFlow(Session.IDLE)
|
||||
|
@ -508,7 +511,7 @@ class PageViewModel(
|
|||
jobs += viewModelScope.launch {
|
||||
interceptThreadStatus
|
||||
.build(InterceptThreadStatus.Params(context))
|
||||
.collect { _toasts.send(it.toString()) }
|
||||
.collect { syncStatus.value = it }
|
||||
}
|
||||
|
||||
jobs += viewModelScope.launch {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue