From ff89b3589717cbcfd72b169424d9d787bc1c3ef9 Mon Sep 17 00:00:00 2001 From: Teodor G Date: Tue, 15 Jun 2021 22:30:58 +0300 Subject: [PATCH] added method to set the top corners radius only for the bottom sheet --- .../material/elements/bottomsheet/BottomDrawer.java | 4 ++-- .../material/elements/shape/MaterialShapeDrawable.java | 7 +++++++ .../material/elements/shape/ShapeAppearanceModel.java | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/material-elements/java/com/zeoflow/material/elements/bottomsheet/BottomDrawer.java b/material-elements/java/com/zeoflow/material/elements/bottomsheet/BottomDrawer.java index c2d4a841..f19aaf7a 100644 --- a/material-elements/java/com/zeoflow/material/elements/bottomsheet/BottomDrawer.java +++ b/material-elements/java/com/zeoflow/material/elements/bottomsheet/BottomDrawer.java @@ -221,10 +221,10 @@ public void setHeaderData(@Nullable View headerRoot, int headerSize) { public void setSubmenuCorners(int submenuCorners) { if (marginSubHeader == 0) { - subContainerBackground.setCornerSize(0); + subContainerBackground.setTopCornerSize(0); return; } - subContainerBackground.setCornerSize(submenuCorners); + subContainerBackground.setTopCornerSize(submenuCorners); } public void addRootView(@NonNull View rootView) { diff --git a/material-elements/java/com/zeoflow/material/elements/shape/MaterialShapeDrawable.java b/material-elements/java/com/zeoflow/material/elements/shape/MaterialShapeDrawable.java index 9de2ce46..c685c774 100644 --- a/material-elements/java/com/zeoflow/material/elements/shape/MaterialShapeDrawable.java +++ b/material-elements/java/com/zeoflow/material/elements/shape/MaterialShapeDrawable.java @@ -460,6 +460,13 @@ public void setCornerSize(float cornerSize) { setShapeAppearanceModel(drawableState.shapeAppearanceModel.withCornerSize(cornerSize)); } + /** + * Updates the corners for the given {@link CornerSize}. + */ + public void setTopCornerSize(float cornerSize) { + setShapeAppearanceModel(drawableState.shapeAppearanceModel.withTopCornerSize(cornerSize)); + } + /** * Updates the corners for the given {@link CornerSize}. */ diff --git a/material-elements/java/com/zeoflow/material/elements/shape/ShapeAppearanceModel.java b/material-elements/java/com/zeoflow/material/elements/shape/ShapeAppearanceModel.java index d1307669..f6dcc253 100644 --- a/material-elements/java/com/zeoflow/material/elements/shape/ShapeAppearanceModel.java +++ b/material-elements/java/com/zeoflow/material/elements/shape/ShapeAppearanceModel.java @@ -393,6 +393,12 @@ public ShapeAppearanceModel withCornerSize(float cornerSize) return toBuilder().setAllCornerSizes(cornerSize).build(); } + @NonNull + public ShapeAppearanceModel withTopCornerSize(float cornerSize) + { + return toBuilder().setTopLeftCornerSize(cornerSize).setTopRightCornerSize(cornerSize).build(); + } + @NonNull public ShapeAppearanceModel withCornerSize(@NonNull CornerSize cornerSize) {