fix(StatusRoundButton): fixes binding loop and removes type property
As per discussion, there's no "primary" and "secondary" type in round buttons. They just appear in different sizes (44x44, 40x40, 32x32). The size determines their look & feel
This commit is contained in:
parent
d134ef8e45
commit
27a140e844
|
@ -39,7 +39,6 @@ Item {
|
||||||
|
|
||||||
StatusButton {
|
StatusButton {
|
||||||
text: "Secondary Small Button"
|
text: "Secondary Small Button"
|
||||||
type: "secondary"
|
|
||||||
size: "small"
|
size: "small"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,12 +49,18 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusRoundButton {
|
StatusRoundButton {
|
||||||
type: "secondary"
|
|
||||||
size: "medium"
|
size: "medium"
|
||||||
icon.name: "arrow-right"
|
icon.name: "arrow-right"
|
||||||
icon.height: 15
|
icon.height: 15
|
||||||
icon.width: 20
|
icon.width: 20
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StatusRoundButton {
|
||||||
|
size: "small"
|
||||||
|
icon.name: "arrow-right"
|
||||||
|
icon.height: 12
|
||||||
|
icon.width: 18
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
@ -91,13 +96,20 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusRoundButton {
|
StatusRoundButton {
|
||||||
type: "secondary"
|
|
||||||
size: "medium"
|
size: "medium"
|
||||||
icon.name: "arrow-right"
|
icon.name: "arrow-right"
|
||||||
icon.height: 15
|
icon.height: 15
|
||||||
icon.width: 20
|
icon.width: 20
|
||||||
enabled: false
|
enabled: false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StatusRoundButton {
|
||||||
|
size: "small"
|
||||||
|
icon.name: "arrow-right"
|
||||||
|
icon.height: 12
|
||||||
|
icon.width: 18
|
||||||
|
enabled: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
@ -130,10 +142,14 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusRoundButton {
|
StatusRoundButton {
|
||||||
type: "secondary"
|
|
||||||
size: "medium"
|
size: "medium"
|
||||||
state: "pending"
|
state: "pending"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StatusRoundButton {
|
||||||
|
size: "small"
|
||||||
|
state: "pending"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
|
|
@ -6,24 +6,54 @@ import "../../imports"
|
||||||
import "../../shared"
|
import "../../shared"
|
||||||
|
|
||||||
RoundButton {
|
RoundButton {
|
||||||
property string type: "primary"
|
|
||||||
property string state: "default"
|
property string state: "default"
|
||||||
property string size: "large"
|
property string size: "large"
|
||||||
|
|
||||||
id: control
|
id: control
|
||||||
|
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
|
|
||||||
implicitWidth: size === "medium" ? 40 : 44
|
implicitWidth: {
|
||||||
implicitHeight: size === "medium" ? 40 : 44
|
switch(size) {
|
||||||
|
case "large":
|
||||||
|
return 44
|
||||||
|
case "medium":
|
||||||
|
return 40
|
||||||
|
case "small":
|
||||||
|
return 32
|
||||||
|
default:
|
||||||
|
return 44
|
||||||
|
}
|
||||||
|
}
|
||||||
|
implicitHeight: implicitWidth
|
||||||
|
|
||||||
enabled: state === "default"
|
enabled: state === "default"
|
||||||
|
|
||||||
icon.source: "../../app/img/" + icon.name + ".svg"
|
icon.height: {
|
||||||
icon.height: size === "medium" ? 14 : 20
|
switch(size) {
|
||||||
icon.width: size === "medium" ? 14 : 20
|
case "large":
|
||||||
icon.color: type === "secondary" ?
|
return 20
|
||||||
|
case "medium":
|
||||||
|
return 14
|
||||||
|
case "small":
|
||||||
|
return 12
|
||||||
|
default:
|
||||||
|
return 20
|
||||||
|
}
|
||||||
|
}
|
||||||
|
icon.width: {
|
||||||
|
switch(size) {
|
||||||
|
case "large":
|
||||||
|
return 20
|
||||||
|
case "medium":
|
||||||
|
return 14
|
||||||
|
case "small":
|
||||||
|
return 12
|
||||||
|
default:
|
||||||
|
return 20
|
||||||
|
}
|
||||||
|
}
|
||||||
|
icon.color: size === "medium" || size === "small" ?
|
||||||
!enabled ?
|
!enabled ?
|
||||||
Style.current.roundedButtonSecondaryDisabledForegroundColor :
|
Style.current.roundedButtonSecondaryDisabledForegroundColor :
|
||||||
Style.current.roundedButtonSecondaryForegroundColor
|
Style.current.roundedButtonSecondaryForegroundColor
|
||||||
|
@ -32,10 +62,14 @@ RoundButton {
|
||||||
Style.current.roundedButtonDisabledForegroundColor :
|
Style.current.roundedButtonDisabledForegroundColor :
|
||||||
Style.current.roundedButtonForegroundColor
|
Style.current.roundedButtonForegroundColor
|
||||||
|
|
||||||
|
onIconChanged: {
|
||||||
|
icon.source = icon.name ? "../../app/img/" + icon.name + ".svg" : ""
|
||||||
|
}
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: {
|
color: {
|
||||||
if (type === "secondary") {
|
if (size === "medium" || size == "small") {
|
||||||
return !enabled ? Style.current.roundedButtonSecondaryDisabledBackgroundColor :
|
return !enabled ? Style.current.roundedButtonSecondaryDisabledBackgroundColor :
|
||||||
hovered ? Style.current.roundedButtonSecondaryHoveredBackgroundColor :
|
hovered ? Style.current.roundedButtonSecondaryHoveredBackgroundColor :
|
||||||
Style.current.roundedButtonSecondaryBackgroundColor
|
Style.current.roundedButtonSecondaryBackgroundColor
|
||||||
|
@ -64,7 +98,7 @@ RoundButton {
|
||||||
LoadingImage {
|
LoadingImage {
|
||||||
id: loadingIndicator
|
id: loadingIndicator
|
||||||
visible: false
|
visible: false
|
||||||
height: 18
|
height: size === "small" ? 14 : 18
|
||||||
width: loadingIndicator.height
|
width: loadingIndicator.height
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
@ -74,7 +108,7 @@ RoundButton {
|
||||||
anchors.fill: iconImg
|
anchors.fill: iconImg
|
||||||
visible: control.state === "default"
|
visible: control.state === "default"
|
||||||
source: iconImg
|
source: iconImg
|
||||||
color: control.type === "secondary" ?
|
color: control.size === "medium" || control.size === "small" ?
|
||||||
Style.current.roundedButtonSecondaryDisabledForegroundColor :
|
Style.current.roundedButtonSecondaryDisabledForegroundColor :
|
||||||
Style.current.roundedButtonDisabledForegroundColor
|
Style.current.roundedButtonDisabledForegroundColor
|
||||||
antialiasing: true
|
antialiasing: true
|
||||||
|
@ -85,7 +119,7 @@ RoundButton {
|
||||||
visible: control.state === "pending"
|
visible: control.state === "pending"
|
||||||
anchors.fill: loadingIndicator
|
anchors.fill: loadingIndicator
|
||||||
source: loadingIndicator
|
source: loadingIndicator
|
||||||
color: control.type === "secondary" ?
|
color: control.size === "medium" || control.size === "small" ?
|
||||||
Style.current.roundedButtonSecondaryDisabledForegroundColor :
|
Style.current.roundedButtonSecondaryDisabledForegroundColor :
|
||||||
Style.current.roundedButtonDisabledForegroundColor
|
Style.current.roundedButtonDisabledForegroundColor
|
||||||
antialiasing: true
|
antialiasing: true
|
||||||
|
|
Loading…
Reference in New Issue