Compare commits

..
Author SHA1 Message Date
Pascal Precht 72592afffd fix(Core): disable StatusIcon ColorOverlay if no color is supplied
This is needed to have the underlying SVG's color bleed through and
make use of the image's opacity at the same time.

Using `ColorOverlay` together with (half) transparent colors doesn't
work very well as it makes the underlying SVG color come through,
result in wrong colors.

Applying `opacity` on the image itself cause the `ColorOverlay` to
reduce in opacity as well. So in order to work with transparent
colors, we need a way to turn of the ColorOverlay and work with the
Image's opacity, which is what this change enables.
2021-05-25 12:40:52 +02:00
Pascal Precht ee800269fd feat(Components): introduce StatusListItem component
This introduces a base list item component that is used in many different
places across Status Desktop. The component is configurable and allows for
child component customization.

Usage:

```qml
StatusListItem {
    title: "Title"
}

StatusListItem {
    title: "Title"
    subTitle: "Subtitle"
}

StatusListItem {
    title: "Title"
    subTitle: "Subtitle"
    icon.name: "info"
}

StatusListItem {
    title: "Title"
    subTitle: "Subtitle"
    image.source: "..."
}

StatusListItem {
    title: "Title"
    subTitle: "Subtitle"
    image.source: "..."
    label: "Some label"
}

StatusListItem {
    title: "Title"
    subTitle: "Subtitle"
    icon.name: "info"
    label: "Some label"
    components: [
        StatusButton {
            text: "Button"
            size: StatusBaseButton.Size.Small
        }
        ...
    ]
}
```

Closes #19
2021-05-25 12:30:31 +02:00
Pascal Precht d9529883a5 feat(Core): introduce StatusImageSettings
Very similar to what we're doing with `StatusIconSettings` in https://github.com/status-im/StatusQ/pull/61,
this commit introduces `StatusImageSettings` to expose a consisten image
API across components.
2021-05-25 12:28:30 +02:00
Pascal Precht 2f09179fcf fix(sandbox): make scrollview content height grow with content
This is just temporary until #40 lands, but for now it allows for
the scrollable content to be grow which is needed to make pages
with many components usable.
2021-05-25 12:27:33 +02:00
Pascal Precht 8639e8ccba feat(Components): introduce StatusRoundIcon component
This commit introduces a `StatusRoundIcon` component which renders
a `StatusIcon` inside a rounded rectangle.

This is similar to `StatusRoundButton`, just that it isn't a clickable
component.

With these changes, we also introduce a new `StatusIconSettings` config
object that can be used across component that need icon configuration.

The configuration includes the following properties:

- `name` - Name of the icon and used to locate the asset
- `width`
- `height`

Closes #53
2021-05-25 12:23:47 +02:00
Pascal Precht 6a92ff6823 fix(Components): add proper foreground color for StatusBadge
Fixes #59
2021-05-25 12:20:39 +02:00
Pascal Precht 9b99d8a957 feat(StatusIconTabButton): introduce image loading state and fallback
This commit introduces a loading indicator for cases where `icon.source`
is set (a custom image/icon) to improve UX of the component.

It also falls back to a letter identicon in case loading the image source
wasn't successful.

Usage:

```
StatusIconTabButton {
    icon.source: "SOME URL THAT CAN'T BE RESOLVED"
    icon.color: "red" // in case fallback is used, icon.color will be gray by default
    name: "Some channel" // used to generated letter identicon as fallback
}
```

Closes #37
2021-05-21 10:17:53 +02:00
Pascal Precht 1cb0c1d389 fix(StatusRadioButton): ensure control label as correct color
Closes #51
2021-05-21 10:14:30 +02:00
Pascal Precht 136cd55560 refactor(sandbox): rely on global Theme instead of theme prop 2021-05-21 10:14:03 +02:00
21 changed files with 380 additions and 86 deletions
+8 -8
View File
@@ -9,7 +9,6 @@ GridLayout {
columns: 6
columnSpacing: 5
rowSpacing: 5
property ThemePalette theme
StatusIconTabButton {
icon.name: "chat"
@@ -19,6 +18,14 @@ GridLayout {
icon.source: "https://pbs.twimg.com/profile_images/1369221718338895873/T_5fny6o_400x400.jpg"
}
StatusIconTabButton {
icon.color: Theme.palette.miscColor9
// This icon source is flawed and demonstrates the fallback case
// when the image source can't be loaded
icon.source: "https://pbs.twimg.com/profile_images/1369221718338895873/T_5fny6o_400x400.jp"
name: "Pascal"
}
StatusIconTabButton {
name: "#status"
}
@@ -95,11 +102,4 @@ GridLayout {
}
StatusCheckBox {}
StatusSlider {
width: 360
from: 0
to: 100
value: 40
}
}
-1
View File
@@ -11,7 +11,6 @@ GridLayout {
columns: 6
columnSpacing: 5
rowSpacing: 5
property ThemePalette theme
Button {
id: btn
+129
View File
@@ -0,0 +1,129 @@
import QtQuick 2.14
import QtQuick.Layouts 1.14
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Controls 0.1
import StatusQ.Components 0.1
GridLayout {
columns: 1
columnSpacing: 5
rowSpacing: 5
StatusListItem {
title: "Title"
}
StatusListItem {
title: "Title"
subTitle: "Subtitle"
}
StatusListItem {
title: "Title"
subTitle: "Subtitle"
icon.name: "info"
}
StatusListItem {
title: "Title"
subTitle: "Subtitle"
image.source: "https://pbs.twimg.com/profile_images/1369221718338895873/T_5fny6o_400x400.jpg"
}
StatusListItem {
title: "Title"
subTitle: "Subtitle"
icon.name: "info"
components: [StatusButton {
text: "Button"
size: StatusBaseButton.Size.Small
}]
}
StatusListItem {
title: "Title"
subTitle: "Subtitle"
icon.name: "info"
components: [StatusSwitch {}]
}
StatusListItem {
title: "Title"
subTitle: "Subtitle"
icon.name: "info"
components: [StatusRadioButton {}]
}
StatusListItem {
title: "Title"
subTitle: "Subtitle"
icon.name: "info"
components: [StatusCheckBox {}]
}
StatusListItem {
title: "Title"
subTitle: "Subtitle"
icon.name: "info"
label: "Text"
}
StatusListItem {
title: "Title"
subTitle: "Subtitle"
icon.name: "info"
label: "Text"
components: [
StatusButton {
text: "Button"
size: StatusBaseButton.Size.Small
}
]
}
StatusListItem {
title: "Title"
subTitle: "Subtitle"
icon.name: "info"
label: "Text"
components: [StatusSwitch {}]
}
StatusListItem {
title: "Title"
subTitle: "Subtitle"
icon.name: "info"
label: "Text"
components: [
StatusRadioButton {}
]
}
StatusListItem {
title: "Title"
subTitle: "Subtitle"
icon.name: "info"
label: "Text"
components: [StatusCheckBox {}]
}
StatusListItem {
title: "Title"
subTitle: "Subtitle"
icon.name: "info"
label: "Text"
components: [
StatusBadge {
value: 1
},
StatusIcon {
icon: "info"
color: Theme.palette.baseColor1
width: 20
height: 20
}
]
}
}
+5 -2
View File
@@ -8,10 +8,9 @@ GridLayout {
columns: 6
columnSpacing: 5
rowSpacing: 5
property ThemePalette theme
StatusLoadingIndicator {
color: parent.theme.directColor4
color: Theme.palette.directColor4
}
StatusLetterIdenticon {
@@ -35,4 +34,8 @@ GridLayout {
StatusBadge {
value: 100
}
StatusRoundIcon {
icon.name: "info"
}
}
+18 -5
View File
@@ -46,6 +46,11 @@ StatusWindow {
checkable: true
text: "Controls"
}
Button {
id: listItemsTab
checkable: true
text: "List Items"
}
Button {
id: layoutTab
checkable: true
@@ -70,7 +75,7 @@ StatusWindow {
width: parent.width
anchors.top: tabs.bottom
anchors.bottom: parent.bottom
contentHeight: rootWindow.height * rootWindow.factor
contentHeight: lightThemeBg.height * rootWindow.factor
contentWidth: rootWindow.width * rootWindow.factor
clip: true
@@ -79,12 +84,14 @@ StatusWindow {
id: lightThemeBg
width: rootWindow.width
height: parent.height
height: page.height + 64
anchors.topMargin: 32
color: Theme.palette.baseColor5
clip: true
scale: rootWindow.factor
Loader {
id: page
active: true
anchors.centerIn: parent
@@ -94,6 +101,8 @@ StatusWindow {
return iconsComponent;
case controlsTab:
return controlsComponent;
case listItemsTab:
return listItemsComponent;
case layoutTab:
return layoutComponent;
case otherTab:
@@ -175,7 +184,13 @@ StatusWindow {
id: controlsComponent
Controls {
anchors.centerIn: parent
theme: Theme.palette
}
}
Component {
id: listItemsComponent
ListItems {
anchors.centerIn: parent
}
}
@@ -183,7 +198,6 @@ StatusWindow {
id: layoutComponent
Layout {
anchors.centerIn: parent
theme: Theme.palette
}
}
@@ -191,7 +205,6 @@ StatusWindow {
id: othersComponent
Others {
anchors.centerIn: parent
theme: Theme.palette
}
}
+1 -1
View File
@@ -28,7 +28,7 @@ Rectangle {
visible: statusBadge.value > 0
font.pixelSize: statusBadge.value > 99 ? 10 : 12
font.weight: Font.Bold
color: Theme.palette.white
color: Theme.palette.statusBadge.foregroundColor
anchors.centerIn: parent
text: {
if (statusBadge.value > 99) {
+109
View File
@@ -0,0 +1,109 @@
import QtQuick 2.13
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Components 0.1
import StatusQ.Controls 0.1
Rectangle {
id: statusListItem
implicitWidth: 448
implicitHeight: 64
color: sensor.containsMouse ? Theme.palette.baseColor2 : Theme.palette.statusListItem.backgroundColor
radius: 8
property string title: ""
property string subTitle: ""
property StatusIconSettings icon: StatusIconSettings {
height: 20
width: 20
}
property StatusImageSettings image: StatusImageSettings {}
property string label: ""
property list<Item> components
onComponentsChanged: {
if (components.length) {
for (let idx in components) {
components[idx].parent = statusListItemComponentsSlot
}
}
}
MouseArea {
id: sensor
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
Loader {
id: iconOrImage
anchors.left: parent.left
anchors.leftMargin: 16
anchors.verticalCenter: parent.verticalCenter
sourceComponent: !!statusListItem.icon.name ? statusRoundedIcon : statusRoundedImage
active: !!statusListItem.icon.name || !!statusListItem.image.source.toString()
}
Component {
id: statusRoundedIcon
StatusRoundIcon {
icon: statusListItem.icon
}
}
Component {
id: statusRoundedImage
StatusRoundedImage {
image.source: statusListItem.image.source
}
}
Item {
anchors.left: iconOrImage.active ? iconOrImage.right : parent.left
anchors.leftMargin: 16
anchors.verticalCenter: parent.verticalCenter
height: statusListItemTitle.height + (statusListItemSubTitle.visible ? statusListItemSubTitle.height : 0)
StatusBaseText {
id: statusListItemTitle
text: statusListItem.title
font.pixelSize: 15
color: Theme.palette.directColor1
}
StatusBaseText {
id: statusListItemSubTitle
anchors.top: statusListItemTitle.bottom
text: statusListItem.subTitle
font.pixelSize: 15
color: Theme.palette.baseColor1
visible: !!statusListItem.subTitle
}
}
StatusBaseText {
anchors.verticalCenter: parent.verticalCenter
anchors.right: statusListItemComponentsSlot.left
anchors.rightMargin: statusListItemComponentsSlot.width > 0 ? 10 : 0
text: statusListItem.label
font.pixelSize: 15
color: Theme.palette.baseColor1
visible: !!statusListItem.label
}
Row {
id: statusListItemComponentsSlot
anchors.right: parent.right
anchors.rightMargin: 16
anchors.verticalCenter: parent.verticalCenter
spacing: 10
}
}
}
@@ -0,0 +1,28 @@
import QtQuick 2.14
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
Rectangle {
id: statusRoundedIcon
implicitWidth: 40
implicitHeight: 40
radius: width / 2;
color: Theme.palette.primaryColor3;
property StatusIconSettings icon: StatusIconSettings {
width: 24
height: 24
}
StatusIcon {
id: statusIcon
anchors.centerIn: parent
width: statusRoundedIcon.icon.width
height: statusRoundedIcon.icon.height
color: Theme.palette.primaryColor1
icon: statusRoundedIcon.icon.name
}
}
+2
View File
@@ -2,5 +2,7 @@ module StatusQ.Components
StatusBadge 0.1 StatusBadge.qml
StatusLetterIdenticon 0.1 StatusLetterIdenticon.qml
StatusListItem 0.1 StatusListItem.qml
StatusLoadingIndicator 0.1 StatusLoadingIndicator.qml
StatusRoundIcon 0.1 StatusRoundIcon.qml
StatusRoundedImage 0.1 StatusRoundedImage.qml
+29 -2
View File
@@ -40,10 +40,37 @@ TabButton {
Component {
id: imageIcon
StatusRoundedImage {
Item {
width: 28
height: 28
image.source: icon.source
StatusRoundedImage {
id: statusRoundImage
width: parent.width
height: parent.height
image.source: icon.source
}
Loader {
sourceComponent: {
switch (statusRoundImage.image.status) {
case Image.Loading:
return statusLoadingIndicator
break;
case Image.Error:
return letterIdenticon
break;
}
}
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
active: statusRoundImage.image.status === Image.Loading || statusRoundImage.image.status === Image.Error
}
Component {
id: statusLoadingIndicator
StatusLoadingIndicator {
color: Theme.palette.directColor6
}
}
}
}
@@ -33,6 +33,7 @@ RadioButton {
}
contentItem: StatusBaseText {
text: statusRadioButton.text
color: Theme.palette.directColor1
verticalAlignment: Text.AlignVCenter
leftPadding: !!statusRadioButton.text ? statusRadioButton.indicator.width + statusRadioButton.spacing
: statusRadioButton.indicator.width
-60
View File
@@ -1,60 +0,0 @@
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtGraphicalEffects 1.14
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Controls 0.1
Slider {
id: statusSlider
implicitWidth: 360
implicitHeight: 4
leftPadding: 0
background: Rectangle {
implicitHeight: 4
implicitWidth: 100
color: {
if (statusSlider.value === statusSlider.to) {
return Theme.palette.primaryColor1
}
return Theme.palette.primaryColor3
}
radius: 2
Rectangle {
radius: 2
anchors.fill: parent
visible: statusSlider.value > statusSlider.from && statusSlider.value < statusSlider.to
gradient: Gradient {
GradientStop { color: Theme.palette.primaryColor1 ; position: 0 }
GradientStop { color: Theme.palette.primaryColor3 ; position: (((statusSlider.value - statusSlider.from) * 100) / (statusSlider.to - statusSlider.from) / 100).toFixed(2) }
GradientStop { color: Theme.palette.primaryColor1 ; position: (((statusSlider.value - statusSlider.from) * 100) / (statusSlider.to - statusSlider.from) / 100).toFixed(2) }
GradientStop { color: Theme.palette.primaryColor3 ; position: 1 }
orientation: Gradient.Horizontal
}
}
} // background
handle: Rectangle {
x: statusSlider.leftPadding + statusSlider.visualPosition * (statusSlider.availableWidth - width / 2)
anchors.verticalCenter: parent.verticalCenter
color: Theme.palette.white
implicitWidth: 28
implicitHeight: 28
radius: 14
layer.enabled: true
layer.effect: DropShadow {
width: parent.width
height: parent.height
visible: true
verticalOffset: 2
samples: 15
fast: true
cached: true
color: Theme.palette.dropShadow
}
}
}
-1
View File
@@ -11,4 +11,3 @@ StatusFlatRoundButton 0.1 StatusFlatRoundButton.qml
StatusSwitch 0.1 StatusSwitch.qml
StatusRadioButton 0.1 StatusRadioButton.qml
StatusCheckBox 0.1 StatusCheckBox.qml
StatusSlider 0.1 StatusSlider.qml
+2 -2
View File
@@ -3,7 +3,7 @@ import QtGraphicalEffects 1.13
Image {
property string icon: ""
property color color
property string color: ""
id: statusIcon
width: 24
@@ -19,7 +19,7 @@ Image {
}
ColorOverlay {
visible: statusIcon.color !== undefined
visible: !!statusIcon.color
anchors.fill: statusIcon
source: statusIcon
color: statusIcon.color
+11
View File
@@ -0,0 +1,11 @@
import QtQuick 2.13
QtObject {
id: statusIconSettings
property string name
property real width
property real height
property color color
property url source
}
+10
View File
@@ -0,0 +1,10 @@
import QtQuick 2.13
QtObject {
id: statusImageSettings
property url source
property real width
property real height
}
@@ -120,5 +120,13 @@ ThemePalette {
property QtObject statusAppNavBar: QtObject {
property color backgroundColor: baseColor5
}
property QtObject statusListItem: QtObject {
property color backgroundColor: baseColor3
}
property QtObject statusBadge: QtObject {
property color foregroundColor: baseColor3
}
}
@@ -120,5 +120,13 @@ ThemePalette {
property QtObject statusAppNavBar: QtObject {
property color backgroundColor: baseColor4
}
property QtObject statusListItem: QtObject {
property color backgroundColor: white
}
property QtObject statusBadge: QtObject {
property color foregroundColor: white
}
}
+1 -4
View File
@@ -4,10 +4,7 @@ import QtQuick 2.13
QtObject {
id: appTheme
// Replace it with:
// property QtObject palette: StatusLightTheme {}
// for reloading
property ThemePalette palette: StatusLightTheme {}
property QtObject palette: StatusLightTheme {}
function setTheme(theme) {
palette = theme
+8
View File
@@ -82,6 +82,14 @@ QtObject {
property color backgroundColor
}
property QtObject statusListItem: QtObject {
property color backgroundColor
}
property QtObject statusBadge: QtObject {
property color foregroundColor
}
function alphaColor(color, alpha) {
let actualColor = Qt.darker(color, 1)
actualColor.a = alpha
+2
View File
@@ -2,4 +2,6 @@ module StatusQ.Core
StatusBaseText 0.1 StatusBaseText.qml
StatusIcon 0.1 StatusIcon.qml
StatusIconSettings 0.1 StatusIconSettings.qml
StatusImageSettings 0.1 StatusImageSettings.qml