Skip to content

Commit 8c2b511

Browse files
afohrmanraajkumars
authored andcommitted
[Adaptive][Side Sheet] Modularized side sheet demo.
PiperOrigin-RevId: 502905537
1 parent f2269bc commit 8c2b511

File tree

3 files changed

+85
-60
lines changed

3 files changed

+85
-60
lines changed

catalog/java/io/material/catalog/sidesheet/SideSheetMainDemoFragment.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import io.material.catalog.windowpreferences.WindowPreferencesManager;
4343

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

4747
@Nullable private CatalogPreferencesHelper catalogPreferencesHelper;
4848

@@ -61,6 +61,10 @@ public View onCreateDemoView(
6161
@Nullable ViewGroup viewGroup,
6262
@Nullable Bundle bundle) {
6363
View view = layoutInflater.inflate(getDemoContent(), viewGroup, false /* attachToRoot */);
64+
65+
ViewGroup sideSheetsContainer = view.findViewById(R.id.cat_sidesheet_coordinator_layout);
66+
View.inflate(getContext(), getSideSheetsContent(), sideSheetsContainer);
67+
6468
setUpToolbar(view);
6569

6670
// Set up standard side sheet.
@@ -247,6 +251,11 @@ int getDemoContent() {
247251
return R.layout.cat_sidesheet_fragment;
248252
}
249253

254+
@LayoutRes
255+
protected int getSideSheetsContent() {
256+
return R.layout.cat_sidesheets;
257+
}
258+
250259
@StyleRes
251260
private int getDetachedModalThemeOverlayResId() {
252261
return R.style.ThemeOverlay_Catalog_SideSheet_Modal_Detached;

catalog/java/io/material/catalog/sidesheet/res/layout/cat_sidesheet_fragment.xml

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
-->
1717
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
1818
xmlns:app="http://schemas.android.com/apk/res-auto"
19-
xmlns:tools="http://schemas.android.com/tools"
2019
android:id="@+id/cat_sidesheet_coordinator_layout"
2120
android:layout_width="match_parent"
2221
android:layout_height="match_parent"
@@ -97,62 +96,4 @@
9796
android:text="@string/cat_sidesheet_filler_text"/>
9897
</LinearLayout>
9998
</androidx.core.widget.NestedScrollView>
100-
101-
<LinearLayout
102-
android:id="@+id/standard_side_sheet_container"
103-
style="@style/Widget.Material3.SideSheet"
104-
android:layout_width="256dp"
105-
android:layout_height="match_parent"
106-
android:orientation="vertical"
107-
app:layout_behavior="@string/side_sheet_behavior"
108-
tools:targetApi="lollipop">
109-
<include layout="@layout/cat_sidesheet_content" />
110-
</LinearLayout>
111-
112-
<LinearLayout
113-
android:id="@+id/standard_detached_side_sheet_container"
114-
style="@style/Widget.Material3.SideSheet.Detached"
115-
android:layout_width="256dp"
116-
android:layout_height="match_parent"
117-
android:orientation="vertical"
118-
app:layout_behavior="@string/side_sheet_behavior"
119-
tools:targetApi="lollipop">
120-
<include layout="@layout/cat_sidesheet_detached_content" />
121-
</LinearLayout>
122-
123-
<LinearLayout
124-
android:id="@+id/vertically_scrolling_side_sheet_container"
125-
style="@style/Widget.Material3.SideSheet"
126-
android:layout_width="256dp"
127-
android:layout_height="match_parent"
128-
android:orientation="vertical"
129-
app:layout_behavior="@string/side_sheet_behavior"
130-
tools:targetApi="lollipop">
131-
<include layout="@layout/cat_sidesheet_content_vertically_scrolling" />
132-
</LinearLayout>
133-
134-
<LinearLayout
135-
android:id="@+id/coplanar_side_sheet_container"
136-
style="@style/Widget.Material3.SideSheet"
137-
android:layout_width="256dp"
138-
android:layout_height="match_parent"
139-
android:orientation="vertical"
140-
app:coplanarSiblingViewId="@id/nested_scroll_view"
141-
app:layout_behavior="@string/side_sheet_behavior"
142-
tools:targetApi="lollipop">
143-
<include layout="@layout/cat_sidesheet_content_coplanar" />
144-
</LinearLayout>
145-
146-
<LinearLayout
147-
android:id="@+id/coplanar_detached_side_sheet_container"
148-
style="@style/Widget.Material3.SideSheet.Detached"
149-
android:layout_width="256dp"
150-
android:layout_height="match_parent"
151-
android:orientation="vertical"
152-
app:coplanarSiblingViewId="@id/nested_scroll_view"
153-
app:layout_behavior="@string/side_sheet_behavior"
154-
tools:targetApi="lollipop">
155-
<include layout="@layout/cat_sidesheet_content_coplanar_detached" />
156-
</LinearLayout>
157-
15899
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="utf-8"?><!--
2+
Copyright 2023 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<merge xmlns:android="http://schemas.android.com/apk/res/android"
17+
xmlns:app="http://schemas.android.com/apk/res-auto"
18+
xmlns:tools="http://schemas.android.com/tools">
19+
<LinearLayout
20+
android:id="@+id/standard_side_sheet_container"
21+
style="@style/Widget.Material3.SideSheet"
22+
android:layout_width="256dp"
23+
android:layout_height="match_parent"
24+
android:orientation="vertical"
25+
app:layout_behavior="@string/side_sheet_behavior"
26+
tools:targetApi="lollipop">
27+
<include layout="@layout/cat_sidesheet_content" />
28+
</LinearLayout>
29+
30+
<LinearLayout
31+
android:id="@+id/standard_detached_side_sheet_container"
32+
style="@style/Widget.Material3.SideSheet.Detached"
33+
android:layout_width="256dp"
34+
android:layout_height="match_parent"
35+
android:orientation="vertical"
36+
app:layout_behavior="@string/side_sheet_behavior"
37+
tools:targetApi="lollipop">
38+
<include layout="@layout/cat_sidesheet_detached_content" />
39+
</LinearLayout>
40+
41+
<LinearLayout
42+
android:id="@+id/vertically_scrolling_side_sheet_container"
43+
style="@style/Widget.Material3.SideSheet"
44+
android:layout_width="256dp"
45+
android:layout_height="match_parent"
46+
android:orientation="vertical"
47+
app:layout_behavior="@string/side_sheet_behavior"
48+
tools:targetApi="lollipop">
49+
<include layout="@layout/cat_sidesheet_content_vertically_scrolling" />
50+
</LinearLayout>
51+
52+
<LinearLayout
53+
android:id="@+id/coplanar_side_sheet_container"
54+
style="@style/Widget.Material3.SideSheet"
55+
android:layout_width="256dp"
56+
android:layout_height="match_parent"
57+
android:orientation="vertical"
58+
app:coplanarSiblingViewId="@id/nested_scroll_view"
59+
app:layout_behavior="@string/side_sheet_behavior"
60+
tools:targetApi="lollipop">
61+
<include layout="@layout/cat_sidesheet_content_coplanar" />
62+
</LinearLayout>
63+
64+
<LinearLayout
65+
android:id="@+id/coplanar_detached_side_sheet_container"
66+
style="@style/Widget.Material3.SideSheet.Detached"
67+
android:layout_width="256dp"
68+
android:layout_height="match_parent"
69+
android:orientation="vertical"
70+
app:coplanarSiblingViewId="@id/nested_scroll_view"
71+
app:layout_behavior="@string/side_sheet_behavior"
72+
tools:targetApi="lollipop">
73+
<include layout="@layout/cat_sidesheet_content_coplanar_detached" />
74+
</LinearLayout>
75+
</merge>

0 commit comments

Comments
 (0)