mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-15 04:06:31 +00:00
Improve daily and todo list look
This commit is contained in:
parent
93187554bd
commit
bf1da74a49
9 changed files with 99 additions and 44 deletions
|
|
@ -92,6 +92,19 @@ open class Task constructor(): Parcelable {
|
|||
val completedChecklistCount: Int
|
||||
get() = checklist?.count { it.completed } ?: 0
|
||||
|
||||
val extraLightTaskColor: Int
|
||||
get() {
|
||||
return when {
|
||||
this.value < -20 -> return R.color.watch_maroon_200
|
||||
this.value < -10 -> return R.color.watch_red_200
|
||||
this.value < -1 -> return R.color.watch_orange_200
|
||||
this.value < 1 -> return R.color.watch_yellow_200
|
||||
this.value < 5 -> return R.color.watch_green_200
|
||||
this.value < 10 -> return R.color.watch_teal_200
|
||||
else -> R.color.watch_blue_200
|
||||
}
|
||||
}
|
||||
|
||||
val lightTaskColor: Int
|
||||
get() {
|
||||
return when {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
package com.habitrpg.wearos.habitica.ui.viewHolders.tasks
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.wearos.habitica.models.tasks.Task
|
||||
|
||||
abstract class CheckedTaskViewHolder(itemView: View) : TaskViewHolder(itemView) {
|
||||
abstract val checkbox: ImageView
|
||||
abstract val checkboxWrapper: ViewGroup
|
||||
|
||||
override fun bind(data: Task) {
|
||||
checkboxWrapper.setOnClickListener { _ ->
|
||||
onTaskScore?.invoke()
|
||||
}
|
||||
super.bind(data)
|
||||
if (data.completed) {
|
||||
checkbox.setImageResource(R.drawable.checkmark)
|
||||
checkboxWrapper.backgroundTintList =
|
||||
ColorStateList.valueOf(ContextCompat.getColor(itemView.context, R.color.amp_transparent))
|
||||
checkbox.backgroundTintList = ColorStateList.valueOf(
|
||||
ContextCompat.getColor(
|
||||
itemView.context,
|
||||
R.color.gray_300
|
||||
)
|
||||
)
|
||||
} else {
|
||||
checkbox.setImageDrawable(null)
|
||||
|
||||
checkboxWrapper.backgroundTintList =
|
||||
ColorStateList.valueOf(ContextCompat.getColor(itemView.context, data.lightTaskColor))
|
||||
checkbox.backgroundTintList = ColorStateList.valueOf(
|
||||
ContextCompat.getColor(
|
||||
itemView.context,
|
||||
data.extraLightTaskColor
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +1,17 @@
|
|||
package com.habitrpg.wearos.habitica.ui.viewHolders.tasks
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.habitrpg.android.habitica.databinding.RowDailyBinding
|
||||
import com.habitrpg.wearos.habitica.models.tasks.Task
|
||||
|
||||
class DailyViewHolder(itemView: View) : TaskViewHolder(itemView) {
|
||||
class DailyViewHolder(itemView: View) : CheckedTaskViewHolder(itemView) {
|
||||
private val binding = RowDailyBinding.bind(itemView)
|
||||
override val titleView: TextView
|
||||
get() = binding.title
|
||||
|
||||
init {
|
||||
binding.checkbox.setOnCheckedChangeListener { buttonView, isChecked ->
|
||||
onTaskScore?.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
override fun bind(data: Task) {
|
||||
super.bind(data)
|
||||
binding.checkbox.isChecked = data.completed
|
||||
binding.checkbox.backgroundTintList = ColorStateList.valueOf(ContextCompat.getColor(itemView.context, data.mediumTaskColor))
|
||||
}
|
||||
override val checkbox: ImageView
|
||||
get() = binding.checkbox
|
||||
override val checkboxWrapper: ViewGroup
|
||||
get() = binding.checkboxWrapper
|
||||
}
|
||||
|
|
@ -1,26 +1,17 @@
|
|||
package com.habitrpg.wearos.habitica.ui.viewHolders.tasks
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.habitrpg.android.habitica.databinding.RowTodoBinding
|
||||
import com.habitrpg.wearos.habitica.models.tasks.Task
|
||||
|
||||
class ToDoViewHolder(itemView: View) : TaskViewHolder(itemView) {
|
||||
class ToDoViewHolder(itemView: View) : CheckedTaskViewHolder(itemView) {
|
||||
private val binding = RowTodoBinding.bind(itemView)
|
||||
override val titleView: TextView
|
||||
get() = binding.title
|
||||
|
||||
init {
|
||||
binding.checkbox.setOnCheckedChangeListener { buttonView, isChecked ->
|
||||
onTaskScore?.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
override fun bind(data: Task) {
|
||||
super.bind(data)
|
||||
binding.checkbox.isChecked = data.completed
|
||||
binding.checkbox.backgroundTintList = ColorStateList.valueOf(ContextCompat.getColor(itemView.context, data.mediumTaskColor))
|
||||
}
|
||||
override val checkbox: ImageView
|
||||
get() = binding.checkbox
|
||||
override val checkboxWrapper: ViewGroup
|
||||
get() = binding.checkboxWrapper
|
||||
}
|
||||
BIN
wearos/src/main/res/drawable-mdpi/checkmark.png
Normal file
BIN
wearos/src/main/res/drawable-mdpi/checkmark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 330 B |
BIN
wearos/src/main/res/drawable-xhdpi/checkmark.png
Normal file
BIN
wearos/src/main/res/drawable-xhdpi/checkmark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 521 B |
BIN
wearos/src/main/res/drawable-xxhdpi/checkmark.png
Normal file
BIN
wearos/src/main/res/drawable-xxhdpi/checkmark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 685 B |
|
|
@ -7,12 +7,20 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Chip">
|
||||
<CheckBox
|
||||
android:id="@+id/checkbox"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginEnd="@dimen/spacing_medium"
|
||||
android:background="@drawable/daily_square" />
|
||||
<FrameLayout
|
||||
android:id="@+id/checkbox_wrapper"
|
||||
android:layout_width="34dp"
|
||||
android:layout_height="34dp"
|
||||
android:background="@drawable/circle"
|
||||
android:layout_marginEnd="6dp">
|
||||
<ImageView
|
||||
android:id="@+id/checkbox"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:background="@drawable/daily_square"
|
||||
android:scaleType="center"
|
||||
android:layout_gravity="center"/>
|
||||
</FrameLayout>
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -7,12 +7,21 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Chip">
|
||||
<CheckBox
|
||||
android:id="@+id/checkbox"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginEnd="@dimen/spacing_medium"
|
||||
android:background="@drawable/circle"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/checkbox_wrapper"
|
||||
android:layout_width="34dp"
|
||||
android:layout_height="34dp"
|
||||
android:background="@drawable/circle"
|
||||
android:layout_marginEnd="@dimen/spacing_medium">
|
||||
<ImageView
|
||||
android:id="@+id/checkbox"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:background="@drawable/circle"
|
||||
android:scaleType="center"
|
||||
android:layout_gravity="center"/>
|
||||
</FrameLayout>
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
Loading…
Reference in a new issue