make hub slightly more appealing

This commit is contained in:
Phillip Thelen 2022-06-03 11:45:09 +02:00
parent aeff57cc9c
commit 97cc310460
21 changed files with 70 additions and 12 deletions

View file

@ -20,5 +20,5 @@
<string name="todos">To Do\'s</string>
<string name="rewards">Rewards</string>
<string name="stats">Stats</string>
<string name="settings">Settings</string>
</resources>

View file

@ -7,6 +7,7 @@ import android.util.Log
import android.view.View
import androidx.activity.viewModels
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import androidx.wear.widget.WearableLinearLayoutManager
import com.habitrpg.common.habitica.models.tasks.TaskType
@ -21,6 +22,7 @@ data class MenuItem(
val identifier: String,
val title: String,
val icon: Drawable?,
val color: Int,
val onClick: () -> Unit
)
@ -52,42 +54,56 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
MenuItem(
"avatar",
"Avatar",
AppCompatResources.getDrawable(this, R.drawable.icon_rewards)
AppCompatResources.getDrawable(this, R.drawable.ic_avatar),
ContextCompat.getColor(this, R.color.brand_400)
) {
},
MenuItem(
"Stats",
getString(R.string.stats),
AppCompatResources.getDrawable(this, R.drawable.icon_rewards)
AppCompatResources.getDrawable(this, R.drawable.ic_stats),
ContextCompat.getColor(this, R.color.red_100)
) {
},
MenuItem(
"habits",
getString(R.string.habits),
AppCompatResources.getDrawable(this, R.drawable.icon_habits)
AppCompatResources.getDrawable(this, R.drawable.icon_habits),
ContextCompat.getColor(this, R.color.orange_100)
) {
openTasklist(TaskType.HABIT)
},
MenuItem(
"dailies",
getString(R.string.dailies),
AppCompatResources.getDrawable(this, R.drawable.icon_dailies)
AppCompatResources.getDrawable(this, R.drawable.icon_dailies),
ContextCompat.getColor(this, R.color.yellow_100)
) {
openTasklist(TaskType.DAILY)
},
MenuItem(
"todos",
getString(R.string.todos),
AppCompatResources.getDrawable(this, R.drawable.icon_todos)
AppCompatResources.getDrawable(this, R.drawable.icon_todos),
ContextCompat.getColor(this, R.color.green_100)
) {
openTasklist(TaskType.TODO)
},
MenuItem(
"rewards",
getString(R.string.rewards),
AppCompatResources.getDrawable(this, R.drawable.icon_rewards)
AppCompatResources.getDrawable(this, R.drawable.icon_rewards),
ContextCompat.getColor(this, R.color.teal_100)
) {
openTasklist(TaskType.REWARD)
},
MenuItem(
"settings",
getString(R.string.settings),
AppCompatResources.getDrawable(this, R.drawable.ic_settings),
ContextCompat.getColor(this, R.color.blue_100)
) {
openTasklist(TaskType.REWARD)
}
@ -99,7 +115,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
private fun openTasklist(type: TaskType) {
val intent = Intent(this, TaskListActivity::class.java).apply {
putExtra("type", type.name)
putExtra("task_type", type.name)
}
startActivity(intent)
}

View file

@ -32,6 +32,7 @@ class HubViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) {
fun bind(item: MenuItem) {
binding.title.text = item.title
binding.iconView.setImageDrawable(item.icon)
binding.iconView.setColorFilter(item.color)
binding.root.setOnClickListener {
item.onClick()
}

View file

@ -1,7 +1,9 @@
package com.habitrpg.wearos.habitica.ui.viewmodels
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.viewModelScope
import com.habitrpg.common.habitica.models.tasks.TaskType
import com.habitrpg.wearos.habitica.data.repositories.TaskRepository
import com.habitrpg.wearos.habitica.data.repositories.UserRepository
import com.habitrpg.wearos.habitica.models.tasks.Task
@ -11,14 +13,18 @@ import javax.inject.Inject
@HiltViewModel
class TaskListViewModel @Inject constructor(
savedStateHandle: SavedStateHandle,
private val taskRepository: TaskRepository,
userRepository: UserRepository
) : BaseViewModel(userRepository) {
val tasks = MutableLiveData<List<Task>>()
val taskType = TaskType.from(savedStateHandle.get<String>("task_type"))
init {
viewModelScope.launch {
tasks.value = taskRepository.retrieveTasks()?.tasks?.values?.toList()
tasks.value = taskRepository.retrieveTasks()?.tasks?.values?.filter {
it.type == taskType
}?.toList()
}
}
}

View file

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#FFFFFF"
android:alpha="0.8">
<path
android:fillColor="@android:color/white"
android:pathData="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/>
</vector>

View file

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#FFFFFF"
android:alpha="0.8">
<path
android:fillColor="@android:color/white"
android:pathData="M19.14,12.94c0.04,-0.3 0.06,-0.61 0.06,-0.94c0,-0.32 -0.02,-0.64 -0.07,-0.94l2.03,-1.58c0.18,-0.14 0.23,-0.41 0.12,-0.61l-1.92,-3.32c-0.12,-0.22 -0.37,-0.29 -0.59,-0.22l-2.39,0.96c-0.5,-0.38 -1.03,-0.7 -1.62,-0.94L14.4,2.81c-0.04,-0.24 -0.24,-0.41 -0.48,-0.41h-3.84c-0.24,0 -0.43,0.17 -0.47,0.41L9.25,5.35C8.66,5.59 8.12,5.92 7.63,6.29L5.24,5.33c-0.22,-0.08 -0.47,0 -0.59,0.22L2.74,8.87C2.62,9.08 2.66,9.34 2.86,9.48l2.03,1.58C4.84,11.36 4.8,11.69 4.8,12s0.02,0.64 0.07,0.94l-2.03,1.58c-0.18,0.14 -0.23,0.41 -0.12,0.61l1.92,3.32c0.12,0.22 0.37,0.29 0.59,0.22l2.39,-0.96c0.5,0.38 1.03,0.7 1.62,0.94l0.36,2.54c0.05,0.24 0.24,0.41 0.48,0.41h3.84c0.24,0 0.44,-0.17 0.47,-0.41l0.36,-2.54c0.59,-0.24 1.13,-0.56 1.62,-0.94l2.39,0.96c0.22,0.08 0.47,0 0.59,-0.22l1.92,-3.32c0.12,-0.22 0.07,-0.47 -0.12,-0.61L19.14,12.94zM12,15.6c-1.98,0 -3.6,-1.62 -3.6,-3.6s1.62,-3.6 3.6,-3.6s3.6,1.62 3.6,3.6S13.98,15.6 12,15.6z"/>
</vector>

View file

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#FFFFFF"
android:alpha="0.8">
<path
android:fillColor="@android:color/white"
android:pathData="M5,9.2h3L8,19L5,19zM10.6,5h2.8v14h-2.8zM16.2,13L19,13v6h-2.8z"/>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="40dp" />
<solid android:color="@color/gray_100" />
<solid android:color="@color/gray_50" />
</shape>

View file

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="@dimen/spacing_medium"
android:paddingVertical="2dp">
android:paddingVertical="1dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -14,6 +15,7 @@
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
tools:text="Task Title"/>
</LinearLayout>
</FrameLayout>