Skip to content

Commit

Permalink
[Side Sheet] Renamed private references of "origin" to "inner" in She…
Browse files Browse the repository at this point in the history
…etDelegate and related delegate classes.

PiperOrigin-RevId: 529193878
  • Loading branch information
afohrman authored and hunterstich committed May 4, 2023
1 parent 1c27404 commit ad9ad20
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,26 @@ int getSheetEdge() {
return SideSheetBehavior.EDGE_LEFT;
}

/** Returns the sheet's offset in pixels from the origin edge when hidden. */
/** Returns the sheet's offset in pixels from the inner edge when hidden. */
@Override
int getHiddenOffset() {
// Return the parent's width in pixels, which results in the sheet being offset entirely off of
// screen.
return -sheetBehavior.getChildWidth() - sheetBehavior.getInnerMargin();
}

/** Returns the sheet's offset in pixels from the origin edge when expanded. */
/** Returns the sheet's offset in pixels from the inner edge when expanded. */
@Override
int getExpandedOffset() {
// Calculate the expanded offset based on the width of the content.
return max(0, sheetBehavior.getParentInnerEdge() + sheetBehavior.getInnerMargin());
}

/** Whether the view has been released from a drag close to the origin edge. */
/** Whether the view has been released from a drag close to the inner edge. */
@Override
boolean isReleasedCloseToOriginEdge(@NonNull View releasedChild) {
// To be considered released close to the origin (left) edge, the released child's right must
// be at least halfway to the origin (left) edge of the screen.
boolean isReleasedCloseToInnerEdge(@NonNull View releasedChild) {
// To be considered released close to the inner (left) edge, the released child's right must
// be at least halfway to the inner (left) edge of the screen.
return releasedChild.getRight() < (getExpandedOffset() - getHiddenOffset()) / 2;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,27 @@ int getSheetEdge() {
return SideSheetBehavior.EDGE_RIGHT;
}

/** Returns the sheet's offset in pixels from the origin edge when hidden. */
/** Returns the sheet's offset in pixels from the inner edge when hidden. */
@Override
int getHiddenOffset() {
// Return the parent's width in pixels, which results in the sheet being offset entirely off of
// screen.
return sheetBehavior.getParentWidth();
}

/** Returns the sheet's offset in pixels from the origin edge when expanded. */
/** Returns the sheet's offset in pixels from the inner edge when expanded. */
@Override
int getExpandedOffset() {
// Calculate the expanded offset based on the width of the content.
return max(
0, getHiddenOffset() - sheetBehavior.getChildWidth() - sheetBehavior.getInnerMargin());
}

/** Whether the view has been released from a drag close to the origin edge. */
/** Whether the view has been released from a drag close to the inner edge. */
@Override
boolean isReleasedCloseToOriginEdge(@NonNull View releasedChild) {
// To be considered released close to the origin (right) edge, the released child's left must
// be at least halfway to the origin (right) edge of the screen.
boolean isReleasedCloseToInnerEdge(@NonNull View releasedChild) {
// To be considered released close to the inner (right) edge, the released child's left must
// be at least halfway to the inner (right) edge of the screen.
return releasedChild.getLeft() > (getHiddenOffset() + getExpandedOffset()) / 2;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ abstract class SheetDelegate {
@SheetEdge
abstract int getSheetEdge();

/** Returns the sheet's offset from the origin edge when hidden. */
/** Returns the sheet's offset from the inner edge when hidden. */
abstract int getHiddenOffset();

/** Returns the sheet's offset from the origin edge when expanded. */
/** Returns the sheet's offset from the inner edge when expanded. */
abstract int getExpandedOffset();

/** Whether the view has been released from a drag close to the origin edge. */
abstract boolean isReleasedCloseToOriginEdge(@NonNull View releasedChild);
/** Whether the view has been released from a drag close to the inner edge. */
abstract boolean isReleasedCloseToInnerEdge(@NonNull View releasedChild);

abstract boolean isSwipeSignificant(float xVelocity, float yVelocity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ private float calculateDragDistance(float initialPoint, float currentPoint) {
}

/**
* Returns the sheet's offset from the origin edge when expanded. It will calculate the offset
* Returns the sheet's offset from the inner edge when expanded. It will calculate the offset
* based on the width of the content.
*/
public int getExpandedOffset() {
Expand Down Expand Up @@ -859,10 +859,10 @@ private int calculateTargetStateOnViewReleased(
targetState = STATE_EXPANDED;

} else if (shouldHide(releasedChild, xVelocity)) {
// Hide if the view was either released close to the origin/right edge or it was a significant
// Hide if the view was either released close to the inner edge or it was a significant
// horizontal swipe; otherwise settle to expanded state.
if (sheetDelegate.isSwipeSignificant(xVelocity, yVelocity)
|| sheetDelegate.isReleasedCloseToOriginEdge(releasedChild)) {
|| sheetDelegate.isReleasedCloseToInnerEdge(releasedChild)) {
targetState = STATE_HIDDEN;
} else {
targetState = STATE_EXPANDED;
Expand Down

0 comments on commit ad9ad20

Please sign in to comment.