Skip to content

Commit 5ba704a

Browse files
afohrmanleticiarossi
authored andcommitted
[Predictive Back] [Side Sheet] Added updateBackProgress() predictive back support for coplanar side sheets.
Before this change, coplanar sheets responded to the sheet during finishBackProgress(), in handleBackInvoked(). After this change, coplanar sheets respond to the back progress while the predictive back event is in progress, in updateBackProgress(). PiperOrigin-RevId: 528470353
1 parent b984e64 commit 5ba704a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lib/java/com/google/android/material/sidesheet/SideSheetBehavior.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,31 @@ public void updateBackProgress(@NonNull BackEvent backEvent) {
991991
return;
992992
}
993993
sideContainerBackHelper.updateBackProgress(backEvent, getGravityFromSheetEdge());
994+
995+
updateCoplanarSiblingBackProgress();
996+
}
997+
998+
private void updateCoplanarSiblingBackProgress() {
999+
if (viewRef == null || viewRef.get() == null) {
1000+
return;
1001+
}
1002+
View sheet = viewRef.get();
1003+
1004+
View coplanarSiblingView = getCoplanarSiblingView();
1005+
if (coplanarSiblingView == null) {
1006+
return;
1007+
}
1008+
1009+
MarginLayoutParams coplanarSiblingLayoutParams =
1010+
(MarginLayoutParams) coplanarSiblingView.getLayoutParams();
1011+
if (coplanarSiblingLayoutParams == null) {
1012+
return;
1013+
}
1014+
1015+
int updatedCoplanarSiblingAdjacentMargin = (int) (childWidth * sheet.getScaleX() + innerMargin);
1016+
sheetDelegate.updateCoplanarSiblingAdjacentMargin(
1017+
coplanarSiblingLayoutParams, updatedCoplanarSiblingAdjacentMargin);
1018+
coplanarSiblingView.requestLayout();
9941019
}
9951020

9961021
@Override

0 commit comments

Comments
 (0)