Skip to content

Commit

Permalink
[Adaptive][Side Sheet] Modularized side sheet demo.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 502905537
  • Loading branch information
afohrman authored and raajkumars committed Jan 19, 2023
1 parent f2269bc commit 8c2b511
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import io.material.catalog.windowpreferences.WindowPreferencesManager;

/** A fragment that displays the main Side Sheet demo for the Catalog app. */
public final class SideSheetMainDemoFragment extends DemoFragment {
public class SideSheetMainDemoFragment extends DemoFragment {

@Nullable private CatalogPreferencesHelper catalogPreferencesHelper;

Expand All @@ -61,6 +61,10 @@ public View onCreateDemoView(
@Nullable ViewGroup viewGroup,
@Nullable Bundle bundle) {
View view = layoutInflater.inflate(getDemoContent(), viewGroup, false /* attachToRoot */);

ViewGroup sideSheetsContainer = view.findViewById(R.id.cat_sidesheet_coordinator_layout);
View.inflate(getContext(), getSideSheetsContent(), sideSheetsContainer);

setUpToolbar(view);

// Set up standard side sheet.
Expand Down Expand Up @@ -247,6 +251,11 @@ int getDemoContent() {
return R.layout.cat_sidesheet_fragment;
}

@LayoutRes
protected int getSideSheetsContent() {
return R.layout.cat_sidesheets;
}

@StyleRes
private int getDetachedModalThemeOverlayResId() {
return R.style.ThemeOverlay_Catalog_SideSheet_Modal_Detached;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
-->
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/cat_sidesheet_coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down Expand Up @@ -97,62 +96,4 @@
android:text="@string/cat_sidesheet_filler_text"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

<LinearLayout
android:id="@+id/standard_side_sheet_container"
style="@style/Widget.Material3.SideSheet"
android:layout_width="256dp"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/side_sheet_behavior"
tools:targetApi="lollipop">
<include layout="@layout/cat_sidesheet_content" />
</LinearLayout>

<LinearLayout
android:id="@+id/standard_detached_side_sheet_container"
style="@style/Widget.Material3.SideSheet.Detached"
android:layout_width="256dp"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/side_sheet_behavior"
tools:targetApi="lollipop">
<include layout="@layout/cat_sidesheet_detached_content" />
</LinearLayout>

<LinearLayout
android:id="@+id/vertically_scrolling_side_sheet_container"
style="@style/Widget.Material3.SideSheet"
android:layout_width="256dp"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/side_sheet_behavior"
tools:targetApi="lollipop">
<include layout="@layout/cat_sidesheet_content_vertically_scrolling" />
</LinearLayout>

<LinearLayout
android:id="@+id/coplanar_side_sheet_container"
style="@style/Widget.Material3.SideSheet"
android:layout_width="256dp"
android:layout_height="match_parent"
android:orientation="vertical"
app:coplanarSiblingViewId="@id/nested_scroll_view"
app:layout_behavior="@string/side_sheet_behavior"
tools:targetApi="lollipop">
<include layout="@layout/cat_sidesheet_content_coplanar" />
</LinearLayout>

<LinearLayout
android:id="@+id/coplanar_detached_side_sheet_container"
style="@style/Widget.Material3.SideSheet.Detached"
android:layout_width="256dp"
android:layout_height="match_parent"
android:orientation="vertical"
app:coplanarSiblingViewId="@id/nested_scroll_view"
app:layout_behavior="@string/side_sheet_behavior"
tools:targetApi="lollipop">
<include layout="@layout/cat_sidesheet_content_coplanar_detached" />
</LinearLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2023 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:id="@+id/standard_side_sheet_container"
style="@style/Widget.Material3.SideSheet"
android:layout_width="256dp"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/side_sheet_behavior"
tools:targetApi="lollipop">
<include layout="@layout/cat_sidesheet_content" />
</LinearLayout>

<LinearLayout
android:id="@+id/standard_detached_side_sheet_container"
style="@style/Widget.Material3.SideSheet.Detached"
android:layout_width="256dp"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/side_sheet_behavior"
tools:targetApi="lollipop">
<include layout="@layout/cat_sidesheet_detached_content" />
</LinearLayout>

<LinearLayout
android:id="@+id/vertically_scrolling_side_sheet_container"
style="@style/Widget.Material3.SideSheet"
android:layout_width="256dp"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/side_sheet_behavior"
tools:targetApi="lollipop">
<include layout="@layout/cat_sidesheet_content_vertically_scrolling" />
</LinearLayout>

<LinearLayout
android:id="@+id/coplanar_side_sheet_container"
style="@style/Widget.Material3.SideSheet"
android:layout_width="256dp"
android:layout_height="match_parent"
android:orientation="vertical"
app:coplanarSiblingViewId="@id/nested_scroll_view"
app:layout_behavior="@string/side_sheet_behavior"
tools:targetApi="lollipop">
<include layout="@layout/cat_sidesheet_content_coplanar" />
</LinearLayout>

<LinearLayout
android:id="@+id/coplanar_detached_side_sheet_container"
style="@style/Widget.Material3.SideSheet.Detached"
android:layout_width="256dp"
android:layout_height="match_parent"
android:orientation="vertical"
app:coplanarSiblingViewId="@id/nested_scroll_view"
app:layout_behavior="@string/side_sheet_behavior"
tools:targetApi="lollipop">
<include layout="@layout/cat_sidesheet_content_coplanar_detached" />
</LinearLayout>
</merge>

0 comments on commit 8c2b511

Please sign in to comment.