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 {
|
|
|
|
id: floatingHeader
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
property var selectedAccount
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
signal updatedSelectedAccount(var account)
|
2022-05-19 08:53:57 +00:00
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
QtObject {
|
2022-06-27 13:41:47 +00:00
|
|
|
id: d
|
|
|
|
property var firstModelData: null
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
delegate: Rectangle {
|
|
|
|
width: button.width
|
|
|
|
height: button.height
|
|
|
|
radius: 8
|
|
|
|
visible: floatingHeader.visibleIndices.includes(index) && walletType !== Constants.watchWalletType
|
2022-07-26 18:14:55 +00:00
|
|
|
color: Theme.palette.baseColor3
|
2022-06-27 13:41:47 +00:00
|
|
|
StatusButton {
|
|
|
|
id: button
|
|
|
|
topPadding: 8
|
|
|
|
bottomPadding: 0
|
|
|
|
implicitHeight: 32
|
|
|
|
defaultLeftPadding: 4
|
|
|
|
text: name
|
|
|
|
icon.emoji: !!emoji ? emoji: ""
|
|
|
|
icon.emojiSize: StatusQUtils.Emoji.size.middle
|
|
|
|
icon.name: !emoji ? "filled-account": ""
|
|
|
|
normalColor: "transparent"
|
2022-07-26 18:14:55 +00:00
|
|
|
hoverColor: Theme.palette.statusFloatingButtonHighlight
|
2022-06-27 13:41:47 +00:00
|
|
|
highlighted: index === floatingHeader.currentIndex
|
|
|
|
onClicked: {
|
|
|
|
updatedSelectedAccount(model)
|
|
|
|
floatingHeader.currentIndex = index
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
2022-06-27 13:41:47 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
// On startup make the preseected wallet in the floating menu,
|
|
|
|
// and if the selectedAccount is watch only then select 0th item
|
|
|
|
if(index === 0) {
|
|
|
|
d.firstModelData = model
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
|
2022-06-27 13:41:47 +00:00
|
|
|
if(name !== floatingHeader.selectedAccount.name) {
|
|
|
|
return
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
2022-06-27 13:41:47 +00:00
|
|
|
|
|
|
|
if(name === floatingHeader.selectedAccount.name) {
|
|
|
|
if(walletType !== Constants.watchWalletType) {
|
|
|
|
// If the selected index wont be displayed, added it to the visible indices
|
|
|
|
if(index > 2) {
|
|
|
|
visibleIndices = [0, 1, index]
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
2022-06-27 13:41:47 +00:00
|
|
|
floatingHeader.currentIndex = index
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
2022-06-27 13:41:47 +00:00
|
|
|
else {
|
|
|
|
floatingHeader.currentIndex = 0
|
|
|
|
updatedSelectedAccount(d.firstModelData)
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-06-27 13:41:47 +00:00
|
|
|
}
|
|
|
|
popupMenuDelegate: StatusListItem {
|
|
|
|
implicitWidth: 272
|
|
|
|
title: name
|
|
|
|
subTitle: currencyBalance
|
|
|
|
icon.emoji: !!emoji ? emoji: ""
|
|
|
|
icon.color: model.color
|
|
|
|
icon.name: !emoji ? "filled-account": ""
|
|
|
|
icon.letterSize: 14
|
|
|
|
icon.isLetterIdenticon: !!model.emoji
|
|
|
|
icon.background.color: Theme.palette.indirectColor1
|
|
|
|
onClicked: {
|
|
|
|
updatedSelectedAccount(model)
|
|
|
|
floatingHeader.itemSelected(index)
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
2022-06-27 13:41:47 +00:00
|
|
|
visible: !floatingHeader.visibleIndices.includes(index) && walletType !== Constants.watchWalletType
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|