fix: using loaders for status button animations

This commit is contained in:
Richard Ramos 2020-09-05 21:18:50 -04:00 committed by Iuri Matias
parent 1481f2648f
commit 17f1f72113
3 changed files with 27 additions and 13 deletions

View File

@ -22,6 +22,8 @@ Item {
}
}
/* Commented due to high cpu usage */
/*
RowLayout {
StatusButton {
text: "Primary Large Button"
@ -182,6 +184,7 @@ Item {
}
}
}
*/
}
}

View File

@ -26,12 +26,21 @@ Button {
verticalAlignment: Text.AlignVCenter
anchors.fill: parent
color: !enabled ? Style.current.buttonDisabledForegroundColor : Style.current.buttonForegroundColor
visible: !loadingIndicator.visible
visible: !loadingIndicator.active
}
LoadingImage {
Component {
id: loadingComponent
LoadingImage {
}
}
Loader {
id: loadingIndicator
visible: control.state === "pending"
active: control.state === "pending"
sourceComponent: loadingComponent
height: loadingIndicator.visible ?
control.size === "large" ?
23 : 17

View File

@ -95,15 +95,24 @@ RoundButton {
fillMode: Image.PreserveAspectFit
}
LoadingImage {
Component {
id: loadingComponent
LoadingImage {
}
}
Loader {
id: loadingIndicator
visible: false
active: control.state === "pending"
sourceComponent: loadingComponent
height: size === "small" ? 14 : 18
width: loadingIndicator.height
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
ColorOverlay {
anchors.fill: iconImg
visible: control.state === "default"
@ -124,14 +133,7 @@ RoundButton {
Style.current.roundedButtonDisabledForegroundColor
antialiasing: true
RotationAnimator {
target: loadingOverlay
from: 0
to: 360
duration: 1200
running: true
loops: Animation.Infinite
}
}
}