2022-03-18 14:47:51 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import StatusQ.Controls.Validators 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2022-06-27 13:41:47 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
2022-03-18 14:47:51 +00:00
|
|
|
|
|
|
|
import "../controls"
|
|
|
|
import "../views"
|
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
StatusFloatingButtonsSelector {
|
2022-11-11 09:24:26 +00:00
|
|
|
id: root
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2023-04-25 16:54:50 +00:00
|
|
|
property string currentAddress
|
2022-06-27 13:41:47 +00:00
|
|
|
property var selectedAccount
|
2023-04-06 12:59:24 +00:00
|
|
|
// Expected signature: function(newAccount)
|
2022-08-01 17:04:23 +00:00
|
|
|
property var changeSelectedAccount: function(){}
|
2022-11-11 09:24:26 +00:00
|
|
|
property bool showAllWalletTypes: false
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2022-07-21 12:15:02 +00:00
|
|
|
repeater.objectName: "accountsListFloatingHeader"
|
2022-11-11 09:24:26 +00:00
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
signal updatedSelectedAccount(var account)
|
2022-05-19 08:53:57 +00:00
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
delegate: Rectangle {
|
|
|
|
width: button.width
|
|
|
|
height: button.height
|
|
|
|
radius: 8
|
2022-07-26 18:14:55 +00:00
|
|
|
color: Theme.palette.baseColor3
|
2022-06-27 13:41:47 +00:00
|
|
|
StatusButton {
|
|
|
|
id: button
|
2022-09-19 12:29:02 +00:00
|
|
|
size: StatusBaseButton.Size.Tiny
|
2022-06-27 13:41:47 +00:00
|
|
|
implicitHeight: 32
|
2022-09-13 07:37:09 +00:00
|
|
|
leftPadding: 4
|
2022-06-27 13:41:47 +00:00
|
|
|
text: name
|
2022-07-21 12:15:02 +00:00
|
|
|
objectName: name
|
2022-09-13 07:37:09 +00:00
|
|
|
asset.emoji: !!emoji ? emoji: ""
|
2022-06-27 13:41:47 +00:00
|
|
|
icon.name: !emoji ? "filled-account": ""
|
|
|
|
normalColor: "transparent"
|
2022-07-26 18:14:55 +00:00
|
|
|
hoverColor: Theme.palette.statusFloatingButtonHighlight
|
2022-11-11 09:24:26 +00:00
|
|
|
highlighted: index === root.currentIndex
|
2022-06-27 13:41:47 +00:00
|
|
|
onClicked: {
|
2023-04-06 12:59:24 +00:00
|
|
|
changeSelectedAccount(model)
|
2022-11-11 09:24:26 +00:00
|
|
|
root.currentIndex = index
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
2022-06-27 13:41:47 +00:00
|
|
|
Component.onCompleted: {
|
2023-04-06 12:59:24 +00:00
|
|
|
// on model reset, set the selected account to the one that was previously selected
|
2023-04-25 16:54:50 +00:00
|
|
|
if(!root.selectedAccount) {
|
2023-04-06 12:59:24 +00:00
|
|
|
if(root.currentIndex === index) {
|
|
|
|
changeSelectedAccount(model)
|
|
|
|
}
|
2023-04-25 16:54:50 +00:00
|
|
|
if(root.currentAddress === model.address) {
|
|
|
|
root.currentIndex = index
|
|
|
|
changeSelectedAccount(model)
|
|
|
|
}
|
|
|
|
} else {
|
2023-04-06 12:59:24 +00:00
|
|
|
// if the selectedAccount is watch only then select 0th item
|
|
|
|
if(index === 0 && !!root.selectedAccount && root.selectedAccount.walletType === Constants.watchWalletType) {
|
|
|
|
changeSelectedAccount(model)
|
2022-11-11 09:24:26 +00:00
|
|
|
root.currentIndex = index
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
|
|
|
popupMenuDelegate: StatusListItem {
|
|
|
|
implicitWidth: 272
|
|
|
|
title: name
|
2023-01-08 22:23:51 +00:00
|
|
|
subTitle: LocaleUtils.currencyAmountToLocaleString(currencyBalance)
|
2022-08-11 11:55:08 +00:00
|
|
|
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
|
2022-06-27 13:41:47 +00:00
|
|
|
onClicked: {
|
2023-04-06 12:59:24 +00:00
|
|
|
changeSelectedAccount(model)
|
2022-12-01 16:58:37 +00:00
|
|
|
root.selectItem(index)
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|