From 12b94c7815b9b54f732fade425aa405e41f0e27b Mon Sep 17 00:00:00 2001 From: Tayfun Cesur Date: Tue, 18 Jun 2019 08:10:36 +0300 Subject: [PATCH] Bottom and Top sheet behavior is now accessible to modify --- .idea/misc.xml | 2 +- lib/build.gradle | 4 ++-- .../curvedbottomsheet/CurvedBottomSheet.kt | 21 +++++++++++-------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 01327bb..b478623 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,7 +5,7 @@ - + diff --git a/lib/build.gradle b/lib/build.gradle index f4f02fa..88c46fe 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -9,8 +9,8 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 28 - versionCode 1 - versionName "1.0" + versionCode 2 + versionName "1.0.1" } } diff --git a/lib/src/main/java/com/tayfuncesur/curvedbottomsheet/CurvedBottomSheet.kt b/lib/src/main/java/com/tayfuncesur/curvedbottomsheet/CurvedBottomSheet.kt index 9871a80..6e5cb4f 100644 --- a/lib/src/main/java/com/tayfuncesur/curvedbottomsheet/CurvedBottomSheet.kt +++ b/lib/src/main/java/com/tayfuncesur/curvedbottomsheet/CurvedBottomSheet.kt @@ -7,13 +7,16 @@ import android.view.View class CurvedBottomSheet( private val radius: Float = 180F, - private var view: View, + private var view: CurvedLayout, private val type: Type = Type.CURVE, private val location: Location = Location.BOTTOM, private val shape: Shape = Shape.Concave, private val callback: Callback? = null ) { + lateinit var bottomSheetBehavior: BottomSheetBehavior<*> + lateinit var topSheetBehavior: TopSheetBehavior<*> + enum class Type { CURVE, WAVE } @@ -26,14 +29,14 @@ class CurvedBottomSheet( Concave, Convex } - fun init() { - (view as CurvedLayout).radius = radius.toInt() - (view as CurvedLayout).type = type - (view as CurvedLayout).shape = shape - (view as CurvedLayout).location = location + fun init() : CurvedBottomSheet{ + view.radius = radius.toInt() + view.type = type + view.shape = shape + view.location = location view.setBackgroundColor(Color.TRANSPARENT) if (location == Location.BOTTOM) { - val bottomSheetBehavior = BottomSheetBehavior.from(view) + bottomSheetBehavior = BottomSheetBehavior.from(view) bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED bottomSheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { override fun onSlide(p0: View, p1: Float) { @@ -47,7 +50,7 @@ class CurvedBottomSheet( } }) } else { - val topSheetBehavior = TopSheetBehavior.from(view) + topSheetBehavior = TopSheetBehavior.from(view) topSheetBehavior.setTopSheetCallback(object : TopSheetBehavior.TopSheetCallback() { override fun onStateChanged(bottomSheet: View, newState: Int) { @@ -61,7 +64,7 @@ class CurvedBottomSheet( }) } - + return this } } \ No newline at end of file