mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2024-11-23 19:26:31 -06:00
Migrate to material components bottom navigation (#1244)
This commit is contained in:
parent
792de4cd3d
commit
0bdd33ef4a
@ -202,7 +202,6 @@ dependencies {
|
||||
implementation "androidx.hilt:hilt-work:$work_hilt"
|
||||
kapt "androidx.hilt:hilt-compiler:$work_hilt"
|
||||
|
||||
implementation "com.aurelhubert:ahbottomnavigation:2.3.4"
|
||||
implementation "com.ncapdevi:frag-nav:3.3.0"
|
||||
implementation "com.github.YarikSOffice:lingver:1.3.0"
|
||||
|
||||
|
@ -26,8 +26,6 @@ import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.aurelhubert.ahbottomnavigation.AHBottomNavigation.TitleState.ALWAYS_SHOW
|
||||
import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem
|
||||
import com.google.android.material.elevation.ElevationOverlayProvider
|
||||
import com.ncapdevi.fragnav.FragNavController
|
||||
import com.ncapdevi.fragnav.FragNavController.Companion.HIDE
|
||||
@ -220,32 +218,21 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
||||
}
|
||||
|
||||
with(binding.mainBottomNav) {
|
||||
addItems(
|
||||
listOf(
|
||||
AHBottomNavigationItem(R.string.grade_title, R.drawable.ic_main_grade, 0),
|
||||
AHBottomNavigationItem(
|
||||
R.string.attendance_title,
|
||||
R.drawable.ic_main_attendance,
|
||||
0
|
||||
),
|
||||
AHBottomNavigationItem(R.string.exam_title, R.drawable.ic_main_exam, 0),
|
||||
AHBottomNavigationItem(
|
||||
R.string.timetable_title,
|
||||
R.drawable.ic_main_timetable,
|
||||
0
|
||||
),
|
||||
AHBottomNavigationItem(R.string.more_title, R.drawable.ic_main_more, 0)
|
||||
)
|
||||
)
|
||||
accentColor = getThemeAttrColor(R.attr.colorPrimary)
|
||||
inactiveColor = getThemeAttrColor(R.attr.colorOnSurface, 153)
|
||||
defaultBackgroundColor =
|
||||
overlayProvider.compositeOverlayWithThemeSurfaceColorIfNeeded(dpToPx(8f))
|
||||
titleState = ALWAYS_SHOW
|
||||
currentItem = startMenuIndex
|
||||
isBehaviorTranslationEnabled = false
|
||||
setTitleTextSizeInSp(10f, 10f)
|
||||
setOnTabSelectedListener(presenter::onTabSelected)
|
||||
with(menu) {
|
||||
add(Menu.NONE, 0, Menu.NONE, R.string.grade_title)
|
||||
.setIcon(R.drawable.ic_main_grade)
|
||||
add(Menu.NONE, 1, Menu.NONE, R.string.attendance_title)
|
||||
.setIcon(R.drawable.ic_main_attendance)
|
||||
add(Menu.NONE, 2, Menu.NONE, R.string.exam_title)
|
||||
.setIcon(R.drawable.ic_main_exam)
|
||||
add(Menu.NONE, 3, Menu.NONE, R.string.timetable_title)
|
||||
.setIcon(R.drawable.ic_main_timetable)
|
||||
add(Menu.NONE, 4, Menu.NONE, R.string.more_title)
|
||||
.setIcon(R.drawable.ic_main_more)
|
||||
}
|
||||
selectedItemId = startMenuIndex
|
||||
setOnNavigationItemSelectedListener { presenter.onTabSelected(it.itemId, false) }
|
||||
setOnNavigationItemReselectedListener { presenter.onTabSelected(it.itemId, true) }
|
||||
}
|
||||
|
||||
with(navController) {
|
||||
|
@ -0,0 +1,19 @@
|
||||
package io.github.wulkanowy.ui.widgets
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
|
||||
class SwipeDisabledViewPager : ViewPager {
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attr: AttributeSet) : super(context, attr)
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onTouchEvent(ev: MotionEvent) = false
|
||||
|
||||
override fun onInterceptTouchEvent(ev: MotionEvent) = false
|
||||
}
|
@ -6,11 +6,11 @@
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/loginToolbar"
|
||||
android:background="@android:color/transparent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent" />
|
||||
|
||||
<com.aurelhubert.ahbottomnavigation.AHBottomNavigationViewPager
|
||||
<io.github.wulkanowy.ui.widgets.SwipeDisabledViewPager
|
||||
android:id="@+id/loginViewpager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
@ -17,11 +17,14 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="?actionBarSize"
|
||||
android:layout_marginBottom="@dimen/bottom_navigation_height" />
|
||||
android:layout_marginBottom="56dp" />
|
||||
|
||||
<com.aurelhubert.ahbottomnavigation.AHBottomNavigation
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/mainBottomNav"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom" />
|
||||
android:layout_gravity="bottom"
|
||||
app:itemTextAppearanceActive="@style/WulkanowyTheme.TextAppearanceBottomNavigation"
|
||||
app:itemTextAppearanceInactive="@style/WulkanowyTheme.TextAppearanceBottomNavigation"
|
||||
app:labelVisibilityMode="labeled" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
@ -1,5 +0,0 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!--BottomNav-->
|
||||
<dimen name="bottom_navigation_margin_top_active" tools:override="true">8dp</dimen>
|
||||
<dimen name="bottom_navigation_margin_top_inactive" tools:override="true">8dp</dimen>
|
||||
</resources>
|
@ -34,6 +34,10 @@
|
||||
<item name="android:textColor">?android:textColorPrimary</item>
|
||||
</style>
|
||||
|
||||
<style name="WulkanowyTheme.TextAppearanceBottomNavigation">
|
||||
<item name="android:textSize">11sp</item>
|
||||
</style>
|
||||
|
||||
<style name="mdtp_ActionButton.Text" parent="Widget.MaterialComponents.Button.TextButton.Dialog" />
|
||||
|
||||
<style name="WulkanowyTheme.Login" parent="WulkanowyTheme.NoActionBar" />
|
||||
|
@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<item
|
||||
name="visible"
|
||||
type="id" />
|
||||
<item
|
||||
name="masked"
|
||||
type="id" />
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user