Skip to content

Commit

Permalink
Override *nestedScrollingEnabled functions #41
Browse files Browse the repository at this point in the history
  • Loading branch information
Droppers committed Oct 20, 2021
1 parent a425b49 commit 09e5233
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 13 deletions.
8 changes: 4 additions & 4 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@
android:theme="@style/AppTheme"
android:versionCode="3"
android:versionName="1.0.2">

<activity
android:name=".bottomsheet.BottomSheetActivity">
</activity>
<activity
android:name=".playground.PlaygroundActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".ExampleActivity"
android:label="ExampleActivity"
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:name=".viewpager.ViewPagerActivity"
android:label="ViewPagerActivity"
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:name=".navcontroller.NavControllerActivity"
android:label="NavControllerActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package nl.joery.demo.animatedbottombar.bottomsheet

import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.bottomsheet.BottomSheetBehavior
import kotlinx.android.synthetic.main.activity_bottom_sheet.*
import nl.joery.demo.animatedbottombar.R
import nl.joery.demo.animatedbottombar.dpPx


class BottomSheetActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_bottom_sheet)

bottom_bar.isNestedScrollingEnabled = false

val bottomSheet: View = findViewById(R.id.bottom_sheet)
val bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet)
bottomSheetBehavior.peekHeight = 150.dpPx
}
}
43 changes: 43 additions & 0 deletions demo/src/main/res/layout/activity_bottom_sheet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".bottomsheet.BottomSheetActivity">

<LinearLayout
android:id="@+id/viewA"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/holo_purple"
android:orientation="horizontal"/>

<androidx.core.widget.NestedScrollView
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/holo_blue_bright"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<nl.joery.animatedbottombar.AnimatedBottomBar
android:id="@+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_margin="16dp"
android:background="#FFF"
app:abb_tabs="@menu/clock_tabs"
/>
<Space
android:id="@+id/dummy"
android:layout_width="match_parent"
android:layout_height="600dp" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,13 @@ class AnimatedBottomBar @JvmOverloads constructor(
setIconSizeAtTabIndex(index, iconSize)
}

override fun isNestedScrollingEnabled(): Boolean {
return recycler.isNestedScrollingEnabled
}

override fun setNestedScrollingEnabled(enabled: Boolean) {
recycler.isNestedScrollingEnabled = enabled
}

/**
* This method will link the given ViewPager and this AnimatedBottomBar together so that changes in one are automatically reflected in the other. This includes scroll state changes and clicks.
Expand Down Expand Up @@ -788,6 +795,13 @@ class AnimatedBottomBar @JvmOverloads constructor(
return -1
}

var selectedTabType
get() = tabStyle.selectedTabType
set(value) {
tabStyle.selectedTabType = value
applyTabStyle(BottomBarStyle.StyleUpdateType.TAB_TYPE)
}

/**
* Retrieve a list of all tabs.
*/
Expand Down Expand Up @@ -816,15 +830,6 @@ class AnimatedBottomBar @JvmOverloads constructor(
val selectedIndex
get() = adapter.selectedIndex


var selectedTabType
get() = tabStyle.selectedTabType
set(value) {
tabStyle.selectedTabType = value
applyTabStyle(BottomBarStyle.StyleUpdateType.TAB_TYPE)
}


var tabAnimationSelected
get() = tabStyle.tabAnimationSelected
set(value) {
Expand Down

0 comments on commit 09e5233

Please sign in to comment.