MainActivity: Add view binding type hint for navigation bar

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2024-07-16 16:44:10 +07:00
parent 8b341c088c
commit e9843a6b45
3 changed files with 10 additions and 7 deletions

View File

@@ -41,7 +41,6 @@ import com.aurora.store.util.AppUtil
import com.aurora.store.util.Preferences
import com.aurora.store.util.Preferences.PREFERENCE_DEFAULT_SELECTED_TAB
import com.aurora.store.view.ui.sheets.NetworkDialogSheet
import com.google.android.material.navigation.NavigationBarView
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
@@ -100,7 +99,7 @@ class MainActivity : AppCompatActivity() {
}
}
(B.navView as NavigationBarView).apply {
B.navView.apply {
val alphaColor = ColorUtils.setAlphaComponent(this@MainActivity.accentColor(), 100)
setupWithNavController(navController)
itemActiveIndicatorColor = ColorStateList.valueOf(alphaColor)
@@ -150,7 +149,7 @@ class MainActivity : AppCompatActivity() {
lifecycleScope.launch {
appUtil.updates.collectLatest { list ->
(B.navView as NavigationBarView).getOrCreateBadge(R.id.updatesFragment).apply {
B.navView.getOrCreateBadge(R.id.updatesFragment).apply {
isVisible = !list.isNullOrEmpty()
number = list?.size ?: 0
}

View File

@@ -2,7 +2,8 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment"
@@ -26,5 +27,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:menu="@menu/menu_bottom_nav"
app:menuGravity="center" />
app:menuGravity="center"
tools:viewBindingType="com.google.android.material.navigation.NavigationBarView" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -21,7 +21,8 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment"
@@ -43,5 +44,6 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/menu_bottom_nav" />
app:menu="@menu/menu_bottom_nav"
tools:viewBindingType="com.google.android.material.navigation.NavigationBarView" />
</androidx.constraintlayout.widget.ConstraintLayout>