Refactored the animation

pull/4/head
rekols 4 years ago
parent d311108e76
commit 443ecabe95

@ -36,24 +36,62 @@ Item {
property real verticalSpacing: launcher.screenRect.height * 0.01 property real verticalSpacing: launcher.screenRect.height * 0.01
property real maxSpacing: horizontalSpacing > verticalSpacing ? horizontalSpacing : verticalSpacing property real maxSpacing: horizontalSpacing > verticalSpacing ? horizontalSpacing : verticalSpacing
property bool showed: launcher.showed property bool showed: launcher.showed
opacity: 1.0
onShowedChanged: { onShowedChanged: {
if (showed) rootOpacityAni.restart()
root.opacity = 1.0 wallpaperColorAni.restart()
else blurAnimation.restart()
closeOpacityAni.restart() appViewOpacityAni.restart()
appViewScaleAni.restart()
} }
NumberAnimation { NumberAnimation {
id: closeOpacityAni id: rootOpacityAni
from: 1 from: root.showed ? 1 : 0
to: 0 to: root.showed ? 0 : 1
target: root target: root
property: "opacity" property: "opacity"
duration: 200 duration: 200
} }
NumberAnimation {
id: blurAnimation
target: wallpaperBlur
property: "radius"
duration: 300
from: root.showed ? 72 : 0
to: root.showed ? 0 : 72
}
NumberAnimation {
id: wallpaperColorAni
target: wallpaperColor
property: "opacity"
from: root.showed ? 0.4 : 0.0
to: root.showed ? 0.0 : 0.4
duration: 250
}
NumberAnimation {
id: appViewScaleAni
target: appView
property: "scale"
easing.type: Easing.OutCubic
from: root.showed ? 1.0 : 1.2
to: root.showed ? 1.2 : 1.0
duration: 180
}
NumberAnimation {
id: appViewOpacityAni
target: appView
property: "opacity"
easing.type: Easing.OutCubic
from: root.showed ? 1.0 : 0.0
to: root.showed ? 0.0 : 1.0
duration: 240
}
Wallpaper { Wallpaper {
id: backend id: backend
} }
@ -75,28 +113,16 @@ Item {
anchors.fill: parent anchors.fill: parent
source: wallpaper source: wallpaper
cached: true cached: true
radius: root.showed ? 72 : 0
visible: true visible: true
Behavior on radius {
NumberAnimation {
duration: 300
}
}
} }
ColorOverlay { ColorOverlay {
id: wallpaperColor
anchors.fill: parent anchors.fill: parent
source: wallpaperBlur source: wallpaperBlur
color: "#000000" color: "#000000"
visible: true visible: true
opacity: showed ? 0.4 : 0.0
Behavior on opacity {
NumberAnimation {
duration: 250
}
}
} }
LauncherModel { LauncherModel {
@ -199,32 +225,16 @@ Item {
Layout.fillWidth: true Layout.fillWidth: true
Keys.enabled: true Keys.enabled: true
Keys.forwardTo: grid Keys.forwardTo: appView
LauncherGridView { LauncherGridView {
id: grid id: appView
anchors.fill: parent anchors.fill: parent
anchors.leftMargin: gridItem.width * 0.07 anchors.leftMargin: gridItem.width * 0.07
anchors.rightMargin: gridItem.width * 0.07 anchors.rightMargin: gridItem.width * 0.07
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
focus: true focus: true
scale: root.showed ? 1.0 : 1.2
Behavior on scale {
NumberAnimation {
easing.type: Easing.OutCubic
duration: 180
}
}
opacity: root.showed ? 1.0 : 0.0
Behavior on opacity {
NumberAnimation {
easing.type: Easing.OutCubic
duration: 240
}
}
Keys.enabled: true Keys.enabled: true
Keys.onPressed: { Keys.onPressed: {
if (event.key === Qt.Key_Escape) if (event.key === Qt.Key_Escape)
@ -250,16 +260,16 @@ Item {
text: qsTr("Not found") text: qsTr("Not found")
font.pointSize: 30 font.pointSize: 30
color: "white" color: "white"
visible: grid.count === 0 visible: appView.count === 0
} }
} }
} }
PageIndicator { PageIndicator {
id: pageIndicator id: pageIndicator
count: grid.pages count: appView.pages
currentIndex: grid.currentPage currentIndex: appView.currentPage
onCurrentIndexChanged: grid.currentPage = currentIndex onCurrentIndexChanged: appView.currentPage = currentIndex
interactive: true interactive: true
spacing: FishUI.Units.largeSpacing spacing: FishUI.Units.largeSpacing
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
@ -289,8 +299,8 @@ Item {
function onVisibleChanged(visible) { function onVisibleChanged(visible) {
if (visible) { if (visible) {
textField.focus = false textField.focus = false
grid.focus = true appView.focus = true
grid.forceActiveFocus() appView.forceActiveFocus()
} else { } else {
textField.text = "" textField.text = ""
} }

Loading…
Cancel
Save