Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fixes #43, #44 & Updated code formation with Readme file updated for version bump #45

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Reverse Curve

```
dependencies {
implementation 'com.github.simformsolutions:SSCustomBottomNavigation:3.4'
implementation 'com.github.simformsolutions:SSCustomBottomNavigation:3.5'
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ class BezierView : View {

override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
mainPath!!.reset()
shadowPath!!.reset()
mainPath?.reset()
shadowPath?.reset()

if (progress == 0f) {
drawInner(canvas, true)
Expand All @@ -193,18 +193,22 @@ class BezierView : View {
color = [email protected]
}
calculateInner()

path!!.lineTo(innerArray[0].x, innerArray[0].y)
path.lineTo(innerArray[1].x, innerArray[1].y)
path.cubicTo(innerArray[2].x, innerArray[2].y, innerArray[3].x, innerArray[3].y, innerArray[4].x, innerArray[4].y)
path.cubicTo(innerArray[5].x, innerArray[5].y, innerArray[6].x, innerArray[6].y, innerArray[7].x, innerArray[7].y)
path.lineTo(innerArray[8].x, innerArray[8].y)
path.lineTo(innerArray[9].x, innerArray[9].y)
path.lineTo(innerArray[10].x, innerArray[10].y)
path?.apply {
lineTo(innerArray[0].x, innerArray[0].y)
lineTo(innerArray[1].x, innerArray[1].y)
cubicTo(innerArray[2].x, innerArray[2].y, innerArray[3].x, innerArray[3].y, innerArray[4].x, innerArray[4].y)
cubicTo(innerArray[5].x, innerArray[5].y, innerArray[6].x, innerArray[6].y, innerArray[7].x, innerArray[7].y)
lineTo(innerArray[8].x, innerArray[8].y)
lineTo(innerArray[9].x, innerArray[9].y)
lineTo(innerArray[10].x, innerArray[10].y)
}

progressArray = innerArray.clone()

canvas.drawPath(path, paint!!)
path?.let { it1 ->
paint?.let { it2 ->
canvas.drawPath(it1, it2)
}
}
}

private fun calculateInner() {
Expand All @@ -226,16 +230,21 @@ class BezierView : View {
private fun drawProgress(canvas: Canvas, isShadow: Boolean) {
val paint = if (isShadow) shadowPaint else mainPaint
val path = if (isShadow) shadowPath else mainPath
path?.apply {
lineTo(progressArray[0].x, progressArray[0].y)
lineTo(progressArray[1].x, progressArray[1].y)
cubicTo(progressArray[2].x, progressArray[2].y, progressArray[3].x, progressArray[3].y, progressArray[4].x, progressArray[4].y)
cubicTo(progressArray[5].x, progressArray[5].y, progressArray[6].x, progressArray[6].y, progressArray[7].x, progressArray[7].y)
lineTo(progressArray[8].x, progressArray[8].y)
lineTo(progressArray[9].x, progressArray[9].y)
lineTo(progressArray[10].x, progressArray[10].y)
}
path?.let { it1 ->
paint?.let { it2 ->
canvas.drawPath(it1, it2)
}
}

path!!.lineTo(progressArray[0].x, progressArray[0].y)
path.lineTo(progressArray[1].x, progressArray[1].y)
path.cubicTo(progressArray[2].x, progressArray[2].y, progressArray[3].x, progressArray[3].y, progressArray[4].x, progressArray[4].y)
path.cubicTo(progressArray[5].x, progressArray[5].y, progressArray[6].x, progressArray[6].y, progressArray[7].x, progressArray[7].y)
path.lineTo(progressArray[8].x, progressArray[8].y)
path.lineTo(progressArray[9].x, progressArray[9].y)
path.lineTo(progressArray[10].x, progressArray[10].y)

canvas.drawPath(path, paint!!)
}

private fun calculate(start: Float, end: Float): Float {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ class CustomBottomNavigationIcon : RelativeLayout, LayoutContainer {
set(value) {
field = value
if (allowDraw && field != null)
tv_count.typeface = field
field?.let {
tv_count.typeface = it
}
}

var rippleColor = 0
Expand All @@ -170,18 +172,6 @@ class CustomBottomNavigationIcon : RelativeLayout, LayoutContainer {
val scale = (1f - progress) * (-0.2f) + 1f
iv.scaleX = scale
iv.scaleY = scale

/*val d = GradientDrawable()
d.setColor(circleColor)
d.shape = GradientDrawable.OVAL

ViewCompat.setBackground(v_circle, d)

ViewCompat.setElevation(v_circle, if (progress > 0.7f) dipf(context, progress * 4f) else 0f)

val m = dip(context, 24)
v_circle.x = (1f - progress) * (if (isFromLeft) -m else m) + ((measuredWidth - dip(context, 48)) / 2f)
v_circle.y = (1f - progress) * measuredHeight + dip(context, 6)*/
}

var isEnabledCell = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import android.content.Context
import android.graphics.Color
import android.graphics.Typeface
import android.os.Build
import android.text.TextUtils
import android.util.AttributeSet
import android.util.LayoutDirection
import android.util.Log
import android.view.Gravity
import android.view.inputmethod.InputMethodManager
import android.widget.FrameLayout
import android.widget.LinearLayout
import androidx.annotation.IdRes
Expand All @@ -23,6 +25,7 @@ import androidx.navigation.NavController
import androidx.navigation.NavDestination
import androidx.navigation.NavGraph
import androidx.navigation.NavOptions
import com.google.android.material.internal.ContextUtils.getActivity
import kotlin.math.abs

internal typealias IBottomNavigationListener = (model: Model) -> Unit
Expand Down Expand Up @@ -216,17 +219,17 @@ class SSCustomBottomNavigation : FrameLayout {
isReverseCurve = getBoolean(R.styleable.SSCustomBottomNavigation_ss_reverseCurve, isReverseCurve)
val iconTextTypeFace =
getString(R.styleable.SSCustomBottomNavigation_ss_iconTextTypeface)
if (iconTextTypeFace != null && iconTextTypeFace.isNotEmpty())
if (TextUtils.isEmpty(iconTextTypeFace))
iconTextTypeface = Typeface.createFromAsset(context.assets, iconTextTypeFace)

val typeface = getString(R.styleable.SSCustomBottomNavigation_ss_countTypeface)
if (typeface != null && typeface.isNotEmpty())
if (TextUtils.isEmpty(typeface))
countTypeface = Typeface.createFromAsset(context.assets, typeface)

val drawable =
a.getDrawable(R.styleable.SSCustomBottomNavigation_ss_backgroundBottomDrawable)
if (drawable != null) {
backgroundBottomDrawable = drawable
drawable?.let {
backgroundBottomDrawable = it
}
}
} finally {
Expand Down Expand Up @@ -270,7 +273,8 @@ class SSCustomBottomNavigation : FrameLayout {
}
if (selectedIndex != -1) {
Log.e("selectedIndex", " $selectedIndex")
show(selectedIndex, false)
val imm: InputMethodManager = getActivity(context)?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
if (!imm.isAcceptingText) show(selectedIndex, false)
}
}

Expand Down Expand Up @@ -378,7 +382,9 @@ class SSCustomBottomNavigation : FrameLayout {
private fun matchDestination(destination: NavDestination, @IdRes destinationId: Int): Boolean {
var currentDestination = destination
while (currentDestination.id != destinationId && currentDestination.parent != null) {
currentDestination = currentDestination.parent!!
currentDestination.parent?.let {
currentDestination = it
}
}

return currentDestination.id == destinationId
Expand All @@ -389,7 +395,9 @@ class SSCustomBottomNavigation : FrameLayout {
private fun findStartDestination(graph: NavGraph): NavDestination {
var startDestination: NavDestination = graph
while (startDestination is NavGraph) {
startDestination = graph.findNode(graph.startDestinationId)!!
graph.findNode(graph.startDestinationId)?.let {
startDestination = it
}
}

return startDestination
Expand Down Expand Up @@ -513,10 +521,10 @@ class SSCustomBottomNavigation : FrameLayout {
val model = models[i]
val cell = cells[i]
if (model.id == id) {
anim(cell, id, enableAnimation)
cell.enableCell()
onShowListener(model)
menuItemClickListener?.invoke(cbnMenuItems[i], i)
anim(cell, id, enableAnimation)
cell.enableCell()
} else {
cell.disableCell()
}
Expand Down