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

DROID-1385 App | Fix | Sync status, colors (#59)

This commit is contained in:
Konstantin Ivanov 2023-06-15 10:51:38 +02:00 committed by GitHub
parent 105e41d5b2
commit 1151585acd
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 28 deletions

View file

@ -1,13 +1,14 @@
package com.anytypeio.anytype.core_ui.widgets
import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import android.view.View
import com.anytypeio.anytype.core_models.SyncStatus
import com.anytypeio.anytype.core_ui.R
import com.anytypeio.anytype.core_ui.extensions.color
import com.anytypeio.anytype.core_ui.extensions.tint
import com.anytypeio.anytype.core_utils.ext.gone
import com.anytypeio.anytype.core_utils.ext.visible
class StatusBadgeWidget @JvmOverloads constructor(
context: Context,
@ -16,24 +17,29 @@ class StatusBadgeWidget @JvmOverloads constructor(
init {
setBackgroundResource(R.drawable.circle_solid_default)
tint(Color.WHITE)
tint(color = context.color(R.color.palette_dark_grey))
}
fun bind(status: SyncStatus?) {
when (status) {
SyncStatus.UNKNOWN,
SyncStatus.FAILED,
SyncStatus.INCOMPATIBLE_VERSION -> {
visible()
tint(color = context.color(R.color.palette_system_red))
}
SyncStatus.SYNCING -> {
visible()
tint(color = context.color(R.color.palette_system_amber_100))
}
SyncStatus.SYNCED -> {
visible()
tint(color = context.color(R.color.palette_system_green))
}
SyncStatus.UNKNOWN,
SyncStatus.OFFLINE,
SyncStatus.INCOMPATIBLE_VERSION -> tint(
color = context.color(R.color.sync_status_red)
)
SyncStatus.SYNCING -> tint(
color = context.color(R.color.sync_status_orange)
)
SyncStatus.SYNCED -> tint(
color = context.color(R.color.sync_status_green)
)
else -> tint(Color.TRANSPARENT)
null -> {
gone()
}
}
}
}

View file

@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--typography, buttons 05.04-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/topToolbar"
android:layout_width="match_parent"
android:layout_height="48dp">
<FrameLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/statusContainer"
android:layout_gravity="center_vertical"
android:paddingStart="10dp"
@ -20,19 +21,27 @@
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center_vertical"
android:backgroundTint="@color/orange" />
android:backgroundTint="@color/orange"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />
<TextView
android:id="@+id/tvStatus"
style="@style/TextView.UXStyle.Captions.1.Regular"
android:textColor="@color/text_secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="16dp"
android:layout_marginStart="6dp"
android:textColor="@color/text_secondary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/statusBadge"
app:layout_constraintTop_toTopOf="parent"
app:layout_goneMarginStart="0dp"
tools:text="Syncing" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<FrameLayout
android:layout_width="match_parent"

View file

@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<FrameLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/statusContainer"
android:layout_width="wrap_content"
android:layout_height="28dp"
@ -17,6 +17,9 @@
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center_vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:backgroundTint="@color/orange" />
<TextView
@ -25,11 +28,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="16dp"
android:layout_marginStart="6dp"
android:textColor="@color/text_secondary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/statusBadge"
app:layout_constraintTop_toTopOf="parent"
app:layout_goneMarginStart="0dp"
tools:text="Syncing" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<FrameLayout
android:layout_width="match_parent"

View file

@ -1,12 +1,6 @@
<?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_shadow_main">#8C000000</color>
<color name="debug">#F44336</color>
<color name="orange">#FFBB2C</color>
<color name="white">#FFFFFF</color>

View file

@ -5,7 +5,7 @@
<!-- Customize your theme here. -->
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="colorPrimary">@color/sync_status_red</item>
<item name="colorPrimary">@color/palette_system_red</item>
<item name="colorPrimaryDark">@color/palette_dark_teal</item>
<item name="colorAccent">@color/orange</item>
<item name="alertDialogTheme">@style/DialogTheme</item>