feat(@desktop/wallet): adapt receive modal design

closes  #5039
This commit is contained in:
Khushboo Mehta 2022-03-15 20:34:28 +01:00 committed by Iuri Matias
parent d4c4fe1f41
commit f5e67fc658
9 changed files with 160 additions and 112 deletions

View File

@ -146,7 +146,9 @@ Popup {
anchors.rightMargin: Style.current.padding anchors.rightMargin: Style.current.padding
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: Style.current.padding anchors.topMargin: Style.current.padding
color: Style.current.transparent
textToCopy: accountSelector.selectedAccount.address textToCopy: accountSelector.selectedAccount.address
store: RootStore
} }
StatusFlatRoundButton { StatusFlatRoundButton {

View File

@ -78,4 +78,8 @@ QtObject {
} }
return tempUrl return tempUrl
} }
function copyToClipboard(text) {
globalUtils.copyToClipboard(text)
}
} }

View File

@ -95,6 +95,7 @@ Item {
destroy(); destroy();
} }
selectedAccount: walletHeader.walletStore.currentAccount selectedAccount: walletHeader.walletStore.currentAccount
anchors.centerIn: parent
} }
} }

View File

@ -1,82 +1,153 @@
import QtQuick 2.13 import QtQuick 2.13
import QtQuick.Controls 2.13 import QtQuick.Controls 2.13
import QtGraphicalEffects 1.13
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Controls 0.1 import StatusQ.Controls 0.1
import StatusQ.Popups 0.1
import StatusQ.Components 0.1
import utils 1.0 import utils 1.0
import shared.popups 1.0
import shared.controls 1.0 import shared.controls 1.0
import "../stores" import "../stores"
// TODO: replace with StatusModal StatusModal {
ModalPopup {
property alias selectedAccount: accountSelector.selectedAccount
id: popup id: popup
property alias selectedAccount: accountSelector.selectedAccount
//% "Receive" //% "Receive"
title: qsTrId("receive") header.title: qsTrId("receive")
height: 500 contentHeight: layout.implicitHeight
width: 500 width: 556
contentItem: Column {
id: layout
width: popup.width
Rectangle { topPadding: Style.current.smallPadding
id: qrCodeBox spacing: Style.current.bigPadding
height: 240
width: 240
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
radius: Style.current.radius
border.width: 1
border.color: Style.current.border
Image { Rectangle {
id: qrCodeImage id: qrCodeBox
asynchronous: true
fillMode: Image.PreserveAspectFit
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter height: 339
height: parent.height - Style.current.padding width: 339
width: parent.width - Style.current.padding layer.enabled: true
mipmap: true layer.effect: OpacityMask {
smooth: false maskSource: Item {
} width: qrCodeBox.width
} height: qrCodeBox.height
Rectangle {
anchors.top: parent.top
anchors.left: parent.left
width: qrCodeBox.width
height: qrCodeBox.height
radius: Style.current.bigPadding
border.width: 1
border.color: Style.current.border
}
Rectangle {
anchors.top: parent.top
anchors.right: parent.right
width: Style.current.bigPadding
height: Style.current.bigPadding
}
Rectangle {
anchors.bottom: parent.bottom
anchors.left: parent.left
width: Style.current.bigPadding
height: Style.current.bigPadding
}
}
}
StatusAccountSelector { Image {
id: accountSelector id: qrCodeImage
label: "" anchors.centerIn: parent
showAccountDetails: false height: parent.height
accounts: RootStore.accounts width: parent.width
currency: RootStore.currentCurrency asynchronous: true
anchors.top: qrCodeBox.bottom fillMode: Image.PreserveAspectFit
anchors.topMargin: Style.current.padding mipmap: true
anchors.horizontalCenter: parent.horizontalCenter smooth: false
width: 240 }
dropdownWidth: parent.width - (Style.current.padding * 2)
dropdownAlignment: StatusSelect.MenuAlignment.Center Rectangle {
onSelectedAccountChanged: { anchors.centerIn: qrCodeImage
if (selectedAccount.address) { width: 78
qrCodeImage.source = RootStore.getQrCode(selectedAccount.address) height: 78
txtWalletAddress.text = selectedAccount.address color: "white"
StatusIcon {
anchors.centerIn: parent
anchors.margins: 2
width: 78
height: 78
source: Style.svg("status-logo-icon")
}
}
}
StatusAccountSelector {
id: accountSelector
anchors.horizontalCenter: parent.horizontalCenter
width: 240
label: ""
showAccountDetails: false
accounts: RootStore.accounts
currency: RootStore.currentCurrency
dropdownWidth: parent.width - (Style.current.padding * 2)
dropdownAlignment: StatusSelect.MenuAlignment.Center
onSelectedAccountChanged: {
if (selectedAccount.address) {
qrCodeImage.source = RootStore.getQrCode(selectedAccount.address)
txtWalletAddress.text = selectedAccount.address
}
}
}
Item {
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
height: addressLabel.height + copyButton.height
Column {
id: addressLabel
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: Style.current.bigPadding
StatusBaseText {
id: contactsLabel
font.pixelSize: 15
color: Theme.palette.baseColor1
text: qsTr("Your Address")
}
StatusAddress {
id: txtWalletAddress
color: Theme.palette.directColor1
font.pixelSize: 15
}
}
Column {
id: copyButton
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: Style.current.bigPadding
spacing: 5
CopyToClipBoardButton {
store: RootStore
textToCopy: txtWalletAddress.text
}
StatusBaseText {
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: 13
color: Theme.palette.primaryColor1
text: qsTr("Copy")
}
} }
} }
} }
Input {
id: txtWalletAddress
//% "Wallet address"
label: qsTrId("wallet-address")
anchors.top: accountSelector.bottom
anchors.topMargin: Style.current.padding
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
anchors.right: parent.right
anchors.rightMargin: Style.current.padding
copyToClipboard: true
textField.readOnly: true
customHeight: 56
}
} }

View File

@ -187,4 +187,8 @@ QtObject {
function toggleNetwork(chainId) { function toggleNetwork(chainId) {
networksModule.toggleNetwork(chainId) networksModule.toggleNetwork(chainId)
} }
function copyToClipboard(text) {
globalUtils.copyToClipboard(text)
}
} }

View File

@ -1,79 +1,42 @@
import QtQuick 2.13 import QtQuick 2.13
import QtQuick.Controls 2.13
import QtGraphicalEffects 1.13
import StatusQ.Controls 0.1 as StatusQ import StatusQ.Controls 0.1
import utils 1.0
import shared.stores 1.0 import shared.stores 1.0
import "./" import utils 1.0
import "../"
// TODO: Replace with StatusQ components StatusRoundButton {
Rectangle {
id: copyToClipboardButton id: copyToClipboardButton
height: 32
width: 32
radius: 8
color: Style.current.transparent
property var onClick: function() {} property var onClick: function() {}
property string textToCopy: "" property string textToCopy: ""
property bool tooltipUnder: false property bool tooltipUnder: false
property var store property var store
Image { icon.name: "copy"
width: 20
height: 20
sourceSize.width: width
sourceSize.height: height
source: Style.svg("copy-to-clipboard-icon")
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
ColorOverlay { onPressed: {
anchors.fill: parent if (!toolTip.visible) {
antialiasing: true toolTip.visible = true
source: parent
color: Style.current.primary
} }
} }
onClicked: {
MouseArea { if (textToCopy) {
cursorShape: Qt.PointingHandCursor store.copyToClipboard(textToCopy)
anchors.fill: parent
hoverEnabled: true
onExited: {
parent.color = Style.current.transparent
}
onEntered:{
parent.color = Style.current.backgroundHover
}
onPressed: {
parent.color = Style.current.backgroundHover
if (!toolTip.visible) {
toolTip.visible = true
}
}
onReleased: {
parent.color = Style.current.backgroundHover
}
onClicked: {
if (textToCopy) {
copyToClipboardButton.store.copyToClipboard(textToCopy)
}
onClick()
} }
onClick()
} }
StatusQ.StatusToolTip { StatusToolTip {
id: toolTip id: toolTip
//% "Copied!" //% "Copied!"
text: qsTrId("copied-") text: qsTrId("copied-")
orientation: tooltipUnder ? StatusQ.StatusToolTip.Orientation.Bottom: StatusQ.StatusToolTip.Orientation.Top orientation: tooltipUnder ? StatusToolTip.Orientation.Bottom: StatusToolTip.Orientation.Top
} }
Timer { Timer {
id:hideTimer id: hideTimer
interval: 2000 interval: 2000
running: toolTip.visible running: toolTip.visible
onTriggered: { onTriggered: {

View File

@ -53,6 +53,7 @@ Item {
Component { Component {
id: copyComponent id: copyComponent
CopyToClipBoardButton { CopyToClipBoardButton {
color: Style.current.transparent
textToCopy: infoText.textToCopy textToCopy: infoText.textToCopy
} }
} }

View File

@ -81,6 +81,7 @@ Item {
anchors.left: control.right anchors.left: control.right
anchors.leftMargin: Style.current.smallPadding anchors.leftMargin: Style.current.smallPadding
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
color: Style.current.transparent
textToCopy: root.address textToCopy: root.address
store: root.store store: root.store
MouseArea { MouseArea {

View File

@ -43,6 +43,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.right anchors.left: parent.right
anchors.leftMargin: Style.current.smallPadding anchors.leftMargin: Style.current.smallPadding
color: Style.current.transparent
store: root.store store: root.store
} }
} }