2020-10-27 01:35:50 +00:00
|
|
|
/*
|
|
|
|
Sailfin: a Jellyfin client written using Qt
|
|
|
|
Copyright (C) 2020 Chris Josten
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQuick 2.6
|
|
|
|
import Sailfish.Silica 1.0
|
|
|
|
|
|
|
|
import ".."
|
|
|
|
import "../.."
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Album details for "narrow" devices such as phones in portrait mode.
|
|
|
|
*/
|
|
|
|
Item {
|
2022-07-23 18:01:23 +00:00
|
|
|
id: listHeader
|
2020-10-27 01:35:50 +00:00
|
|
|
property ListView listview
|
2021-01-17 20:11:55 +00:00
|
|
|
property alias albumArt: albumArtImage.source
|
2020-10-27 01:35:50 +00:00
|
|
|
property string name
|
2021-01-17 20:11:55 +00:00
|
|
|
property alias blurhash : albumArtImage.blurhash
|
|
|
|
property bool twoColumns
|
2021-09-10 03:18:05 +00:00
|
|
|
property real aspectRatio
|
2022-07-23 18:01:23 +00:00
|
|
|
property string description
|
|
|
|
|
|
|
|
readonly property real smallHeight: albumHeader.height
|
|
|
|
readonly property real smallWidth: smallHeight * aspectRatio
|
|
|
|
readonly property real bigWidth: listHeader.width
|
|
|
|
readonly property real bigHeight: bigWidth / aspectRatio
|
2020-10-27 01:35:50 +00:00
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
//spacing: Theme.paddingLarge
|
2021-01-17 20:11:55 +00:00
|
|
|
|
2021-02-16 16:53:31 +00:00
|
|
|
Connections {
|
|
|
|
target: listview
|
|
|
|
onVerticalVelocityChanged: {
|
|
|
|
if (!listview.draggingVertically && Math.abs(listview.verticalVelocity) < Theme.itemSizeMedium
|
2022-07-23 18:01:23 +00:00
|
|
|
&& listview.contentY < -smallHeight) {
|
2021-02-16 16:53:31 +00:00
|
|
|
if (listview.verticalVelocity > 0) {
|
|
|
|
listview.cancelFlick()
|
|
|
|
listviewShrinkAnimation.start()
|
|
|
|
} else if (listview.verticalVelocity < 0){
|
|
|
|
listview.cancelFlick()
|
|
|
|
listviewGrowAnimation.start()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onDraggingVerticallyChanged: {
|
|
|
|
if (!listview.draggingVertically && listview.verticalVelocity == 0) {
|
2022-07-23 18:01:23 +00:00
|
|
|
if (-smallHeight - listview.contentY > -bigHeight - listview.contentY) {
|
2021-02-16 16:53:31 +00:00
|
|
|
listviewShrinkAnimation.start()
|
|
|
|
} else {
|
|
|
|
listviewGrowAnimation.start()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-27 01:35:50 +00:00
|
|
|
MouseArea {
|
2021-01-17 20:11:55 +00:00
|
|
|
anchors.fill: albumArtImage
|
2020-10-27 01:35:50 +00:00
|
|
|
onClicked: {
|
2022-07-23 18:01:23 +00:00
|
|
|
if (listview.contentY < -bigHeight + 10) {
|
2021-01-17 20:11:55 +00:00
|
|
|
listviewShrinkAnimation.start()
|
2020-10-27 01:35:50 +00:00
|
|
|
} else {
|
2021-01-17 20:11:55 +00:00
|
|
|
listviewGrowAnimation.start()
|
2020-10-27 01:35:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-17 20:11:55 +00:00
|
|
|
|
|
|
|
NumberAnimation {
|
|
|
|
id: listviewShrinkAnimation
|
|
|
|
target: listview
|
|
|
|
property: "contentY"
|
|
|
|
easing.type: Easing.OutCubic
|
2022-07-23 18:01:23 +00:00
|
|
|
to: -smallHeight
|
2021-01-17 20:11:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NumberAnimation {
|
|
|
|
id: listviewGrowAnimation
|
|
|
|
target: listview
|
|
|
|
property: "contentY"
|
|
|
|
easing.type: Easing.OutCubic
|
2022-07-23 18:01:23 +00:00
|
|
|
to: -bigHeight
|
2020-10-27 01:35:50 +00:00
|
|
|
}
|
2021-01-17 20:11:55 +00:00
|
|
|
|
2020-10-27 01:35:50 +00:00
|
|
|
PageHeader {
|
|
|
|
id: albumHeader
|
|
|
|
width: parent.width - Theme.horizontalPageMargin - height
|
|
|
|
title: name
|
2022-07-23 18:01:23 +00:00
|
|
|
description: listHeader.description
|
2020-10-27 01:35:50 +00:00
|
|
|
}
|
|
|
|
|
2021-01-17 20:11:55 +00:00
|
|
|
RemoteImage {
|
|
|
|
id: albumArtImage
|
|
|
|
anchors {
|
|
|
|
right: parent.right
|
|
|
|
bottom: parent.bottom
|
|
|
|
}
|
2022-07-23 18:01:23 +00:00
|
|
|
aspectRatio: listHeader.aspectRatio
|
2021-01-17 20:11:55 +00:00
|
|
|
sourceSize.width: listHeader.width
|
2022-07-23 18:01:23 +00:00
|
|
|
sourceSize.height: listHeader.width / aspectRatio
|
2021-01-17 20:11:55 +00:00
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
opacity: 1
|
|
|
|
clip: true
|
|
|
|
}
|
|
|
|
|
2020-10-27 01:35:50 +00:00
|
|
|
states: [
|
|
|
|
State {
|
2021-01-17 20:11:55 +00:00
|
|
|
name: "art"
|
|
|
|
when: albumArtImage.status != Image.Null && !twoColumns
|
2020-10-27 01:35:50 +00:00
|
|
|
PropertyChanges {
|
2021-01-17 20:11:55 +00:00
|
|
|
target: listview
|
2022-07-23 18:01:23 +00:00
|
|
|
//contentY: -smallHeight
|
|
|
|
topMargin: bigHeight - smallHeight
|
2021-01-17 20:11:55 +00:00
|
|
|
bottomMargin: listview.contentHeight < listview.height ? listview.height - listview.contentHeight : 0
|
2020-10-27 01:35:50 +00:00
|
|
|
}
|
|
|
|
PropertyChanges {
|
2021-01-17 20:11:55 +00:00
|
|
|
target: albumArtImage
|
|
|
|
opacity: 1
|
2022-07-23 18:01:23 +00:00
|
|
|
width: height * aspectRatio
|
|
|
|
height: smallHeight + -(Math.min(listview.contentY + smallHeight , 0) / (listview.topMargin)) * (bigHeight - smallHeight)
|
2020-10-27 01:35:50 +00:00
|
|
|
}
|
|
|
|
PropertyChanges {
|
2021-01-17 20:11:55 +00:00
|
|
|
target: listHeader
|
2022-07-23 18:01:23 +00:00
|
|
|
height: smallHeight
|
2021-01-17 20:11:55 +00:00
|
|
|
visible: true
|
2020-10-27 01:35:50 +00:00
|
|
|
}
|
|
|
|
PropertyChanges {
|
2021-01-17 20:11:55 +00:00
|
|
|
target: albumHeader
|
2022-07-23 18:01:23 +00:00
|
|
|
opacity: 1.0 - Math.min(1.0, Math.max(0.0, -Math.min(listview.contentY + smallHeight, 0) / (listview.topMargin)))
|
2021-01-17 20:11:55 +00:00
|
|
|
anchors.rightMargin: Theme.paddingMedium + albumArtImage.width
|
2020-10-27 01:35:50 +00:00
|
|
|
}
|
|
|
|
AnchorChanges {
|
|
|
|
target: albumHeader
|
2021-01-17 20:11:55 +00:00
|
|
|
anchors.top: albumArtImage.top
|
2020-10-27 01:35:50 +00:00
|
|
|
anchors.left: undefined
|
2021-01-17 20:11:55 +00:00
|
|
|
anchors.right: parent.right
|
2020-10-27 01:35:50 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
2021-01-17 20:11:55 +00:00
|
|
|
name: "noArt"
|
|
|
|
when: albumArtImage.status == Image.Null && !twoColumns
|
2020-10-27 01:35:50 +00:00
|
|
|
PropertyChanges {
|
2021-01-17 20:11:55 +00:00
|
|
|
target: albumArtImage
|
|
|
|
opacity: 0
|
2020-10-27 01:35:50 +00:00
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: listHeader
|
2022-07-23 18:01:23 +00:00
|
|
|
height: smallHeight
|
2020-10-27 01:35:50 +00:00
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: albumHeader
|
2021-01-17 20:11:55 +00:00
|
|
|
width: parent.width - Theme.horizontalPageMargin * 2
|
2020-10-27 01:35:50 +00:00
|
|
|
opacity: 1
|
|
|
|
}
|
|
|
|
AnchorChanges {
|
|
|
|
target: albumHeader
|
2021-01-17 20:11:55 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2020-10-27 01:35:50 +00:00
|
|
|
}
|
2021-01-17 20:11:55 +00:00
|
|
|
|
2020-10-27 01:35:50 +00:00
|
|
|
},
|
|
|
|
State {
|
2021-01-17 20:11:55 +00:00
|
|
|
name: "hidden"
|
|
|
|
when: twoColumns
|
2020-10-27 01:35:50 +00:00
|
|
|
PropertyChanges {
|
2021-01-17 20:11:55 +00:00
|
|
|
target: listview
|
|
|
|
topMargin: 0
|
2020-10-27 01:35:50 +00:00
|
|
|
}
|
2021-01-17 20:11:55 +00:00
|
|
|
|
2020-10-27 01:35:50 +00:00
|
|
|
PropertyChanges {
|
2021-01-17 20:11:55 +00:00
|
|
|
target: listHeader
|
|
|
|
height: 0
|
|
|
|
visible: false
|
2020-10-27 01:35:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
transitions: [
|
2021-01-17 20:11:55 +00:00
|
|
|
/*Transition {
|
2020-10-27 01:35:50 +00:00
|
|
|
from: "noArt"
|
|
|
|
// No transitions from "noArt", otherwise the layout animates every load
|
2021-01-17 20:11:55 +00:00
|
|
|
},*/
|
|
|
|
Transition {
|
|
|
|
from: "hidden"
|
|
|
|
SequentialAnimation {
|
|
|
|
PauseAnimation {
|
|
|
|
duration: 50
|
|
|
|
}
|
|
|
|
ScriptAction {
|
|
|
|
script: {
|
|
|
|
if (listview.contentY < 10) {
|
|
|
|
listviewShrinkAnimation.start()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Transition {
|
|
|
|
to: "noArt"
|
|
|
|
SequentialAnimation {
|
|
|
|
PauseAnimation {
|
|
|
|
duration: 10
|
|
|
|
}
|
|
|
|
ScriptAction {
|
|
|
|
script: {
|
|
|
|
if (listview.contentY < 10) {
|
2022-07-23 18:01:23 +00:00
|
|
|
listview.contentY = -smallHeight
|
2021-01-17 20:11:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Transition {
|
|
|
|
to: "art"
|
|
|
|
SequentialAnimation {
|
|
|
|
PauseAnimation {
|
|
|
|
duration: 10
|
|
|
|
}
|
|
|
|
ScriptAction {
|
|
|
|
script: {
|
|
|
|
if (listview.contentY < 10) {
|
2022-07-23 18:01:23 +00:00
|
|
|
listview.contentY = -smallHeight
|
2021-01-17 20:11:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-27 01:35:50 +00:00
|
|
|
},
|
|
|
|
Transition {
|
|
|
|
OpacityAnimator { target: albumHeader}
|
|
|
|
OpacityAnimator { target: _albumArt}
|
|
|
|
NumberAnimation {
|
|
|
|
properties: "width,height,contentY"
|
|
|
|
//velocity: 1600
|
|
|
|
duration: 300
|
|
|
|
easing.type: Easing.OutQuad
|
|
|
|
}
|
|
|
|
AnchorAnimation {}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|