Skip to content

Commit

Permalink
[Side Sheet] Fixed modal sheet text field formatting bug in catalog.
Browse files Browse the repository at this point in the history
Before this change, the modal sheet is initially expanded with a "%f" for the slide offset text and the state TextView doesn't change until the first drag of the sheet.

There was actually no underlying side sheet bug here; the modal sheet has two ways of animating, window animations and the "native" SideSheetBehavior ViewDragHelper animations. In the catalog, the modal sheet's text views weren't getting set yet because it was using the window animations to enter/exit and the callback doesn't run until it's dragged with SideSheetBehavior's ViewDragHelper. The only change necessary here is to set the TextViews to Visibility#GONE until the callback runs, so that there are no uninitialized TextViews visible on screen.

Resolves #3167.

PiperOrigin-RevId: 529220073
  • Loading branch information
afohrman authored and hunterstich committed May 4, 2023
1 parent ad9ad20 commit 87a45a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,12 @@ public boolean shouldShowDefaultDemoActionBar() {
}

private SideSheetCallback createSideSheetCallback(
TextView stateTextView, TextView slideOffsetTextView) {
@NonNull TextView stateTextView, @NonNull TextView slideOffsetTextView) {
return new SideSheetCallback() {
@Override
public void onStateChanged(@NonNull View sheet, int newState) {
stateTextView.setVisibility(View.VISIBLE);

switch (newState) {
case SideSheetBehavior.STATE_DRAGGING:
stateTextView.setText(R.string.cat_sidesheet_state_dragging);
Expand All @@ -393,6 +395,7 @@ public void onStateChanged(@NonNull View sheet, int newState) {

@Override
public void onSlide(@NonNull View sheet, float slideOffset) {
slideOffsetTextView.setVisibility(View.VISIBLE);
slideOffsetTextView.setText(
getResources().getString(R.string.cat_sidesheet_slide_offset_text, slideOffset));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
android:layout_height="wrap_content"
android:text="@string/cat_sidesheet_state_settling"
android:textAppearance="?attr/textAppearanceHeadlineSmall"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/side_sheet_title_text" />
Expand All @@ -61,6 +62,7 @@
android:layout_height="wrap_content"
android:text="@string/cat_sidesheet_slide_offset_text"
android:textAppearance="?attr/textAppearanceHeadlineSmall"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/side_sheet_state_text" />
Expand Down

0 comments on commit 87a45a2

Please sign in to comment.