Alex Jbanca 8b4cbc59a8 refactor: Refactoring of AccountSelector dropdown
The new account selector expects a generic account model. It will display all the account data if provided, including preferred chains, balance or asset balance. Otherwise it will display only the available data.
The account selector can receive an initial selection based on account address and will provide the current selected address and the current selected model item.

- Unify the account selector between communities and wallet
- Update the account selector to work with addresses instead of model indexes
- Adapt all components using the account selector or the account selection
- Move/reuse qml components involved in the account selector UI
- Remove nim logic used to handle index based account selection.
- Adding storybook page
2024-06-20 11:24:35 +03:00

104 lines
2.3 KiB
QML

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import shared.controls 1.0
import utils 1.0
Control {
id: root
property alias generalErrorText: generalErrorText.text
property bool showTotal: true
property alias totalFeeText: feeTotalRow.feeText
readonly property alias accountsSelector: accountSelector
property bool showAccountsSelector: true
property alias accountErrorText: accountErrorText.text
required property string accountSelectorText
component Separator: Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 1
Layout.topMargin: Style.current.padding
color: Theme.palette.baseColor2
}
component ErrorText: StatusBaseText {
Layout.fillWidth: true
Layout.topMargin: Style.current.halfPadding
horizontalAlignment: Text.AlignRight
font.pixelSize: Theme.tertiaryTextFontSize
color: Theme.palette.dangerColor1
wrapMode: Text.Wrap
}
contentItem: ColumnLayout {
spacing: 0
ErrorText {
id: generalErrorText
visible: text !== ""
}
Separator {
visible: root.showTotal
}
FeeRow {
id: feeTotalRow
Layout.fillWidth: true
Layout.topMargin: Style.current.padding
title: qsTr("Total")
highlightFee: true
visible: root.showTotal
}
Separator {
visible: accountSelector.visible
}
StatusBaseText {
Layout.topMargin: Style.current.padding
Layout.fillWidth: true
visible: accountSelector.visible
text: root.accountSelectorText
color: Theme.palette.baseColor1
font.pixelSize: Theme.primaryTextFontSize
lineHeight: 1.2
wrapMode: Text.WordWrap
}
AccountSelector {
id: accountSelector
Layout.fillWidth: true
Layout.topMargin: Style.current.halfPadding
visible: root.showAccountsSelector
forceError: accountErrorText.visible
}
ErrorText {
id: accountErrorText
visible: accountSelector.visible && text !== ""
}
}
}