aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/ca
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-07-05 23:44:01 -0700
committerAllan Wang <me@allanwang.ca>2017-07-05 23:44:01 -0700
commitf0731069057bb52614ba184389eb1432d9ba7e16 (patch)
tree0bf8a3e6a3a217e1f7167fcf358a742d9de982d2 /core/src/main/kotlin/ca
parente803969433b56e7e6ef4b02ed01aaa2e410eb1f9 (diff)
downloadkau-f0731069057bb52614ba184389eb1432d9ba7e16.tar.gz
kau-f0731069057bb52614ba184389eb1432d9ba7e16.tar.bz2
kau-f0731069057bb52614ba184389eb1432d9ba7e16.zip
More swipe customization
Diffstat (limited to 'core/src/main/kotlin/ca')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt7
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt33
2 files changed, 36 insertions, 4 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt
index 4473e23..9041c90 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt
@@ -9,7 +9,6 @@ import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
-import ca.allanwang.kau.logging.KL
import ca.allanwang.kau.utils.adjustAlpha
import ca.allanwang.kau.utils.navigationBarColor
import ca.allanwang.kau.utils.statusBarColor
@@ -83,7 +82,7 @@ class SwipeBackLayout @JvmOverloads constructor(context: Context, attrs: Attribu
val chromeFadeListener: SwipeListener by lazy {
object : SwipeListener {
override fun onScroll(percent: Float, px: Int, edgeFlag: Int) {
- KL.d("PER $percent")
+ if (!transitionSystemBars) return
activity?.apply {
statusBarColor = statusBarBase.adjustAlpha(scrimOpacity)
navigationBarColor = navBarBase.adjustAlpha(scrimOpacity)
@@ -138,6 +137,8 @@ class SwipeBackLayout @JvmOverloads constructor(context: Context, attrs: Attribu
dragHelper.setSensitivity(context, value)
}
+ override var transitionSystemBars: Boolean = true
+
init {
dragHelper = ViewDragHelper.create(this, ViewDragCallback())
val density = resources.displayMetrics.density
@@ -162,7 +163,7 @@ class SwipeBackLayout @JvmOverloads constructor(context: Context, attrs: Attribu
}
override fun setEdgeSizePercent(swipeEdgePercent: Float) {
- edgeSize = (resources.displayMetrics.widthPixels * swipeEdgePercent).toInt()
+ edgeSize = ((if (horizontal) resources.displayMetrics.widthPixels else resources.displayMetrics.heightPixels) * swipeEdgePercent).toInt()
}
/**
diff --git a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt
index cb28342..81ddb62 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt
@@ -50,16 +50,47 @@ class SwipeBackPage(activity: Activity) : SwipeBackContract by SwipeBackLayout(a
}
interface SwipeBackContract {
+ /**
+ * Toggle main touch intercept
+ */
var swipeEnabled: Boolean
+ /**
+ * Set the background color for the outside of the page
+ * This dynamically fades as the page gets closer to exiting
+ */
var scrimColor: Int
val swipeBackLayout: SwipeBackLayout
var edgeSize: Int
+ /**
+ * Set the flag for which edge the page is scrolling from
+ */
var edgeFlag: Int
+ /**
+ * Set the scrolling threshold for wish a page is deemed closing
+ */
var scrollThreshold: Float
var disallowIntercept: Boolean
+ /**
+ * Set the min velocity of the view drag helper
+ */
var minVelocity: Float
+ /**
+ * Set the max velocity of the view drag helper
+ */
var maxVelocity: Float
- var sensitivity:Float
+ /**
+ * Set the sensitivity of the view drag helper
+ */
+ var sensitivity: Float
+ /**
+ * Dynamically change the alpha for the status bar and nav bar
+ * as the page scrolls
+ */
+ var transitionSystemBars: Boolean
+
+ /**
+ * Sets edge size based on screen size
+ */
fun setEdgeSizePercent(swipeEdgePercent: Float)
fun addListener(listener: SwipeListener)
fun removeListener(listener: SwipeListener)