feat(categories): Improve category item layout

This commit is contained in:
Peter Vacho 2025-01-04 22:32:48 +01:00
parent 354e00487a
commit 15576b6c39
Signed by: school
GPG key ID: 8CFC3837052871B4
2 changed files with 49 additions and 41 deletions

View file

@ -1,6 +1,5 @@
package com.p_vacho.neat_calendar.adapters package com.p_vacho.neat_calendar.adapters
import android.graphics.Color
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup

View file

@ -1,50 +1,59 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp"> android:layout_margin="8dp"
app:cardCornerRadius="8dp"
app:cardElevation="4dp"
app:cardBackgroundColor="?android:attr/colorBackground">
<!-- Color Indicator --> <androidx.constraintlayout.widget.ConstraintLayout
<View android:layout_width="match_parent"
android:id="@+id/colorIndicator"
android:layout_width="8dp"
android:layout_height="match_parent"
android:background="@android:color/holo_blue_dark"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<!-- Category Name -->
<TextView
android:id="@+id/tvCategoryName"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="16sp" android:padding="8dp">
android:textColor="?android:attr/textColorPrimary"
android:paddingStart="16dp"
android:paddingEnd="8dp"
android:ellipsize="end"
android:maxLines="1"
tools:text="Work"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/colorIndicator"
app:layout_constraintEnd_toStartOf="@id/btnDeleteCategory" />
<!-- Delete Button --> <!-- Vertical Color Indicator -->
<ImageButton <View
android:id="@+id/btnDeleteCategory" android:id="@+id/colorIndicator"
android:layout_width="40dp" android:layout_width="8dp"
android:layout_height="40dp" android:layout_height="0dp"
android:background="?attr/selectableItemBackgroundBorderless" android:background="@android:color/holo_blue_dark"
android:src="@drawable/ic_trashbin" app:layout_constraintTop_toTopOf="parent"
android:contentDescription="@string/delete_category" app:layout_constraintBottom_toBottomOf="parent"
app:tint="?android:attr/textColorSecondary" app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> <!-- Category Name -->
<TextView
android:id="@+id/tvCategoryName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="16sp"
android:textColor="?android:attr/textColorPrimary"
android:paddingStart="16dp"
android:paddingEnd="8dp"
android:ellipsize="end"
android:maxLines="1"
tools:text="Work"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/colorIndicator"
app:layout_constraintEnd_toStartOf="@id/btnDeleteCategory" />
<!-- Delete Button -->
<ImageButton
android:id="@+id/btnDeleteCategory"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_trashbin"
android:contentDescription="@string/delete_category"
app:tint="?android:attr/textColorSecondary"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>