feat: add receive modal

Add receive modal in the wallet to show a QR code and address selector
Improve Input component to be able to show a Copy button that copies to clipboard
Improve AccountSelector modal to be able to not show details and fix eliding
This commit is contained in:
Jonathan Rainville 2020-08-14 15:19:08 -04:00 committed by Pascal Precht
parent f6cf197983
commit 79cf818202
8 changed files with 139 additions and 6 deletions

View File

@ -102,10 +102,14 @@ Item {
StyledText { StyledText {
id: walletName id: walletName
text: name text: name
elide: Text.ElideRight
anchors.right: walletBalance.left
anchors.rightMargin: Style.current.smallPadding
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: Style.current.smallPadding anchors.topMargin: Style.current.smallPadding
anchors.left: walletIcon.right anchors.left: walletIcon.right
anchors.leftMargin: 10 anchors.leftMargin: Style.current.smallPadding
font.pixelSize: 15 font.pixelSize: 15
font.weight: Font.Medium font.weight: Font.Medium
color: selected ? Style.current.white : Style.current.textColor color: selected ? Style.current.white : Style.current.textColor

View File

@ -0,0 +1,68 @@
import QtQuick 2.13
import QtQuick.Controls 2.13
import "../../../imports"
import "../../../shared"
ModalPopup {
property string address: ""
id: popup
title: qsTr("Receive")
height: 500
width: 500
Rectangle {
id: qrCodeBox
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 {
id: qrCodeImage
asynchronous: true
fillMode: Image.PreserveAspectFit
source: profileModel.qrCode(accountSelector.selectedAccount.address)
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
height: parent.height - Style.current.padding
width: parent.width - Style.current.padding
mipmap: true
smooth: false
}
}
AccountSelector {
id: accountSelector
label: ""
showAccountDetails: false
accounts: walletModel.accounts
currency: walletModel.defaultCurrency
anchors.top: qrCodeBox.bottom
anchors.topMargin: Style.current.padding
anchors.horizontalCenter: parent.horizontalCenter
width: 240
}
Input {
label: qsTr("Wallet address")
text: accountSelector.selectedAccount.address
anchors.top: accountSelector.bottom
anchors.topMargin: Style.current.padding
copyToClipboard: true
textField.readOnly: true
customHeight: 56
}
}
/*##^##
Designer {
D{i:0;autoSize:true;height:480;width:640}
}
##^##*/

View File

@ -71,6 +71,11 @@ Item {
id: sendModal id: sendModal
} }
ReceiveModal{
id: receiveModal
address: currentAccount.address
}
SetCurrencyModal{ SetCurrencyModal{
id: setCurrencyModal id: setCurrencyModal
} }
@ -114,7 +119,7 @@ Item {
flipImage: true flipImage: true
text: qsTr("Receive") text: qsTr("Receive")
onClicked: function () { onClicked: function () {
// Nothing for now receiveModal.open()
} }
anchors.left: sendBtn.right anchors.left: sendBtn.right
anchors.leftMargin: walletMenu.btnOuterMargin anchors.leftMargin: walletMenu.btnOuterMargin

View File

@ -146,6 +146,7 @@ DISTFILES += \
app/AppLayouts/Profile/Sections/AppearanceContainer.qml \ app/AppLayouts/Profile/Sections/AppearanceContainer.qml \
app/AppLayouts/Profile/Sections/MyProfileContainer.qml \ app/AppLayouts/Profile/Sections/MyProfileContainer.qml \
app/AppLayouts/Profile/Sections/SoundsContainer.qml \ app/AppLayouts/Profile/Sections/SoundsContainer.qml \
app/AppLayouts/Wallet/ReceiveModal.qml \
app/AppLayouts/Wallet/components/HeaderButton.qml \ app/AppLayouts/Wallet/components/HeaderButton.qml \
app/AppLayouts/Profile/Sections/Data/locales.js \ app/AppLayouts/Profile/Sections/Data/locales.js \
fonts/InterStatus/InterStatus-Black.otf \ fonts/InterStatus/InterStatus-Black.otf \

View File

@ -7,12 +7,14 @@ import "../imports"
Item { Item {
id: root id: root
property string label: qsTr("Choose account") property string label: qsTr("Choose account")
property bool showAccountDetails: true
property var accounts property var accounts
property var selectedAccount: { property var selectedAccount: {
"address": "", "name": "", "iconColor": "", "fiatBalance": "" "address": "", "name": "", "iconColor": "", "fiatBalance": ""
} }
property string currency: "usd" property string currency: "usd"
height: select.height + selectedAccountDetails.height height: select.height +
(selectedAccountDetails.visible ? selectedAccountDetails.height : 0)
// set to asset symbol to display asset's balance top right // set to asset symbol to display asset's balance top right
// NOTE: if this asset is not selected as a wallet token in the UI, then // NOTE: if this asset is not selected as a wallet token in the UI, then
// nothing will be displayed // nothing will be displayed
@ -43,7 +45,7 @@ Item {
selectedAccountDetails.visible = false selectedAccountDetails.visible = false
} }
menu.onClosed: { menu.onClosed: {
selectedAccountDetails.visible = true selectedAccountDetails.visible = root.showAccountDetails
} }
menu.width: dropdownWidth menu.width: dropdownWidth
selectedItemView: Item { selectedItemView: Item {
@ -68,6 +70,9 @@ Item {
StyledText { StyledText {
id: selectedTextField id: selectedTextField
text: selectedAccount.name text: selectedAccount.name
elide: Text.ElideRight
anchors.right: parent.right
anchors.rightMargin: Style.current.bigPadding
anchors.left: selectedIconImg.right anchors.left: selectedIconImg.right
anchors.leftMargin: 8 anchors.leftMargin: 8
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -80,6 +85,7 @@ Item {
Row { Row {
id: selectedAccountDetails id: selectedAccountDetails
visible: root.showAccountDetails
anchors.top: select.bottom anchors.top: select.bottom
anchors.topMargin: 8 anchors.topMargin: 8
anchors.left: parent.left anchors.left: parent.left
@ -134,6 +140,7 @@ Item {
color: iconColor color: iconColor
} }
Column { Column {
id: column
anchors.left: iconImg.right anchors.left: iconImg.right
anchors.leftMargin: 14 anchors.leftMargin: 14
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -141,6 +148,9 @@ Item {
StyledText { StyledText {
id: accountName id: accountName
text: name text: name
elide: Text.ElideRight
anchors.right: parent.right
anchors.left: parent.left
font.pixelSize: 15 font.pixelSize: 15
height: 22 height: 22
} }

View File

@ -1,6 +1,7 @@
import QtQuick 2.13 import QtQuick 2.13
import QtQuick.Controls 2.13 import QtQuick.Controls 2.13
import "../imports" import "../imports"
import "."
Item { Item {
property alias textField: inputValue property alias textField: inputValue
@ -16,6 +17,7 @@ Item {
property url icon: "" property url icon: ""
property int iconHeight: 24 property int iconHeight: 24
property int iconWidth: 24 property int iconWidth: 24
property bool copyToClipboard: false
readonly property bool hasIcon: icon.toString() !== "" readonly property bool hasIcon: icon.toString() !== ""
readonly property var forceActiveFocus: function () { readonly property var forceActiveFocus: function () {
@ -90,6 +92,46 @@ Item {
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
source: inputBox.icon source: inputBox.icon
} }
Loader {
active: inputBox.copyToClipboard
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: 8
sourceComponent: copyToClipboardComponent
}
Component {
id: copyToClipboardComponent
Item {
width: copyBtn.width
height: copyBtn.height
Timer {
id: timer
}
StyledButton {
id: copyBtn
label: qsTr("Copy")
height: 28
textSize: 12
btnBorderColor: Style.current.blue
btnBorderWidth: 1
onClicked: {
chatsModel.copyToClipboard(inputValue.text)
copyBtn.label = qsTr("Copied")
timer.setTimeout(function(){
copyBtn.label = qsTr("Copy")
}, 2000);
}
}
}
}
} }
TextEdit { TextEdit {

View File

@ -9,6 +9,7 @@ Button {
property color btnBorderColor: "transparent" property color btnBorderColor: "transparent"
property int btnBorderWidth: 0 property int btnBorderWidth: 0
property color textColor: Style.current.blue property color textColor: Style.current.blue
property int textSize: 15
property bool disabled: false property bool disabled: false
id: btnStyled id: btnStyled
@ -17,7 +18,8 @@ Button {
enabled: !disabled enabled: !disabled
background: Rectangle { background: Rectangle {
color: disabled ? Style.current.grey : btnStyled.btnColor color: disabled ? Style.current.grey :
hovered ? Qt.darker(btnStyled.btnColor, 1.1) : btnStyled.btnColor
radius: Style.current.radius radius: Style.current.radius
anchors.fill: parent anchors.fill: parent
border.color: btnBorderColor border.color: btnBorderColor
@ -27,7 +29,7 @@ Button {
StyledText { StyledText {
id: txtBtnLabel id: txtBtnLabel
color: btnStyled.disabled ? Style.current.darkGrey : btnStyled.textColor color: btnStyled.disabled ? Style.current.darkGrey : btnStyled.textColor
font.pixelSize: 15 font.pixelSize: btnStyled.textSize
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
text: btnStyled.label text: btnStyled.label

View File

@ -20,3 +20,4 @@ NotificationWindow 1.0 NotificationWindow.qml
BlockContactConfirmationDialog 1.0 BlockContactConfirmationDialog.qml BlockContactConfirmationDialog 1.0 BlockContactConfirmationDialog.qml
ConfirmationDialog 1.0 ConfirmationDialog.qml ConfirmationDialog 1.0 ConfirmationDialog.qml
StatusSlider 1.0 StatusSlider.qml StatusSlider 1.0 StatusSlider.qml
Timer 1.0 Timer.qml