mirror of
https://github.com/recloudstream/cloudstream.git
synced 2026-03-13 15:19:43 +08:00
Feat: Expandable navigation rail on focus
This commit is contained in:
@@ -1709,6 +1709,35 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
|
||||
}
|
||||
}
|
||||
|
||||
val rail = binding?.navRailView
|
||||
if (rail != null && isLayout(TV)) {
|
||||
val focus = mutableSetOf<Int>()
|
||||
for (id in arrayOf(
|
||||
R.id.navigation_home,
|
||||
R.id.navigation_library,
|
||||
R.id.navigation_search,
|
||||
R.id.navigation_downloads,
|
||||
R.id.navigation_settings
|
||||
)) {
|
||||
rail.findViewById<View?>(id)?.onFocusChangeListener =
|
||||
View.OnFocusChangeListener { v, hasFocus ->
|
||||
if (hasFocus) {
|
||||
focus += id
|
||||
binding?.navRailView?.labelVisibilityMode = NavigationRailView.LABEL_VISIBILITY_LABELED
|
||||
binding?.navRailView?.expand()
|
||||
} else {
|
||||
focus -= id
|
||||
v.post {
|
||||
if(focus.isEmpty()) {
|
||||
binding?.navRailView?.labelVisibilityMode = NavigationRailView.LABEL_VISIBILITY_UNLABELED
|
||||
binding?.navRailView?.collapse()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Navigation button long click functionality to scroll to top
|
||||
for (view in listOf(binding?.navView, binding?.navRailView)) {
|
||||
view?.findViewById<View?>(R.id.navigation_home)?.setOnLongClickListener {
|
||||
|
||||
@@ -25,14 +25,18 @@
|
||||
|
||||
<com.google.android.material.navigationrail.NavigationRailView
|
||||
android:id="@+id/nav_rail_view"
|
||||
android:layout_width="62dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:minWidth="62dp"
|
||||
android:maxWidth="62dp"
|
||||
app:expanded="false"
|
||||
app:expandedMaxWidth="180dp"
|
||||
app:itemIconTint="@color/item_select_color"
|
||||
app:itemTextColor="@color/item_select_color"
|
||||
android:background="?attr/primaryGrayBackground"
|
||||
android:descendantFocusability="afterDescendants"
|
||||
app:headerLayout="@layout/rail_header"
|
||||
app:labelVisibilityMode="unlabeled"
|
||||
app:labelVisibilityMode="labeled"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:menu="@menu/bottom_nav_menu"
|
||||
|
||||
@@ -23,7 +23,7 @@ kotlinGradlePluginVersion = "2.1.10"
|
||||
kotlinxCoroutinesCore = "1.10.1"
|
||||
lifecycleLivedataKtx = "2.8.7"
|
||||
lifecycleViewmodelKtx = "2.8.7"
|
||||
material = "1.12.0"
|
||||
material = "1.14.0-alpha04"
|
||||
media3 = "1.6.1"
|
||||
navigationKtx = "2.8.9"
|
||||
newpipeextractor = "v0.24.6"
|
||||
|
||||
Reference in New Issue
Block a user