fix(WarningBanners): updated show/hide as per design

Closes #10607
This commit is contained in:
Alexandra Betouni 2023-11-02 16:50:58 +02:00
parent a3ef9d6a27
commit 7d9414ef93
2 changed files with 27 additions and 13 deletions

View File

@ -739,7 +739,7 @@ Item {
type: ModuleWarning.Warning type: ModuleWarning.Warning
iconName: "warning" iconName: "warning"
active: appMain.rootStore.profileSectionStore.walletStore.areTestNetworksEnabled active: appMain.rootStore.profileSectionStore.walletStore.areTestNetworksEnabled
delay: false
onClicked: Global.openTestnetPopup() onClicked: Global.openTestnetPopup()
onCloseClicked: hide() onCloseClicked: hide()
} }
@ -753,7 +753,7 @@ Item {
type: ModuleWarning.Danger type: ModuleWarning.Danger
text: qsTr("Secure your seed phrase") text: qsTr("Secure your seed phrase")
buttonText: qsTr("Back up now") buttonText: qsTr("Back up now")
delay: false
onClicked: popups.openBackUpSeedPopup() onClicked: popups.openBackUpSeedPopup()
onCloseClicked: { onCloseClicked: {
@ -776,7 +776,7 @@ Item {
readonly property string channelId: appMain.communitiesStore.discordImportChannelId readonly property string channelId: appMain.communitiesStore.discordImportChannelId
readonly property string channelName: appMain.communitiesStore.discordImportChannelName readonly property string channelName: appMain.communitiesStore.discordImportChannelName
readonly property string channelOrCommunityName: channelName || communityName readonly property string channelOrCommunityName: channelName || communityName
delay: false
active: !cancelled && (inProgress || finished || stopped) active: !cancelled && (inProgress || finished || stopped)
type: errors ? ModuleWarning.Type.Danger : ModuleWarning.Type.Success type: errors ? ModuleWarning.Type.Danger : ModuleWarning.Type.Success
text: { text: {
@ -824,6 +824,7 @@ Item {
type: ModuleWarning.Danger type: ModuleWarning.Danger
text: qsTr("Downloading message history archives, DO NOT CLOSE THE APP until this banner disappears.") text: qsTr("Downloading message history archives, DO NOT CLOSE THE APP until this banner disappears.")
closeBtnVisible: false closeBtnVisible: false
delay: false
} }
ModuleWarning { ModuleWarning {
@ -879,6 +880,7 @@ Item {
objectName: "appVersionUpdateBanner" objectName: "appVersionUpdateBanner"
Layout.fillWidth: true Layout.fillWidth: true
type: ModuleWarning.Success type: ModuleWarning.Success
delay: false
text: updateAvailable ? qsTr("A new version of Status (%1) is available").arg(version) text: updateAvailable ? qsTr("A new version of Status (%1) is available").arg(version)
: qsTr("Your version is up to date") : qsTr("Your version is up to date")

View File

@ -18,13 +18,14 @@ Item {
Success Success
} }
property bool active property bool active: false
property int type: ModuleWarning.Danger property int type: ModuleWarning.Danger
property int progressValue: -1 // 0..100, -1 not visible property int progressValue: -1 // 0..100, -1 not visible
property string text: "" property string text: ""
property alias buttonText: button.text property alias buttonText: button.text
property alias closeBtnVisible: closeImg.visible property alias closeBtnVisible: closeImg.visible
property string iconName property string iconName
property bool delay: true
signal clicked() signal clicked()
signal closeClicked() signal closeClicked()
@ -54,22 +55,23 @@ Item {
signal linkActivated(string link) signal linkActivated(string link)
implicitHeight: active ? content.implicitHeight : 0
visible: implicitHeight > 0
onActiveChanged: { onActiveChanged: {
active ? showAnimation.start() : hideAnimation.start() if (root.active && root.delay) {
showTimer.start();
}
} }
NumberAnimation { NumberAnimation {
id: showAnimation id: showAnimation
target: root target: root
running: (root.active && !root.delay)
property: "implicitHeight" property: "implicitHeight"
from: 0 from: 0
to: content.implicitHeight to: 32
duration: 500 duration: 500
easing.type: Easing.OutCubic easing.type: Easing.OutCubic
onStarted: { onStarted: {
root.visible = true;
root.showStarted() root.showStarted()
} }
onFinished: { onFinished: {
@ -79,20 +81,32 @@ Item {
NumberAnimation { NumberAnimation {
id: hideAnimation id: hideAnimation
running: !root.active
target: root target: root
property: "implicitHeight" property: "implicitHeight"
from: 32
to: 0 to: 0
from: content.implicitHeight
duration: 500 duration: 500
easing.type: Easing.OutCubic easing.type: Easing.OutCubic
onStarted: { onStarted: {
root.hideStarted() root.hideStarted()
root.visible = false;
} }
onFinished: { onFinished: {
root.hideFinished() root.hideFinished()
} }
} }
Timer {
id: showTimer
interval: 3000
onTriggered: {
if (root.active) {
showAnimation.start();
}
}
}
Timer { Timer {
id: hideTimer id: hideTimer
repeat: false repeat: false
@ -104,9 +118,7 @@ Item {
Rectangle { Rectangle {
id: content id: content
anchors.bottom: parent.bottom anchors.fill: parent
width: parent.width
implicitHeight: 32
readonly property color baseColor: { readonly property color baseColor: {
switch (root.type) { switch (root.type) {