Updated toolbar and bottom bar design implementation
TBD: Both toolbars should move away from the screen when scrolling
This commit is contained in:
parent
af1f5d5ab2
commit
ee06aed94b
@ -2,6 +2,8 @@ package com.topjohnwu.magisk.redesign
|
|||||||
|
|
||||||
import android.graphics.Insets
|
import android.graphics.Insets
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.ViewTreeObserver
|
||||||
|
import androidx.core.view.setPadding
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.ncapdevi.fragnav.FragNavController
|
import com.ncapdevi.fragnav.FragNavController
|
||||||
import com.topjohnwu.magisk.Const
|
import com.topjohnwu.magisk.Const
|
||||||
@ -32,6 +34,14 @@ open class MainActivity : CompatActivity<MainViewModel, ActivityMainMd2Binding>(
|
|||||||
SettingsFragment::class
|
SettingsFragment::class
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//This temporarily fixes unwanted feature of BottomNavigationView - where the view applies
|
||||||
|
//padding on itself given insets are not consumed beforehand. Unfortunately the listener
|
||||||
|
//implementation doesn't favor us against the design library, so on re-create it's often given
|
||||||
|
//upper hand.
|
||||||
|
private val navObserver = ViewTreeObserver.OnGlobalLayoutListener {
|
||||||
|
binding.mainNavigation.setPadding(0)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
@ -49,11 +59,18 @@ open class MainActivity : CompatActivity<MainViewModel, ActivityMainMd2Binding>(
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.mainNavigation.viewTreeObserver.addOnGlobalLayoutListener(navObserver)
|
||||||
|
|
||||||
if (intent.getBooleanExtra(Const.Key.OPEN_SETTINGS, false)) {
|
if (intent.getBooleanExtra(Const.Key.OPEN_SETTINGS, false)) {
|
||||||
binding.mainNavigation.selectedItemId = R.id.settingsFragment
|
binding.mainNavigation.selectedItemId = R.id.settingsFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
binding.mainNavigation.viewTreeObserver.removeOnGlobalLayoutListener(navObserver)
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onTabTransaction(fragment: Fragment?, index: Int) {
|
override fun onTabTransaction(fragment: Fragment?, index: Int) {
|
||||||
super.onTabTransaction(fragment, index)
|
super.onTabTransaction(fragment, index)
|
||||||
|
|
||||||
|
@ -24,12 +24,14 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.card.MaterialCardView
|
||||||
style="?styleAppbar"
|
style="?styleCardElevated"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="@{viewModel.insets.top}"
|
android:layout_marginStart="@dimen/l1"
|
||||||
tools:paddingTop="24dp">
|
android:layout_marginTop="@{(int) @dimen/l1 + viewModel.insets.top}"
|
||||||
|
android:layout_marginEnd="@dimen/l1"
|
||||||
|
tools:layout_marginTop="40dp">
|
||||||
|
|
||||||
<com.google.android.material.appbar.MaterialToolbar
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
android:id="@+id/main_toolbar"
|
android:id="@+id/main_toolbar"
|
||||||
@ -45,21 +47,18 @@
|
|||||||
android:layout_gravity="start|bottom"
|
android:layout_gravity="start|bottom"
|
||||||
android:background="@drawable/bg_accent" />
|
android:background="@drawable/bg_accent" />
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
<com.google.android.material.bottomappbar.BottomAppBar
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:id="@+id/main_bottom_bar"
|
android:id="@+id/main_bottom_bar"
|
||||||
|
style="?styleCardElevated"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:background="?colorSurface"
|
android:layout_marginStart="@dimen/l1"
|
||||||
android:paddingBottom="@{viewModel.insets.bottom}"
|
android:layout_marginEnd="@dimen/l1"
|
||||||
app:backgroundTint="?colorSurface"
|
android:layout_marginBottom="@{(int) @dimen/l1 + viewModel.insets.bottom}"
|
||||||
app:contentInsetEnd="0dp"
|
tools:layout_marginBottom="64dp">
|
||||||
app:contentInsetStart="0dp"
|
|
||||||
app:fabCradleMargin="@dimen/l_50"
|
|
||||||
app:hideOnScroll="true"
|
|
||||||
tools:paddingBottom="48dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -94,15 +93,7 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.google.android.material.bottomappbar.BottomAppBar>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="@{viewModel.insets.bottom + (int) @dimen/l1}"
|
|
||||||
app:fabSize="normal"
|
|
||||||
app:layout_anchor="@+id/main_bottom_bar"
|
|
||||||
app:srcCompat="@drawable/ic_superuser_md2" />
|
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:paddingTop="@{viewModel.insets.top + (int) @dimen/internal_action_bar_size + (int) @dimen/l1}"
|
android:paddingTop="@{viewModel.insets.top + (int) @dimen/internal_action_bar_size + (int) @dimen/l2}"
|
||||||
android:paddingBottom="@{viewModel.insets.bottom + (int) @dimen/margin_fab + (int) @dimen/l1}"
|
android:paddingBottom="@{viewModel.insets.bottom + (int) @dimen/margin_fab + (int) @dimen/l1}"
|
||||||
tools:layout_marginTop="24dp">
|
tools:layout_marginTop="24dp">
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
tools:showAsAction="always" />
|
tools:showAsAction="always" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/fake"
|
android:id="@+id/superuserFragment"
|
||||||
android:enabled="false"
|
android:icon="@drawable/ic_superuser_md2"
|
||||||
android:title=""
|
android:title="@string/section_superuser"
|
||||||
tools:showAsAction="always" />
|
tools:showAsAction="always" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
<!--Card-->
|
<!--Card-->
|
||||||
<attr name="styleCardNormal" format="reference" />
|
<attr name="styleCardNormal" format="reference" />
|
||||||
|
<attr name="styleCardElevated" format="reference" />
|
||||||
<attr name="styleCardOnPrimary" format="reference" />
|
<attr name="styleCardOnPrimary" format="reference" />
|
||||||
|
|
||||||
<!--Button-->
|
<!--Button-->
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
<item name="styleToolbar">@style/WidgetFoundation.Toolbar</item>
|
<item name="styleToolbar">@style/WidgetFoundation.Toolbar</item>
|
||||||
|
|
||||||
<item name="styleCardNormal">@style/WidgetFoundation.Card</item>
|
<item name="styleCardNormal">@style/WidgetFoundation.Card</item>
|
||||||
|
<item name="styleCardElevated">@style/WidgetFoundation.Card.Elevated</item>
|
||||||
<item name="styleCardOnPrimary">@style/WidgetFoundation.Card.OnPrimary</item>
|
<item name="styleCardOnPrimary">@style/WidgetFoundation.Card.OnPrimary</item>
|
||||||
|
|
||||||
<item name="styleButtonDefault">@style/WidgetFoundation.Button</item>
|
<item name="styleButtonDefault">@style/WidgetFoundation.Button</item>
|
||||||
|
@ -27,6 +27,13 @@ variant. Make sure to use style referenced by attribute defined it attrs.xml.
|
|||||||
<item name="cardBackgroundColor">?colorSurfaceVariant</item>
|
<item name="cardBackgroundColor">?colorSurfaceVariant</item>
|
||||||
<item name="cardCornerRadius">@dimen/l_50</item>
|
<item name="cardCornerRadius">@dimen/l_50</item>
|
||||||
<item name="cardElevation">0dp</item>
|
<item name="cardElevation">0dp</item>
|
||||||
|
<item name="cardPreventCornerOverlap">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
<style name="WidgetFoundation.Card.Elevated" parent="Widget.MaterialComponents.CardView">
|
||||||
|
<item name="cardBackgroundColor">?colorSurface</item>
|
||||||
|
<item name="cardElevation">@dimen/l_25</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="WidgetFoundation.Card.OnPrimary" parent="Widget.MaterialComponents.CardView">
|
<style name="WidgetFoundation.Card.OnPrimary" parent="Widget.MaterialComponents.CardView">
|
||||||
@ -35,6 +42,7 @@ variant. Make sure to use style referenced by attribute defined it attrs.xml.
|
|||||||
<item name="strokeColor">?colorOnPrimaryVariant</item>
|
<item name="strokeColor">?colorOnPrimaryVariant</item>
|
||||||
<item name="strokeWidth">1dp</item>
|
<item name="strokeWidth">1dp</item>
|
||||||
<item name="cardBackgroundColor">?colorPrimary</item>
|
<item name="cardBackgroundColor">?colorPrimary</item>
|
||||||
|
<item name="cardPreventCornerOverlap">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user