mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-24 10:13:50 +02:00
Bugfixes, refactoring, and improvements
This commit is contained in:
parent
1e608b13b2
commit
464bbe5d43
2 changed files with 159 additions and 147 deletions
|
@ -0,0 +1,118 @@
|
||||||
|
//
|
||||||
|
// RecipientDisplay.qml
|
||||||
|
// qml/hifi/commerce/wallet/sendMoney
|
||||||
|
//
|
||||||
|
// RecipientDisplay
|
||||||
|
//
|
||||||
|
// Created by Zach Fox on 2018-01-11
|
||||||
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
import Hifi 1.0 as Hifi
|
||||||
|
import QtQuick 2.6
|
||||||
|
import QtQuick.Controls 2.2
|
||||||
|
import QtGraphicalEffects 1.0
|
||||||
|
import "../../../../styles-uit"
|
||||||
|
import "../../../../controls-uit" as HifiControlsUit
|
||||||
|
import "../../../../controls" as HifiControls
|
||||||
|
import "../../common" as HifiCommerceCommon
|
||||||
|
|
||||||
|
// references XXX from root context
|
||||||
|
|
||||||
|
Item {
|
||||||
|
HifiConstants { id: hifi; }
|
||||||
|
|
||||||
|
id: root;
|
||||||
|
|
||||||
|
property bool isDisplayingNearby; // as opposed to 'connections'
|
||||||
|
property string displayName;
|
||||||
|
property string userName;
|
||||||
|
property string profilePic;
|
||||||
|
|
||||||
|
Item {
|
||||||
|
visible: root.isDisplayingNearby;
|
||||||
|
anchors.fill: parent;
|
||||||
|
|
||||||
|
RalewaySemiBold {
|
||||||
|
id: recipientDisplayName;
|
||||||
|
text: root.displayName;
|
||||||
|
// Anchors
|
||||||
|
anchors.top: parent.top;
|
||||||
|
anchors.left: parent.left;
|
||||||
|
anchors.right: parent.right;
|
||||||
|
anchors.rightMargin: 12;
|
||||||
|
height: parent.height/2;
|
||||||
|
// Text size
|
||||||
|
size: 18;
|
||||||
|
// Style
|
||||||
|
color: hifi.colors.baseGray;
|
||||||
|
verticalAlignment: Text.AlignBottom;
|
||||||
|
elide: Text.ElideRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
RalewaySemiBold {
|
||||||
|
text: root.userName;
|
||||||
|
// Anchors
|
||||||
|
anchors.bottom: parent.bottom;
|
||||||
|
anchors.left: recipientDisplayName.anchors.left;
|
||||||
|
anchors.leftMargin: recipientDisplayName.anchors.leftMargin;
|
||||||
|
anchors.right: recipientDisplayName.anchors.right;
|
||||||
|
anchors.rightMargin: recipientDisplayName.anchors.rightMargin;
|
||||||
|
height: parent.height/2;
|
||||||
|
// Text size
|
||||||
|
size: 16;
|
||||||
|
// Style
|
||||||
|
color: hifi.colors.baseGray;
|
||||||
|
verticalAlignment: Text.AlignTop;
|
||||||
|
elide: Text.ElideRight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
visible: !root.isDisplayingNearby;
|
||||||
|
anchors.fill: parent;
|
||||||
|
|
||||||
|
Image {
|
||||||
|
id: userImage;
|
||||||
|
source: root.profilePic;
|
||||||
|
mipmap: true;
|
||||||
|
// Anchors
|
||||||
|
anchors.left: parent.left;
|
||||||
|
anchors.verticalCenter: parent.verticalCenter;
|
||||||
|
height: parent.height - 36;
|
||||||
|
width: height;
|
||||||
|
layer.enabled: true;
|
||||||
|
layer.effect: OpacityMask {
|
||||||
|
maskSource: Item {
|
||||||
|
width: userImage.width;
|
||||||
|
height: userImage.height;
|
||||||
|
Rectangle {
|
||||||
|
anchors.centerIn: parent;
|
||||||
|
width: userImage.width; // This works because userImage is square
|
||||||
|
height: width;
|
||||||
|
radius: width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RalewaySemiBold {
|
||||||
|
text: root.userName;
|
||||||
|
// Anchors
|
||||||
|
anchors.left: userImage.right;
|
||||||
|
anchors.leftMargin: 8;
|
||||||
|
anchors.right: parent.right;
|
||||||
|
anchors.verticalCenter: parent.verticalCenter;
|
||||||
|
height: parent.height - 4;
|
||||||
|
// Text size
|
||||||
|
size: 16;
|
||||||
|
// Style
|
||||||
|
color: hifi.colors.baseGray;
|
||||||
|
verticalAlignment: Text.AlignVCenter;
|
||||||
|
elide: Text.ElideRight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -87,22 +87,21 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
onNextActiveViewChanged: {
|
onNextActiveViewChanged: {
|
||||||
|
if (root.currentActiveView === 'chooseRecipientNearby') {
|
||||||
|
sendSignalToWallet({method: 'disable_ChooseRecipientNearbyMode'});
|
||||||
|
}
|
||||||
|
|
||||||
root.currentActiveView = root.nextActiveView;
|
root.currentActiveView = root.nextActiveView;
|
||||||
if (root.currentActiveView === 'chooseRecipientConnection') {
|
|
||||||
|
if (root.nextActiveView === 'chooseRecipientConnection') {
|
||||||
// Refresh connections model
|
// Refresh connections model
|
||||||
connectionsLoading.visible = false;
|
connectionsLoading.visible = false;
|
||||||
connectionsLoading.visible = true;
|
connectionsLoading.visible = true;
|
||||||
sendSignalToWallet({method: 'refreshConnections'});
|
sendSignalToWallet({method: 'refreshConnections'});
|
||||||
}
|
} else if (root.nextActiveView === 'sendMoneyHome') {
|
||||||
|
|
||||||
if (root.currentActiveView === 'chooseRecipientNearby') {
|
|
||||||
sendSignalToWallet({method: 'enable_ChooseRecipientNearbyMode'});
|
|
||||||
} else {
|
|
||||||
sendSignalToWallet({method: 'disable_ChooseRecipientNearbyMode'});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (root.currentActiveView === 'sendMoneyHome') {
|
|
||||||
Commerce.balance();
|
Commerce.balance();
|
||||||
|
} else if (root.nextActiveView === 'chooseRecipientNearby') {
|
||||||
|
sendSignalToWallet({method: 'enable_ChooseRecipientNearbyMode'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,8 +438,8 @@ Item {
|
||||||
onSendToSendMoney: {
|
onSendToSendMoney: {
|
||||||
sendMoneyStep.referrer = "connections";
|
sendMoneyStep.referrer = "connections";
|
||||||
sendMoneyStep.selectedRecipientNodeID = '';
|
sendMoneyStep.selectedRecipientNodeID = '';
|
||||||
sendMoneyStep.selectedRecipientDisplayName = msg.userName;
|
sendMoneyStep.selectedRecipientDisplayName = 'connection';
|
||||||
sendMoneyStep.selectedRecipientUserName = 'connection';
|
sendMoneyStep.selectedRecipientUserName = msg.userName;
|
||||||
sendMoneyStep.selectedRecipientProfilePic = msg.profilePicUrl;
|
sendMoneyStep.selectedRecipientProfilePic = msg.profilePicUrl;
|
||||||
|
|
||||||
root.nextActiveView = "sendMoneyStep";
|
root.nextActiveView = "sendMoneyStep";
|
||||||
|
@ -740,94 +739,18 @@ Item {
|
||||||
verticalAlignment: Text.AlignVCenter;
|
verticalAlignment: Text.AlignVCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
RecipientDisplay {
|
||||||
id: recipientIsNearby;
|
|
||||||
visible: sendMoneyStep.referrer === "nearby";
|
|
||||||
anchors.top: parent.top;
|
anchors.top: parent.top;
|
||||||
anchors.left: sendToText_sendMoneyStep.right;
|
anchors.left: sendToText_sendMoneyStep.right;
|
||||||
anchors.right: changeButton.left;
|
anchors.right: changeButton.left;
|
||||||
anchors.rightMargin: 12;
|
anchors.rightMargin: 12;
|
||||||
height: parent.height;
|
height: parent.height;
|
||||||
|
|
||||||
RalewaySemiBold {
|
displayName: sendMoneyStep.selectedRecipientDisplayName;
|
||||||
id: recipientDisplayName;
|
userName: sendMoneyStep.selectedRecipientUserName;
|
||||||
text: sendMoneyStep.selectedRecipientDisplayName;
|
profilePic: sendMoneyStep.selectedRecipientProfilePic !== "" ? ((0 === sendMoneyStep.selectedRecipientProfilePic.indexOf("http")) ?
|
||||||
// Anchors
|
sendMoneyStep.selectedRecipientProfilePic : (Account.metaverseServerURL + sendMoneyStep.selectedRecipientProfilePic)) : "";
|
||||||
anchors.top: parent.top;
|
isDisplayingNearby: sendMoneyStep.referrer === "nearby";
|
||||||
anchors.left: parent.left;
|
|
||||||
anchors.right: parent.right;
|
|
||||||
anchors.rightMargin: 12;
|
|
||||||
height: parent.height/2;
|
|
||||||
// Text size
|
|
||||||
size: 18;
|
|
||||||
// Style
|
|
||||||
color: hifi.colors.baseGray;
|
|
||||||
verticalAlignment: Text.AlignBottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
RalewaySemiBold {
|
|
||||||
text: sendMoneyStep.selectedRecipientUserName;
|
|
||||||
// Anchors
|
|
||||||
anchors.bottom: parent.bottom;
|
|
||||||
anchors.left: recipientDisplayName.anchors.left;
|
|
||||||
anchors.leftMargin: recipientDisplayName.anchors.leftMargin;
|
|
||||||
anchors.right: recipientDisplayName.anchors.right;
|
|
||||||
anchors.rightMargin: recipientDisplayName.anchors.rightMargin;
|
|
||||||
height: parent.height/2;
|
|
||||||
// Text size
|
|
||||||
size: 16;
|
|
||||||
// Style
|
|
||||||
color: hifi.colors.baseGray;
|
|
||||||
verticalAlignment: Text.AlignTop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: recipientIsConnection;
|
|
||||||
visible: sendMoneyStep.referrer === "connections";
|
|
||||||
anchors.top: parent.top;
|
|
||||||
anchors.left: sendToText_sendMoneyStep.right;
|
|
||||||
anchors.right: changeButton.left;
|
|
||||||
anchors.rightMargin: 12;
|
|
||||||
height: parent.height;
|
|
||||||
|
|
||||||
Image {
|
|
||||||
id: userImage;
|
|
||||||
source: sendMoneyStep.selectedRecipientProfilePic !== "" ? ((0 === sendMoneyStep.selectedRecipientProfilePic.indexOf("http")) ?
|
|
||||||
sendMoneyStep.selectedRecipientProfilePic : (Account.metaverseServerURL + sendMoneyStep.selectedRecipientProfilePic)) : "";
|
|
||||||
mipmap: true;
|
|
||||||
// Anchors
|
|
||||||
anchors.left: parent.left;
|
|
||||||
anchors.verticalCenter: parent.verticalCenter;
|
|
||||||
height: parent.height - 4;
|
|
||||||
layer.enabled: true;
|
|
||||||
layer.effect: OpacityMask {
|
|
||||||
maskSource: Item {
|
|
||||||
width: userImage.width;
|
|
||||||
height: userImage.height;
|
|
||||||
Rectangle {
|
|
||||||
anchors.centerIn: parent;
|
|
||||||
width: userImage.width; // This works because userImage is square
|
|
||||||
height: width;
|
|
||||||
radius: width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RalewaySemiBold {
|
|
||||||
text: sendMoneyStep.selectedRecipientUserName;
|
|
||||||
// Anchors
|
|
||||||
anchors.left: userImage.right;
|
|
||||||
anchors.leftMargin: 8;
|
|
||||||
anchors.verticalCenter: parent.verticalCenter;
|
|
||||||
height: parent.height - 4;
|
|
||||||
// Text size
|
|
||||||
size: 16;
|
|
||||||
// Style
|
|
||||||
color: hifi.colors.baseGray;
|
|
||||||
verticalAlignment: Text.AlignVCenter;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// "CHANGE" button
|
// "CHANGE" button
|
||||||
|
@ -1031,6 +954,10 @@ Item {
|
||||||
amountTextField.focus = true;
|
amountTextField.focus = true;
|
||||||
amountTextField.error = true;
|
amountTextField.error = true;
|
||||||
amountTextFieldError.text = "<i>amount exceeds available funds</i>";
|
amountTextFieldError.text = "<i>amount exceeds available funds</i>";
|
||||||
|
} else if (amountTextField.text === "" || parseInt(amountTextField.text) < 1) {
|
||||||
|
amountTextField.focus = true;
|
||||||
|
amountTextField.error = true;
|
||||||
|
amountTextFieldError.text = "<i>invalid amount</i>";
|
||||||
} else {
|
} else {
|
||||||
amountTextFieldError.text = "";
|
amountTextFieldError.text = "";
|
||||||
amountTextField.error = false;
|
amountTextField.error = false;
|
||||||
|
@ -1171,36 +1098,17 @@ Item {
|
||||||
verticalAlignment: Text.AlignVCenter;
|
verticalAlignment: Text.AlignVCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
RalewaySemiBold {
|
RecipientDisplay {
|
||||||
id: recipientDisplayName_paymentSuccess;
|
|
||||||
text: sendMoneyStep.selectedRecipientDisplayName;
|
|
||||||
// Anchors
|
|
||||||
anchors.top: parent.top;
|
anchors.top: parent.top;
|
||||||
anchors.left: sendToText_paymentSuccess.right;
|
anchors.left: sendToText_paymentSuccess.right;
|
||||||
anchors.right: parent.right;
|
anchors.right: parent.right;
|
||||||
height: parent.height/2;
|
height: parent.height;
|
||||||
// Text size
|
|
||||||
size: 18;
|
|
||||||
// Style
|
|
||||||
color: hifi.colors.baseGray;
|
|
||||||
verticalAlignment: Text.AlignBottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
RalewaySemiBold {
|
displayName: sendMoneyStep.selectedRecipientDisplayName;
|
||||||
id: recipientUsername_paymentSuccess;
|
userName: sendMoneyStep.selectedRecipientUserName;
|
||||||
text: sendMoneyStep.selectedRecipientUserName;
|
profilePic: sendMoneyStep.selectedRecipientProfilePic !== "" ? ((0 === sendMoneyStep.selectedRecipientProfilePic.indexOf("http")) ?
|
||||||
// Anchors
|
sendMoneyStep.selectedRecipientProfilePic : (Account.metaverseServerURL + sendMoneyStep.selectedRecipientProfilePic)) : "";
|
||||||
anchors.bottom: parent.bottom;
|
isDisplayingNearby: sendMoneyStep.referrer === "nearby";
|
||||||
anchors.left: recipientDisplayName_paymentSuccess.anchors.left;
|
|
||||||
anchors.leftMargin: recipientDisplayName_paymentSuccess.anchors.leftMargin;
|
|
||||||
anchors.right: recipientDisplayName_paymentSuccess.anchors.right;
|
|
||||||
anchors.rightMargin: recipientDisplayName_paymentSuccess.anchors.rightMargin;
|
|
||||||
height: parent.height/2;
|
|
||||||
// Text size
|
|
||||||
size: 16;
|
|
||||||
// Style
|
|
||||||
color: hifi.colors.baseGray;
|
|
||||||
verticalAlignment: Text.AlignTop;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1393,36 +1301,17 @@ Item {
|
||||||
verticalAlignment: Text.AlignVCenter;
|
verticalAlignment: Text.AlignVCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
RalewaySemiBold {
|
RecipientDisplay {
|
||||||
id: recipientDisplayName_paymentFailure;
|
|
||||||
text: sendMoneyStep.selectedRecipientDisplayName;
|
|
||||||
// Anchors
|
|
||||||
anchors.top: parent.top;
|
anchors.top: parent.top;
|
||||||
anchors.left: sentToText_paymentFailure.right;
|
anchors.left: sentToText_paymentFailure.right;
|
||||||
anchors.right: parent.right;
|
anchors.right: parent.right;
|
||||||
height: parent.height/2;
|
height: parent.height;
|
||||||
// Text size
|
|
||||||
size: 18;
|
|
||||||
// Style
|
|
||||||
color: hifi.colors.baseGray;
|
|
||||||
verticalAlignment: Text.AlignBottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
RalewaySemiBold {
|
displayName: sendMoneyStep.selectedRecipientDisplayName;
|
||||||
id: recipientUsername_paymentFailure;
|
userName: sendMoneyStep.selectedRecipientUserName;
|
||||||
text: sendMoneyStep.selectedRecipientUserName;
|
profilePic: sendMoneyStep.selectedRecipientProfilePic !== "" ? ((0 === sendMoneyStep.selectedRecipientProfilePic.indexOf("http")) ?
|
||||||
// Anchors
|
sendMoneyStep.selectedRecipientProfilePic : (Account.metaverseServerURL + sendMoneyStep.selectedRecipientProfilePic)) : "";
|
||||||
anchors.bottom: parent.bottom;
|
isDisplayingNearby: sendMoneyStep.referrer === "nearby";
|
||||||
anchors.left: recipientDisplayName_paymentFailure.anchors.left;
|
|
||||||
anchors.leftMargin: recipientDisplayName_paymentFailure.anchors.leftMargin;
|
|
||||||
anchors.right: recipientDisplayName_paymentFailure.anchors.right;
|
|
||||||
anchors.rightMargin: recipientDisplayName_paymentFailure.anchors.rightMargin;
|
|
||||||
height: parent.height/2;
|
|
||||||
// Text size
|
|
||||||
size: 16;
|
|
||||||
// Style
|
|
||||||
color: hifi.colors.baseGray;
|
|
||||||
verticalAlignment: Text.AlignTop;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1489,7 +1378,7 @@ Item {
|
||||||
anchors.leftMargin: 110;
|
anchors.leftMargin: 110;
|
||||||
anchors.right: parent.right;
|
anchors.right: parent.right;
|
||||||
anchors.rightMargin: 16;
|
anchors.rightMargin: 16;
|
||||||
anchors.bottom: closeButton.top;
|
anchors.bottom: closeButton_paymentFailure.top;
|
||||||
anchors.bottomMargin: 40;
|
anchors.bottomMargin: 40;
|
||||||
// Text size
|
// Text size
|
||||||
size: 22;
|
size: 22;
|
||||||
|
@ -1530,6 +1419,11 @@ Item {
|
||||||
text: "Retry";
|
text: "Retry";
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.isCurrentlySendingMoney = true;
|
root.isCurrentlySendingMoney = true;
|
||||||
|
if (sendMoneyStep.referrer === "connections") {
|
||||||
|
Commerce.transferHfcToUsername(sendMoneyStep.selectedRecipientUserName, parseInt(amountTextField.text), optionalMessage.text);
|
||||||
|
} else if (sendMoneyStep.referrer === "nearby") {
|
||||||
|
Commerce.transferHfcToNode(sendMoneyStep.selectedRecipientNodeID, parseInt(amountTextField.text), optionalMessage.text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue