Skip to content

Commit

Permalink
Fix elevation over view size is shown ugly on PressedShape only (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
fornewid committed May 7, 2020
1 parent a800728 commit 5a249b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import soup.neumorphism.NeumorphShapeDrawable.NeumorphShapeDrawableState
import soup.neumorphism.internal.util.onCanvas
import soup.neumorphism.internal.util.withClip
import soup.neumorphism.internal.util.withTranslation
import kotlin.math.min

internal class PressedShape(
private var drawableState: NeumorphShapeDrawableState
Expand Down Expand Up @@ -47,10 +48,12 @@ internal class PressedShape(
shape = GradientDrawable.OVAL
}
CornerFamily.ROUNDED -> {
val cornerSize = min(
min(w / 2f, h / 2f),
drawableState.shapeAppearanceModel.getCornerSize()
)
shape = GradientDrawable.RECTANGLE
cornerRadii = drawableState.shapeAppearanceModel.getCornerSize().let {
floatArrayOf(0f, 0f, 0f, 0f, it, it, 0f, 0f)
}
cornerRadii = floatArrayOf(0f, 0f, 0f, 0f, cornerSize, cornerSize, 0f, 0f)
}
}
}
Expand All @@ -63,10 +66,12 @@ internal class PressedShape(
shape = GradientDrawable.OVAL
}
CornerFamily.ROUNDED -> {
val cornerSize = min(
min(w / 2f, h / 2f),
drawableState.shapeAppearanceModel.getCornerSize()
)
shape = GradientDrawable.RECTANGLE
cornerRadii = drawableState.shapeAppearanceModel.getCornerSize().let {
floatArrayOf(it, it, 0f, 0f, 0f, 0f, 0f, 0f)
}
cornerRadii = floatArrayOf(cornerSize, cornerSize, 0f, 0f, 0f, 0f, 0f, 0f)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion neumorphism/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

<style name="ShapeAppearance.Neumorph.CardView" parent="">
<item name="neumorph_cornerFamily">rounded</item>
<item name="neumorph_cornerSize">24dp</item>
<item name="neumorph_cornerSize">36dp</item>
</style>

<style name="ShapeAppearance.Neumorph.FAB" parent="">
Expand Down

0 comments on commit 5a249b6

Please sign in to comment.