fix(@desktop/wallet): Update wallet accounts list effects (#11680)

fixes #11626
This commit is contained in:
Cuteivist 2023-08-03 10:19:36 +02:00 committed by GitHub
parent 238a18b462
commit 3366f23f12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 186 additions and 170 deletions

View File

@ -1,5 +1,5 @@
import QtQuick 2.13 import QtQuick 2.15
import QtQuick.Controls 2.13 import QtQuick.Controls 2.15
import QtQuick.Layouts 1.13 import QtQuick.Layouts 1.13
import QtGraphicalEffects 1.13 import QtGraphicalEffects 1.13
import SortFilterProxyModel 0.2 import SortFilterProxyModel 0.2
@ -34,16 +34,25 @@ Rectangle {
property bool showAllAccounts: true property bool showAllAccounts: true
property string currentAddress: "" property string currentAddress: ""
onCurrentAddressChanged: {
if (!currentAddress)
return
root.showAllAccounts = false
root.showSavedAddresses = false
}
onShowSavedAddressesChanged: { onShowSavedAddressesChanged: {
if (!showSavedAddresses)
return
root.currentAddress = "" root.currentAddress = ""
walletAccountsListView.headerItem.highlighted = root.showAllAccounts root.showAllAccounts = false
walletAccountsListView.footerItem.button.highlighted = root.showSavedAddresses
} }
onShowAllAccountsChanged: { onShowAllAccountsChanged: {
if (!showAllAccounts)
return
root.currentAddress = "" root.currentAddress = ""
walletAccountsListView.headerItem.highlighted = root.showAllAccounts root.showSavedAddresses = false
walletAccountsListView.footerItem.button.highlighted = root.showSavedAddresses
} }
property var emojiPopup: null property var emojiPopup: null
@ -160,7 +169,7 @@ Rectangle {
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
spacing: Style.current.padding spacing: 0
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
@ -172,9 +181,7 @@ Rectangle {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
acceptedButtons: Qt.RightButton acceptedButtons: Qt.RightButton
onClicked: { onClicked: mouse.accepted = true
mouse.accepted = true
}
} }
StatusBaseText { StatusBaseText {
@ -199,20 +206,46 @@ Rectangle {
} }
} }
Rectangle {
Layout.fillWidth: true
Layout.minimumHeight: Style.current.bigPadding
color: root.color
z: 2
layer.enabled: !walletAccountsListView.atYBeginning
layer.effect: DropShadow {
verticalOffset: 10
radius: 20
samples: 41
fast: true
cached: true
color: Theme.palette.dropShadow2
}
}
Item {
Layout.fillHeight: true
Layout.fillWidth: true
StatusListView { StatusListView {
id: walletAccountsListView id: walletAccountsListView
objectName: "walletAccountsListView" objectName: "walletAccountsListView"
anchors {
top: parent.top
left: parent.left
right: parent.right
}
height: parent.height - footer.height
spacing: Style.current.smallPadding spacing: Style.current.smallPadding
Layout.fillWidth: true
Layout.fillHeight: true
Layout.topMargin: Style.current.halfPadding
currentIndex: -1 currentIndex: -1
highlightRangeMode: ListView.ApplyRange highlightRangeMode: ListView.ApplyRange
preferredHighlightBegin: 0 preferredHighlightBegin: 0
preferredHighlightEnd: height - (footerOverlayed ? footerItem.height : 0) preferredHighlightEnd: height
bottomMargin: Style.current.padding
readonly property Item firstItem: count > 0 ? itemAtIndex(0) : null readonly property Item firstItem: count > 0 ? itemAtIndex(0) : null
readonly property bool footerOverlayed: contentHeight > availableHeight
delegate: StatusListItem { delegate: StatusListItem {
objectName: "walletAccount-" + model.name objectName: "walletAccount-" + model.name
@ -247,8 +280,6 @@ Rectangle {
walletAccountContextMenu.item.popup(this, mouse.x, mouse.y) walletAccountContextMenu.item.popup(this, mouse.x, mouse.y)
return return
} }
root.showSavedAddresses = false
root.showAllAccounts = false
changeSelectedAccount(model.address) changeSelectedAccount(model.address)
} }
components: [ components: [
@ -267,13 +298,11 @@ Rectangle {
] ]
} }
readonly property bool footerOverlayed: contentHeight > availableHeight
header: Button { header: Button {
id: header id: header
verticalPadding: Style.current.padding verticalPadding: Style.current.padding
horizontalPadding: Style.current.padding horizontalPadding: Style.current.padding
highlighted: true highlighted: root.showAllAccounts
objectName: "allAccountsBtn" objectName: "allAccountsBtn"
leftInset: Style.current.padding leftInset: Style.current.padding
@ -285,26 +314,13 @@ Rectangle {
anchors.fill: parent anchors.fill: parent
acceptedButtons: Qt.LeftButton acceptedButtons: Qt.LeftButton
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: root.selectAllAccounts()
root.showSavedAddresses = false
walletAccountsListView.currentIndex = -1
root.selectAllAccounts()
}
hoverEnabled: true hoverEnabled: true
} }
radius: Style.current.radius radius: Style.current.radius
color: header.highlighted || mouseArea.containsMouse ? Theme.palette.baseColor3 : root.color color: header.highlighted || mouseArea.containsMouse ? Style.current.backgroundHover : root.color
implicitWidth: parent.ListView.view.width - Style.current.padding * 2 implicitWidth: parent.ListView.view.width - Style.current.padding * 2
implicitHeight: parent.ListView.view.firstItem.height + Style.current.padding implicitHeight: parent.ListView.view.firstItem.height + Style.current.padding
layer.effect: DropShadow {
verticalOffset: -10
radius: 20
samples: 41
fast: true
cached: true
color: Theme.palette.dropShadow2
}
} }
contentItem: Item { contentItem: Item {
@ -346,22 +362,33 @@ Rectangle {
} }
} }
footerPositioning: footerOverlayed ? ListView.OverlayFooter : ListView.InlineFooter model: SortFilterProxyModel {
footer: Control { sourceModel: RootStore.accounts
sorters: RoleSorter { roleName: "position"; sortOrder: Qt.AscendingOrder }
}
}
Control {
id: footer id: footer
z: 2 // to be on top of delegates when in ListView.OverlayFooter anchors {
top: parent.top
// Bottom Margin is not applied to ListView if it's fully visible
topMargin: Math.min(walletAccountsListView.contentHeight, parent.height - height) + (walletAccountsListView.footerOverlayed ? 0 : walletAccountsListView.bottomMargin)
left: parent.left
right: parent.right
}
horizontalPadding: Style.current.padding horizontalPadding: Style.current.padding
verticalPadding: Style.current.padding verticalPadding: Style.current.padding
property alias button: savedAddressesBtn
background: Rectangle { background: Rectangle {
id: footerBackground
color: root.color color: root.color
implicitWidth: root.width implicitWidth: root.width
implicitHeight: parent.ListView.view.firstItem.height + Style.current.xlPadding implicitHeight: walletAccountsListView.firstItem.height + Style.current.xlPadding
layer.enabled: parent.ListView.view.footerOverlayed layer.enabled: walletAccountsListView.footerOverlayed && !walletAccountsListView.atYEnd
layer.effect: DropShadow { layer.effect: DropShadow {
verticalOffset: -10 verticalOffset: -10
radius: 20 radius: 20
@ -371,19 +398,17 @@ Rectangle {
color: Theme.palette.dropShadow2 color: Theme.palette.dropShadow2
} }
StatusMenuSeparator { Separator {
id: footerSeparator anchors.top: parent.top
anchors.topMargin: -1
width: parent.width width: parent.width
visible: !footer.ListView.view.footerOverlayed
} }
} }
contentItem: StatusFlatButton { contentItem: StatusFlatButton {
id: savedAddressesBtn
objectName: "savedAddressesBtn" objectName: "savedAddressesBtn"
hoverColor: Theme.palette.baseColor3 highlighted: root.showSavedAddresses
hoverColor: Style.current.backgroundHover
asset.bgColor: Theme.palette.primaryColor3 asset.bgColor: Theme.palette.primaryColor3
text: qsTr("Saved addresses") text: qsTr("Saved addresses")
icon.name: "address" icon.name: "address"
@ -393,28 +418,19 @@ Rectangle {
isRoundIcon: true isRoundIcon: true
textColor: Theme.palette.directColor1 textColor: Theme.palette.directColor1
textFillWidth: true textFillWidth: true
spacing: parent.ListView.view.firstItem.statusListItemTitleArea.anchors.leftMargin spacing: walletAccountsListView.firstItem.statusListItemTitleArea.anchors.leftMargin
onClicked: { onClicked: root.showSavedAddresses = true
root.showAllAccounts = false
root.showSavedAddresses = true
}
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
acceptedButtons: Qt.RightButton acceptedButtons: Qt.RightButton
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
propagateComposedEvents: true propagateComposedEvents: true
onClicked: { onClicked: mouse.accepted = true
mouse.accepted = true
} }
} }
} }
} }
model: SortFilterProxyModel {
sourceModel: RootStore.accounts
sorters: RoleSorter { roleName: "position"; sortOrder: Qt.AscendingOrder }
}
}
} }
} }