2022-03-31 11:46:25 +00:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import "../stores"
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: derivedAddresses
|
|
|
|
|
|
|
|
property string pathSubFix: ""
|
2022-05-12 15:24:03 +00:00
|
|
|
property bool isLoading: RootStore.derivedAddressesLoading
|
|
|
|
property bool pathError: Utils.isInvalidPath(RootStore.derivedAddressesError)
|
|
|
|
|
2022-03-31 11:46:25 +00:00
|
|
|
function reset() {
|
|
|
|
RootStore.resetDerivedAddressModel()
|
2022-04-13 12:58:42 +00:00
|
|
|
_internal.nextSelectableAddressIndex = 0
|
2022-03-31 11:46:25 +00:00
|
|
|
selectedDerivedAddress.pathSubFix = 0
|
|
|
|
selectedDerivedAddress.title = "---"
|
|
|
|
selectedDerivedAddress.subTitle = qsTr("No activity")
|
|
|
|
}
|
|
|
|
|
2022-05-12 15:24:03 +00:00
|
|
|
onIsLoadingChanged: {
|
|
|
|
if(isLoading) {
|
|
|
|
selectedDerivedAddress.title = qsTr("Pending")
|
|
|
|
selectedDerivedAddress.subTitle = ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onPathErrorChanged: {
|
|
|
|
if(pathError) {
|
|
|
|
selectedDerivedAddress.title = qsTr("Invalid path")
|
|
|
|
selectedDerivedAddress.subTitle = ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-31 11:46:25 +00:00
|
|
|
QtObject {
|
|
|
|
id: _internal
|
|
|
|
property int pageSize: 6
|
|
|
|
property int noOfPages: Math.ceil(RootStore.derivedAddressesList.count/pageSize)
|
|
|
|
property int lastPageSize: RootStore.derivedAddressesList.count - ((noOfPages -1) * pageSize)
|
|
|
|
property bool isLastPage: stackLayout.currentIndex == (noOfPages - 1)
|
2022-04-13 12:58:42 +00:00
|
|
|
property int nextSelectableAddressIndex: RootStore.getNextSelectableDerivedAddressIndex()
|
|
|
|
|
|
|
|
onNextSelectableAddressIndexChanged: {
|
|
|
|
stackLayout.currentIndex = nextSelectableAddressIndex/_internal.pageSize
|
|
|
|
if(nextSelectableAddressIndex >= 0 && nextSelectableAddressIndex < RootStore.derivedAddressesList.count) {
|
|
|
|
selectedDerivedAddress.title = RootStore.getDerivedAddressData(nextSelectableAddressIndex)
|
2022-05-05 15:01:54 +00:00
|
|
|
selectedDerivedAddress.hasActivity = RootStore.getDerivedAddressHasActivityData(nextSelectableAddressIndex)
|
2022-04-13 12:58:42 +00:00
|
|
|
selectedDerivedAddress.subTitle = RootStore.getDerivedAddressHasActivityData(nextSelectableAddressIndex) ? qsTr("Has Activity"): qsTr("No Activity")
|
|
|
|
selectedDerivedAddress.enabled = !RootStore.getDerivedAddressAlreadyCreatedData(nextSelectableAddressIndex)
|
|
|
|
selectedDerivedAddress.pathSubFix = nextSelectableAddressIndex
|
|
|
|
}
|
|
|
|
}
|
2022-03-31 11:46:25 +00:00
|
|
|
|
|
|
|
// dimensions
|
|
|
|
property int popupWidth: 359
|
|
|
|
property int maxAddressWidth: 102
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: RootStore.derivedAddressesList
|
|
|
|
onModelReset: {
|
|
|
|
_internal.pageSize = 0
|
|
|
|
_internal.pageSize = 6
|
2022-04-13 12:58:42 +00:00
|
|
|
_internal.nextSelectableAddressIndex = -1
|
|
|
|
_internal.nextSelectableAddressIndex = RootStore.getNextSelectableDerivedAddressIndex()
|
2022-03-31 11:46:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: layout
|
|
|
|
width: parent.width
|
|
|
|
spacing: 7
|
|
|
|
StatusBaseText {
|
|
|
|
id: inputLabel
|
|
|
|
width: parent.width
|
|
|
|
text: qsTr("Account")
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: selectedDerivedAddress.enabled ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
StatusListItem {
|
|
|
|
id: selectedDerivedAddress
|
|
|
|
property int pathSubFix: 0
|
2022-05-05 15:01:54 +00:00
|
|
|
property bool hasActivity: false
|
2022-03-31 11:46:25 +00:00
|
|
|
implicitWidth: parent.width
|
|
|
|
color: "transparent"
|
|
|
|
border.width: 1
|
|
|
|
border.color: Theme.palette.baseColor2
|
|
|
|
title: "---"
|
2022-05-05 15:01:54 +00:00
|
|
|
subTitle: selectedDerivedAddress.hasActivity ? qsTr("Has Activity"): qsTr("No Activity")
|
|
|
|
statusListItemSubTitle.color: selectedDerivedAddress.hasActivity ? Theme.palette.primaryColor1 : Theme.palette.baseColor1
|
2022-03-31 11:46:25 +00:00
|
|
|
statusListItemTitle.wrapMode: Text.NoWrap
|
|
|
|
statusListItemTitle.width: _internal.maxAddressWidth
|
|
|
|
statusListItemTitle.elide: Qt.ElideMiddle
|
|
|
|
statusListItemTitle.anchors.left: undefined
|
|
|
|
statusListItemTitle.anchors.right: undefined
|
|
|
|
components: [
|
|
|
|
StatusIcon {
|
|
|
|
width: 24
|
|
|
|
height: 24
|
|
|
|
icon: "chevron-down"
|
|
|
|
color: Theme.palette.baseColor1
|
2022-05-12 15:24:03 +00:00
|
|
|
visible: RootStore.derivedAddressesList.count > 1
|
2022-03-31 11:46:25 +00:00
|
|
|
}
|
|
|
|
]
|
2022-05-12 15:24:03 +00:00
|
|
|
onClicked: {
|
|
|
|
if(RootStore.derivedAddressesList.count > 0 && RootStore.derivedAddressesList.count !== 1)
|
|
|
|
derivedAddressPopup.popup(derivedAddresses.x - layout.width - Style.current.bigPadding , derivedAddresses.y + layout.height + 8)
|
|
|
|
}
|
2022-03-31 11:46:25 +00:00
|
|
|
enabled: RootStore.derivedAddressesList.count > 0
|
|
|
|
Component.onCompleted: derivedAddresses.pathSubFix = Qt.binding(function() { return pathSubFix})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusPopupMenu {
|
|
|
|
id: derivedAddressPopup
|
|
|
|
width: _internal.popupWidth
|
|
|
|
contentItem: Column {
|
|
|
|
StackLayout {
|
|
|
|
id: stackLayout
|
|
|
|
Layout.fillWidth:true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Repeater {
|
|
|
|
id: pageModel
|
|
|
|
model: _internal.noOfPages
|
|
|
|
delegate: Page {
|
|
|
|
id: page
|
|
|
|
contentItem: ColumnLayout {
|
|
|
|
Repeater {
|
|
|
|
id: repeater
|
|
|
|
model: _internal.isLastPage ? _internal.lastPageSize : _internal.pageSize
|
|
|
|
delegate: StatusListItem {
|
|
|
|
id: element
|
|
|
|
property int actualIndex: index + (stackLayout.currentIndex* _internal.pageSize)
|
2022-05-12 15:24:03 +00:00
|
|
|
property bool hasActivity: {
|
|
|
|
if(actualIndex >= 0 && actualIndex < RootStore.derivedAddressesList.count) {
|
|
|
|
return RootStore.getDerivedAddressHasActivityData(actualIndex)
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2022-03-31 11:46:25 +00:00
|
|
|
implicitWidth: derivedAddressPopup.width
|
|
|
|
statusListItemTitle.wrapMode: Text.NoWrap
|
|
|
|
statusListItemTitle.width: _internal.maxAddressWidth
|
|
|
|
statusListItemTitle.elide: Qt.ElideMiddle
|
|
|
|
statusListItemTitle.anchors.left: undefined
|
|
|
|
statusListItemTitle.anchors.right: undefined
|
2022-05-12 15:24:03 +00:00
|
|
|
title: {
|
|
|
|
if(actualIndex >= 0 && actualIndex < RootStore.derivedAddressesList.count) {
|
|
|
|
return RootStore.getDerivedAddressData(actualIndex)
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
2022-05-05 15:01:54 +00:00
|
|
|
subTitle: element.hasActivity ? qsTr("Has Activity"): qsTr("No Activity")
|
|
|
|
statusListItemSubTitle.color: element.hasActivity ? Theme.palette.primaryColor1 : Theme.palette.baseColor1
|
2022-05-12 15:24:03 +00:00
|
|
|
enabled: {
|
|
|
|
if(actualIndex >= 0 && actualIndex < RootStore.derivedAddressesList.count) {
|
|
|
|
return !RootStore.getDerivedAddressAlreadyCreatedData(actualIndex)
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
2022-03-31 11:46:25 +00:00
|
|
|
components: [
|
|
|
|
StatusBaseText {
|
|
|
|
text: element.actualIndex
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.baseColor1
|
2022-05-05 15:01:54 +00:00
|
|
|
},
|
|
|
|
Rectangle {
|
|
|
|
radius: width/2
|
|
|
|
height: 5
|
|
|
|
width: 5
|
|
|
|
color: Theme.palette.primaryColor1
|
|
|
|
visible: element.hasActivity
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2022-03-31 11:46:25 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
onClicked: {
|
|
|
|
selectedDerivedAddress.title = title
|
|
|
|
selectedDerivedAddress.subTitle = subTitle
|
|
|
|
selectedDerivedAddress.pathSubFix = actualIndex
|
2022-05-05 15:01:54 +00:00
|
|
|
selectedDerivedAddress.hasActivity = element.hasActivity
|
2022-03-31 11:46:25 +00:00
|
|
|
derivedAddressPopup.close()
|
2022-05-12 15:24:03 +00:00
|
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
|
|
if(RootStore.derivedAddressesList.count === 1 && index === 0) {
|
|
|
|
selectedDerivedAddress.title = title
|
|
|
|
selectedDerivedAddress.subTitle = subTitle
|
|
|
|
selectedDerivedAddress.pathSubFix = actualIndex
|
|
|
|
selectedDerivedAddress.hasActivity = element.hasActivity
|
|
|
|
selectedDerivedAddress.enabled = !RootStore.getDerivedAddressAlreadyCreatedData(index)
|
|
|
|
}
|
2022-03-31 11:46:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-08 09:48:37 +00:00
|
|
|
background: Rectangle {
|
|
|
|
implicitWidth: stackLayout.width
|
|
|
|
implicitHeight: stackLayout.height
|
|
|
|
color: Theme.palette.statusPopupMenu.backgroundColor
|
|
|
|
radius: 8
|
|
|
|
}
|
2022-03-31 11:46:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PageIndicator {
|
|
|
|
id: pageIndicator
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
interactive: true
|
|
|
|
currentIndex: stackLayout.currentIndex
|
|
|
|
count: stackLayout.count
|
|
|
|
onCurrentIndexChanged: stackLayout.currentIndex = currentIndex
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|