2020-10-15 17:05:34 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
2020-10-15 18:44:22 +00:00
|
|
|
import QtQuick.Layouts 1.13
|
2020-10-15 17:05:34 +00:00
|
|
|
import QtGraphicalEffects 1.13
|
2021-10-18 10:34:16 +00:00
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.controls 1.0
|
2021-10-18 10:34:16 +00:00
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
import utils 1.0
|
2021-10-18 10:34:16 +00:00
|
|
|
|
2021-10-05 20:50:22 +00:00
|
|
|
import "../../Wallet/views"
|
2021-09-30 09:43:29 +00:00
|
|
|
import "../stores"
|
2020-10-15 17:05:34 +00:00
|
|
|
|
2021-10-14 10:24:37 +00:00
|
|
|
// TODO: replace with StatusPopupMenu
|
2020-10-15 17:05:34 +00:00
|
|
|
Popup {
|
|
|
|
id: popup
|
2021-12-07 23:15:17 +00:00
|
|
|
|
|
|
|
signal sendTriggered(var selectedAccount)
|
|
|
|
signal disconnect()
|
|
|
|
signal reload()
|
|
|
|
|
2020-10-15 17:05:34 +00:00
|
|
|
modal: false
|
|
|
|
|
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
|
|
|
parent: Overlay.overlay
|
|
|
|
width: 360
|
|
|
|
height: 480
|
|
|
|
background: Rectangle {
|
|
|
|
id: bgPopup
|
|
|
|
color: Style.current.background
|
|
|
|
radius: Style.current.radius
|
|
|
|
layer.enabled: true
|
2021-12-07 23:15:17 +00:00
|
|
|
layer.effect: DropShadow {
|
2020-10-15 17:05:34 +00:00
|
|
|
width: bgPopup.width
|
|
|
|
height: bgPopup.height
|
|
|
|
x: bgPopup.x
|
|
|
|
y: bgPopup.y + 10
|
|
|
|
visible: bgPopup.visible
|
|
|
|
source: bgPopup
|
|
|
|
horizontalOffset: 0
|
|
|
|
verticalOffset: 5
|
|
|
|
radius: 10
|
|
|
|
samples: 15
|
2021-07-29 19:20:15 +00:00
|
|
|
color: Style.current.dropShadow
|
2020-10-15 17:05:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
padding: Style.current.padding
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: walletHeader
|
|
|
|
width: parent.width
|
|
|
|
height: networkText.height
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: networkColorCircle
|
|
|
|
width: 8
|
|
|
|
height: 8
|
|
|
|
radius: width / 2
|
2020-10-15 19:08:56 +00:00
|
|
|
color: {
|
2022-03-14 12:32:21 +00:00
|
|
|
switch (Web3ProviderStore.currentNetwork) {
|
2020-10-15 19:08:56 +00:00
|
|
|
case Constants.networkMainnet: return Style.current.green;
|
|
|
|
case Constants.networkRopsten: return Style.current.turquoise;
|
|
|
|
default: return Style.current.red
|
|
|
|
}
|
|
|
|
}
|
2020-10-15 17:05:34 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
StatusBaseText {
|
2020-10-15 17:05:34 +00:00
|
|
|
id: networkText
|
2020-10-15 19:08:56 +00:00
|
|
|
text: {
|
2022-03-14 12:32:21 +00:00
|
|
|
switch (Web3ProviderStore.currentNetwork) {
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Mainnet"
|
|
|
|
case Constants.networkMainnet: return qsTrId("mainnet");
|
|
|
|
//% "Ropsten"
|
|
|
|
case Constants.networkRopsten: return qsTrId("ropsten");
|
|
|
|
//% "Unknown"
|
|
|
|
default: return qsTrId("active-unknown")
|
2020-10-15 19:08:56 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-15 17:05:34 +00:00
|
|
|
font.pixelSize: 15
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: networkColorCircle.right
|
|
|
|
anchors.leftMargin: Style.current.halfPadding
|
|
|
|
}
|
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
StatusBaseText {
|
2020-10-15 17:05:34 +00:00
|
|
|
id: disconectBtn
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Disconnect"
|
|
|
|
text: qsTrId("disconnect")
|
2020-10-15 17:05:34 +00:00
|
|
|
font.pixelSize: 15
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
|
|
|
color: Style.current.danger
|
2022-03-14 12:32:21 +00:00
|
|
|
visible: RootStore.currentTabConnected
|
2020-10-15 17:05:34 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
2021-12-07 23:15:17 +00:00
|
|
|
onClicked: disconnect()
|
2020-10-15 17:05:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-15 18:12:35 +00:00
|
|
|
|
2022-03-24 11:23:38 +00:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: WalletStore.dappBrowserAccount
|
|
|
|
onConnectedAccountDeleted: {
|
|
|
|
popup.reload()
|
|
|
|
// This is done because when an account is deleted and the account is updated to default one,
|
|
|
|
// only the properties are updated and we need to listen to those events and update the selected account
|
|
|
|
accountSelectorRow.currentAddress = ""
|
|
|
|
accountSelector.selectedAccount = Qt.binding(function () {return WalletStore.dappBrowserAccount})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-15 18:12:35 +00:00
|
|
|
Item {
|
|
|
|
property string currentAddress: ""
|
|
|
|
id: accountSelectorRow
|
|
|
|
width: parent.width
|
2020-10-15 18:44:22 +00:00
|
|
|
height: accountSelector.height
|
2020-10-15 18:12:35 +00:00
|
|
|
anchors.top: walletHeader.bottom
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
|
|
|
|
2021-10-27 10:25:42 +00:00
|
|
|
StatusAccountSelector {
|
2020-10-15 18:44:22 +00:00
|
|
|
id: accountSelector
|
2020-10-15 18:12:35 +00:00
|
|
|
label: ""
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: copyBtn.left
|
|
|
|
anchors.rightMargin: Style.current.padding
|
2021-09-30 09:43:29 +00:00
|
|
|
accounts: WalletStore.accounts
|
|
|
|
selectedAccount: WalletStore.dappBrowserAccount
|
|
|
|
currency: WalletStore.defaultCurrency
|
2020-10-15 18:12:35 +00:00
|
|
|
onSelectedAccountChanged: {
|
|
|
|
if (!accountSelectorRow.currentAddress) {
|
|
|
|
// We just set the account for the first time. Nothing to do here
|
|
|
|
accountSelectorRow.currentAddress = selectedAccount.address
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (accountSelectorRow.currentAddress === selectedAccount.address) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
accountSelectorRow.currentAddress = selectedAccount.address
|
2021-09-30 09:43:29 +00:00
|
|
|
Web3ProviderStore.web3ProviderInst.dappsAddress = selectedAccount.address;
|
2022-03-16 11:36:04 +00:00
|
|
|
WalletStore.switchAccountByAddress(selectedAccount.address)
|
2021-12-07 23:15:17 +00:00
|
|
|
reload()
|
2020-10-15 18:12:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyToClipBoardButton {
|
|
|
|
id: copyBtn
|
|
|
|
width: 20
|
|
|
|
height: 20
|
|
|
|
anchors.right: sendBtn.left
|
|
|
|
anchors.rightMargin: Style.current.padding
|
2020-10-15 19:08:56 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Style.current.padding
|
2022-03-15 19:34:28 +00:00
|
|
|
color: Style.current.transparent
|
2020-10-15 18:44:22 +00:00
|
|
|
textToCopy: accountSelector.selectedAccount.address
|
2022-03-15 19:34:28 +00:00
|
|
|
store: RootStore
|
2020-10-15 18:12:35 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 10:34:16 +00:00
|
|
|
StatusFlatRoundButton {
|
2020-10-15 18:12:35 +00:00
|
|
|
id: sendBtn
|
2021-10-18 10:34:16 +00:00
|
|
|
width: 40
|
|
|
|
height: 40
|
2020-10-15 18:12:35 +00:00
|
|
|
anchors.right: parent.right
|
2020-10-15 19:08:56 +00:00
|
|
|
anchors.top: parent.top
|
2021-10-18 10:34:16 +00:00
|
|
|
anchors.topMargin: Style.current.halfPadding
|
|
|
|
icon.name: "send"
|
2021-12-07 23:15:17 +00:00
|
|
|
onClicked: sendTriggered(accountSelector.selectedAccount)
|
2020-10-15 18:12:35 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-15 18:44:22 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: walletInfoContent
|
|
|
|
width: parent.width
|
|
|
|
anchors.top: accountSelectorRow.bottom
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
|
|
|
TabBar {
|
|
|
|
id: walletTabBar
|
|
|
|
width: parent.width
|
|
|
|
anchors.top: parent.top
|
|
|
|
height: assetBtn.height
|
|
|
|
background: Rectangle {
|
|
|
|
color: Style.current.transparent
|
|
|
|
border.width: 0
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusTabButton {
|
|
|
|
id: assetBtn
|
|
|
|
//% "Assets"
|
|
|
|
btnText: qsTrId("wallet-assets")
|
|
|
|
anchors.top: parent.top
|
|
|
|
}
|
|
|
|
StatusTabButton {
|
|
|
|
id: historyBtn
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: assetBtn.right
|
|
|
|
anchors.leftMargin: 32
|
|
|
|
//% "History"
|
|
|
|
btnText: qsTrId("history")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StackLayout {
|
|
|
|
id: stackLayout
|
|
|
|
width: parent.width
|
|
|
|
anchors.top: walletTabBar.bottom
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
currentIndex: walletTabBar.currentIndex
|
|
|
|
|
2021-10-05 20:50:22 +00:00
|
|
|
AssetsView {
|
2020-10-15 18:44:22 +00:00
|
|
|
id: assetsTab
|
|
|
|
}
|
2021-10-05 20:50:22 +00:00
|
|
|
HistoryView {
|
2020-10-15 18:44:22 +00:00
|
|
|
id: historyTab
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-15 17:05:34 +00:00
|
|
|
}
|