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

+ 17 - 0
app/src/main/java/io/legato/kazusa/ui/rss/article/RssSortActivity.kt

@@ -6,6 +6,7 @@ import android.os.Bundle
 import android.view.Menu
 import android.view.MenuItem
 import androidx.activity.viewModels
+import androidx.appcompat.widget.PopupMenu
 import androidx.fragment.app.Fragment
 import androidx.fragment.app.FragmentActivity
 import androidx.lifecycle.lifecycleScope
@@ -122,6 +123,22 @@ class RssSortActivity : VMBaseActivity<ActivityRssArtivlesBinding, RssSortViewMo
                 tab.text = sortList[position].first
             }.attach()
         }
+
+        binding.btnExpandTabs.setOnClickListener {
+            val popup = PopupMenu(this, it)
+            sortList.forEachIndexed { index, pair ->
+                popup.menu.add(0, index, index, pair.first)
+            }
+            popup.setOnMenuItemClickListener { item ->
+                binding.viewPager.setCurrentItem(item.itemId, true)
+                true
+            }
+            popup.setOnDismissListener {
+                binding.btnExpandTabs.isChecked = false
+            }
+            popup.show()
+        }
+
     }
 
     private fun setSourceVariable() {

+ 9 - 0
app/src/main/res/drawable/tab_right_fade.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <gradient
+        android:startColor="@android:color/transparent"
+        android:endColor="?attr/colorSurface"
+        android:angle="0" />
+</shape>
+
+

+ 39 - 4
app/src/main/res/layout/activity_rss_artivles.xml

@@ -36,12 +36,47 @@
 
         </com.google.android.material.appbar.CollapsingToolbarLayout>
 
-        <com.google.android.material.tabs.TabLayout
-            android:id="@+id/tab_layout"
+        <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:background="@android:color/transparent"
-            android:paddingHorizontal="16dp"/>
+            android:orientation="horizontal"
+            android:gravity="center_vertical"
+            android:paddingStart="16dp"
+            android:paddingEnd="10dp">
+
+            <FrameLayout
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:clipToPadding="false"
+                android:clipChildren="false">
+
+                <com.google.android.material.tabs.TabLayout
+                    android:id="@+id/tab_layout"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:background="@android:color/transparent"
+                    app:tabMode="scrollable"
+                    android:scrollbars="none" />
+
+                <View
+                    android:layout_width="40dp"
+                    android:layout_height="match_parent"
+                    android:layout_gravity="end"
+                    android:background="@drawable/tab_right_fade" />
+
+            </FrameLayout>
+
+            <com.google.android.material.button.MaterialButton
+                android:id="@+id/btn_expand_tabs"
+                android:layout_width="40dp"
+                android:layout_height="40dp"
+                android:checkable="true"
+                app:iconGravity="textStart"
+                style="@style/Widget.Material3Expressive.Button.IconButton.Outlined"
+                app:icon="@drawable/m3_split_button_chevron_avd" />
+
+        </LinearLayout>
 
     </com.google.android.material.appbar.AppBarLayout>
 

+ 1 - 0
app/src/main/res/layout/fragment_rss_articles.xml

@@ -8,6 +8,7 @@
         android:id="@+id/recycler_view"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
+        android:padding="4dp"
         android:clipToPadding="false" />
 
 </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

+ 1 - 1
app/src/main/res/layout/item_rss_article_1.xml

@@ -2,7 +2,7 @@
 <com.google.android.material.card.MaterialCardView 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:layout_margin="8dp"
+    android:layout_margin="4dp"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     app:strokeWidth="0dp"

+ 1 - 1
app/src/main/res/layout/item_rss_article_2.xml

@@ -2,7 +2,7 @@
 <com.google.android.material.card.MaterialCardView 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:layout_margin="8dp"
+    android:layout_margin="4dp"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     app:strokeWidth="0dp"

+ 1 - 1
app/src/main/res/layout/item_rss_article_3.xml

@@ -2,7 +2,7 @@
 <com.google.android.material.card.MaterialCardView 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:layout_margin="8dp"
+    android:layout_margin="4dp"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     app:strokeWidth="0dp"