HapeLee 1 год назад
Родитель
Сommit
d31dbdb694

+ 19 - 14
app/src/main/java/io/legato/kazusa/ui/main/explore/ExploreAdapter.kt

@@ -65,8 +65,7 @@ class ExploreAdapter(
             val isExpanded = (item.bookSourceUrl == expandedId)
 
             if (isExpanded) {
-                ivStatus.icon = ContextCompat.getDrawable(context, R.drawable.ic_arrow_right)
-                ivStatus.rotation = 90f
+                ivStatus.isChecked = true
                 rotateLoading.visible()
                 if (scrollToId == item.bookSourceUrl) {
                     val pos = holder.bindingAdapterPosition
@@ -82,8 +81,7 @@ class ExploreAdapter(
                     rotateLoading.gone()
                 }
             } else {
-                ivStatus.icon = ContextCompat.getDrawable(context, R.drawable.ic_arrow_right)
-                ivStatus.rotation = 0f
+                ivStatus.isChecked = false
                 recyclerFlexbox(flexbox)
                 flexbox.gone()
             }
@@ -135,16 +133,10 @@ class ExploreAdapter(
     override fun registerListener(holder: ItemViewHolder, binding: ItemFindBookBinding) {
         binding.apply {
             llTitle.setOnClickListener {
-                val item = getItem(holder.bindingAdapterPosition) ?: return@setOnClickListener
-                val oldId = expandedId
-                expandedId = if (expandedId == item.bookSourceUrl) null else item.bookSourceUrl
-                notifyItemChangedById(oldId)
-                notifyItemChangedById(expandedId)
-
-                if (expandedId != null) {
-                    scrollToId = expandedId
-                    callBack.scrollTo(holder.bindingAdapterPosition)
-                }
+                toggleExpandState(holder)
+            }
+            ivStatus.setOnClickListener {
+                toggleExpandState(holder)
             }
             llTitle.onLongClick {
                 showMenu(ivStatus, holder.bindingAdapterPosition)
@@ -152,6 +144,19 @@ class ExploreAdapter(
         }
     }
 
+    private fun toggleExpandState(holder: ItemViewHolder) {
+        val item = getItem(holder.bindingAdapterPosition) ?: return
+        val oldId = expandedId
+        expandedId = if (expandedId == item.bookSourceUrl) null else item.bookSourceUrl
+        notifyItemChangedById(oldId)
+        notifyItemChangedById(expandedId)
+
+        if (expandedId != null) {
+            scrollToId = expandedId
+            callBack.scrollTo(holder.bindingAdapterPosition)
+        }
+    }
+
     fun compressExplore(): Boolean {
         return if (expandedId == null) {
             false

+ 3 - 1
app/src/main/res/layout/item_find_book.xml

@@ -37,7 +37,8 @@
             style="@style/Widget.Material3Expressive.Button.IconButton.Tonal"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            app:icon="@drawable/ic_arrow_right"
+            android:checkable="true"
+            app:icon="@drawable/m3_split_button_chevron_avd"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintTop_toTopOf="parent"
             app:layout_constraintBottom_toBottomOf="parent"/>
@@ -46,6 +47,7 @@
             android:id="@+id/rotate_loading"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            app:indicatorColor="?attr/colorSurface"
             app:indicatorSize="24dp"
             android:visibility="gone"
             app:layout_constraintTop_toTopOf="@id/iv_status"