Skip to content

Commit 175375b

Browse files
committed
fix(listitems): Support list items on dark backgrounds
1 parent 422fa4b commit 175375b

File tree

8 files changed

+29
-10
lines changed

8 files changed

+29
-10
lines changed

src/components/ThinDivider.qml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
import QtQuick 2.4
12+
import Material 0.3
1213

1314
/*!
1415
\qmltype ThinDivider
@@ -22,6 +23,8 @@ Rectangle {
2223
right: parent.right
2324
}
2425

25-
color: Qt.rgba(0,0,0,0.1)
26+
property bool darkBackground
27+
28+
color: darkBackground ? Theme.dark.hintColor : Theme.light.hintColor
2629
height: 1
2730
}

src/listitems/BaseListItem.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ View {
2626
right: parent ? parent.right : undefined
2727
}
2828

29+
property bool darkBackground
2930
property int margins: 16 * Units.dp
3031

3132
property bool selected
@@ -44,6 +45,7 @@ View {
4445
anchors.leftMargin: dividerInset
4546

4647
visible: showDivider
48+
darkBackground: listItem.darkBackground
4749
}
4850

4951
Ink {

src/listitems/Divider.qml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ Item {
2525
right: parent.right
2626
}
2727

28+
property bool darkBackground
29+
2830
height: 16 * Units.dp
2931

3032
ThinDivider {
3133
anchors.verticalCenter: parent.verticalCenter
34+
darkBackground: divider.darkBackground
3235
}
3336
}

src/listitems/SectionHeader.qml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ BaseListItem {
5252
}
5353

5454
visible: name != ""
55-
color: listItem.expanded ? Theme.primaryColor : Theme.light.iconColor
55+
color: listItem.expanded ? Theme.primaryColor
56+
: darkBackground ? Theme.dark.iconColor : Theme.light.iconColor
5657
size: 24 * Units.dp
5758
}
5859
}
@@ -66,7 +67,8 @@ BaseListItem {
6667
elide: Text.ElideRight
6768
style: "subheading"
6869

69-
color: listItem.expanded ? Theme.primaryColor : Theme.light.textColor
70+
color: listItem.expanded ? Theme.primaryColor
71+
: darkBackground ? Theme.dark.textColor : Theme.light.textColor
7072
}
7173

7274
Item {
@@ -83,6 +85,7 @@ BaseListItem {
8385
name: "navigation/expand_more"
8486
rotation: listItem.expanded ? 180 : 0
8587
size: 24 * Units.dp
88+
color: darkBackground ? Theme.dark.iconColor : Theme.light.iconColor
8689

8790
Behavior on rotation {
8891
NumberAnimation { duration: 200 }

src/listitems/SimpleMenu.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Subtitled {
3434
id: hiddenLabel
3535
style: "subheading"
3636
visible: false
37+
color: darkBackground ? Theme.dark.textColor : Theme.light.textColor
3738

3839
onContentWidthChanged: {
3940
__maxWidth = Math.max(contentWidth + 33 * Units.dp, __maxWidth)

src/listitems/Standard.qml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ BaseListItem {
9191
}
9292

9393
visible: valid
94-
color: listItem.selected ? Theme.primaryColor : Theme.light.iconColor
94+
color: listItem.selected ? Theme.primaryColor
95+
: darkBackground ? Theme.dark.iconColor : Theme.light.iconColor
96+
9597
size: 24 * Units.dp
9698
}
9799
}
@@ -118,7 +120,8 @@ BaseListItem {
118120
elide: Text.ElideRight
119121
style: "subheading"
120122

121-
color: listItem.selected ? Theme.primaryColor : Theme.light.textColor
123+
color: listItem.selected ? Theme.primaryColor
124+
: darkBackground ? Theme.dark.textColor : Theme.light.textColor
122125

123126
visible: !contentItem.visible
124127
}
@@ -129,7 +132,7 @@ BaseListItem {
129132

130133
Layout.alignment: Qt.AlignVCenter
131134

132-
color: Theme.light.subTextColor
135+
color: darkBackground ? Theme.dark.subTextColor : Theme.light.subTextColor
133136
elide: Text.ElideRight
134137
style: "body1"
135138

src/listitems/Subheader.qml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ View {
3535
property alias text: label.text
3636
property alias style: label.style
3737
property alias textColor: label.color
38+
property bool darkBackground
3839

3940
Label {
4041
id: label
@@ -50,13 +51,14 @@ View {
5051
margins: margins
5152
}
5253

53-
color: Theme.light.subTextColor
54+
color: darkBackground ? Theme.dark.subTextColor : Theme.light.subTextColor
5455
}
5556

5657
property bool showDivider: false
5758

5859
ThinDivider {
5960
anchors.bottom: parent.bottom
6061
visible: showDivider
62+
darkBackground: listItem.darkBackground
6163
}
6264
}

src/listitems/Subtitled.qml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ BaseListItem {
7474
}
7575

7676
visible: valid
77-
color: listItem.selected ? Theme.primaryColor : Theme.light.iconColor
77+
color: listItem.selected ? Theme.primaryColor
78+
: darkBackground ? Theme.dark.iconColor : Theme.light.iconColor
7879
size: 24 * Units.dp
7980
}
8081
}
@@ -99,6 +100,7 @@ BaseListItem {
99100

100101
elide: Text.ElideRight
101102
style: "subheading"
103+
color: darkBackground ? Theme.dark.textColor : Theme.light.textColor
102104
}
103105

104106
Label {
@@ -107,7 +109,7 @@ BaseListItem {
107109
Layout.alignment: Qt.AlignVCenter
108110
Layout.preferredWidth: visible ? implicitWidth : 0
109111

110-
color: Theme.light.subTextColor
112+
color: darkBackground ? Theme.dark.subTextColor : Theme.light.subTextColor
111113
elide: Text.ElideRight
112114
horizontalAlignment: Qt.AlignHCenter
113115
style: "body1"
@@ -130,7 +132,7 @@ BaseListItem {
130132
Layout.fillWidth: true
131133
Layout.preferredHeight: implicitHeight * maximumLineCount/lineCount
132134

133-
color: Theme.light.subTextColor
135+
color: darkBackground ? Theme.dark.subTextColor : Theme.light.subTextColor
134136
elide: Text.ElideRight
135137
wrapMode: Text.WordWrap
136138
style: "body1"

0 commit comments

Comments
 (0)