fix(receive) fix header alignment for ReceiveModal

Add a reusable header shared between Send and Receive modals

Updates #8180
This commit is contained in:
Stefan 2022-11-11 11:24:26 +02:00 committed by Stefan Dunca
parent 245f3a7266
commit 7bd9808476
4 changed files with 33 additions and 66 deletions

View File

@ -1,6 +1,7 @@
import QtQuick 2.13
import QtGraphicalEffects 1.13
import QtQuick.Layouts 1.13
import QtQuick.Controls 2.14
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
@ -13,6 +14,7 @@ import StatusQ.Core.Utils 0.1
import utils 1.0
import shared.controls 1.0
import shared.popups 1.0
import "../stores"
@ -25,7 +27,7 @@ StatusModal {
onSelectedAccountChanged: {
if (selectedAccount.address) {
txtWalletAddress.text = selectedAccount.mixedcaseAddress
txtWalletAddress.text = selectedAccount.address
}
}
@ -50,53 +52,13 @@ StatusModal {
}
hasFloatingButtons: true
advancedHeaderComponent: StatusFloatingButtonsSelector {
id: floatingHeader
advancedHeaderComponent: AccountsModalHeader {
model: RootStore.accounts
delegate: Rectangle {
width: button.width
height: button.height
radius: 8
visible: floatingHeader.visibleIndices.includes(index)
StatusButton {
id: button
topPadding: 8
bottomPadding: 0
implicitHeight: 32
leftPadding: 4
text: name
asset.emoji: !!emoji ? emoji: ""
asset.emojiSize: Emoji.size.middle
icon.name: !emoji ? "filled-account": ""
normalColor: "transparent"
highlighted: index === floatingHeader.currentIndex
onClicked: {
popup.selectedAccount = model
floatingHeader.currentIndex = index
}
Component.onCompleted: {
// On startup make the preseected wallet in the floating menu
if(name === popup.selectedAccount.name)
floatingHeader.currentIndex = index
}
}
}
popupMenuDelegate: StatusListItem {
implicitWidth: 272
title: name
subTitle: currencyBalance
asset.emoji: !!emoji ? emoji: ""
asset.color: model.color
asset.name: !emoji ? "filled-account": ""
asset.letterSize: 14
asset.isLetterIdenticon: !!model.emoji
asset.bgColor: Theme.palette.indirectColor1
onClicked: {
popup.selectedAccount = model
floatingHeader.itemSelected(index)
}
visible: !floatingHeader.visibleIndices.includes(index)
selectedAccount: popup.selectedAccount
changeSelectedAccount: function(newAccount, newIndex) {
popup.selectedAccount = newAccount
}
showAllWalletTypes: true
}
contentItem: Column {
@ -286,9 +248,7 @@ StatusModal {
testNetworks: RootStore.testNetworks
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
onToggleNetwork: {
RootStore.toggleNetwork(chainId)
}
onToggleNetwork: (chainId) => RootStore.toggleNetwork(chainId)
}
states: [

View File

@ -16,25 +16,31 @@ import "../controls"
import "../views"
StatusFloatingButtonsSelector {
id: floatingHeader
id: root
property var selectedAccount
// Expected signature: function(newAccount, newIndex)
property var changeSelectedAccount: function(){}
property bool showAllWalletTypes: false
repeater.objectName: "accountsListFloatingHeader"
signal updatedSelectedAccount(var account)
QtObject {
id: d
property var firstModelData: null
function isWalletTypeAccepted(walletType, index) {
return (root.showAllWalletTypes || walletType !== Constants.watchWalletType)
}
}
delegate: Rectangle {
width: button.width
height: button.height
radius: 8
visible: floatingHeader.visibleIndices.includes(index) && walletType !== Constants.watchWalletType
visible: root.visibleIndices.includes(index) && d.isWalletTypeAccepted(walletType, index)
color: Theme.palette.baseColor3
StatusButton {
id: button
@ -47,10 +53,10 @@ StatusFloatingButtonsSelector {
icon.name: !emoji ? "filled-account": ""
normalColor: "transparent"
hoverColor: Theme.palette.statusFloatingButtonHighlight
highlighted: index === floatingHeader.currentIndex
highlighted: index === root.currentIndex
onClicked: {
changeSelectedAccount(index)
floatingHeader.currentIndex = index
changeSelectedAccount(model, index)
root.currentIndex = index
}
Component.onCompleted: {
// On startup make the preseected wallet in the floating menu,
@ -59,21 +65,21 @@ StatusFloatingButtonsSelector {
d.firstModelData = model
}
if(name !== floatingHeader.selectedAccount.name) {
if(name !== root.selectedAccount.name) {
return
}
if(name === floatingHeader.selectedAccount.name) {
if(walletType !== Constants.watchWalletType) {
if(name === root.selectedAccount.name) {
if(d.isWalletTypeAccepted(walletType, index)) {
// If the selected index wont be displayed, added it to the visible indices
if(index > 2) {
visibleIndices = [0, 1, index]
}
floatingHeader.currentIndex = index
root.currentIndex = index
}
else {
changeSelectedAccount(0)
floatingHeader.currentIndex = 0
changeSelectedAccount(root.selectedAccount, 0)
root.currentIndex = 0
}
}
}
@ -90,10 +96,10 @@ StatusFloatingButtonsSelector {
asset.isLetterIdenticon: !!model.emoji
asset.bgColor: Theme.palette.indirectColor1
onClicked: {
changeSelectedAccount(index)
floatingHeader.itemSelected(index)
changeSelectedAccount(model, index)
root.itemSelected(index)
}
visible: !floatingHeader.visibleIndices.includes(index) && walletType !== Constants.watchWalletType
visible: !root.visibleIndices.includes(index) && d.isWalletTypeAccepted(walletType, index)
}
}

View File

@ -160,12 +160,12 @@ StatusDialog {
}
}
header: SendModalHeader {
header: AccountsModalHeader {
anchors.top: parent.top
anchors.topMargin: -height - 18
model: popup.store.accounts
selectedAccount: popup.selectedAccount
changeSelectedAccount: function(newIndex) {
changeSelectedAccount: function(newAccount, newIndex) {
if (newIndex > popup.store.accounts) {
return
}

View File

@ -24,3 +24,4 @@ ImportCommunityPopup 1.0 ImportCommunityPopup.qml
DisplayNamePopup 1.0 DisplayNamePopup.qml
AddEditSavedAddressPopup 1.0 AddEditSavedAddressPopup.qml
SendContactRequestModal 1.0 SendContactRequestModal.qml
AccountsModalHeader 1.0 AccountsModalHeader.qml