Skip to content

Commit

Permalink
Merge pull request #37 from MehulKK/feature/reverse_curve
Browse files Browse the repository at this point in the history
✨ Added New reverse curve feature.

LGTM.
  • Loading branch information
yashwantgowla-simform authored Aug 25, 2022
2 parents 30e5984 + 49b265e commit 43fd772
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ The actual features are:

![demo_data](https://github.com/simformsolutions/SSCustomBottomNavigation/blob/master/images/custom_bottom_navigation.gif)

Reverse Curve

![demo_data](https://github.com/simformsolutions/SSCustomBottomNavigation/blob/master/images/custom_bottom_navigation_revese.gif)


### Gradle Dependency
* Add it in your root build.gradle at the end of repositories:
Expand Down Expand Up @@ -67,6 +71,7 @@ The actual features are:
| `app:ss_countTypeface` | Set Font for Notification Badge | `none` |
| `app:ss_rippleColor` | Set Ripple Color | `#757575` |
| `app:ss_shadowColor` | Set Bottom Bar Shadow Color | `shadowColor` |
| `app:ss_reverseCurve` | Set Reverse Bzier Curve | `false` |

# Customization
------------------------
Expand Down
2 changes: 1 addition & 1 deletion custombottomnavigation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ afterEvaluate {
from components.release
groupId = 'com.simform.custombottomnavigation'
artifactId = 'custombottomnavigation'
version = '3.3'
version = '3.4'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class BezierView : View {
private var bezierInnerWidth = 0f
private var bezierInnerHeight = 0f
private val shadowHeight = dipf(context, 35) // this height will change bottomnavigation bg height
private val reverseCurveHeight = dipf(context, 10) // this will change bottomnavigation bg height reverse

var color = 0
set(value) {
Expand Down Expand Up @@ -90,6 +91,11 @@ class BezierView : View {
}
}

var isReverseCurve = false
set(value) {
field = value
invalidate()
}

@SuppressLint("NewApi")
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
Expand Down Expand Up @@ -203,12 +209,13 @@ class BezierView : View {

private fun calculateInner() {
val extra = shadowHeight
val pickHeight = if(isReverseCurve) (height - reverseCurveHeight) else (height - extra) / waveHeight
innerArray[0] = PointF(0f, bezierInnerHeight + extra)
innerArray[1] = PointF((bezierX - bezierInnerWidth / 2), bezierInnerHeight + extra)
innerArray[2] = PointF(bezierX - bezierInnerWidth / 4, bezierInnerHeight + extra)
innerArray[3] = PointF(bezierX - bezierInnerWidth / 4, (height - extra) / waveHeight)
innerArray[4] = PointF(bezierX, (height - extra) / waveHeight)
innerArray[5] = PointF(bezierX + bezierInnerWidth / 4, (height - extra) / waveHeight)
innerArray[3] = PointF(bezierX - bezierInnerWidth / 4, pickHeight)
innerArray[4] = PointF(bezierX, pickHeight)
innerArray[5] = PointF(bezierX + bezierInnerWidth / 4, pickHeight)
innerArray[6] = PointF(bezierX + bezierInnerWidth / 4, bezierInnerHeight + extra)
innerArray[7] = PointF(bezierX + bezierInnerWidth / 2, bezierInnerHeight + extra)
innerArray[8] = PointF(width, bezierInnerHeight + extra)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ class SSCustomBottomNavigation : FrameLayout {
updateAllIfAllowDraw()
}

var isReverseCurve = false
set(value) {
field = value
updateAllIfAllowDraw()
}

fun setSelectedIndex(activeIndex: Int = 0) {
selectedIndex = activeIndex
}
Expand Down Expand Up @@ -206,6 +212,8 @@ class SSCustomBottomNavigation : FrameLayout {
).toFloat()
waveHeight =
getInteger(R.styleable.SSCustomBottomNavigation_ss_waveHeight, waveHeight)

isReverseCurve = getBoolean(R.styleable.SSCustomBottomNavigation_ss_reverseCurve, isReverseCurve)
val iconTextTypeFace =
getString(R.styleable.SSCustomBottomNavigation_ss_iconTextTypeface)
if (iconTextTypeFace != null && iconTextTypeFace.isNotEmpty())
Expand Down Expand Up @@ -242,6 +250,7 @@ class SSCustomBottomNavigation : FrameLayout {
layoutParams = LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, (heightCell))
color = backgroundBottomColor
shadowColor = this@SSCustomBottomNavigation.shadowColor
isReverseCurve = this@SSCustomBottomNavigation.isReverseCurve
}
bezierView.waveHeight = waveHeight

Expand Down
1 change: 1 addition & 0 deletions custombottomnavigation/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<attr name="ss_countTypeface" format="string" />
<attr name="ss_rippleColor" format="color" />
<attr name="ss_shadowColor" format="color" />
<attr name="ss_reverseCurve" format="boolean" />
</declare-styleable>

</resources>
Binary file added images/custom_bottom_navigation_revese.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 43fd772

Please sign in to comment.