Skip to content

Commit 1a7d27c

Browse files
committed
add SettingsListItem to ADS
I think this is worth having on the ADS screen, even if not officially a component. Happy to move it if needs be.
1 parent bc4bb02 commit 1a7d27c

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed

common/common-ui/src/main/java/com/duckduckgo/common/ui/themepreview/ui/component/Component.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ enum class Component {
4444
SECTION_HEADER_LIST_ITEM,
4545
SINGLE_LINE_LIST_ITEM,
4646
TWO_LINE_LIST_ITEM,
47+
SETTINGS_LIST_ITEM,
4748
SECTION_DIVIDER,
4849
}

common/common-ui/src/main/java/com/duckduckgo/common/ui/themepreview/ui/component/ComponentViewHolder.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ sealed class ComponentViewHolder(val view: View) : RecyclerView.ViewHolder(view)
384384
}
385385
}
386386

387+
class SettingsListItemComponentViewHolder(parent: ViewGroup) :
388+
ComponentViewHolder(inflate(parent, R.layout.component_settings))
389+
387390
companion object {
388391
fun create(
389392
parent: ViewGroup,
@@ -408,6 +411,7 @@ sealed class ComponentViewHolder(val view: View) : RecyclerView.ViewHolder(view)
408411
Component.SECTION_DIVIDER -> DividerComponentViewHolder(parent)
409412
Component.CARD -> CardComponentViewHolder(parent)
410413
Component.EXPANDABLE_LAYOUT -> ExpandableComponentViewHolder(parent)
414+
Component.SETTINGS_LIST_ITEM -> SettingsListItemComponentViewHolder(parent)
411415
else -> {
412416
TODO()
413417
}

common/common-ui/src/main/java/com/duckduckgo/common/ui/themepreview/ui/component/listitems/ComponentListItemsElementsFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ import com.duckduckgo.common.ui.themepreview.ui.component.Component
2020
import com.duckduckgo.common.ui.themepreview.ui.component.Component.MENU_ITEM
2121
import com.duckduckgo.common.ui.themepreview.ui.component.Component.POPUP_MENU_ITEM
2222
import com.duckduckgo.common.ui.themepreview.ui.component.Component.SECTION_HEADER_LIST_ITEM
23+
import com.duckduckgo.common.ui.themepreview.ui.component.Component.SETTINGS_LIST_ITEM
2324
import com.duckduckgo.common.ui.themepreview.ui.component.Component.SINGLE_LINE_LIST_ITEM
2425
import com.duckduckgo.common.ui.themepreview.ui.component.Component.TWO_LINE_LIST_ITEM
2526
import com.duckduckgo.common.ui.themepreview.ui.component.ComponentFragment
2627

2728
class ComponentListItemsElementsFragment : ComponentFragment() {
2829
override fun getComponents(): List<Component> {
29-
return listOf(SECTION_HEADER_LIST_ITEM, SINGLE_LINE_LIST_ITEM, TWO_LINE_LIST_ITEM, MENU_ITEM, POPUP_MENU_ITEM)
30+
return listOf(SECTION_HEADER_LIST_ITEM, SINGLE_LINE_LIST_ITEM, TWO_LINE_LIST_ITEM, SETTINGS_LIST_ITEM, MENU_ITEM, POPUP_MENU_ITEM)
3031
}
3132
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="utf-8"?><!--
2+
~ Copyright (c) 2022 DuckDuckGo
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+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
17+
xmlns:app="http://schemas.android.com/apk/res-auto"
18+
android:layout_width="match_parent"
19+
android:layout_height="wrap_content"
20+
android:clipToPadding="false"
21+
android:orientation="vertical">
22+
23+
<com.duckduckgo.common.ui.view.listitem.SectionHeaderListItem
24+
android:id="@+id/label"
25+
android:layout_width="match_parent"
26+
android:layout_height="wrap_content"
27+
app:primaryText="Settings List Item" />
28+
29+
<com.duckduckgo.common.ui.view.listitem.SettingsListItem
30+
android:id="@+id/settingsListItemWithIcon"
31+
android:layout_width="match_parent"
32+
android:layout_height="wrap_content"
33+
app:leadingIcon="@drawable/ic_dax_icon"
34+
app:primaryText="Settings List Item" />
35+
36+
<com.duckduckgo.common.ui.view.listitem.SettingsListItem
37+
android:id="@+id/settingsListItemOn"
38+
android:layout_width="match_parent"
39+
android:layout_height="wrap_content"
40+
app:isOn="true"
41+
app:leadingIcon="@drawable/ic_dax_icon"
42+
app:primaryText="Settings List Item on" />
43+
44+
<com.duckduckgo.common.ui.view.listitem.SettingsListItem
45+
android:id="@+id/settingsListItemWithBetaTag"
46+
android:layout_width="match_parent"
47+
android:layout_height="wrap_content"
48+
app:isOn="true"
49+
app:leadingIcon="@drawable/ic_dax_icon"
50+
app:primaryText="Settings List Item with Beta Pill"
51+
app:showBetaPill="true" />
52+
53+
<com.duckduckgo.common.ui.view.listitem.SettingsListItem
54+
android:id="@+id/settingsListItemWithBetaTagAndLongText"
55+
android:layout_width="match_parent"
56+
android:layout_height="wrap_content"
57+
app:isOn="true"
58+
app:leadingIcon="@drawable/ic_dax_icon"
59+
app:primaryText="Settings List Item with Beta Pill and a very long piece of text that should hopefully wrap"
60+
app:showBetaPill="true" />
61+
62+
</LinearLayout>

0 commit comments

Comments
 (0)