Skip to content
This repository was archived by the owner on Nov 21, 2024. It is now read-only.

Commit 66917c7

Browse files
committed
restrict touchable area depends on translationX
1 parent 6444fb5 commit 66917c7

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.materialstudies.owl.ui.lessons
2+
3+
import android.content.Context
4+
import android.util.AttributeSet
5+
import android.view.MotionEvent
6+
import android.view.View
7+
import androidx.coordinatorlayout.widget.CoordinatorLayout
8+
import com.google.android.material.bottomsheet.BottomSheetBehavior
9+
10+
class LessonBottomSheetBehavior<T : View>(context: Context, attrs: AttributeSet?) :
11+
BottomSheetBehavior<T>(context, attrs) {
12+
13+
override fun onTouchEvent(parent: CoordinatorLayout, child: T, event: MotionEvent): Boolean {
14+
if (event.x < child.translationX) {
15+
return false
16+
}
17+
return super.onTouchEvent(parent, child, event)
18+
}
19+
}

Owl/app/src/main/res/layout/fragment_lessons_sheet.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
android:id="@+id/lessons_sheet"
3535
android:layout_height="match_parent"
3636
android:layout_width="match_parent"
37-
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
37+
app:layout_behavior="com.materialstudies.owl.ui.lessons.LessonBottomSheetBehavior"
3838
app:behavior_peekHeight="56dp">
3939

4040
<ImageView

0 commit comments

Comments
 (0)