Skip to content

Commit 541433b

Browse files
afohrmanpekingme
authored andcommitted
[Floating Toolbar] Add initial catalog demo for Floating Toolbar.
PiperOrigin-RevId: 686112314
1 parent 7f01739 commit 541433b

File tree

6 files changed

+169
-0
lines changed

6 files changed

+169
-0
lines changed

catalog/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def srcDirs = [
7575
'imageview',
7676
'fab',
7777
'feature',
78+
'floatingappbar',
7879
'font',
7980
'internal',
8081
'loadingindicator',
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright 2024 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+
package io.material.catalog.floatingappbar;
17+
18+
import io.material.catalog.R;
19+
20+
import androidx.fragment.app.Fragment;
21+
import androidx.annotation.NonNull;
22+
import dagger.Provides;
23+
import dagger.android.ContributesAndroidInjector;
24+
import dagger.multibindings.IntoSet;
25+
import io.material.catalog.application.scope.ActivityScope;
26+
import io.material.catalog.application.scope.FragmentScope;
27+
import io.material.catalog.feature.Demo;
28+
import io.material.catalog.feature.DemoLandingFragment;
29+
import io.material.catalog.feature.FeatureDemo;
30+
31+
/** A fragment that displays Floating App Bar demos for the Catalog app. */
32+
public class FloatingAppBarFragment extends DemoLandingFragment {
33+
@Override
34+
public int getTitleResId() {
35+
return R.string.cat_floating_app_bar_title;
36+
}
37+
38+
@Override
39+
public int getDescriptionResId() {
40+
return R.string.cat_floating_app_bar_description;
41+
}
42+
43+
@Override
44+
@NonNull
45+
public Demo getMainDemo() {
46+
return new Demo() {
47+
@Override
48+
public Fragment createFragment() {
49+
return new FloatingAppBarMainDemoFragment();
50+
}
51+
};
52+
}
53+
54+
/** The Dagger module for {@link FloatingAppBarFragment} dependencies. */
55+
@dagger.Module
56+
public abstract static class Module {
57+
@FragmentScope
58+
@ContributesAndroidInjector
59+
abstract FloatingAppBarFragment contributeInjector();
60+
61+
@IntoSet
62+
@Provides
63+
@ActivityScope
64+
static FeatureDemo provideFeatureDemo() {
65+
return new FeatureDemo(R.string.cat_floating_app_bar_title, R.drawable.ic_sliders_24px) {
66+
@Override
67+
public Fragment createFragment() {
68+
return new FloatingAppBarFragment();
69+
}
70+
};
71+
}
72+
}
73+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2024 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+
package io.material.catalog.floatingappbar;
17+
18+
import io.material.catalog.R;
19+
20+
import android.os.Bundle;
21+
import android.view.LayoutInflater;
22+
import android.view.View;
23+
import android.view.ViewGroup;
24+
import androidx.annotation.NonNull;
25+
import androidx.annotation.Nullable;
26+
import io.material.catalog.feature.DemoFragment;
27+
28+
/** A fragment that displays the main Floating App Bar demos for the Catalog app. */
29+
public class FloatingAppBarMainDemoFragment extends DemoFragment {
30+
31+
@NonNull
32+
@Override
33+
public View onCreateDemoView(
34+
@NonNull LayoutInflater layoutInflater,
35+
@Nullable ViewGroup viewGroup,
36+
@Nullable Bundle bundle) {
37+
38+
return layoutInflater.inflate(
39+
R.layout.cat_floating_app_bar_fragment, viewGroup, false /* attachToRoot */);
40+
}
41+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2024 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:layout_width="match_parent"
19+
android:layout_height="match_parent">
20+
21+
<TextView
22+
android:layout_width="wrap_content"
23+
android:layout_height="wrap_content"
24+
android:text="@string/cat_floating_app_bar_title" />
25+
26+
</FrameLayout>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2024 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<resources>
18+
<string name="cat_floating_app_bar_title"
19+
description="Title for the screen that showcases demonstrative usages of the Floating App Bar widget [CHAR LIMIT=NONE]">
20+
Floating App Bar
21+
</string>
22+
<string name="cat_floating_app_bar_description"
23+
description="Body text describing the Floating App Bar component within the design system [CHAR LIMIT=NONE]">
24+
The floating toolbar floats above the body content and can be used to display contextual actions relevant to the body content or the specific page.
25+
</string>
26+
</resources>

catalog/java/io/material/catalog/tableofcontents/TocModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import io.material.catalog.divider.DividerFragment;
3535
import io.material.catalog.elevation.ElevationFragment;
3636
import io.material.catalog.fab.FabFragment;
37+
import io.material.catalog.floatingappbar.FloatingAppBarFragment;
3738
import io.material.catalog.font.FontFragment;
3839
import io.material.catalog.imageview.ShapeableImageViewFragment;
3940
import io.material.catalog.loadingindicator.LoadingIndicatorFragment;
@@ -72,6 +73,7 @@
7273
DividerFragment.Module.class,
7374
ElevationFragment.Module.class,
7475
FabFragment.Module.class,
76+
FloatingAppBarFragment.Module.class,
7577
FontFragment.Module.class,
7678
LoadingIndicatorFragment.Module.class,
7779
MenuFragment.Module.class,

0 commit comments

Comments
 (0)