订阅界面优化 #146

This commit is contained in:
HapeLee
2025-10-26 14:07:37 +08:00
parent 9183d2fc48
commit b8ee311f70
7 changed files with 69 additions and 7 deletions
@@ -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() {
@@ -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>
@@ -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>
@@ -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>
@@ -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"
@@ -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"
@@ -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"