Refactor MainActivity navigation and AppBars behavior

This commit is contained in:
Koitharu
2022-08-01 10:33:58 +03:00
parent 656405edbc
commit 8b0f221eef
21 changed files with 350 additions and 666 deletions

View File

@@ -1,28 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<org.koitharu.kotatsu.base.ui.widgets.KotatsuCoordinatorLayout
<LinearLayout
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_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".main.ui.MainActivity">
<androidx.constraintlayout.widget.ConstraintLayout
<com.google.android.material.navigationrail.NavigationRailView
android:id="@+id/navRail"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:elevation="1dp"
app:headerLayout="@layout/navigation_rail_fab"
app:labelVisibilityMode="labeled"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/nav_bottom" />
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.KotatsuAppBarLayout
<androidx.fragment.app.FragmentContainerView
android:id="@id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:layout="@layout/fragment_list" />
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:clipToPadding="false"
android:fitsSystemWindows="false"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:clipToPadding="false"
android:stateListAnimator="@null"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/navRail"
app:layout_constraintTop_toTopOf="parent">
app:liftOnScroll="false">
<org.koitharu.kotatsu.base.ui.widgets.WindowInsetHolder
android:id="@+id/insetsHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
app:layout_scrollFlags="scroll|enterAlways|snap" />
<FrameLayout
android:id="@+id/toolbar_card"
@@ -30,7 +53,8 @@
android:layout_height="48dp"
android:layout_marginVertical="8dp"
android:background="@drawable/toolbar_background"
android:theme="@style/ThemeOverlay.Kotatsu.MainToolbar">
android:theme="@style/ThemeOverlay.Kotatsu.MainToolbar"
app:layout_scrollFlags="scroll|enterAlways|snap">
<com.google.android.material.appbar.MaterialToolbar
android:id="@id/toolbar"
@@ -51,7 +75,7 @@
android:background="@null"
android:gravity="center_vertical"
android:hint="@string/search_manga"
android:imeOptions="actionSearch"
android:imeOptions="actionSearch|flagNoFullscreen"
android:importantForAutofill="no"
android:singleLine="true"
tools:drawableEnd="@drawable/abc_ic_clear_material" />
@@ -60,28 +84,8 @@
</FrameLayout>
</com.google.android.material.appbar.KotatsuAppBarLayout>
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.navigationrail.NavigationRailView
android:id="@+id/navRail"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:elevation="1dp"
app:headerLayout="@layout/navigation_rail_fab"
app:labelVisibilityMode="labeled"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/nav_bottom" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<androidx.fragment.app.FragmentContainerView
android:id="@id/container"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/navRail"
app:layout_constraintTop_toBottomOf="@id/appbar"
tools:layout="@layout/fragment_list" />
</androidx.constraintlayout.widget.ConstraintLayout>
</org.koitharu.kotatsu.base.ui.widgets.KotatsuCoordinatorLayout>
</LinearLayout>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<org.koitharu.kotatsu.base.ui.widgets.KotatsuCoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
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"
@@ -14,14 +14,22 @@
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:layout="@layout/fragment_list" />
<com.google.android.material.appbar.KotatsuAppBarLayout
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:fitsSystemWindows="true"
android:fitsSystemWindows="false"
android:paddingHorizontal="16dp"
android:stateListAnimator="@null">
android:stateListAnimator="@null"
app:liftOnScroll="false">
<org.koitharu.kotatsu.base.ui.widgets.WindowInsetHolder
android:id="@+id/insetsHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
app:layout_scrollFlags="scroll|enterAlways|snap" />
<FrameLayout
android:id="@+id/toolbar_card"
@@ -60,7 +68,7 @@
</FrameLayout>
</com.google.android.material.appbar.KotatsuAppBarLayout>
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/fab"
@@ -68,6 +76,7 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginBottom="-4dp"
android:paddingBottom="8dp"
android:text="@string/_continue"
android:visibility="gone"
app:backgroundTint="?attr/colorContainer"
@@ -75,12 +84,11 @@
app:layout_anchor="@id/bottomNav"
app:layout_anchorGravity="top|end"
app:layout_behavior="org.koitharu.kotatsu.base.ui.util.ShrinkOnScrollBehavior"
app:layout_insetEdge="bottom"
app:layout_dodgeInsetEdges="bottom"
android:paddingBottom="8dp"
app:layout_insetEdge="bottom"
tools:visibility="visible" />
<org.koitharu.kotatsu.base.ui.widgets.KotatsuBottomNavigationView
<org.koitharu.kotatsu.base.ui.widgets.SlidingBottomNavigationView
android:id="@+id/bottomNav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -90,4 +98,4 @@
app:menu="@menu/nav_bottom"
tools:ignore="KeyboardInaccessibleWidget" />
</org.koitharu.kotatsu.base.ui.widgets.KotatsuCoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<org.koitharu.kotatsu.base.ui.widgets.KotatsuCoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
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">
<com.google.android.material.appbar.KotatsuAppBarLayout
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -29,7 +29,7 @@
</com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.KotatsuAppBarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.fragment.app.FragmentContainerView
android:id="@id/container"
@@ -37,4 +37,4 @@
android:layout_height="match_parent"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
</org.koitharu.kotatsu.base.ui.widgets.KotatsuCoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@@ -1,16 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<org.koitharu.kotatsu.base.ui.widgets.KotatsuCoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
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">
<com.google.android.material.appbar.KotatsuAppBarLayout
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:elevation="0dp">
android:fitsSystemWindows="false"
app:elevation="0dp"
app:liftOnScroll="false">
<org.koitharu.kotatsu.base.ui.widgets.WindowInsetHolder
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
app:layout_scrollFlags="scroll|enterAlways|snap" />
<com.google.android.material.appbar.MaterialToolbar
android:id="@id/toolbar"
@@ -18,7 +25,7 @@
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways" />
</com.google.android.material.appbar.KotatsuAppBarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@id/recyclerView"
@@ -28,4 +35,4 @@
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
</org.koitharu.kotatsu.base.ui.widgets.KotatsuCoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/railFab"
android:theme="@style/ThemeOverlay.Material3.FloatingActionButton.Tertiary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_read" />
android:contentDescription="@string/_continue"
app:srcCompat="@drawable/ic_read" />

View File

@@ -8,5 +8,6 @@
<color name="scrollbar">#66FFFFFF</color>
<color name="selector_foreground">#29FFFFFF</color>
<color name="divider_default">#1FFFFFFF</color>
<color name="dim_statusbar">#99000000</color>
</resources>
</resources>

View File

@@ -18,8 +18,9 @@
<color name="grey">#424242</color>
<color name="grey_dark">#212121</color>
<color name="dim">#99000000</color>
<color name="dim_statusbar">#99FFFFFF</color>
<color name="scrollbar">#66000000</color>
<color name="selector_foreground">#29000000</color>
<color name="divider_default">#1F000000</color>
</resources>
</resources>

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="config_defaultAnimTime">300</integer>
<integer name="config_shorterAnimTime">150</integer>
<integer name="config_tinyAnimTime">50</integer>
<integer name="manga_badge_max_character_count">3</integer>